}
public void testPagingInMemory() throws Exception {
insertMoreData(10);
FilteredRowSet filteredRowSet = newFilterRowSet();
st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery("SELECT * FROM USER_INFO");
// the max rows load into memory
filteredRowSet.setMaxRows(5);
filteredRowSet.setPageSize(3);
filteredRowSet.populate(rs, 1);
OddRowFilter filter = new OddRowFilter();
filteredRowSet.setFilter(filter);
if (!"true".equals(System.getProperty("Testing Harmony"))) {
// RI need nextPage one more time
assertTrue(filteredRowSet.nextPage());
}
assertTrue(filteredRowSet.next());
assertEquals(1, filteredRowSet.getInt(1));
assertTrue(filteredRowSet.next());
assertEquals(3, filteredRowSet.getInt(1));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
assertTrue(filteredRowSet.nextPage());
filteredRowSet.beforeFirst();
assertTrue(filteredRowSet.next());
assertEquals(5, filteredRowSet.getInt(1));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
assertFalse(filteredRowSet.nextPage());
st = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = st.executeQuery("SELECT * FROM USER_INFO");
filteredRowSet = newFilterRowSet();
filteredRowSet.setFilter(filter);
filteredRowSet.setPageSize(3);
filteredRowSet.populate(rs, 1);
if (!"true".equals(System.getProperty("Testing Harmony"))) {
// RI need nextPage one more time
assertTrue(filteredRowSet.nextPage());
}
assertTrue(filteredRowSet.next());
assertEquals(1, filteredRowSet.getInt(1));
assertTrue(filteredRowSet.next());
assertEquals(3, filteredRowSet.getInt(1));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
filteredRowSet.setPageSize(2);
assertTrue(filteredRowSet.nextPage());
assertTrue(filteredRowSet.isBeforeFirst());
assertTrue(filteredRowSet.next());
assertEquals(5, filteredRowSet.getInt(1));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
filteredRowSet.setPageSize(5);
assertTrue(filteredRowSet.nextPage());
assertTrue(filteredRowSet.isBeforeFirst());
assertTrue(filteredRowSet.next());
assertEquals(7, filteredRowSet.getInt(1));
assertTrue(filteredRowSet.next());
assertEquals(9, filteredRowSet.getInt(1));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
assertTrue(filteredRowSet.previousPage());
assertTrue(filteredRowSet.isBeforeFirst());
assertTrue(filteredRowSet.next());
assertEquals(1, filteredRowSet.getInt(1));
assertTrue(filteredRowSet.next());
assertEquals(3, filteredRowSet.getInt(1));
assertTrue(filteredRowSet.next());
assertEquals(5, filteredRowSet.getInt(1));
assertFalse(filteredRowSet.next());
assertTrue(filteredRowSet.isAfterLast());
assertFalse(filteredRowSet.previousPage());
}