assertTrue(filteredRowSet.isBeforeFirst());
}
public void testCursorMove() throws Exception {
insertMoreData(30);
FilteredRowSet filteredRowSet = newFilterRowSet();
rs = st.executeQuery("SELECT * FROM USER_INFO");
filteredRowSet.populate(rs);
RangeThree range = new RangeThree();
filteredRowSet.setFilter(range);
assertTrue(filteredRowSet.first());
assertEquals("hermit", filteredRowSet.getString(2));
/*
* TODO It's really strange. When running on RI, filteredRowSet.first()
* is true. The cursor stays on the first row. However,
* filteredRowSet.absolute(1) is false. But the cursor still stays on
* the first row.
*/
if ("true".equals(System.getProperty("Testing Harmony"))) {
assertTrue(filteredRowSet.absolute(1));
} else {
assertFalse(filteredRowSet.absolute(1));
}
assertEquals("hermit", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(1));
assertEquals("test4", filteredRowSet.getString(2));
/*
* First call absolute(2), then call relative(-1), the cursor returns
* the first row.
*/
assertTrue(filteredRowSet.absolute(2));
assertEquals("test4", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(-1));
assertEquals("hermit", filteredRowSet.getString(2));
assertTrue(filteredRowSet.last());
assertEquals("test34", filteredRowSet.getString(2));
assertTrue(filteredRowSet.previous());
assertEquals("test32", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(-1));
assertEquals("test30", filteredRowSet.getString(2));
assertTrue(filteredRowSet.absolute(5));
assertEquals("test10", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(3));
assertEquals("test16", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(-3));
assertEquals("test10", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(4));
assertEquals("test18", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(13));
assertEquals("test34", filteredRowSet.getString(2));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
assertTrue(filteredRowSet.absolute(22));
assertEquals("test34", filteredRowSet.getString(2));
assertTrue(filteredRowSet.relative(-21));
assertEquals("hermit", filteredRowSet.getString(2));
assertFalse(filteredRowSet.relative(-1));
assertTrue(filteredRowSet.isBeforeFirst());
}