Search in sources :

Example 6 with WebRowSet

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

the class CommonWebRowSetTests method writeWebRowSetWithOutputStream.

/*
     * Utility method to write a WebRowSet XML file via an OutputStream
     * and populating the WebRowSet via a ResultSet
     */
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(ResultSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        WebRowSet wrs = rsf.createWebRowSet();
        wrs.writeXml(rs, oos);
    }
    return baos;
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 7 with WebRowSet

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

the class CommonWebRowSetTests method readWebRowSetWithOInputStreamWithReader.

/*
     * Utility method to popoulate a WebRowSet via a Readar
     */
protected WebRowSet readWebRowSetWithOInputStreamWithReader(ByteArrayOutputStream baos) throws Exception {
    WebRowSet wrs1 = rsf.createWebRowSet();
    InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(baos.toByteArray()));
    wrs1.readXml(isr);
    return wrs1;
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 8 with WebRowSet

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

the class CommonWebRowSetTests method WebRowSetTest0005.

/*
     * 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 WebRowSetTest0005(WebRowSet wrs) throws Exception {
    ByteArrayOutputStream baos = writeWebRowSetWithOutputStreamWithWriter(wrs);
    try (WebRowSet wrs1 = readWebRowSetWithOInputStreamWithReader(baos)) {
        assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
        assertEquals(wrs1.size(), COFFEES_ROWS);
    }
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Aggregations

WebRowSet (javax.sql.rowset.WebRowSet)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Test (org.testng.annotations.Test)5 ResultSet (java.sql.ResultSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStreamReader (java.io.InputStreamReader)1 ObjectOutputStream (java.io.ObjectOutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1