@Test
 public void canRetrieveMetadata() throws IOException, SQLException {
   File file = new File("whatever");
   try {
     writeObjectsToFile(file);
     Cursor cursor = new FileCursor(file);
     try {
       CursorMetadata actual = cursor.getMetadata();
       assertThat(actual.getColumnCount(), equalTo(2));
       assertThat(actual.getColumnName(1), equalTo("A"));
       assertThat(actual.getColumnName(2), equalTo("B"));
     } finally {
       cursor.close();
     }
   } finally {
     assertTrue(file.delete());
   }
 }
 private void writeObjectsToFile(File file) throws IOException, SQLException {
   FileOutputStream fileOut = new FileOutputStream(file);
   try {
     ObjectOutputStream objectOut = new ObjectOutputStream(fileOut);
     rs =
         MockResultSet.create(
             MockResultSet.cols("A", "B"), MockResultSet.data(MockResultSet.row(row)));
     try {
       objectOut.writeObject(metadata);
       rs.next();
       metadata.writeRow(objectOut, new ResultSetWrapper(rs));
       rs.next();
       metadata.writeRow(objectOut, new ResultSetWrapper(rs));
     } finally {
       objectOut.close();
     }
   } finally {
     fileOut.close();
   }
 }