Java 类javax.sql.rowset.Predicate 实例源码

项目:cn1    文件:FilteredRowSetTest.java   
public void testCreateCopy() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    if ("true".equals(System.getProperty("Testing Harmony"))) {
        filteredRowSet.createCopy();
    } else {
        try {
            filteredRowSet.createCopy();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }
    }
}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testCreateCopy() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    if ("true".equals(System.getProperty("Testing Harmony"))) {
        filteredRowSet.createCopy();
    } else {
        try {
            filteredRowSet.createCopy();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }
    }
}
项目:jdk8u-jdk    文件:FilteredRowSetTests.java   
@Test
public void FilteredRowSetTest0001() throws SQLException {
    Predicate p = new PrimaryKeyFilter(0, 100030, 1);
    frs.setFilter(p);
    assertTrue(frs.getFilter().equals(p));
    frs.setFilter(null);
    assertNull(frs.getFilter());
}
项目:openjdk-jdk10    文件:FilteredRowSetTests.java   
@Test
public void FilteredRowSetTest0001() throws SQLException {
    Predicate p = new PrimaryKeyFilter(0, 100030, 1);
    frs.setFilter(p);
    assertTrue(frs.getFilter().equals(p));
    frs.setFilter(null);
    assertNull(frs.getFilter());
}
项目:openjdk9    文件:FilteredRowSetTests.java   
@Test
public void FilteredRowSetTest0001() throws SQLException {
    Predicate p = new PrimaryKeyFilter(0, 100030, 1);
    frs.setFilter(p);
    assertTrue(frs.getFilter().equals(p));
    frs.setFilter(null);
    assertNull(frs.getFilter());
}
项目:jdk8u_jdk    文件:FilteredRowSetTests.java   
@Test
public void FilteredRowSetTest0001() throws SQLException {
    Predicate p = new PrimaryKeyFilter(0, 100030, 1);
    frs.setFilter(p);
    assertTrue(frs.getFilter().equals(p));
    frs.setFilter(null);
    assertNull(frs.getFilter());
}
项目:lookaside_java-1.8.0-openjdk    文件:FilteredRowSetTests.java   
@Test
public void FilteredRowSetTest0001() throws SQLException {
    Predicate p = new PrimaryKeyFilter(0, 100030, 1);
    frs.setFilter(p);
    assertTrue(frs.getFilter().equals(p));
    frs.setFilter(null);
    assertNull(frs.getFilter());
}
项目:cn1    文件:FilteredRowSetTest.java   
public void testCreateShared() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    FilteredRowSet copyFilteredRs = (FilteredRowSet) filteredRowSet
            .createShared();
    assertSame(range, copyFilteredRs.getFilter());
}
项目:cn1    文件:FilteredRowSetTest.java   
public void testFilter_Update() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    /*
     * Update the third row. Filter has no effect here.
     */
    assertTrue(filteredRowSet.last());
    assertEquals("test4", filteredRowSet.getString(2));
    filteredRowSet.updateString(2, "update4");
    filteredRowSet.updateRow();
    assertEquals("update4", filteredRowSet.getString(2));
    // the updated row becomes not visible through filter
    assertTrue(filteredRowSet.last());
    assertEquals("test3", filteredRowSet.getString(2));

    // commit to database
    filteredRowSet.acceptChanges(conn);
    rs = st
            .executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE NAME = 'update4'");
    assertTrue(rs.next());
    assertEquals(0, rs.getInt(1));

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    assertTrue(filteredRowSet.last());
    assertEquals("update4", filteredRowSet.getString(2));
    /*
     * The forth row isn't updated to database, and it lost it's status
     * after acceptChanges().
     */
    assertFalse(filteredRowSet.rowUpdated());
}
项目:cn1    文件:FilteredRowSetTest.java   
public void testFilter_Delete() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    /*
     * Mark the first row as delete.
     */
    assertTrue(filteredRowSet.first());
    assertEquals(1, filteredRowSet.getInt(1));
    filteredRowSet.deleteRow();

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));

    filteredRowSet.acceptChanges(conn);
    rs = st.executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE ID = 1");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.acceptChanges(conn);
    rs = st.executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE ID = 1");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));
    /*
     * The first row has been deleted from FilteredRowSet. However, it isn't
     * deleted from database.
     */
    filteredRowSet.setShowDeleted(true);
    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));
}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testCreateShared() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    FilteredRowSet copyFilteredRs = (FilteredRowSet) filteredRowSet
            .createShared();
    assertSame(range, copyFilteredRs.getFilter());
}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testFilter_Update() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    /*
     * Update the third row. Filter has no effect here.
     */
    assertTrue(filteredRowSet.last());
    assertEquals("test4", filteredRowSet.getString(2));
    filteredRowSet.updateString(2, "update4");
    filteredRowSet.updateRow();
    assertEquals("update4", filteredRowSet.getString(2));
    // the updated row becomes not visible through filter
    assertTrue(filteredRowSet.last());
    assertEquals("test3", filteredRowSet.getString(2));

    // commit to database
    filteredRowSet.acceptChanges(conn);
    rs = st
            .executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE NAME = 'update4'");
    assertTrue(rs.next());
    assertEquals(0, rs.getInt(1));

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    assertTrue(filteredRowSet.last());
    assertEquals("update4", filteredRowSet.getString(2));
    /*
     * The forth row isn't updated to database, and it lost it's status
     * after acceptChanges().
     */
    assertFalse(filteredRowSet.rowUpdated());
}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testFilter_Delete() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    /*
     * Mark the first row as delete.
     */
    assertTrue(filteredRowSet.first());
    assertEquals(1, filteredRowSet.getInt(1));
    filteredRowSet.deleteRow();

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));

    filteredRowSet.acceptChanges(conn);
    rs = st.executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE ID = 1");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.acceptChanges(conn);
    rs = st.executeQuery("SELECT COUNT(*) FROM USER_INFO WHERE ID = 1");
    assertTrue(rs.next());
    assertEquals(1, rs.getInt(1));
    /*
     * The first row has been deleted from FilteredRowSet. However, it isn't
     * deleted from database.
     */
    filteredRowSet.setShowDeleted(true);
    assertTrue(filteredRowSet.first());
    assertEquals(2, filteredRowSet.getInt(1));
}
项目:jdk8u-jdk    文件:StubFilteredRowSetImpl.java   
@Override
public void setFilter(Predicate p) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u-jdk    文件:StubFilteredRowSetImpl.java   
@Override
public Predicate getFilter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:StubFilteredRowSetImpl.java   
@Override
public void setFilter(Predicate p) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10    文件:StubFilteredRowSetImpl.java   
@Override
public Predicate getFilter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk9    文件:StubFilteredRowSetImpl.java   
@Override
public void setFilter(Predicate p) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk9    文件:StubFilteredRowSetImpl.java   
@Override
public Predicate getFilter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u_jdk    文件:StubFilteredRowSetImpl.java   
@Override
public void setFilter(Predicate p) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:jdk8u_jdk    文件:StubFilteredRowSetImpl.java   
@Override
public Predicate getFilter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:lookaside_java-1.8.0-openjdk    文件:StubFilteredRowSetImpl.java   
@Override
public void setFilter(Predicate p) throws SQLException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:lookaside_java-1.8.0-openjdk    文件:StubFilteredRowSetImpl.java   
@Override
public Predicate getFilter() {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:cn1    文件:FilteredRowSetImpl.java   
public Predicate getFilter() {
    return predicate;
}
项目:cn1    文件:FilteredRowSetImpl.java   
public void setFilter(Predicate p) throws SQLException {
    this.predicate = p;
}
项目:cn1    文件:FilteredRowSetTest.java   
public void testSetFilter() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    /*
     * Set Filter: RangeOne
     */
    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);
    filteredRowSet.beforeFirst();
    int index = 0;
    while (filteredRowSet.next()) {
        index++;
        assertTrue(filteredRowSet.getString(2).indexOf("test") != -1);
    }
    assertEquals(3, index);
    assertSame(range, filteredRowSet.getFilter());

    /*
     * Set another Filter: RangeTwo
     */
    range = new RangeTwo();
    filteredRowSet.setFilter(range);
    filteredRowSet.beforeFirst();
    index = 0;
    boolean isSecondRowFiltered = true;
    while (filteredRowSet.next()) {
        index++;
        if ("test2".equals(filteredRowSet.getString(2))) {
            isSecondRowFiltered = false;
        }
    }
    assertEquals(3, index);
    assertTrue(isSecondRowFiltered);
    assertSame(range, filteredRowSet.getFilter());

    /*
     * Remove Filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.beforeFirst();
    index = 0;
    while (filteredRowSet.next()) {
        index++;
        assertEquals(index, filteredRowSet.getInt(1));
    }
    assertEquals(4, index);
    assertNull(filteredRowSet.getFilter());
}
项目:cn1    文件:FilteredRowSetTest.java   
public void testSetFilterOnFilteredRow() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    filteredRowSet.next();
    assertEquals(1, filteredRowSet.getRow());
    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    // not filtered
    assertEquals(1, filteredRowSet.getRow());
    assertEquals("hermit", filteredRowSet.getString(2));

    filteredRowSet.updateString(2, "update");
    assertEquals("update", filteredRowSet.getString(2));

    filteredRowSet.next();
    assertEquals(2, filteredRowSet.getRow());
    assertEquals("test", filteredRowSet.getString(2));

    filteredRowSet.previous();
    assertTrue(filteredRowSet.isBeforeFirst());

    try {
        filteredRowSet.getString(2);
        fail("should should SQLException");
    } catch (SQLException e) {
        // expected, Not a valid cursor
    }

    filteredRowSet.setFilter(null);

    assertTrue(filteredRowSet.isBeforeFirst());

    assertTrue(filteredRowSet.next());
    assertEquals("update", filteredRowSet.getString(2));

    filteredRowSet.setFilter(range);
    assertEquals("update", filteredRowSet.getString(2));
    filteredRowSet.updateString(2, "testUpdate");

    filteredRowSet.next();
    assertEquals(2, filteredRowSet.getRow());
    assertEquals("test", filteredRowSet.getString(2));

    filteredRowSet.previous();
    assertEquals(1, filteredRowSet.getRow());
    assertEquals("testUpdate", filteredRowSet.getString(2));

}
项目:cn1    文件:FilteredRowSetTest.java   
public void testFilter_Insert() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    /*
     * Insert a row. when call updateXXX(), evaluate(Object value, int
     * column) is called to check first.
     */
    filteredRowSet.afterLast();
    filteredRowSet.moveToInsertRow();
    filteredRowSet.updateInt(1, 200);
    try {
        filteredRowSet.updateString("NAME", "test200");
        fail("should throw SQLException");
    } catch (SQLException e) {
        filteredRowSet.updateString("NAME", "insert200");
    }
    filteredRowSet.insertRow();
    filteredRowSet.moveToCurrentRow();

    /*
     * Although the new row is inserted, it is invalid through
     * evaluate(RowSet rs). Therefore, the inserted row is not visible.
     */
    filteredRowSet.beforeFirst();
    int index = 0;
    while (filteredRowSet.next()) {
        index++;
        assertEquals(index + 1, filteredRowSet.getInt(1));
    }
    assertEquals(3, index);

    /*
     * Remove filter. See the inserted row. Then set again, and commit to
     * database.
     */
    filteredRowSet.setFilter(null);
    assertTrue(filteredRowSet.last());
    assertEquals(200, filteredRowSet.getInt(1));
    assertTrue(filteredRowSet.rowInserted());
    filteredRowSet.setFilter(range);
    filteredRowSet.acceptChanges(conn);
    // check database: the inserted row isn't commited to database
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    index = 0;
    while (rs.next()) {
        index++;
        assertEquals(index, rs.getInt(1));
    }
    assertEquals(4, index);

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.beforeFirst();
    index = 0;
    while (filteredRowSet.next()) {
        index++;
        if (index == 5) {
            /*
             * Though the new row isn't inserted into database, the inserted
             * row lost it's status after acceptChanges().
             */
            assertEquals(200, filteredRowSet.getInt(1));
            assertFalse(filteredRowSet.rowInserted());
        } else {
            assertEquals(index, filteredRowSet.getInt(1));
        }
    }
    assertEquals(5, index);
}
项目:freeVM    文件:FilteredRowSetImpl.java   
public Predicate getFilter() {
    return predicate;
}
项目:freeVM    文件:FilteredRowSetImpl.java   
public void setFilter(Predicate p) throws SQLException {
    this.predicate = p;
}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testSetFilter() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    /*
     * Set Filter: RangeOne
     */
    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);
    filteredRowSet.beforeFirst();
    int index = 0;
    while (filteredRowSet.next()) {
        index++;
        assertTrue(filteredRowSet.getString(2).indexOf("test") != -1);
    }
    assertEquals(3, index);
    assertSame(range, filteredRowSet.getFilter());

    /*
     * Set another Filter: RangeTwo
     */
    range = new RangeTwo();
    filteredRowSet.setFilter(range);
    filteredRowSet.beforeFirst();
    index = 0;
    boolean isSecondRowFiltered = true;
    while (filteredRowSet.next()) {
        index++;
        if ("test2".equals(filteredRowSet.getString(2))) {
            isSecondRowFiltered = false;
        }
    }
    assertEquals(3, index);
    assertTrue(isSecondRowFiltered);
    assertSame(range, filteredRowSet.getFilter());

    /*
     * Remove Filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.beforeFirst();
    index = 0;
    while (filteredRowSet.next()) {
        index++;
        assertEquals(index, filteredRowSet.getInt(1));
    }
    assertEquals(4, index);
    assertNull(filteredRowSet.getFilter());
}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testSetFilterOnFilteredRow() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    filteredRowSet.next();
    assertEquals(1, filteredRowSet.getRow());
    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    // not filtered
    assertEquals(1, filteredRowSet.getRow());
    assertEquals("hermit", filteredRowSet.getString(2));

    filteredRowSet.updateString(2, "update");
    assertEquals("update", filteredRowSet.getString(2));

    filteredRowSet.next();
    assertEquals(2, filteredRowSet.getRow());
    assertEquals("test", filteredRowSet.getString(2));

    filteredRowSet.previous();
    assertTrue(filteredRowSet.isBeforeFirst());

    try {
        filteredRowSet.getString(2);
        fail("should should SQLException");
    } catch (SQLException e) {
        // expected, Not a valid cursor
    }

    filteredRowSet.setFilter(null);

    assertTrue(filteredRowSet.isBeforeFirst());

    assertTrue(filteredRowSet.next());
    assertEquals("update", filteredRowSet.getString(2));

    filteredRowSet.setFilter(range);
    assertEquals("update", filteredRowSet.getString(2));
    filteredRowSet.updateString(2, "testUpdate");

    filteredRowSet.next();
    assertEquals(2, filteredRowSet.getRow());
    assertEquals("test", filteredRowSet.getString(2));

    filteredRowSet.previous();
    assertEquals(1, filteredRowSet.getRow());
    assertEquals("testUpdate", filteredRowSet.getString(2));

}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testFilter_Insert() throws Exception {
    FilteredRowSet filteredRowSet = newFilterRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    filteredRowSet.populate(rs);

    Predicate range = new RangeOne();
    filteredRowSet.setFilter(range);

    /*
     * Insert a row. when call updateXXX(), evaluate(Object value, int
     * column) is called to check first.
     */
    filteredRowSet.afterLast();
    filteredRowSet.moveToInsertRow();
    filteredRowSet.updateInt(1, 200);
    try {
        filteredRowSet.updateString("NAME", "test200");
        fail("should throw SQLException");
    } catch (SQLException e) {
        filteredRowSet.updateString("NAME", "insert200");
    }
    filteredRowSet.insertRow();
    filteredRowSet.moveToCurrentRow();

    /*
     * Although the new row is inserted, it is invalid through
     * evaluate(RowSet rs). Therefore, the inserted row is not visible.
     */
    filteredRowSet.beforeFirst();
    int index = 0;
    while (filteredRowSet.next()) {
        index++;
        assertEquals(index + 1, filteredRowSet.getInt(1));
    }
    assertEquals(3, index);

    /*
     * Remove filter. See the inserted row. Then set again, and commit to
     * database.
     */
    filteredRowSet.setFilter(null);
    assertTrue(filteredRowSet.last());
    assertEquals(200, filteredRowSet.getInt(1));
    assertTrue(filteredRowSet.rowInserted());
    filteredRowSet.setFilter(range);
    filteredRowSet.acceptChanges(conn);
    // check database: the inserted row isn't commited to database
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    index = 0;
    while (rs.next()) {
        index++;
        assertEquals(index, rs.getInt(1));
    }
    assertEquals(4, index);

    /*
     * Remove filter
     */
    filteredRowSet.setFilter(null);
    filteredRowSet.beforeFirst();
    index = 0;
    while (filteredRowSet.next()) {
        index++;
        if (index == 5) {
            /*
             * Though the new row isn't inserted into database, the inserted
             * row lost it's status after acceptChanges().
             */
            assertEquals(200, filteredRowSet.getInt(1));
            assertFalse(filteredRowSet.rowInserted());
        } else {
            assertEquals(index, filteredRowSet.getInt(1));
        }
    }
    assertEquals(5, index);
}
项目:cn1    文件:FilteredRowSetTest.java   
public void testPaging() throws Exception {
    insertMoreData(4);

    FilteredRowSet filteredRowSet = newFilterRowSet();

    filteredRowSet.setCommand("select * from USER_INFO");
    filteredRowSet.setUrl(DERBY_URL);

    filteredRowSet.setPageSize(3);
    filteredRowSet.execute();

    Predicate filter = new OddRowFilter();

    filteredRowSet.setFilter(filter);

    assertEquals("select * from USER_INFO", filteredRowSet.getCommand());

    assertFalse(filteredRowSet.previousPage());

    assertTrue(filteredRowSet.next());
    assertEquals(1, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.next());
    assertEquals(3, filteredRowSet.getInt(1));

    assertFalse(filteredRowSet.next());
    assertTrue(filteredRowSet.isAfterLast());

    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        // RI need nextPage one more time
        assertTrue(filteredRowSet.nextPage());
    }

    int index = 5;
    while (filteredRowSet.nextPage()) {
        while (filteredRowSet.next()) {
            assertEquals(index, filteredRowSet.getInt(1));
            index += 2;
        }
    }

    assertEquals(9, index);

    filteredRowSet = newFilterRowSet();
    filteredRowSet.setCommand("select * from USER_INFO");
    filteredRowSet.setUrl(DERBY_URL);

    filteredRowSet.setPageSize(3);
    filteredRowSet.execute();

    filteredRowSet.setFilter(filter);

    assertTrue(filteredRowSet.next());
    assertEquals(1, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.nextPage());
    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        // RI need nextPage one more time
        assertTrue(filteredRowSet.nextPage());
    }

    assertTrue(filteredRowSet.next());

    assertEquals(5, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.nextPage());

    assertTrue(filteredRowSet.next());
    assertEquals(7, filteredRowSet.getInt(1));

    assertFalse(filteredRowSet.nextPage());

}
项目:freeVM    文件:FilteredRowSetTest.java   
public void testPaging() throws Exception {
    insertMoreData(4);

    FilteredRowSet filteredRowSet = newFilterRowSet();

    filteredRowSet.setCommand("select * from USER_INFO");
    filteredRowSet.setUrl(DERBY_URL);

    filteredRowSet.setPageSize(3);
    filteredRowSet.execute();

    Predicate filter = new OddRowFilter();

    filteredRowSet.setFilter(filter);

    assertEquals("select * from USER_INFO", filteredRowSet.getCommand());

    assertFalse(filteredRowSet.previousPage());

    assertTrue(filteredRowSet.next());
    assertEquals(1, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.next());
    assertEquals(3, filteredRowSet.getInt(1));

    assertFalse(filteredRowSet.next());
    assertTrue(filteredRowSet.isAfterLast());

    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        // RI need nextPage one more time
        assertTrue(filteredRowSet.nextPage());
    }

    int index = 5;
    while (filteredRowSet.nextPage()) {
        while (filteredRowSet.next()) {
            assertEquals(index, filteredRowSet.getInt(1));
            index += 2;
        }
    }

    assertEquals(9, index);

    filteredRowSet = newFilterRowSet();
    filteredRowSet.setCommand("select * from USER_INFO");
    filteredRowSet.setUrl(DERBY_URL);

    filteredRowSet.setPageSize(3);
    filteredRowSet.execute();

    filteredRowSet.setFilter(filter);

    assertTrue(filteredRowSet.next());
    assertEquals(1, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.nextPage());
    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        // RI need nextPage one more time
        assertTrue(filteredRowSet.nextPage());
    }

    assertTrue(filteredRowSet.next());

    assertEquals(5, filteredRowSet.getInt(1));

    assertTrue(filteredRowSet.nextPage());

    assertTrue(filteredRowSet.next());
    assertEquals(7, filteredRowSet.getInt(1));

    assertFalse(filteredRowSet.nextPage());

}