use of javax.sql.rowset.WebRowSet in project jdk8u_jdk by JetBrains.
the class CommonWebRowSetTests method WebRowSetTest0003.
/*
* Write a WebRowSet via writeXML(OutputStream), read it
* back via readXML(InputStream) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
public void WebRowSetTest0003(WebRowSet wrs) throws Exception {
ByteArrayOutputStream baos = writeWebRowSetWithOutputStream(wrs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStream(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
}
}
use of javax.sql.rowset.WebRowSet in project jdk8u_jdk by JetBrains.
the class CommonWebRowSetTests method WebRowSetTest0007.
/*
* Validate the expected Rows are contained within the RowSet
* after deleting the specified rows
*/
@Test(dataProvider = "rowsetUsingCoffees", enabled = false)
public void WebRowSetTest0007(WebRowSet wrs) throws Exception {
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
int[] rowsToDelete = { 2, 4 };
assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS);
for (int row : rowsToDelete) {
assertTrue(deleteRowByPrimaryKey(wrs, row, 1));
}
FileInputStream fis = new FileInputStream(MODFIED_DELETED_COFFEE_ROWS_XML);
try (WebRowSet wrs1 = rsf.createWebRowSet()) {
wrs1.readXml(fis);
// the deleted row should not be visible
for (int row : rowsToDelete) {
assertTrue(findRowByPrimaryKey(wrs1, row, 1));
}
assertTrue(wrs.size() == COFFEES_ROWS);
// With setShowDeleted(true), the deleted row should be visible
for (int row : rowsToDelete) {
assertTrue(findRowByPrimaryKey(wrs, row, 1));
}
}
}
use of javax.sql.rowset.WebRowSet in project jdk8u_jdk by JetBrains.
the class CommonWebRowSetTests method WebRowSetTest0006.
/*
* Write a WebRowSet via writeXML(Writer), read it
* back via readXML(Reader) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
public void WebRowSetTest0006(WebRowSet wrs) throws Exception {
ResultSet rs = wrs;
rs.beforeFirst();
ByteArrayOutputStream baos = writeWebRowSetWithOutputStreamWithWriter(rs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStreamWithReader(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
}
}
use of javax.sql.rowset.WebRowSet in project jdk8u_jdk by JetBrains.
the class CommonWebRowSetTests method WebRowSetTest0004.
/*
* Write a ResultSet via writeXML(OutputStream), read it
* back via readXML(InputStream) and validate the primary keys
* are the same
*/
@Test(dataProvider = "rowsetUsingCoffees")
public void WebRowSetTest0004(WebRowSet wrs) throws Exception {
ResultSet rs = wrs;
rs.beforeFirst();
ByteArrayOutputStream baos = writeWebRowSetWithOutputStream(rs);
try (WebRowSet wrs1 = readWebRowSetWithOInputStream(baos)) {
assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
assertEquals(wrs1.size(), COFFEES_ROWS);
}
}
use of javax.sql.rowset.WebRowSet in project jdk8u_jdk by JetBrains.
the class CommonWebRowSetTests method writeWebRowSetWithOutputStreamWithWriter.
/*
* Utility method to write a WebRowSet XML file via an Writer and populating
* the WebRowSet via a ResultSet
*/
protected ByteArrayOutputStream writeWebRowSetWithOutputStreamWithWriter(ResultSet rs) throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(baos);
WebRowSet wrs = rsf.createWebRowSet();
wrs.writeXml(rs, osw);
return baos;
}
Aggregations