Java Code Examples for javax.sql.rowset.WebRowSet

The following examples show how to use javax.sql.rowset.WebRowSet. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hottub   Source File: CommonWebRowSetTests.java    License: GNU General Public License v2.0 6 votes vote down vote up
@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();
}
 
Example 2
@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();
}
 
Example 3
@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();
}
 
Example 4
@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();
}
 
Example 5
@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();
}
 
Example 6
@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();
}
 
Example 7
@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();
}
 
Example 8
@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();
}
 
Example 9
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        rs.writeXml(oos);
    }
    return baos;
}
 
Example 10
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;
}
 
Example 11
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;
}
 
Example 12
@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();
}
 
Example 13
@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();

}
 
Example 14
@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();
}
 
Example 15
@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);
    }
}
 
Example 16
@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();
}
 
Example 17
@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();
}
 
Example 18
@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();
}
 
Example 19
Source Project: hottub   Source File: CommonWebRowSetTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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();
}
 
Example 20
@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();
}
 
Example 21
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        rs.writeXml(oos);
    }
    return baos;
}
 
Example 22
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;
}
 
Example 23
@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();

}
 
Example 24
@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();
}
 
Example 25
Source Project: hottub   Source File: CommonWebRowSetTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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();
}
 
Example 26
Source Project: hottub   Source File: CommonWebRowSetTests.java    License: GNU General Public License v2.0 5 votes vote down vote up
@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);
    }
}
 
Example 27
@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);
    }
}
 
Example 28
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;
}
 
Example 29
@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();
}
 
Example 30
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;
}