当前位置: 首页>>代码示例>>Java>>正文


Java WebRowSet类代码示例

本文整理汇总了Java中javax.sql.rowset.WebRowSet的典型用法代码示例。如果您正苦于以下问题:Java WebRowSet类的具体用法?Java WebRowSet怎么用?Java WebRowSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WebRowSet类属于javax.sql.rowset包,在下文中一共展示了WebRowSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WebRowSetTest0004

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:CommonWebRowSetTests.java

示例2: WebRowSetTest0006

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:CommonWebRowSetTests.java

示例3: WebRowSetTest0010

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:CommonWebRowSetTests.java

示例4: WebRowSetTest0011

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:CommonWebRowSetTests.java

示例5: testWriteXML_Delete

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:XmlWriterTest.java

示例6: assertData

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:XmlWriterTest.java

示例7: testReaderXml_Header

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:XmlReaderTest.java

示例8: testReaderXml_Reader

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:XmlReaderTest.java

示例9: testReaderXml_InputStream

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:XmlReaderTest.java

示例10: writeWebRowSetWithOutputStream

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        rs.writeXml(oos);
    }
    return baos;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:CommonWebRowSetTests.java

示例11: readWebRowSetWithOInputStream

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:CommonWebRowSetTests.java

示例12: writeWebRowSetWithOutputStreamWithWriter

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:CommonWebRowSetTests.java

示例13: WebRowSetTest0001

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:CommonWebRowSetTests.java

示例14: WebRowSetTest0002

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:CommonWebRowSetTests.java

示例15: WebRowSetTest0003

import javax.sql.rowset.WebRowSet; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:CommonWebRowSetTests.java


注:本文中的javax.sql.rowset.WebRowSet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。