Search in sources :

Example 16 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0060.

/*
     * Validate that restoreOrginal will restore the RowSet to its
     * state prior to updating a row
     */
@Test(dataProvider = "rowsetUsingCoffees", enabled = true)
public void commonCachedRowSetTest0060(CachedRowSet rs) throws Exception {
    int rowToUpdate = 2;
    String coffee = "Hazelnut";
    try (CachedRowSet crs1 = rsf.createCachedRowSet()) {
        rs.beforeFirst();
        crs1.populate(rs);
        TestRowSetListener rsl = new TestRowSetListener();
        crs1.addRowSetListener(rsl);
        // Delete a row, the PK is also the absolute position as a List
        // backs the RowSet
        crs1.absolute(rowToUpdate);
        String origCoffee = crs1.getString(2);
        crs1.updateString(2, coffee);
        assertTrue(crs1.columnUpdated(2));
        crs1.updateRow();
        assertTrue(crs1.rowUpdated());
        assertFalse(origCoffee.equals(crs1.getString(2)));
        // Restore back to our original state and the
        // previous value for the column within the row should be there
        rsl.resetFlag();
        crs1.restoreOriginal();
        assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
        assertTrue(crs1.isBeforeFirst());
        // absolute() is failing for some reason so need to look at this later
        crs1.next();
        crs1.next();
        assertFalse(crs1.columnUpdated(2));
        assertFalse(crs1.rowUpdated());
        assertTrue(origCoffee.equals(crs1.getString(2)));
    }
    rs.close();
}
Also used : TestRowSetListener(util.TestRowSetListener) CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 17 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class BaseRowSetTests method baseRowSetTest0000.

/*
     * Create a RowSetListener and validate that notifyCursorMoved is called
     */
@Test(dataProvider = "rowSetType")
public void baseRowSetTest0000(StubBaseRowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.notifyCursorMoved();
    assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED));
}
Also used : TestRowSetListener(util.TestRowSetListener) Test(org.testng.annotations.Test)

Example 18 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class BaseRowSetTests method baseRowSetTest0008.

/*
     * Create a RowSetListener and validate that notifyRowSetChanged is called,
     * remove the listener, invoke notifyRowSetChanged again and verify the
     * listner is not called
     */
@Test(dataProvider = "rowSetType")
public void baseRowSetTest0008(StubBaseRowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.notifyRowSetChanged();
    assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
    // Clear the flag indicating the listener has been called
    rsl.resetFlag();
    rs.removeRowSetListener(rsl);
    rs.notifyRowSetChanged();
    assertFalse(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
}
Also used : TestRowSetListener(util.TestRowSetListener) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)18 TestRowSetListener (util.TestRowSetListener)18 CachedRowSet (javax.sql.rowset.CachedRowSet)3