Search in sources :

Example 1 with WebRowSet

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);
    }
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 2 with WebRowSet

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));
        }
    }
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) FileInputStream(java.io.FileInputStream) Test(org.testng.annotations.Test)

Example 3 with WebRowSet

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);
    }
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) ResultSet(java.sql.ResultSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 4 with WebRowSet

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);
    }
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) ResultSet(java.sql.ResultSet) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.testng.annotations.Test)

Example 5 with WebRowSet

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;
}
Also used : WebRowSet(javax.sql.rowset.WebRowSet) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

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