private void validateResults(final JoinRowSet jrs) throws SQLException { List<Integer> results = new ArrayList<>(); jrs.beforeFirst(); while (jrs.next()) { if (jrs.getInt(JOIN_COLNAME) == SUP_ID) { results.add(jrs.getInt("COF_ID")); } } assertEquals(results.toArray(), EXPECTED); }
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0000(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { jrs.addRowSet(crs, JOIN_COLNAME); jrs.addRowSet(crs1, JOIN_COLNAME); validateResults(jrs); crs.close(); crs1.close(); } }
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0001(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { jrs.addRowSet(crs, COFFEES_JOIN_COLUMN_INDEX); jrs.addRowSet(crs1, SUPPLIERS_JOIN_COLUMN_INDEX); validateResults(jrs); crs.close(); crs1.close(); } }
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0002(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { RowSet[] rowsets = {crs, crs1}; String[] joinCols = {JOIN_COLNAME, JOIN_COLNAME}; jrs.addRowSet(rowsets, joinCols); validateResults(jrs); crs.close(); crs1.close(); } }
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0003(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { RowSet[] rowsets = {crs, crs1}; int[] joinCols = {COFFEES_JOIN_COLUMN_INDEX, SUPPLIERS_JOIN_COLUMN_INDEX}; jrs.addRowSet(rowsets, joinCols); validateResults(jrs); crs.close(); crs1.close(); } }
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0005(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { crs.setMatchColumn(JOIN_COLNAME); crs1.setMatchColumn(JOIN_COLNAME); jrs.addRowSet(crs); jrs.addRowSet(crs1); validateResults(jrs); crs.close(); crs1.close(); } }
@Test(dataProvider = "createCachedRowSetsToUse") public void joinRowSetTests0006(CachedRowSet crs, CachedRowSet crs1) throws Exception { try (JoinRowSet jrs = newInstance()) { crs.setMatchColumn(COFFEES_JOIN_COLUMN_INDEX); crs1.setMatchColumn(SUPPLIERS_JOIN_COLUMN_INDEX); jrs.addRowSet(crs); jrs.addRowSet(crs1); validateResults(jrs); crs.close(); crs1.close(); } }
public void testReadXml_Empty() throws Exception { jrs = newJoinRowSet(); jrs.addRowSet(crset, 1); StringWriter writer = new StringWriter(); jrs.writeXml(writer); JoinRowSet another = newJoinRowSet(); another.readXml(new StringReader(writer.getBuffer().toString())); assertCachedRowSetEquals(jrs, another); }
public void testWriteAndRead_Insert() throws Exception { jrs.addRowSet(crset, 1); jrs.beforeFirst(); assertTrue(jrs.next()); jrs.moveToInsertRow(); jrs.updateInt(1, 5); jrs.updateString(2, "insertrow"); jrs.insertRow(); jrs.moveToCurrentRow(); jrs.beforeFirst(); jrs.absolute(2); assertTrue(jrs.rowInserted()); StringWriter writer = new StringWriter(); jrs.writeXml(writer); JoinRowSet another = newJoinRowSet(); another.readXml(new StringReader(writer.getBuffer().toString())); if (System.getProperty("Testing Harmony") == "true") { assertCachedRowSetEquals(jrs, another); } else { // TODO why the output xml has no insert information. another.absolute(2); assertFalse(another.rowInserted()); jrs.absolute(2); assertTrue(jrs.rowInserted()); } }
public void testWriteAndRead_Update() throws Exception { jrs.addRowSet(crset, 1); jrs.beforeFirst(); assertTrue(jrs.absolute(3)); jrs.updateString(2, "updateRow"); jrs.updateRow(); assertTrue(jrs.next()); jrs.updateString(2, "anotherUpdateRow"); jrs.updateRow(); StringWriter writer = new StringWriter(); jrs.writeXml(writer); JoinRowSet another = newJoinRowSet(); another.readXml(new StringReader(writer.getBuffer().toString())); if (System.getProperty("Testing Harmony") == "true") { assertCachedRowSetEquals(jrs, another); } else { another.absolute(3); assertFalse(another.rowUpdated()); jrs.absolute(3); assertTrue(jrs.rowUpdated()); // TODO why the output xml has no update information. another.absolute(4); assertFalse(another.rowUpdated()); jrs.absolute(4); assertTrue(jrs.rowUpdated()); } }
public void testWriteXmlLResultSet() throws Exception { StringWriter writer = new StringWriter(); rs = st.executeQuery("select * from user_info"); jrs.writeXml(rs, writer); JoinRowSet jrs2 = newJoinRowSet(); jrs2.readXml(new StringReader(writer.getBuffer().toString())); assertCachedRowSetEquals(crset, jrs2); }