public void testIterators() {
MemoryMetaData metadata = new MemoryMetaData( new String[][] { { "col1", "col2" } }, null );
MemoryResultSet dataSet = new MemoryResultSet( metadata );
JavaScriptResultSet data = new JavaScriptResultSet();
data.setResultSet( dataSet );
data.addRow( new Object[] { "a", new Integer( 1 ) } );
data.addRow( new Object[] { "b", new Integer( 2 ) } );
data.addRow( new Object[] { "c", new Integer( 3 ) } );
assertEquals( 3, data.getRowCount() );
assertEquals( "a", data.getValueAt( 0, 0 ) );
assertEquals( 1, data.getValueAt( 0, 1 ) );
assertEquals( "b", data.getValueAt( 1, 0 ) );
assertEquals( 2, data.getValueAt( 1, 1 ) );
assertEquals( "c", data.getValueAt( 2, 0 ) );
assertEquals( 3, data.getValueAt( 2, 1 ) );
assertEquals( "a", data.next()[0] );
assertEquals( "b", data.next()[0] );
assertEquals( "c", data.next()[0] );
assertNull( data.next() );
data.beforeFirst();
assertEquals( "a", data.next()[0] );
assertEquals( "b", data.next()[0] );
assertEquals( "c", data.next()[0] );
assertNull( data.next() );
data.close();
assertEquals( "a", data.next()[0] );
assertEquals( "b", data.next()[0] );
assertEquals( "c", data.next()[0] );
assertNull( data.next() );
data.closeConnection();
assertEquals( "a", data.next()[0] );
assertEquals( "b", data.next()[0] );
assertEquals( "c", data.next()[0] );
assertNull( data.next() );
data.dispose();
assertEquals( "a", data.next()[0] );
assertEquals( "b", data.next()[0] );
assertEquals( "c", data.next()[0] );
assertNull( data.next() );
}