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();
}
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();
}
use of javax.sql.rowset.CachedRowSet 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();
}
use of javax.sql.rowset.CachedRowSet in project jdk8u_jdk by JetBrains.
the class CommonCachedRowSetTests method commonCachedRowSetTest0039.
/*
* Validate that createCopyNoConstraints() returns the proper values
* and getMatchColumnIndexes should throw a SQLException. This test
* specifies setMatchColumn(String)
*/
@Test(dataProvider = "rowsetUsingCoffeeHouses")
public void commonCachedRowSetTest0039(CachedRowSet rs) throws Exception {
rs.setMatchColumn("ID");
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();
}
use of javax.sql.rowset.CachedRowSet 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();
}
Aggregations