Пример #1
0
 @Test
 public void nextOnNonEmptyCursor_shouldReturnTrue() throws IOException, SQLException {
   File file = new File("whatever");
   try {
     writeObjectsToFile(file);
     Cursor cursor = new FileCursor(file);
     try {
       assertTrue(cursor.next());
     } finally {
       cursor.close();
     }
   } finally {
     assertTrue(file.delete());
   }
 }
Пример #2
0
 @Test
 public void afterReseting_nextReturnsTrue() throws IOException, SQLException {
   File file = new File("whatever");
   try {
     writeObjectsToFile(file);
     Cursor cursor = new FileCursor(file);
     try {
       iterateThrough(cursor);
       cursor.reset();
       assertTrue(cursor.next());
     } finally {
       cursor.close();
     }
   } finally {
     assertTrue(file.delete());
   }
 }
Пример #3
0
 @Test
 public void testGetObject() throws IOException, SQLException {
   File file = new File("whatever");
   try {
     writeObjectsToFile(file);
     Cursor cursor = new FileCursor(file);
     try {
       cursor.next();
       assertEquals("1", cursor.getObject(1));
       assertEquals("2", cursor.getObject(2));
     } finally {
       cursor.close();
     }
   } finally {
     assertTrue(file.delete());
   }
 }
Пример #4
0
 private void iterateThrough(Cursor cursor) {
   while (cursor.next()) {}
 }