Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. @Test
  2. public void readFileTest(){
  3. BufferedReader bufferedReader = null;
  4. try {
  5. InputStream in = getInstrumentation().getContext().getResources().getAssets().open("test1.csv");
  6.  
  7. bufferedReader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
  8. String line = bufferedReader.readLine();
  9.  
  10.  
  11.  
  12. } catch (IOException e) {
  13. fail("IOException on file");
  14. }
  15.  
  16. }
  17.  
  18. @Test(timeout = 100)
  19. public void openValidFileOnDevice() {
  20. MyComponent component = new MyComponent();
  21.  
  22. FileObserver fileObserver = new FileObserver(VALID_FILE) {
  23. @Override
  24. public void onEvent(int i, String s) {
  25. assertTrue(true);
  26. }
  27. };
  28.  
  29. try {
  30. component.open(VALID_FILE, CSVReaderWriter.Mode.READ);
  31.  
  32. } catch (FileNotFoundException e) {
  33. fail("FileNotFoundException on: " + VALID_FILE);
  34. } catch (IOException e) {
  35. fail("IOException on: " + VALID_FILE);
  36. } catch (Exception e) {
  37. fail("Exception thrown, should not throw exceptions on valid file");
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement