Java 类javax.sql.rowset.WebRowSet 实例源码

项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@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);
    }
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@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);
    }
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0010(WebRowSet wrs1) throws Exception {
    FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == COFFEES_ROWS);
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 3) {
            assertTrue(wrs1.rowUpdated());
            assertTrue(wrs1.getInt(5) == 21 && wrs1.getInt(6) == 69);
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        } else {
            assertFalse(wrs1.rowUpdated());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        }
    }
    wrs1.close();
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
    int expectedSize = COFFEES_ROWS + 2;
    int addedRowPK = 15;
    int addedRowPK2 = 20;
    Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize);
    expected[expectedSize - 2] = addedRowPK;
    expected[expectedSize - 1] = addedRowPK2;
    FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == expectedSize);
    assertEqualsNoOrder(getPrimaryKeys(wrs1), expected);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) {
            assertTrue(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        } else {
            assertFalse(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        }
    }
    wrs1.close();
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
@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);
    }
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
@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);
    }
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0010(WebRowSet wrs1) throws Exception {
    FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == COFFEES_ROWS);
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 3) {
            assertTrue(wrs1.rowUpdated());
            assertTrue(wrs1.getInt(5) == 21 && wrs1.getInt(6) == 69);
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        } else {
            assertFalse(wrs1.rowUpdated());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        }
    }
    wrs1.close();
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
    int expectedSize = COFFEES_ROWS + 2;
    int addedRowPK = 15;
    int addedRowPK2 = 20;
    Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize);
    expected[expectedSize - 2] = addedRowPK;
    expected[expectedSize - 1] = addedRowPK2;
    FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == expectedSize);
    assertEqualsNoOrder(getPrimaryKeys(wrs1), expected);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) {
            assertTrue(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        } else {
            assertFalse(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        }
    }
    wrs1.close();
}
项目:openjdk9    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0010(WebRowSet wrs1) throws Exception {
    FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == COFFEES_ROWS);
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 3) {
            assertTrue(wrs1.rowUpdated());
            assertTrue(wrs1.getInt(5) == 21 && wrs1.getInt(6) == 69);
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        } else {
            assertFalse(wrs1.rowUpdated());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        }
    }
    wrs1.close();
}
项目:openjdk9    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
    int expectedSize = COFFEES_ROWS + 2;
    int addedRowPK = 15;
    int addedRowPK2 = 20;
    Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize);
    expected[expectedSize - 2] = addedRowPK;
    expected[expectedSize - 1] = addedRowPK2;
    FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == expectedSize);
    assertEqualsNoOrder(getPrimaryKeys(wrs1), expected);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) {
            assertTrue(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        } else {
            assertFalse(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        }
    }
    wrs1.close();
}
项目:jdk8u_jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0010(WebRowSet wrs1) throws Exception {
    FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == COFFEES_ROWS);
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 3) {
            assertTrue(wrs1.rowUpdated());
            assertTrue(wrs1.getInt(5) == 21 && wrs1.getInt(6) == 69);
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        } else {
            assertFalse(wrs1.rowUpdated());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        }
    }
    wrs1.close();
}
项目:jdk8u_jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
    int expectedSize = COFFEES_ROWS + 2;
    int addedRowPK = 15;
    int addedRowPK2 = 20;
    Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize);
    expected[expectedSize - 2] = addedRowPK;
    expected[expectedSize - 1] = addedRowPK2;
    FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == expectedSize);
    assertEqualsNoOrder(getPrimaryKeys(wrs1), expected);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) {
            assertTrue(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        } else {
            assertFalse(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        }
    }
    wrs1.close();
}
项目:lookaside_java-1.8.0-openjdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0010(WebRowSet wrs1) throws Exception {
    FileInputStream fis = new FileInputStream(UPDATED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == COFFEES_ROWS);
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 3) {
            assertTrue(wrs1.rowUpdated());
            assertTrue(wrs1.getInt(5) == 21 && wrs1.getInt(6) == 69);
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        } else {
            assertFalse(wrs1.rowUpdated());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowInserted());
        }
    }
    wrs1.close();
}
项目:lookaside_java-1.8.0-openjdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0011(WebRowSet wrs1) throws Exception {
    int expectedSize = COFFEES_ROWS + 2;
    int addedRowPK = 15;
    int addedRowPK2 = 20;
    Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize);
    expected[expectedSize - 2] = addedRowPK;
    expected[expectedSize - 1] = addedRowPK2;
    FileInputStream fis = new FileInputStream(INSERTED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == expectedSize);
    assertEqualsNoOrder(getPrimaryKeys(wrs1), expected);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == 15 || wrs1.getInt(1) == 20) {
            assertTrue(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        } else {
            assertFalse(wrs1.rowInserted());
            assertFalse(wrs1.rowDeleted());
            assertFalse(wrs1.rowUpdated());
        }
    }
    wrs1.close();
}
项目:cn1    文件:XmlWriterTest.java   
public void testWriteXML_Delete() throws Exception {
    WebRowSet webRs = newWebRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    webRs.populate(rs);

    webRs.absolute(3);
    webRs.deleteRow();

    assertEquals(0, webRs.getRow());

    webRs.writeXml(strWriter);

    assertTrue(webRs.isAfterLast());

    Document doc = getDocument(strWriter);

    assertProperties(doc, webRs);
    assertMetadata(doc, webRs);
    assertData(doc, webRs);
}
项目:cn1    文件:XmlWriterTest.java   
public static void assertData(Document doc, WebRowSet webRs)
        throws Exception {
    webRs.setShowDeleted(true);
    webRs.beforeFirst();

    Element element = (Element) doc.getFirstChild();
    Element dataEle = getElement(element, "data");
    NodeList nodeList = dataEle.getChildNodes();
    int rowIndex = 0;
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node instanceof Element) {
            rowIndex++;
            Element rowEle = (Element) node;
            assertRow(rowEle, webRs, rowIndex);
        }
    }
    assertEquals(webRs.size(), rowIndex);
    webRs.setShowDeleted(false);
}
项目:cn1    文件:XmlReaderTest.java   
public void testReaderXml_Header() throws Exception {
    /*
     * when run on RI, the Attribute xmlns can be empty. And the
     * xsi:schemaLocation also can be empty. However, The value of the
     * attribute "prefix="xmlns",localpart="xsi" can't be empty. No matter
     * what the value of these attributes are, the output xml's header of
     * WebRowSet keeps the same.
     */
    WebRowSet webRs = newWebRowSet();
    Reader fileReader = new FileReader(XML_SRC_URL_INVALID_HEADER);
    webRs.readXml(fileReader);

    StringWriter strWriter = new StringWriter();
    webRs.writeXml(strWriter);
    assertFalse(-1 == strWriter.toString().indexOf(
            "http://java.sun.com/xml/ns/jdbc"));
    assertFalse(-1 == strWriter.toString().indexOf(
            "http://www.w3.org/2001/XMLSchema-instance"));
}
项目:cn1    文件:XmlReaderTest.java   
public void testReaderXml_Reader() throws Exception {
    WebRowSet webRs = newWebRowSet();
    webRs.readXml(new FileReader(currentUrl));

    /*
     * TODO A row is marked as delete in XML. The row isn't marked as delete
     * any more after populate to WebRowSet.
     */
    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        assertTrue(webRs.absolute(3));
        assertEquals(3, webRs.getInt(1));
        assertFalse(webRs.rowDeleted());
        webRs.deleteRow();
    }

    Document srcDoc = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().parse(currentUrl);
    XmlWriterTest.assertProperties(srcDoc, webRs);
    XmlWriterTest.assertMetadata(srcDoc, webRs);
    XmlWriterTest.assertData(srcDoc, webRs);
}
项目:cn1    文件:XmlReaderTest.java   
public void testReaderXml_InputStream() throws Exception {
    WebRowSet webRs = newWebRowSet();
    webRs.readXml(new FileInputStream(currentUrl));

    /*
     * TODO A row is marked as delete in XML. The row isn't marked as delete
     * any more after populating to WebRowSet.
     */
    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        assertTrue(webRs.absolute(3));
        assertEquals(3, webRs.getInt(1));
        assertFalse(webRs.rowDeleted());
        webRs.deleteRow();
    }

    Document srcDoc = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().parse(currentUrl);
    XmlWriterTest.assertProperties(srcDoc, webRs);
    XmlWriterTest.assertMetadata(srcDoc, webRs);
    XmlWriterTest.assertData(srcDoc, webRs);
}
项目:freeVM    文件:XmlWriterTest.java   
public void testWriteXML_Delete() throws Exception {
    WebRowSet webRs = newWebRowSet();
    rs = st.executeQuery("SELECT * FROM USER_INFO");
    webRs.populate(rs);

    webRs.absolute(3);
    webRs.deleteRow();

    assertEquals(0, webRs.getRow());

    webRs.writeXml(strWriter);

    assertTrue(webRs.isAfterLast());

    Document doc = getDocument(strWriter);

    assertProperties(doc, webRs);
    assertMetadata(doc, webRs);
    assertData(doc, webRs);
}
项目:freeVM    文件:XmlWriterTest.java   
public static void assertData(Document doc, WebRowSet webRs)
        throws Exception {
    webRs.setShowDeleted(true);
    webRs.beforeFirst();

    Element element = (Element) doc.getFirstChild();
    Element dataEle = getElement(element, "data");
    NodeList nodeList = dataEle.getChildNodes();
    int rowIndex = 0;
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node instanceof Element) {
            rowIndex++;
            Element rowEle = (Element) node;
            assertRow(rowEle, webRs, rowIndex);
        }
    }
    assertEquals(webRs.size(), rowIndex);
    webRs.setShowDeleted(false);
}
项目:freeVM    文件:XmlReaderTest.java   
public void testReaderXml_Header() throws Exception {
    /*
     * when run on RI, the Attribute xmlns can be empty. And the
     * xsi:schemaLocation also can be empty. However, The value of the
     * attribute "prefix="xmlns",localpart="xsi" can't be empty. No matter
     * what the value of these attributes are, the output xml's header of
     * WebRowSet keeps the same.
     */
    WebRowSet webRs = newWebRowSet();
    Reader fileReader = new FileReader(XML_SRC_URL_INVALID_HEADER);
    webRs.readXml(fileReader);

    StringWriter strWriter = new StringWriter();
    webRs.writeXml(strWriter);
    assertFalse(-1 == strWriter.toString().indexOf(
            "http://java.sun.com/xml/ns/jdbc"));
    assertFalse(-1 == strWriter.toString().indexOf(
            "http://www.w3.org/2001/XMLSchema-instance"));
}
项目:freeVM    文件:XmlReaderTest.java   
public void testReaderXml_Reader() throws Exception {
    WebRowSet webRs = newWebRowSet();
    webRs.readXml(new FileReader(currentUrl));

    /*
     * TODO A row is marked as delete in XML. The row isn't marked as delete
     * any more after populate to WebRowSet.
     */
    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        assertTrue(webRs.absolute(3));
        assertEquals(3, webRs.getInt(1));
        assertFalse(webRs.rowDeleted());
        webRs.deleteRow();
    }

    Document srcDoc = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().parse(currentUrl);
    XmlWriterTest.assertProperties(srcDoc, webRs);
    XmlWriterTest.assertMetadata(srcDoc, webRs);
    XmlWriterTest.assertData(srcDoc, webRs);
}
项目:freeVM    文件:XmlReaderTest.java   
public void testReaderXml_InputStream() throws Exception {
    WebRowSet webRs = newWebRowSet();
    webRs.readXml(new FileInputStream(currentUrl));

    /*
     * TODO A row is marked as delete in XML. The row isn't marked as delete
     * any more after populating to WebRowSet.
     */
    if (!"true".equals(System.getProperty("Testing Harmony"))) {
        assertTrue(webRs.absolute(3));
        assertEquals(3, webRs.getInt(1));
        assertFalse(webRs.rowDeleted());
        webRs.deleteRow();
    }

    Document srcDoc = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder().parse(currentUrl);
    XmlWriterTest.assertProperties(srcDoc, webRs);
    XmlWriterTest.assertMetadata(srcDoc, webRs);
    XmlWriterTest.assertData(srcDoc, webRs);
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        rs.writeXml(oos);
    }
    return baos;
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
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;
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
protected WebRowSet readWebRowSetWithOInputStream(ByteArrayOutputStream baos) throws Exception {
    WebRowSet wrs1 = rsf.createWebRowSet();
    try (ObjectInputStream ois
            = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
        wrs1.readXml(ois);
    }
    return wrs1;
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
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;
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0001(WebRowSet wrs1) throws Exception {

    try (FileReader fr = new FileReader(COFFEE_ROWS_XML)) {
        wrs1.readXml(fr);
    }
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    assertEquals(wrs1.size(), COFFEES_ROWS);
    wrs1.close();

}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0002(WebRowSet wrs1) throws Exception {
    try (FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML)) {
        wrs1.readXml(fis);
    }
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    assertEquals(wrs1.size(), COFFEES_ROWS);
    wrs1.close();
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@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);
    }
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@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);
    }
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0008(WebRowSet wrs1) throws Exception {
    FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == COFFEES_ROWS);
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    // Validate that the rows are not marked as deleted, inserted or updated
    wrs1.beforeFirst();
    while (wrs1.next()) {
        assertFalse(wrs1.rowDeleted());
        assertFalse(wrs1.rowInserted());
        assertFalse(wrs1.rowUpdated());
    }
    wrs1.close();
}
项目:jdk8u-jdk    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0012(WebRowSet wrs1) throws Exception {
    int expectedSize = COFFEES_ROWS + 1;
    int addedRowPK = 100;
    Object[] expected = Arrays.copyOf(COFFEES_PRIMARY_KEYS, expectedSize);
    expected[expectedSize - 1] = addedRowPK;
    FileInputStream fis = new FileInputStream(UPDATED_INSERTED_COFFEE_ROWS_XML);
    wrs1.readXml(fis);
    assertTrue(wrs1.size() == expectedSize);
    assertEquals(getPrimaryKeys(wrs1), expected);
    wrs1.beforeFirst();
    while (wrs1.next()) {
        if (wrs1.getInt(1) == addedRowPK) {
            // Row that was inserted and updated
            assertTrue(wrs1.rowUpdated());
            assertTrue(
                    wrs1.getBigDecimal(4).equals(BigDecimal.valueOf(12.99))
                    && wrs1.getInt(6) == 125);
            assertFalse(wrs1.rowDeleted());
            assertTrue(wrs1.rowInserted());
        } else {
            // Remaining rows should only be inserted
            assertFalse(wrs1.rowUpdated());
            assertFalse(wrs1.rowDeleted());
            assertTrue(wrs1.rowInserted());
        }
    }
    wrs1.close();
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        rs.writeXml(oos);
    }
    return baos;
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
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;
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
protected WebRowSet readWebRowSetWithOInputStream(ByteArrayOutputStream baos) throws Exception {
    WebRowSet wrs1 = rsf.createWebRowSet();
    try (ObjectInputStream ois
            = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
        wrs1.readXml(ois);
    }
    return wrs1;
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
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;
}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0001(WebRowSet wrs1) throws Exception {

    try (FileReader fr = new FileReader(COFFEE_ROWS_XML)) {
        wrs1.readXml(fr);
    }
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    assertEquals(wrs1.size(), COFFEES_ROWS);
    wrs1.close();

}
项目:openjdk-jdk10    文件:CommonWebRowSetTests.java   
@Test(dataProvider = "rowSetType")
public void WebRowSetTest0002(WebRowSet wrs1) throws Exception {
    try (FileInputStream fis = new FileInputStream(COFFEE_ROWS_XML)) {
        wrs1.readXml(fis);
    }
    assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS);
    assertEquals(wrs1.size(), COFFEES_ROWS);
    wrs1.close();
}