Search in sources :

Example 11 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class BaseRowSetTests method baseRowSetTest0006.

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

Example 12 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0009.

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

Example 13 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0059.

/*
     * Validate that restoreOrginal will restore the RowSet to its
     * state prior to deleting a row
     */
@Test(dataProvider = "rowsetUsingCoffees", enabled = true)
public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception {
    int rowToDelete = 2;
    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(rowToDelete);
        crs1.deleteRow();
        assertTrue(crs1.rowDeleted());
        assertFalse(findRowByPrimaryKey(crs1, rowToDelete, 1));
        // Restore back to our original state and the
        // previously deleted row should be there
        rsl.resetFlag();
        crs1.restoreOriginal();
        assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
        assertTrue(crs1.isBeforeFirst());
        crs1.absolute(rowToDelete);
        assertFalse(crs1.rowDeleted());
        assertTrue(findRowByPrimaryKey(crs1, rowToDelete, 1));
    }
    rs.close();
}
Also used : TestRowSetListener(util.TestRowSetListener) CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 14 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0058.

/*
     * Validate that restoreOrginal will restore the RowSet to its
     * state prior to the insert of a row
     */
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0058(CachedRowSet rs) throws Exception {
    int rowToInsert = 1961;
    assertTrue(rs.size() == COFFEE_HOUSES_ROWS);
    try (// Add new row
    CachedRowSet crs1 = rsf.createCachedRowSet()) {
        rs.beforeFirst();
        crs1.populate(rs);
        TestRowSetListener rsl = new TestRowSetListener();
        crs1.addRowSetListener(rsl);
        crs1.moveToInsertRow();
        crs1.updateInt(1, rowToInsert);
        crs1.updateString(2, "GOTHAM");
        crs1.updateInt(3, 3450);
        crs1.updateInt(4, 2005);
        crs1.updateInt(5, 5455);
        crs1.insertRow();
        assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED));
        crs1.moveToCurrentRow();
        assertTrue(findRowByPrimaryKey(crs1, rowToInsert, 1));
        // Restore back to our original state and the
        // previously inserted row should not be there
        rsl.resetFlag();
        crs1.restoreOriginal();
        assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
        assertTrue(crs1.isBeforeFirst());
        crs1.last();
        assertFalse(crs1.rowInserted());
        assertFalse(findRowByPrimaryKey(crs1, rowToInsert, 1));
    }
    rs.close();
}
Also used : TestRowSetListener(util.TestRowSetListener) CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 15 with TestRowSetListener

use of util.TestRowSetListener in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0004.

/*
     * Create a RowSetListener and validate that notifyRowSetChanged is called
     */
@Test(dataProvider = "rowSetType")
public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception {
    TestRowSetListener rsl = new TestRowSetListener();
    rs.addRowSetListener(rsl);
    rs.release();
    assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
    rs.close();
}
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