Search in sources :

Example 6 with CachedRowSet

use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0038.

/*
     * Validate that createCopyNoConstraints() returns the proper values
     * and getMatchColumnIndexes should throw a SQLException. This test
     * specifies setMatchColumn(int)
     */
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0038(CachedRowSet rs) throws Exception {
    rs.setMatchColumn(1);
    try (CachedRowSet crs1 = rs.createCopyNoConstraints()) {
        assertTrue(crs1.size() == COFFEE_HOUSES_ROWS);
        compareRowSets(rs, crs1);
        boolean recievedSQE = false;
        try {
            int[] indexes = crs1.getMatchColumnIndexes();
        } catch (SQLException e) {
            recievedSQE = true;
        }
        assertTrue(recievedSQE);
        recievedSQE = false;
        try {
            String[] colNames = crs1.getMatchColumnNames();
        } catch (SQLException e) {
            recievedSQE = true;
        }
        assertTrue(recievedSQE);
    }
    rs.close();
}
Also used : SQLException(java.sql.SQLException) CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 7 with CachedRowSet

use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.

the class JoinRowSetTests method joinRowSetTests0003.

/*
     * Join two CachedRowSets specifying a column index to join against
     */
@Test(dataProvider = "createCachedRowSetsToUse")
public void joinRowSetTests0003(CachedRowSet crs, CachedRowSet crs1) throws Exception {
    try (JoinRowSet jrs = newInstance()) {
        RowSet[] rowsets = { crs, crs1 };
        int[] joinCols = { COFFEES_JOIN_COLUMN_INDEX, SUPPLIERS_JOIN_COLUMN_INDEX };
        jrs.addRowSet(rowsets, joinCols);
        validateResults(jrs);
        crs.close();
        crs1.close();
    }
}
Also used : JoinRowSet(javax.sql.rowset.JoinRowSet) JoinRowSet(javax.sql.rowset.JoinRowSet) WebRowSet(javax.sql.rowset.WebRowSet) CachedRowSet(javax.sql.rowset.CachedRowSet) RowSet(javax.sql.RowSet) Test(org.testng.annotations.Test)

Example 8 with CachedRowSet

use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0035.

/*
     * Validate that toCollection() returns the proper values
     */
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0035(CachedRowSet rs) throws Exception {
    Collection<?> col = rs.toCollection();
    assertTrue(rs.size() == col.size());
    assertTrue(rs.toCollection().containsAll(col) && col.containsAll(rs.toCollection()));
    try (// Validate that False is returned when compared to a different RowSet;
    CachedRowSet crs1 = createCoffeesRowSet()) {
        assertFalse(crs1.toCollection().containsAll(col) && col.containsAll(crs1.toCollection()));
    }
    rs.close();
}
Also used : CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 9 with CachedRowSet

use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.

the class CommonCachedRowSetTests method commonCachedRowSetTest0037.

/*
     * Validate that createCopySchema() returns the proper values
     */
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0037(CachedRowSet rs) throws Exception {
    try (CachedRowSet crs1 = rs.createCopySchema()) {
        assertTrue(crs1.size() == 0);
        compareMetaData(crs1.getMetaData(), rs.getMetaData());
    }
    rs.close();
}
Also used : CachedRowSet(javax.sql.rowset.CachedRowSet) Test(org.testng.annotations.Test)

Example 10 with CachedRowSet

use of javax.sql.rowset.CachedRowSet 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)

Aggregations

CachedRowSet (javax.sql.rowset.CachedRowSet)16 Test (org.testng.annotations.Test)11 OracleCachedRowSet (oracle.jdbc.rowset.OracleCachedRowSet)3 TestRowSetListener (util.TestRowSetListener)3 SQLException (java.sql.SQLException)2 RowSet (javax.sql.RowSet)2 JoinRowSet (javax.sql.rowset.JoinRowSet)2 WebRowSet (javax.sql.rowset.WebRowSet)2 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 ResultSetWrappingSqlRowSet (org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet)1 DataProvider (org.testng.annotations.DataProvider)1