--- old/test/javax/sql/testng/test/rowset/BaseRowSetTests.java 2015-01-09 09:47:15.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/BaseRowSetTests.java 2015-01-09 09:47:14.000000000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,13 +30,9 @@ import java.sql.Array; import java.sql.Blob; import java.sql.Clob; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; import java.sql.Date; import java.sql.Ref; -import java.sql.RowId; -import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLException; import java.sql.Time; import java.sql.Timestamp; import java.sql.Types; @@ -44,407 +40,74 @@ import java.time.LocalDateTime; import java.time.LocalTime; import java.util.Calendar; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; +import javax.sql.RowSet; import javax.sql.rowset.serial.SerialArray; import javax.sql.rowset.serial.SerialBlob; import javax.sql.rowset.serial.SerialClob; import javax.sql.rowset.serial.SerialRef; import static org.testng.Assert.*; -import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import util.BaseTest; import util.StubArray; import util.StubBaseRowSet; import util.StubBlob; import util.StubClob; -import util.StubNClob; import util.StubRef; -import util.StubRowId; -import util.StubSQLXML; import util.TestRowSetListener; -public class BaseRowSetTests extends BaseTest { +public class BaseRowSetTests extends CommonRowSetTests { private StubBaseRowSet brs; - private StubBaseRowSet brs1; - private final String query = "SELECT * FROM SUPERHEROS"; - private final String url = "jdbc:derby://localhost:1527/myDB"; - private final String dsName = "jdbc/myDB"; - private final String user = "Bruce Wayne"; - private final String password = "The Dark Knight"; - private final Date aDate = Date.valueOf(LocalDate.now()); - private final Time aTime = Time.valueOf(LocalTime.now()); - private final Timestamp ts = Timestamp.valueOf(LocalDateTime.now()); - private final Calendar cal = Calendar.getInstance(); - private final byte[] bytes = new byte[10]; - private RowId aRowid; - private Ref aRef; - private Blob aBlob; - private Clob aClob; - private Array aArray; - private InputStream is; - private Reader rdr; - private Map> map = new HashMap<>(); - - public BaseRowSetTests() { - brs1 = new StubBaseRowSet(); - is = new StringBufferInputStream(query); - rdr = new StringReader(query); - aRowid = new StubRowId(); - try { - aBlob = new SerialBlob(new StubBlob()); - aClob = new SerialClob(new StubClob()); - aRef = new SerialRef(new StubRef("INTEGER", query)); - aArray = new SerialArray(new StubArray("INTEGER", new Object[1])); - map.put("SUPERHERO", Class.forName("util.SuperHero")); - } catch (SQLException | ClassNotFoundException ex) { - Logger.getLogger(BaseRowSetTests.class.getName()).log(Level.SEVERE, null, ex); - } - } - @BeforeMethod @Override - public void setUpMethod() throws Exception { - brs = new StubBaseRowSet(); - } - - /* - * Validate that getCommand() returns null by default - */ - @Test - public void test() { - assertTrue(brs.getCommand() == null); - } - - /* - * Validate that getCommand() returns command specified to setCommand - */ - @Test - public void test01() throws Exception { - brs.setCommand(query); - assertTrue(brs.getCommand().equals(query)); - } - - /* - * Validate that getCurrency() returns the correct default value - */ - @Test - public void test02() throws Exception { - assertTrue(brs.getConcurrency() == ResultSet.CONCUR_UPDATABLE); - } - - /* - * Validate that getCurrency() returns the correct value - * after a call to setConcurrency()) - */ - @Test(dataProvider = "concurTypes") - public void test03(int concurType) throws Exception { - brs.setConcurrency(concurType); - assertTrue(brs.getConcurrency() == concurType); - } - - /* - * Validate that getCurrency() throws a SQLException for an invalid value - */ - @Test(expectedExceptions = SQLException.class) - public void test04() throws Exception { - brs.setConcurrency(ResultSet.CLOSE_CURSORS_AT_COMMIT); - } - - /* - * Validate that getDataSourceName() returns null by default - */ - @Test - public void test05() throws Exception { - assertTrue(brs.getDataSourceName() == null); - } - - /* - * Validate that getDataSourceName() returns the value specified - * by setDataSourceName() and getUrl() returns null - */ - @Test - public void test06() throws Exception { - brs.setUrl(url); - brs.setDataSourceName(dsName); - assertTrue(brs.getDataSourceName().equals(dsName)); - assertTrue(brs.getUrl() == null); - } - - /* - * Validate that setDataSourceName() throws a SQLException for an empty - * String specified for the data source name - */ - @Test(expectedExceptions = SQLException.class) - public void test07() throws Exception { - String dsname = ""; - brs.setDataSourceName(dsname); - } - - /* - * Validate that getEscapeProcessing() returns true by default - */ - @Test - public void test08() throws Exception { - assertTrue(brs.getEscapeProcessing()); - } - - /* - * Validate that getEscapeProcessing() returns value set by - * setEscapeProcessing() - */ - @Test(dataProvider = "trueFalse") - public void test09(boolean val) throws Exception { - brs.setEscapeProcessing(val); - assertTrue(brs.getEscapeProcessing() == val); - } - - /* - * Validate that getFetchDirection() returns the correct default value - */ - @Test - public void test10() throws Exception { - assertTrue(brs.getFetchDirection() == ResultSet.FETCH_FORWARD); - } - - /* - * Validate that getFetchDirection() returns the value set by - * setFetchDirection() - */ - @Test(dataProvider = "fetchDirection") - public void test11(int direction) throws Exception { - brs.setFetchDirection(direction); - assertTrue(brs.getFetchDirection() == direction); - } - - /* - * Validate that setConcurrency() throws a SQLException for an invalid value - */ - @Test(expectedExceptions = SQLException.class) - public void test12() throws Exception { - brs.setConcurrency(ResultSet.CLOSE_CURSORS_AT_COMMIT); - } - - /* - * Validate that setFetchSize() throws a SQLException for an invalid value - */ - @Test(expectedExceptions = SQLException.class) - public void test13() throws Exception { - brs.setFetchSize(-1); - } - - /* - * Validate that setFetchSize() throws a SQLException for a - * value greater than getMaxRows() - */ - @Test(expectedExceptions = SQLException.class) - public void test14() throws Exception { - brs.setMaxRows(5); - brs.setFetchSize(brs.getMaxRows() + 1); - } - - /* - * Validate that getFetchSize() returns the correct value after - * setFetchSize() has been called - */ - @Test - public void test15() throws Exception { - int maxRows = 150; - brs.setFetchSize(0); - assertTrue(brs.getFetchSize() == 0); - brs.setFetchSize(100); - assertTrue(brs.getFetchSize() == 100); - brs.setMaxRows(maxRows); - brs.setFetchSize(maxRows); - assertTrue(brs.getFetchSize() == maxRows); - } - - /* - * Validate that setMaxFieldSize() throws a SQLException for an invalid value - */ - @Test(expectedExceptions = SQLException.class) - public void test16() throws Exception { - brs.setMaxFieldSize(-1); - } - - /* - * Validate that getMaxFieldSize() returns the value set by - * setMaxFieldSize() - */ - @Test - public void test17() throws Exception { - brs.setMaxFieldSize(0); - assertTrue(brs.getMaxFieldSize() == 0); - brs.setMaxFieldSize(100); - assertTrue(brs.getMaxFieldSize() == 100); - brs.setMaxFieldSize(50); - assertTrue(brs.getMaxFieldSize() == 50); - } - - /* - * Validate that isReadOnly() returns value set by - * setReadOnly() - */ - @Test(dataProvider = "trueFalse") - public void test18(boolean val) throws Exception { - brs.setReadOnly(val); - assertTrue(brs.isReadOnly() == val); - } - - /* - * Validate that getTransactionIsolation() returns value set by - * setTransactionIsolation() - */ - @Test(dataProvider = "isolationTypes") - public void test19(int val) throws Exception { - brs.setTransactionIsolation(val); - assertTrue(brs.getTransactionIsolation() == val); - } - - /* - * Validate that getType() returns value set by setType() - */ - @Test(dataProvider = "scrollTypes") - public void test20(int val) throws Exception { - brs.setType(val); - assertTrue(brs.getType() == val); - } - - /* - * Validate that getEscapeProcessing() returns value set by - * setEscapeProcessing() - */ - @Test(dataProvider = "trueFalse") - public void test21(boolean val) throws Exception { - brs.setShowDeleted(val); - assertTrue(brs.getShowDeleted() == val); - } - - /* - * Validate that getTypeMap() returns same value set by - * setTypeMap() - */ - @Test() - public void test22() throws Exception { - brs.setTypeMap(map); - assertTrue(brs.getTypeMap().equals(map)); - } - - /* - * Validate that getUsername() returns same value set by - * setUsername() - */ - @Test() - public void test23() throws Exception { - brs.setUsername(user); - assertTrue(brs.getUsername().equals(user)); - } - - /* - * Validate that getPassword() returns same password set by - * setPassword() - */ - @Test() - public void test24() throws Exception { - brs.setPassword(password); - assertTrue(brs.getPassword().equals(password)); - } - - /* - * Validate that getQueryTimeout() returns same value set by - * setQueryTimeout() and that 0 is a valid timeout value - */ - @Test() - public void test25() throws Exception { - int timeout = 0; - brs.setQueryTimeout(timeout); - assertTrue(brs.getQueryTimeout() == timeout); - } - - /* - * Validate that getQueryTimeout() returns same value set by - * setQueryTimeout() and that 0 is a valid timeout value - */ - @Test() - public void test26() throws Exception { - int timeout = 10000; - brs.setQueryTimeout(timeout); - assertTrue(brs.getQueryTimeout() == timeout); + protected RowSet newInstance() throws SQLException { + return new StubBaseRowSet(); } /* - * Validate that setQueryTimeout() throws a SQLException for a timeout - * value < 0 - */ - @Test(expectedExceptions = SQLException.class) - public void test27() throws Exception { - brs.setQueryTimeout(-1); - } - - /* - * Create a RowSetListener and validate that notifyRowSetChanged is called + * Create a RowSetListener and validate that notifyCursorMoved is called */ - @Test() - public void test28() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0000(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.notifyRowSetChanged(); - assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + rs.addRowSetListener(rsl); + rs.notifyCursorMoved(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); } /* * Create a RowSetListener and validate that notifyRowChanged is called */ - @Test() - public void test29() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0001(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.notifyRowChanged(); + rs.addRowSetListener(rsl); + rs.notifyRowChanged(); assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); } /* - * Create a RowSetListener and validate that notifyCursorMoved is called - */ - @Test() - public void test30() throws Exception { - TestRowSetListener rsl = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.notifyCursorMoved(); - assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); - } - - /* - * Create a RowSetListener and validate that notifyRowSetChanged, - * notifyRowChanged() and notifyCursorMoved are called + * Create a RowSetListener and validate that notifyRowSetChanged is called */ - @Test() - public void test31() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0002(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.notifyRowSetChanged(); - brs.notifyRowChanged(); - brs.notifyCursorMoved(); - assertTrue(rsl.isNotified( - TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED - | TestRowSetListener.ROW_CHANGED)); + rs.addRowSetListener(rsl); + rs.notifyRowSetChanged(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); } /* * Create multiple RowSetListeners and validate that notifyRowSetChanged * is called on all listeners */ - @Test() - public void test32() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0003(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); TestRowSetListener rsl2 = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.addRowSetListener(rsl2); - brs.notifyRowSetChanged(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyRowSetChanged(); assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); assertTrue(rsl2.isNotified(TestRowSetListener.ROWSET_CHANGED)); } @@ -453,13 +116,13 @@ * Create multiple RowSetListeners and validate that notifyRowChanged * is called on all listeners */ - @Test() - public void test33() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0004(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); TestRowSetListener rsl2 = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.addRowSetListener(rsl2); - brs.notifyRowChanged(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyRowChanged(); assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); assertTrue(rsl2.isNotified(TestRowSetListener.ROW_CHANGED)); } @@ -468,30 +131,47 @@ * Create multiple RowSetListeners and validate that notifyCursorMoved * is called on all listeners */ - @Test() - public void test34() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0005(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); TestRowSetListener rsl2 = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.addRowSetListener(rsl2); - brs.notifyCursorMoved(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyCursorMoved(); assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED)); } /* + * Create a RowSetListener and validate that notifyRowSetChanged, + * notifyRowChanged() and notifyCursorMoved are called + */ + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0006(StubBaseRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.notifyRowSetChanged(); + rs.notifyRowChanged(); + rs.notifyCursorMoved(); + assertTrue(rsl.isNotified( + TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED + | TestRowSetListener.ROW_CHANGED)); + } + + + /* * Create multiple RowSetListeners and validate that notifyRowSetChanged, * notifyRowChanged() and notifyCursorMoved are called on all listeners */ - @Test() - public void test35() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0007(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); TestRowSetListener rsl2 = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.addRowSetListener(rsl2); - brs.notifyRowSetChanged(); - brs.notifyRowChanged(); - brs.notifyCursorMoved(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.notifyRowSetChanged(); + rs.notifyRowChanged(); + rs.notifyCursorMoved(); assertTrue(rsl.isNotified( TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED | TestRowSetListener.ROW_CHANGED)); @@ -505,55 +185,25 @@ * remove the listener, invoke notifyRowSetChanged again and verify the * listner is not called */ - @Test() - public void test36() throws Exception { + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0008(StubBaseRowSet rs) throws Exception { TestRowSetListener rsl = new TestRowSetListener(); - brs.addRowSetListener(rsl); - brs.notifyRowSetChanged(); + rs.addRowSetListener(rsl); + rs.notifyRowSetChanged(); assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); // Clear the flag indicating the listener has been called rsl.resetFlag(); - brs.removeRowSetListener(rsl); - brs.notifyRowSetChanged(); + rs.removeRowSetListener(rsl); + rs.notifyRowSetChanged(); assertFalse(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); } /* - * Validate addRowSetListener does not throw an Exception when null is - * passed as the parameter - */ - @Test() - public void test37() throws Exception { - brs.addRowSetListener(null); - } - - /* - * Validate removeRowSetListener does not throw an Exception when null is - * passed as the parameter - */ - @Test() - public void test38() throws Exception { - brs.removeRowSetListener(null); - } - - /* - * Set two parameters and then validate clearParameters() will clear them - */ - @Test() - public void test39() throws Exception { - brs.setInt(1, 1); - brs.setString(2, query); - assertTrue(brs.getParams().length == 2); - brs.clearParameters(); - assertTrue(brs.getParams().length == 0); - } - - /* * Set the base parameters and validate that the value set is * the correct type and value */ @Test(dataProvider = "testBaseParameters") - public void test40(int pos, Object o) throws Exception { + public void baseRowSetTest0009(int pos, Object o) throws Exception { assertTrue(getParam(pos, o).getClass().isInstance(o)); assertTrue(o.equals(getParam(pos, o))); } @@ -563,7 +213,7 @@ * the correct type */ @Test(dataProvider = "testAdvancedParameters") - public void test41(int pos, Object o) throws Exception { + public void baseRowSetTest0010(int pos, Object o) throws Exception { assertTrue(getParam(pos, o).getClass().isInstance(o)); } @@ -571,7 +221,8 @@ * Validate setNull specifying the supported type values */ @Test(dataProvider = "jdbcTypes") - public void test42(Integer type) throws Exception { + public void baseRowSetTest0011(Integer type) throws Exception { + brs = new StubBaseRowSet(); brs.setNull(1, type); assertTrue(checkNullParam(1, type, null)); } @@ -581,7 +232,8 @@ * typeName is set internally */ @Test(dataProvider = "jdbcTypes") - public void test43(Integer type) throws Exception { + public void baseRowSetTest0012(Integer type) throws Exception { + brs = new StubBaseRowSet(); brs.setNull(1, type, "SUPERHERO"); assertTrue(checkNullParam(1, type, "SUPERHERO")); } @@ -590,8 +242,10 @@ * Validate that setDate sets the specified Calendar internally */ @Test() - public void test44() throws Exception { - brs.setDate(1, aDate, cal); + public void baseRowSetTest0013() throws Exception { + Calendar cal = Calendar.getInstance(); + brs = new StubBaseRowSet(); + brs.setDate(1, Date.valueOf(LocalDate.now()), cal); assertTrue(checkCalendarParam(1, cal)); } @@ -599,8 +253,10 @@ * Validate that setTime sets the specified Calendar internally */ @Test() - public void test45() throws Exception { - brs.setTime(1, aTime, cal); + public void baseRowSetTest0014() throws Exception { + Calendar cal = Calendar.getInstance(); + brs = new StubBaseRowSet(); + brs.setTime(1, Time.valueOf(LocalTime.now()), cal); assertTrue(checkCalendarParam(1, cal)); } @@ -608,564 +264,23 @@ * Validate that setTimestamp sets the specified Calendar internally */ @Test() - public void test46() throws Exception { - brs.setTimestamp(1, ts, cal); + public void baseRowSetTest0015() throws Exception { + Calendar cal = Calendar.getInstance(); + brs = new StubBaseRowSet(); + brs.setTimestamp(1, Timestamp.valueOf(LocalDateTime.now()), cal); assertTrue(checkCalendarParam(1, cal)); } /* - * Validate that getURL() returns same value set by - * setURL() - */ - @Test() - public void test47() throws Exception { - brs.setUrl(url); - assertTrue(brs.getUrl().equals(url)); - } - - /* * Validate that initParams() initializes the parameters */ - @Test() - public void test48() throws Exception { - brs.setInt(1, 1); - brs.initParams(); - assertTrue(brs.getParams().length == 0); + @Test(dataProvider = "rowSetType") + public void baseRowSetTest0016(StubBaseRowSet rs) throws Exception { + rs.setInt(1, 1); + rs.initParams(); + assertTrue(rs.getParams().length == 0); } - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test100() throws Exception { - brs1.setAsciiStream(1, is); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test101() throws Exception { - brs1.setAsciiStream("one", is); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test102() throws Exception { - brs1.setAsciiStream("one", is, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test103() throws Exception { - brs1.setBinaryStream(1, is); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test104() throws Exception { - brs1.setBinaryStream("one", is); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test105() throws Exception { - brs1.setBinaryStream("one", is, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test106() throws Exception { - brs1.setBigDecimal("one", BigDecimal.ONE); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test107() throws Exception { - brs1.setBlob(1, is); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test108() throws Exception { - brs1.setBlob("one", is); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test109() throws Exception { - brs1.setBlob("one", is, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test110() throws Exception { - brs1.setBlob("one", aBlob); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test111() throws Exception { - brs1.setBoolean("one", true); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test112() throws Exception { - byte b = 1; - brs1.setByte("one", b); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test113() throws Exception { - byte b = 1; - brs1.setBytes("one", bytes); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test114() throws Exception { - brs1.setCharacterStream("one", rdr, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test115() throws Exception { - brs1.setCharacterStream("one", rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test116() throws Exception { - brs1.setCharacterStream(1, rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test117() throws Exception { - brs1.setClob(1, rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test118() throws Exception { - brs1.setClob("one", rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test119() throws Exception { - brs1.setClob("one", rdr, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test120() throws Exception { - brs1.setClob("one", aClob); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test121() throws Exception { - brs1.setDate("one", aDate); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test122() throws Exception { - brs1.setDate("one", aDate, cal); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test123() throws Exception { - brs1.setTime("one", aTime); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test124() throws Exception { - brs1.setTime("one", aTime, cal); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test125() throws Exception { - brs1.setTimestamp("one", ts); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test126() throws Exception { - brs1.setTimestamp("one", ts, cal); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test127() throws Exception { - brs1.setDouble("one", 2.0d); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test128() throws Exception { - brs1.setFloat("one", 2.0f); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test129() throws Exception { - brs1.setInt("one", 21); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test130() throws Exception { - brs1.setLong("one", 21l); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test131() throws Exception { - brs1.setNCharacterStream("one", rdr, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test132() throws Exception { - brs1.setNCharacterStream("one", rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test133() throws Exception { - brs1.setNCharacterStream(1, rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test134() throws Exception { - brs1.setNCharacterStream(1, rdr, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test135() throws Exception { - brs1.setClob("one", rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test136() throws Exception { - brs1.setClob("one", rdr, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test137() throws Exception { - brs1.setNClob("one", new StubNClob()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test138() throws Exception { - brs1.setNClob(1, rdr); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test139() throws Exception { - brs1.setNClob(1, rdr, query.length()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test140() throws Exception { - brs1.setNClob(1, new StubNClob()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test141() throws Exception { - brs1.setNString(1, query); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test142() throws Exception { - brs1.setNull("one", Types.INTEGER); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test143() throws Exception { - brs1.setNull("one", Types.INTEGER, "my.type"); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test144() throws Exception { - brs1.setObject("one", query, Types.VARCHAR); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test145() throws Exception { - brs1.setObject("one", query, Types.VARCHAR, 0); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test146() throws Exception { - brs1.setObject("one", query); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test147() throws Exception { - brs1.setRowId("one", aRowid); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test148() throws Exception { - brs1.setSQLXML("one", new StubSQLXML()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test149() throws Exception { - brs1.setSQLXML(1, new StubSQLXML()); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test150() throws Exception { - brs1.setNString(1, query); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test151() throws Exception { - brs1.setNString("one", query); - } - - /* - * This method is currently not implemented in BaseRowSet and will - * throw a SQLFeatureNotSupportedException - */ - @Test(expectedExceptions = SQLFeatureNotSupportedException.class) - public void test152() throws Exception { - short val = 21; - brs1.setShort("one", val); - } - - /* - * DataProvider used to specify the value to set and check for - * methods using transaction isolation types - */ - @DataProvider(name = "isolationTypes") - private Object[][] isolationTypes() { - return new Object[][]{ - {Connection.TRANSACTION_NONE}, - {Connection.TRANSACTION_READ_COMMITTED}, - {Connection.TRANSACTION_READ_UNCOMMITTED}, - {Connection.TRANSACTION_REPEATABLE_READ}, - {Connection.TRANSACTION_SERIALIZABLE} - }; - } - - /* - * DataProvider used to specify the value to set and check for the - * methods for fetch direction - */ - @DataProvider(name = "fetchDirection") - private Object[][] fetchDirection() { - return new Object[][]{ - {ResultSet.FETCH_FORWARD}, - {ResultSet.FETCH_REVERSE}, - {ResultSet.FETCH_UNKNOWN} - }; - } - - /* - * DataProvider used to specify the value to set and check for the - * methods for Concurrency - */ - @DataProvider(name = "concurTypes") - private Object[][] concurTypes() { - return new Object[][]{ - {ResultSet.CONCUR_READ_ONLY}, - {ResultSet.CONCUR_UPDATABLE} - }; - } - - /* - * DataProvider used to specify the value to set and check for the - * methods for Cursor Scroll Type - */ - @DataProvider(name = "scrollTypes") - private Object[][] scrollTypes() { - return new Object[][]{ - {ResultSet.TYPE_FORWARD_ONLY}, - {ResultSet.TYPE_SCROLL_INSENSITIVE}, - {ResultSet.TYPE_SCROLL_SENSITIVE} - }; - } /* * DataProvider used to set parameters for basic types that are supported @@ -1177,29 +292,33 @@ Short aShort = Short.MIN_VALUE; BigDecimal bd = BigDecimal.ONE; Double aDouble = Double.MAX_VALUE; + Date aDate = Date.valueOf(LocalDate.now()); + Time aTime = Time.valueOf(LocalTime.now()); + Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now()); + Calendar cal = Calendar.getInstance(); Boolean aBoolean = true; Float aFloat = 1.5f; Byte aByte = 1; + brs = new StubBaseRowSet(); - brs1.clearParameters(); - brs1.setInt(1, aInt); - brs1.setString(2, query); - brs1.setLong(3, aLong); - brs1.setBoolean(4, aBoolean); - brs1.setShort(5, aShort); - brs1.setDouble(6, aDouble); - brs1.setBigDecimal(7, bd); - brs1.setFloat(8, aFloat); - brs1.setByte(9, aByte); - brs1.setDate(10, aDate); - brs1.setTime(11, aTime); - brs1.setTimestamp(12, ts); - brs1.setDate(13, aDate, cal); - brs1.setTime(14, aTime, cal); - brs1.setTimestamp(15, ts); - brs1.setObject(16, query); - brs1.setObject(17, query, Types.CHAR); - brs1.setObject(18, query, Types.CHAR, 0); + brs.setInt(1, aInt); + brs.setString(2, query); + brs.setLong(3, aLong); + brs.setBoolean(4, aBoolean); + brs.setShort(5, aShort); + brs.setDouble(6, aDouble); + brs.setBigDecimal(7, bd); + brs.setFloat(8, aFloat); + brs.setByte(9, aByte); + brs.setDate(10, aDate); + brs.setTime(11, aTime); + brs.setTimestamp(12, aTimeStamp); + brs.setDate(13, aDate, cal); + brs.setTime(14, aTime, cal); + brs.setTimestamp(15, aTimeStamp); + brs.setObject(16, query); + brs.setObject(17, query, Types.CHAR); + brs.setObject(18, query, Types.CHAR, 0); return new Object[][]{ {1, aInt}, @@ -1213,10 +332,10 @@ {9, aByte}, {10, aDate}, {11, aTime}, - {12, ts}, + {12, aTimeStamp}, {13, aDate}, {14, aTime}, - {15, ts}, + {15, aTimeStamp}, {16, query}, {17, query}, {18, query} @@ -1230,16 +349,23 @@ @DataProvider(name = "testAdvancedParameters") private Object[][] testAdvancedParameters() throws SQLException { - brs1.clearParameters(); - brs1.setBytes(1, bytes); - brs1.setAsciiStream(2, is, query.length()); - brs1.setRef(3, aRef); - brs1.setArray(4, aArray); - brs1.setBlob(5, aBlob); - brs1.setClob(6, aClob); - brs1.setBinaryStream(7, is, query.length()); - brs1.setUnicodeStream(8, is, query.length()); - brs1.setCharacterStream(9, rdr, query.length()); + byte[] bytes = new byte[10]; + Ref aRef = new SerialRef(new StubRef("INTEGER", query)); + Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1])); + Blob aBlob = new SerialBlob(new StubBlob()); + Clob aClob = new SerialClob(new StubClob()); + Reader rdr = new StringReader(query); + InputStream is = new StringBufferInputStream(query);; + brs = new StubBaseRowSet(); + brs.setBytes(1, bytes); + brs.setAsciiStream(2, is, query.length()); + brs.setRef(3, aRef); + brs.setArray(4, aArray); + brs.setBlob(5, aBlob); + brs.setClob(6, aClob); + brs.setBinaryStream(7, is, query.length()); + brs.setUnicodeStream(8, is, query.length()); + brs.setCharacterStream(9, rdr, query.length()); return new Object[][]{ {1, bytes}, @@ -1261,7 +387,7 @@ */ @SuppressWarnings("unchecked") private T getParam(int pos, T o) throws SQLException { - Object[] params = brs1.getParams(); + Object[] params = brs.getParams(); if (params[pos - 1] instanceof Object[]) { Object[] param = (Object[]) params[pos - 1]; return (T) param[0]; --- old/test/javax/sql/testng/util/StubSyncProvider.java 2015-01-09 09:47:16.000000000 -0500 +++ new/test/javax/sql/testng/util/StubSyncProvider.java 2015-01-09 09:47:16.000000000 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,12 +51,12 @@ @Override public RowSetReader getRowSetReader() { - throw new UnsupportedOperationException("Not supported yet."); + return null; } @Override public RowSetWriter getRowSetWriter() { - throw new UnsupportedOperationException("Not supported yet."); + return null; } @Override --- /dev/null 2015-01-09 09:47:18.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/CommonRowSetTests.java 2015-01-09 09:47:17.000000000 -0500 @@ -0,0 +1,1372 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.sql.RowSet; +import javax.sql.rowset.BaseRowSet; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetFactory; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.RowSetProvider; +import org.testng.Assert; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import util.BaseTest; +import util.StubBlob; +import util.StubClob; +import util.StubNClob; +import util.StubSQLXML; + +public abstract class CommonRowSetTests extends BaseTest { + + protected final String stubProvider = "util.StubSyncProvider"; + protected final String query = "SELECT * FROM SUPERHEROS"; + private final String url = "jdbc:derby://localhost:1527/myDB"; + private final String dsName = "jdbc/myDB"; + private final String user = "Bruce Wayne"; + private final String password = "The Dark Knight"; + protected final String COFFEE_HOUSES_TABLE = "COFFEE_HOUSES"; + protected final String COFFEES_TABLE = "COFFEES"; + protected final int COFFEE_HOUSES_ROWS = 14; + protected final int COFFEES_ROWS = 5; + protected final Object[] COFFEES_PRIMARY_KEYS = {1, 2, 3, 4, 5}; + protected final Object[] COFFEE_HOUSES_PRIMARY_KEYS = { + 10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041, + 33005, 33010, 10035, 10037, 10034, 32004 + }; + + /* + * COFFEES_HOUSES Table column names + */ + protected final String[] COFFEE_HOUSES_COLUMN_NAMES = { + "STORE_ID", "CITY", "COFFEE", "MERCH", "TOTAL" + }; + + /* + * COFFEES Table column names + */ + protected final String[] COFFEES_COLUMN_NAMES = { + "COF_ID", "COF_NAME", "SUP_ID", "PRICE", "SALES", "TOTAL" + }; + + protected RowSetFactory rsf; + + public CommonRowSetTests() { + try { + rsf = RowSetProvider.newFactory(); + } catch (SQLException ex) { + Assert.fail(ex.getMessage()); + } + } + + // Create an instance of the RowSet we are using + protected abstract T newInstance() throws SQLException; + + //DataProvider to use for common tests + + /* + * DataProvider used to specify the value to set and check for the + * methods for fetch direction + */ + @DataProvider(name = "rowSetFetchDirection") + protected Object[][] rowSetFetchDirection() throws Exception { + RowSet rs = newInstance(); + return new Object[][]{ + {rs, ResultSet.FETCH_FORWARD}, + {rs, ResultSet.FETCH_REVERSE}, + {rs, ResultSet.FETCH_UNKNOWN} + }; + } + + /* + * DataProvider used to specify the value to set and check for the + * methods for Cursor Scroll Type + */ + @DataProvider(name = "rowSetScrollTypes") + protected Object[][] rowSetScrollTypes() throws Exception { + RowSet rs = newInstance(); + + return new Object[][]{ + {rs, ResultSet.TYPE_FORWARD_ONLY}, + {rs, ResultSet.TYPE_SCROLL_INSENSITIVE}, + {rs, ResultSet.TYPE_SCROLL_SENSITIVE} + }; + } + + /* + * DataProvider used to specify the value to set and check for + * methods using transaction isolation types + */ + @DataProvider(name = "rowSetIsolationTypes") + protected Object[][] rowSetIsolationTypes() throws Exception { + RowSet rs = newInstance(); + + return new Object[][]{ + {rs, Connection.TRANSACTION_NONE}, + {rs, Connection.TRANSACTION_READ_COMMITTED}, + {rs, Connection.TRANSACTION_READ_UNCOMMITTED}, + {rs, Connection.TRANSACTION_REPEATABLE_READ}, + {rs, Connection.TRANSACTION_SERIALIZABLE} + }; + } + + /* + * DataProvider used to specify the value to set and check for the + * methods for Concurrency + */ + @DataProvider(name = "rowSetConcurrencyTypes") + protected Object[][] rowSetConcurrencyTypes() throws Exception { + RowSet rs = newInstance(); + return new Object[][]{ + {rs, ResultSet.CONCUR_READ_ONLY}, + {rs, ResultSet.CONCUR_UPDATABLE} + }; + } + + /* + * DataProvider used to specify the value to set and check for + * methods using boolean values + */ + @DataProvider(name = "rowSetTrueFalse") + protected Object[][] rowSetTrueFalse() throws Exception { + RowSet rs = newInstance(); + return new Object[][]{ + {rs, true}, + {rs, false} + }; + } + /* + * DataProvider used to specify the type of RowSet to use. We also must + * initialize the RowSet + */ + @DataProvider(name = "rowSetType") + protected Object[][] rowSetType() throws Exception { + + RowSet rs = newInstance(); + return new Object[][]{ + {rs} + }; + } + + /* + * Initializes a RowSet containing the COFFEE_HOUSES data + */ + protected T createCoffeeHousesRowSet() throws SQLException { + T rs = (T) newInstance(); + initCoffeeHousesMetaData((CachedRowSet) rs); + createCoffeeHouseRows(rs); + // Make sure you are not on the insertRow + rs.moveToCurrentRow(); + return rs; + } + + /* + * Initializes a RowSet containing the COFFEE_HOUSES data + */ + protected T createCoffeesRowSet() throws SQLException { + T rs = (T) newInstance(); + initCoffeesMetaData((CachedRowSet) rs); + createCoffeesRows(rs); + // Make sure you are not on the insertRow + rs.moveToCurrentRow(); + return rs; + } + + /* + * Initializes the COFFEE_HOUSES metadata + */ + private void initCoffeeHousesMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); + + /* + * CREATE TABLE COFFEE_HOUSES( + * STORE_ID Integer NOT NULL, + * CITY VARCHAR(32), + * COFFEE INTEGER NOT NULL, + * MERCH INTEGER NOT NULL, + * TOTAL INTEGER NOT NULL, + * PRIMARY KEY (STORE_ID)) + */ + rsmd.setColumnCount(COFFEE_HOUSES_COLUMN_NAMES.length); + for(int i = 1; i <= COFFEE_HOUSES_COLUMN_NAMES.length; i++){ + rsmd.setColumnName(i, COFFEE_HOUSES_COLUMN_NAMES[i-1]); + rsmd.setColumnLabel(i, rsmd.getColumnName(i)); + } + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.VARCHAR); + rsmd.setColumnType(3, Types.INTEGER); + rsmd.setColumnType(4, Types.INTEGER); + rsmd.setColumnType(5, Types.INTEGER); + crs.setMetaData(rsmd); + crs.setTableName(COFFEE_HOUSES_TABLE); + + } + + /* + * Add rows to COFFEE_HOUSES table + */ + protected void createCoffeeHouseRows(RowSet rs) throws SQLException { + + // insert into COFFEE_HOUSES values(10023, 'Mendocino', 3450, 2005, 5455) + rs.moveToInsertRow(); + rs.updateInt(1, 10023); + rs.updateString(2, "Mendocino"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + // insert into COFFEE_HOUSES values(33002, 'Seattle', 4699, 3109, 7808) + rs.moveToInsertRow(); + rs.updateInt(1, 33002); + rs.updateString(2, "Seattle"); + rs.updateInt(3, 4699); + rs.updateInt(4, 3109); + rs.updateInt(5, 7808); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10040, 'SF', 5386, 2841, 8227) + rs.moveToInsertRow(); + rs.updateInt(1, 10040); + rs.updateString(2, "SF"); + rs.updateInt(3, 5386); + rs.updateInt(4, 2841); + rs.updateInt(5, 8227); + rs.insertRow(); + // insert into COFFEE_HOUSES values(32001, 'Portland', 3147, 3579, 6726) + rs.moveToInsertRow(); + rs.updateInt(1, 32001); + rs.updateString(2, "Portland"); + rs.updateInt(3, 3147); + rs.updateInt(4, 3579); + rs.updateInt(5, 6726); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10042, 'SF', 2863, 1874, 4710) + rs.moveToInsertRow(); + rs.updateInt(1, 10042); + rs.updateString(2, "SF"); + rs.updateInt(3, 2863); + rs.updateInt(4, 1874); + rs.updateInt(5, 4710); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10024, 'Sacramento', 1987, 2341, 4328) + rs.moveToInsertRow(); + rs.updateInt(1, 10024); + rs.updateString(2, "Sacramento"); + rs.updateInt(3, 1987); + rs.updateInt(4, 2341); + rs.updateInt(5, 4328); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10039, 'Carmel', 2691, 1121, 3812) + rs.moveToInsertRow(); + rs.updateInt(1, 10039); + rs.updateString(2, "Carmel"); + rs.updateInt(3, 2691); + rs.updateInt(4, 1121); + rs.updateInt(5, 3812); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10041, 'LA', 1533, 1007, 2540) + rs.moveToInsertRow(); + rs.updateInt(1, 10041); + rs.updateString(2, "LA"); + rs.updateInt(3, 1533); + rs.updateInt(4, 1007); + rs.updateInt(5, 2540); + rs.insertRow(); + // insert into COFFEE_HOUSES values(33005, 'Olympia', 2733, 1550, 1550) + rs.moveToInsertRow(); + rs.updateInt(1, 33005); + rs.updateString(2, "Olympia"); + rs.updateInt(3, 2733); + rs.updateInt(4, 1550); + rs.updateInt(5, 1550); + rs.insertRow(); + // insert into COFFEE_HOUSES values(33010, 'Seattle', 3210, 2177, 5387) + rs.moveToInsertRow(); + rs.updateInt(1, 33010); + rs.updateString(2, "Seattle"); + rs.updateInt(3, 3210); + rs.updateInt(4, 2177); + rs.updateInt(5, 5387); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10035, 'SF', 1922, 1056, 2978) + rs.moveToInsertRow(); + rs.updateInt(1, 10035); + rs.updateString(2, "SF"); + rs.updateInt(3, 1922); + rs.updateInt(4, 1056); + rs.updateInt(5, 2978); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10037, 'LA', 2143, 1876, 4019) + rs.moveToInsertRow(); + rs.updateInt(1, 10037); + rs.updateString(2, "LA"); + rs.updateInt(3, 2143); + rs.updateInt(4, 1876); + rs.updateInt(5, 4019); + rs.insertRow(); + // insert into COFFEE_HOUSES values(10034, 'San_Jose', 1234, 1032, 2266) + rs.moveToInsertRow(); + rs.updateInt(1, 10034); + rs.updateString(2, "San Jose"); + rs.updateInt(3, 1234); + rs.updateInt(4, 1032); + rs.updateInt(5, 2266); + rs.insertRow(); + // insert into COFFEE_HOUSES values(32004, 'Eugene', 1356, 1112, 2468) + rs.moveToInsertRow(); + rs.updateInt(1, 32004); + rs.updateString(2, "Eugene"); + rs.updateInt(3, 1356); + rs.updateInt(4, 1112); + rs.updateInt(5, 2468); + rs.insertRow(); + rs.moveToCurrentRow(); + } + + /* + * Initializes the COFFEES metadata + */ + protected void initCoffeesMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); + + /* + * CREATE TABLE COFFEES ( + * COF_ID INTEGER NOT NULL, + * COF_NAME VARCHAR(32) NOT NULL, + * SUP_ID INTEGER NOT NULL, + * PRICE NUMBERIC(10,2 NOT NULL, + * SALES INTEGER NOT NULL, + * TOTAL INTEGER NOT NULL, + * PRIMARY KEY (COF_ID), + * FOREIGN KEY (SUP_ID) REFERENCES SUPPLIERS (SUP_ID) ) + */ + rsmd.setColumnCount(COFFEES_COLUMN_NAMES.length); + for(int i = 1; i <= COFFEES_COLUMN_NAMES.length; i++){ + rsmd.setColumnName(i, COFFEES_COLUMN_NAMES[i-1]); + rsmd.setColumnLabel(i, rsmd.getColumnName(i)); + } + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.VARCHAR); + rsmd.setColumnType(3, Types.INTEGER); + rsmd.setColumnType(4, Types.NUMERIC); + rsmd.setPrecision(4, 10); + rsmd.setScale(4, 2); + rsmd.setColumnType(5, Types.INTEGER); + rsmd.setColumnType(6, Types.INTEGER); + crs.setMetaData(rsmd); + crs.setTableName(COFFEES_TABLE); + + } + + /* + * Add rows to COFFEES table + */ + protected void createCoffeesRows(RowSet rs) throws SQLException { + + // insert into COFFEES values(1, 'Colombian', 101, 7.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 1); + rs.updateString(2, "Colombian"); + rs.updateInt(3, 101); + rs.updateBigDecimal(4, BigDecimal.valueOf(7.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(2, 'French_Roast', 49, 8.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 2); + rs.updateString(2, "French_Roast"); + rs.updateInt(3, 49); + rs.updateBigDecimal(4, BigDecimal.valueOf(8.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(3, 'Espresso', 150, 9.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 3); + rs.updateString(2, "Espresso"); + rs.updateInt(3, 150); + rs.updateBigDecimal(4, BigDecimal.valueOf(9.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(4, 'Colombian_Decaf', 101, 8.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 4); + rs.updateString(2, "Colombian_Decaf"); + rs.updateInt(3, 101); + rs.updateBigDecimal(4, BigDecimal.valueOf(8.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + // insert into COFFEES values(5, 'French_Roast_Decaf', 049, 9.99, 0, 0) + rs.moveToInsertRow(); + rs.updateInt(1, 5); + rs.updateString(2, "French_Roast_Decaf"); + rs.updateInt(3, 49); + rs.updateBigDecimal(4, BigDecimal.valueOf(9.99)); + rs.updateInt(5, 0); + rs.updateInt(6, 0); + rs.insertRow(); + + } + + + /* + * Utility method to return the Primary Keys for a RowSet. The Primary + * keys are assumed to be in the first column of the RowSet + */ + protected Object[] getPrimaryKeys(ResultSet rs) throws SQLException { + List result = new ArrayList<>(); + if (rs == null) { + return null; + } + rs.beforeFirst(); + while (rs.next()) { + result.add(rs.getInt(1)); + } + return result.toArray(); + } + + /* + * Utility method to display the RowSet and will return the row count + * it found + */ + protected int displayResults(ResultSet rs) throws SQLException { + int rows = 0; + ResultSetMetaData rsmd = rs.getMetaData(); + int cols = rsmd.getColumnCount(); + if (rs != null) { + rs.beforeFirst(); + while (rs.next()) { + rows++; + + for (int i = 0; i < cols; i++) { + System.out.print(rs.getString(i + 1) + " "); + } + System.out.println(); + } + } + + return rows; + } + + + // Insert common tests here + + /* + * Validate that getCommand() returns null by default + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0000(RowSet rs) { + assertNull(rs.getCommand()); + } + + /* + * Validate that getCommand() returns command specified to setCommand + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0001(RowSet rs) throws Exception { + rs.setCommand(query); + assertTrue(rs.getCommand().equals(query)); + } + + + /* + * Validate that getCurrency() returns the correct default value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0002(RowSet rs) throws Exception { + assertTrue(rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE); + } + + /* + * Validate that getCurrency() returns the correct value + * after a call to setConcurrency()) + */ + @Test(dataProvider = "rowSetConcurrencyTypes") + public void commonRowSetTest0003(RowSet rs, int concurType) throws Exception { + rs.setConcurrency(concurType); + assertTrue(rs.getConcurrency() == concurType); + } + + /* + * Validate that getCurrency() throws a SQLException for an invalid value + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0004(RowSet rs) throws Exception { + rs.setConcurrency(ResultSet.CLOSE_CURSORS_AT_COMMIT); + } + + /* + * Validate that getDataSourceName() returns null by default + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0005(RowSet rs) throws Exception { + assertTrue(rs.getDataSourceName() == null); + } + + /* + * Validate that getDataSourceName() returns the value specified + * by setDataSourceName() and getUrl() returns null + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0006(RowSet rs) throws Exception { + rs.setUrl(url); + rs.setDataSourceName(dsName); + assertTrue(rs.getDataSourceName().equals(dsName)); + assertNull(rs.getUrl()); + } + + /* + * Validate that setDataSourceName() throws a SQLException for an empty + * String specified for the data source name + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0007(RowSet rs) throws Exception { + String dsname = ""; + rs.setDataSourceName(dsname); + } + + /* + * Validate that getEscapeProcessing() returns false by default + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0008(RowSet rs) throws Exception { + assertTrue(rs.getEscapeProcessing()); + } + + /* + * Validate that getEscapeProcessing() returns value set by + * setEscapeProcessing() + */ + @Test(dataProvider = "rowSetTrueFalse") + public void commonRowSetTest0009(RowSet rs, boolean val) throws Exception { + rs.setEscapeProcessing(val); + assertTrue(rs.getEscapeProcessing() == val); + } + + /* + * Validate that getFetchDirection() returns the correct default value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0010(RowSet rs) throws Exception { + assertTrue(rs.getFetchDirection() == ResultSet.FETCH_FORWARD); + } + + /* + * Validate that getFetchDirection() returns the value set by + * setFetchDirection() + */ + @Test(dataProvider = "rowSetFetchDirection") + public void commonRowSetTest0011(RowSet rs, int direction) throws Exception { + rs.setFetchDirection(direction); + assertTrue(rs.getFetchDirection() == direction); + } + + /* + * Validate that setFetchSize() throws a SQLException for an invalid value + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0013(RowSet rs) throws Exception { + rs.setFetchSize(-1); + } + + /* + * Validate that setFetchSize() throws a SQLException for a + * value greater than getMaxRows() + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0014(RowSet rs) throws Exception { + rs.setMaxRows(5); + rs.setFetchSize(rs.getMaxRows() + 1); + } + + /* + * Validate that getFetchSize() returns the correct value after + * setFetchSize() has been called + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0015(RowSet rs) throws Exception { + int maxRows = 150; + rs.setFetchSize(0); + assertTrue(rs.getFetchSize() == 0); + rs.setFetchSize(100); + assertTrue(rs.getFetchSize() == 100); + rs.setMaxRows(maxRows); + rs.setFetchSize(maxRows); + assertTrue(rs.getFetchSize() == maxRows); + } + + /* + * Validate that setMaxFieldSize() throws a SQLException for an invalid value + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0016(RowSet rs) throws Exception { + rs.setMaxFieldSize(-1); + } + + /* + * Validate that getMaxFieldSize() returns the value set by + * setMaxFieldSize() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0017(RowSet rs) throws Exception { + rs.setMaxFieldSize(0); + assertTrue(rs.getMaxFieldSize() == 0); + rs.setMaxFieldSize(100); + assertTrue(rs.getMaxFieldSize() == 100); + rs.setMaxFieldSize(50); + assertTrue(rs.getMaxFieldSize() == 50); + } + + /* + * Validate that isReadOnly() returns value set by + * setReadOnly() + */ + @Test(dataProvider = "rowSetTrueFalse") + public void commonRowSetTest0018(RowSet rs, boolean val) throws Exception { + rs.setReadOnly(val); + assertTrue(rs.isReadOnly() == val); + } + + /* + * Validate that getTransactionIsolation() returns value set by + * setTransactionIsolation() + */ + @Test(dataProvider = "rowSetIsolationTypes") + public void commonRowSetTest0019(RowSet rs, int val) throws Exception { + rs.setTransactionIsolation(val); + assertTrue(rs.getTransactionIsolation() == val); + } + + /* + * Validate that getType() returns value set by setType() + */ + @Test(dataProvider = "rowSetScrollTypes") + public void commonRowSetTest0020(RowSet rs, int val) throws Exception { + rs.setType(val); + assertTrue(rs.getType() == val); + } + + /* + * Validate that getEscapeProcessing() returns value set by + * setEscapeProcessing() + */ + @Test(dataProvider = "rowSetTrueFalse") + public void commonRowSetTest0021(BaseRowSet rs, boolean val) throws Exception { + rs.setShowDeleted(val); + assertTrue(rs.getShowDeleted() == val); + } + + /* + * Validate that getTypeMap() returns same value set by + * setTypeMap() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0022(RowSet rs) throws Exception { + Map> map = new HashMap<>(); + map.put("SUPERHERO", Class.forName("util.SuperHero")); + rs.setTypeMap(map); + assertTrue(rs.getTypeMap().equals(map)); + } + + /* + * Validate that getUsername() returns same value set by + * setUsername() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0023(RowSet rs) throws Exception { + rs.setUsername(user); + assertTrue(rs.getUsername().equals(user)); + } + + /* + * Validate that getPassword() returns same password set by + * setPassword() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0024(RowSet rs) throws Exception { + rs.setPassword(password); + assertTrue(rs.getPassword().equals(password)); + } + + /* + * Validate that getQueryTimeout() returns same value set by + * setQueryTimeout() and that 0 is a valid timeout value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0025(RowSet rs) throws Exception { + int timeout = 0; + rs.setQueryTimeout(timeout); + assertTrue(rs.getQueryTimeout() == timeout); + } + + /* + * Validate that getQueryTimeout() returns same value set by + * setQueryTimeout() and that 0 is a valid timeout value + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0026(RowSet rs) throws Exception { + int timeout = 10000; + rs.setQueryTimeout(timeout); + assertTrue(rs.getQueryTimeout() == timeout); + } + + /* + * Validate that setQueryTimeout() throws a SQLException for a timeout + * value < 0 + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonRowSetTest0027(RowSet rs) throws Exception { + rs.setQueryTimeout(-1); + } + + + /* + * Validate addRowSetListener does not throw an Exception when null is + * passed as the parameter + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0028(RowSet rs) throws Exception { + rs.addRowSetListener(null); + } + + /* + * Validate removeRowSetListener does not throw an Exception when null is + * passed as the parameter + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0029(RowSet rs) throws Exception { + rs.removeRowSetListener(null); + } + + /* + * Set two parameters and then validate clearParameters() will clear them + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0030(BaseRowSet rs) throws Exception { + rs.setInt(1, 1); + rs.setString(2, query); + assertTrue(rs.getParams().length == 2); + rs.clearParameters(); + assertTrue(rs.getParams().length == 0); + } + + /* + * Validate that getURL() returns same value set by + * setURL() + */ + @Test(dataProvider = "rowSetType") + public void commonRowSetTest0031(RowSet rs) throws Exception { + rs.setUrl(url); + assertTrue(rs.getUrl().equals(url)); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0100(RowSet rs) throws Exception { + InputStream is = null; + rs.setAsciiStream(1, is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0101(RowSet rs) throws Exception { + InputStream is = null; + rs.setAsciiStream("one", is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0102(RowSet rs) throws Exception { + InputStream is = null; + rs.setAsciiStream("one", is, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0103(RowSet rs) throws Exception { + InputStream is = null; + rs.setBinaryStream(1, is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0104(RowSet rs) throws Exception { + InputStream is = null; + rs.setBinaryStream("one", is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0105(RowSet rs) throws Exception { + InputStream is = null; + rs.setBinaryStream("one", is, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0106(RowSet rs) throws Exception { + rs.setBigDecimal("one", BigDecimal.ONE); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0107(RowSet rs) throws Exception { + InputStream is = null; + rs.setBlob(1, is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0108(RowSet rs) throws Exception { + InputStream is = null; + rs.setBlob("one", is); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0109(RowSet rs) throws Exception { + InputStream is = null; + rs.setBlob("one", is, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0110(RowSet rs) throws Exception { + rs.setBlob("one", new StubBlob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0111(RowSet rs) throws Exception { + rs.setBoolean("one", true); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0112(RowSet rs) throws Exception { + byte b = 1; + rs.setByte("one", b); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0113(RowSet rs) throws Exception { + byte b = 1; + rs.setBytes("one", new byte[10]); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0114(RowSet rs) throws Exception { + Reader rdr = null; + rs.setCharacterStream("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0115(RowSet rs) throws Exception { + Reader rdr = null; + rs.setCharacterStream("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0116(RowSet rs) throws Exception { + Reader rdr = null; + rs.setCharacterStream(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0117(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0118(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0119(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0120(RowSet rs) throws Exception { + rs.setClob("one", new StubClob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0121(RowSet rs) throws Exception { + rs.setDate("one", Date.valueOf(LocalDate.now())); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0122(RowSet rs) throws Exception { + rs.setDate("one", Date.valueOf(LocalDate.now()), + Calendar.getInstance()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0123(RowSet rs) throws Exception { + rs.setTime("one", Time.valueOf(LocalTime.now())); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0124(RowSet rs) throws Exception { + rs.setTime("one", Time.valueOf(LocalTime.now()), + Calendar.getInstance()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0125(RowSet rs) throws Exception { + rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now())); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0126(RowSet rs) throws Exception { + rs.setTimestamp("one", Timestamp.valueOf(LocalDateTime.now()), + Calendar.getInstance()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0127(RowSet rs) throws Exception { + rs.setDouble("one", 2.0d); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0128(RowSet rs) throws Exception { + rs.setFloat("one", 2.0f); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0129(RowSet rs) throws Exception { + rs.setInt("one", 21); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0130(RowSet rs) throws Exception { + rs.setLong("one", 21l); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0131(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0132(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0133(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0134(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNCharacterStream(1, rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0135(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0136(RowSet rs) throws Exception { + Reader rdr = null; + rs.setClob("one", rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0137(RowSet rs) throws Exception { + rs.setNClob("one", new StubNClob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0138(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNClob(1, rdr); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0139(RowSet rs) throws Exception { + Reader rdr = null; + rs.setNClob(1, rdr, query.length()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0140(RowSet rs) throws Exception { + rs.setNClob(1, new StubNClob()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0141(RowSet rs) throws Exception { + rs.setNString(1, query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0142(RowSet rs) throws Exception { + rs.setNull("one", Types.INTEGER); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0143(RowSet rs) throws Exception { + rs.setNull("one", Types.INTEGER, "my.type"); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0144(RowSet rs) throws Exception { + rs.setObject("one", query, Types.VARCHAR); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0145(RowSet rs) throws Exception { + rs.setObject("one", query, Types.VARCHAR, 0); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0146(RowSet rs) throws Exception { + rs.setObject("one", query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0147(RowSet rs) throws Exception { + RowId aRowid = null; + rs.setRowId("one", aRowid); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0148(RowSet rs) throws Exception { + rs.setSQLXML("one", new StubSQLXML()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0149(RowSet rs) throws Exception { + rs.setSQLXML(1, new StubSQLXML()); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0150(RowSet rs) throws Exception { + rs.setNString(1, query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0151(RowSet rs) throws Exception { + rs.setNString("one", query); + } + + /* + * This method is currently not implemented in BaseRowSet and will + * throw a SQLFeatureNotSupportedException + */ + @Test(dataProvider = "rowSetType", + expectedExceptions = SQLFeatureNotSupportedException.class) + public void commonRowSetTest0152(RowSet rs) throws Exception { + short val = 21; + rs.setShort("one", val); + } + +} --- /dev/null 2015-01-09 09:47:20.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/cachedrowset/CachedRowSetTests.java 2015-01-09 09:47:20.000000000 -0500 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.cachedrowset; + +import java.sql.SQLException; +import javax.sql.rowset.CachedRowSet; + +public class CachedRowSetTests extends CommonCachedRowSetTests { + + @Override + protected CachedRowSet newInstance() throws SQLException { + return rsf.createCachedRowSet(); + } + +} --- /dev/null 2015-01-09 09:47:22.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/cachedrowset/CommonCachedRowSetTests.java 2015-01-09 09:47:21.000000000 -0500 @@ -0,0 +1,1612 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.cachedrowset; + +import java.math.BigDecimal; +import java.sql.Array; +import java.sql.Date; +import java.sql.JDBCType; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Time; +import java.sql.Timestamp; +import java.sql.Types; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Collection; +import javax.sql.RowSet; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.serial.SerialRef; +import javax.sql.rowset.spi.SyncFactory; +import javax.sql.rowset.spi.SyncProvider; +import javax.sql.rowset.spi.SyncProviderException; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import test.rowset.CommonRowSetTests; +import util.StubArray; +import util.StubRef; +import util.StubSyncProvider; +import util.TestRowSetListener; + +public abstract class CommonCachedRowSetTests extends CommonRowSetTests { + + /* + * DATATYPES Table column names + */ + private final String[] DATATYPES_COLUMN_NAMES = {"AINTEGER", "ACHAR", + "AVARCHAR", "ALONG", "ABOOLEAN", "ASHORT", "ADOUBLE", "ABIGDECIMAL", + "AREAL", "ABYTE", "ADATE", "ATIME", "ATIMESTAMP", "ABYTES", "ARRAY", + "AREF", "AFLOAT"}; + + /* + * Initializes a RowSet containing the DATAYPES data + */ + protected T createDataTypesRowSet() throws SQLException { + T rs = (T) newInstance(); + initDataTypesMetaData((CachedRowSet) rs); + createDataTypesRows(rs); + // Make sure you are not on the insertRow + rs.moveToCurrentRow(); + return rs; + } + + //DataProviders to use for common tests + + /* + * DataProvider that uses a RowSet with the COFFEE_HOUSES Table + */ + @DataProvider(name = "rowsetUsingCoffeeHouses") + protected Object[][] rowsetUsingCoffeeHouses() throws Exception { + RowSet rs = createCoffeeHousesRowSet(); + return new Object[][]{ + {rs} + }; + } + + /* + * DataProvider that uses a RowSet with the COFFEES Table + */ + @DataProvider(name = "rowsetUsingCoffees") + protected Object[][] rowsetUsingCoffees() throws Exception { + RowSet rs = createCoffeesRowSet(); + return new Object[][]{ + {rs} + }; + } + + /* + * DataProvider that uses a RowSet with the DATAYPES Table and + * used to validate the various supported data types + */ + @DataProvider(name = "rowsetUsingDataTypes") + protected Object[][] rowsetUsingDataTypes() throws Exception { + + CachedRowSet rs = createDataTypesRowSet(); + return new Object[][]{ + {rs, JDBCType.INTEGER}, + {rs, JDBCType.CHAR}, + {rs, JDBCType.VARCHAR}, + {rs, JDBCType.BIGINT}, + {rs, JDBCType.BOOLEAN}, + {rs, JDBCType.SMALLINT}, + {rs, JDBCType.DOUBLE}, + {rs, JDBCType.DECIMAL}, + {rs, JDBCType.REAL}, + {rs, JDBCType.TINYINT}, + {rs, JDBCType.DATE}, + {rs, JDBCType.TIME}, + {rs, JDBCType.TIMESTAMP}, + {rs, JDBCType.VARBINARY}, + {rs, JDBCType.ARRAY}, + {rs, JDBCType.REF}, + {rs, JDBCType.FLOAT} + }; + } + + /* + * Initializes the DATAYPES table metadata + */ + protected void initDataTypesMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE); + + rsmd.setColumnCount(DATATYPES_COLUMN_NAMES.length); + + for (int i = 1; i <= DATATYPES_COLUMN_NAMES.length; i++) { + rsmd.setColumnName(i, DATATYPES_COLUMN_NAMES[i - 1]); + rsmd.setColumnLabel(i, rsmd.getColumnName(i)); + } + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.CHAR); + rsmd.setColumnType(3, Types.VARCHAR); + rsmd.setColumnType(4, Types.BIGINT); + rsmd.setColumnType(5, Types.BOOLEAN); + rsmd.setColumnType(6, Types.SMALLINT); + rsmd.setColumnType(7, Types.DOUBLE); + rsmd.setColumnType(8, Types.DECIMAL); + rsmd.setColumnType(9, Types.REAL); + rsmd.setColumnType(10, Types.TINYINT); + rsmd.setColumnType(11, Types.DATE); + rsmd.setColumnType(12, Types.TIME); + rsmd.setColumnType(13, Types.TIMESTAMP); + rsmd.setColumnType(14, Types.VARBINARY); + rsmd.setColumnType(15, Types.ARRAY); + rsmd.setColumnType(16, Types.REF); + rsmd.setColumnType(17, Types.FLOAT); + crs.setMetaData(rsmd); + + } + + /* + * Add rows to DATAYPES table + */ + protected void createDataTypesRows(RowSet crs) throws SQLException { + + Integer aInteger = 100; + String aChar = "Oswald Cobblepot"; + Long aLong = Long.MAX_VALUE; + Short aShort = Short.MAX_VALUE; + Double aDouble = Double.MAX_VALUE; + BigDecimal aBigDecimal = BigDecimal.ONE; + Boolean aBoolean = false; + Float aFloat = Float.MAX_VALUE; + Byte aByte = Byte.MAX_VALUE; + Date aDate = Date.valueOf(LocalDate.now()); + Time aTime = Time.valueOf(LocalTime.now()); + Timestamp aTimeStamp = Timestamp.valueOf(LocalDateTime.now()); + Array aArray = new StubArray("INTEGER", new Object[1]); + Ref aRef = new SerialRef(new StubRef("INTEGER", query)); + byte[] bytes = new byte[10]; + crs.moveToInsertRow(); + crs.updateInt(1, aInteger); + crs.updateString(2, aChar); + crs.updateString(3, aChar); + crs.updateLong(4, aLong); + crs.updateBoolean(5, aBoolean); + crs.updateShort(6, aShort); + crs.updateDouble(7, aDouble); + crs.updateBigDecimal(8, aBigDecimal); + crs.updateFloat(9, aFloat); + crs.updateByte(10, aByte); + crs.updateDate(11, aDate); + crs.updateTime(12, aTime); + crs.updateTimestamp(13, aTimeStamp); + crs.updateBytes(14, bytes); + crs.updateArray(15, aArray); + crs.updateRef(16, aRef); + crs.updateDouble(17, aDouble); + crs.insertRow(); + crs.moveToCurrentRow(); + + } + + /* + * Dermine if a Row exists in a ResultSet by its primary key + * If the parameter deleteRow is true, delete the row and validate + * the RowSet indicates it is deleted + */ + protected boolean findRowByPrimaryKey(RowSet rs, int id, int idPos, + boolean deleteRow) throws Exception { + boolean foundRow = false; + rs.beforeFirst(); + while (rs.next()) { + if (rs.getInt(idPos) == id) { + foundRow = true; + if (deleteRow) { + rs.deleteRow(); + // validate row is marked as deleted + assertTrue(rs.rowDeleted()); + } + break; + } + } + return foundRow; + } + + /* + * Wrapper method to find if a row exists within a RowSet by its primary key + */ + protected boolean findRowByPrimaryKey(RowSet rs, int id, int idPos) throws Exception { + return findRowByPrimaryKey(rs, id, idPos, false); + } + + /* + * Wrapper method to find if a row exists within a RowSet by its primary key + * and delete it + */ + protected boolean deleteRowByPrimaryKey(RowSet rs, int id, int idPos) throws Exception { + return findRowByPrimaryKey(rs, id, idPos, true); + } + + /* + * Utility method that compares two ResultSetMetaDataImpls for containing + * the same values + */ + private void compareMetaData(ResultSetMetaData rsmd, + ResultSetMetaData rsmd1) throws SQLException { + + assertEquals(rsmd1.getColumnCount(), rsmd.getColumnCount()); + int cols = rsmd.getColumnCount(); + for (int i = 1; i <= cols; i++) { + assertTrue(rsmd1.getCatalogName(i).equals(rsmd.getCatalogName(i))); + assertTrue(rsmd1.getColumnClassName(i).equals(rsmd.getColumnClassName(i))); + assertTrue(rsmd1.getColumnDisplaySize(i) == rsmd.getColumnDisplaySize(i)); + assertTrue(rsmd1.getColumnLabel(i).equals(rsmd.getColumnLabel(i))); + assertTrue(rsmd1.getColumnName(i).equals(rsmd.getColumnName(i))); + assertTrue(rsmd1.getColumnType(i) == rsmd.getColumnType(i)); + assertTrue(rsmd1.getPrecision(i) == rsmd.getPrecision(i)); + assertTrue(rsmd1.getScale(i) == rsmd.getScale(i)); + assertTrue(rsmd1.getSchemaName(i).equals(rsmd.getSchemaName(i))); + assertTrue(rsmd1.getTableName(i).equals(rsmd.getTableName(i))); + assertTrue(rsmd1.isAutoIncrement(i) == rsmd.isAutoIncrement(i)); + assertTrue(rsmd1.isCaseSensitive(i) == rsmd.isCaseSensitive(i)); + assertTrue(rsmd1.isCurrency(i) == rsmd.isCurrency(i)); + assertTrue(rsmd1.isDefinitelyWritable(i) == rsmd.isDefinitelyWritable(i)); + assertTrue(rsmd1.isNullable(i) == rsmd.isNullable(i)); + assertTrue(rsmd1.isReadOnly(i) == rsmd.isReadOnly(i)); + assertTrue(rsmd1.isSearchable(i) == rsmd.isSearchable(i)); + assertTrue(rsmd1.isSigned(i) == rsmd.isSigned(i)); + assertTrue(rsmd1.isWritable(i) == rsmd.isWritable(i)); + + } + } + + /* + * Utility method to compare two rowsets + */ + private void compareRowSets(CachedRowSet crs, CachedRowSet crs1) throws Exception { + + int rows = crs.size(); + assertTrue(rows == crs1.size()); + + ResultSetMetaData rsmd = crs.getMetaData(); + + compareMetaData(rsmd, crs1.getMetaData()); + int cols = rsmd.getColumnCount(); + + for (int row = 1; row <= rows; row++) { + crs.absolute((row)); + crs1.absolute(row); + for (int col = 1; col <= cols; col++) { + compareColumnValue(JDBCType.valueOf(rsmd.getColumnType(col)), + crs, crs1, col); + } + } + + } + + /* + * Utility method to compare two columns + */ + private void compareColumnValue(JDBCType type, ResultSet rs, ResultSet rs1, + int col) throws SQLException { + + switch (type) { + case INTEGER: + assertTrue(rs.getInt(col) == rs1.getInt(col)); + break; + case CHAR: + case VARCHAR: + assertTrue(rs.getString(col).equals(rs1.getString(col))); + break; + case BIGINT: + assertTrue(rs.getLong(col) == rs1.getLong(col)); + break; + case BOOLEAN: + assertTrue(rs.getBoolean(col) == rs1.getBoolean(col)); + break; + case SMALLINT: + assertTrue(rs.getShort(col) == rs1.getShort(col)); + break; + case DOUBLE: + case FLOAT: + assertTrue(rs.getDouble(col) == rs1.getDouble(col)); + break; + case DECIMAL: + assertTrue(rs.getBigDecimal(col).equals(rs1.getBigDecimal(col))); + break; + case REAL: + assertTrue(rs.getFloat(col) == rs1.getFloat(col)); + break; + case TINYINT: + assertTrue(rs.getByte(col) == rs1.getByte(col)); + break; + case DATE: + assertTrue(rs.getDate(col).equals(rs1.getDate(col))); + break; + case TIME: + assertTrue(rs.getTime(col).equals(rs1.getTime(col))); + break; + case TIMESTAMP: + assertTrue(rs.getTimestamp(col).equals(rs1.getTimestamp(col))); + break; + } + } + + /* + * Validate SyncProviderException is thrown when acceptChanges is called + * but there is not a way to make a connection to the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SyncProviderException.class) + public void commonCachedRowSetTest0000(CachedRowSet rs) throws Exception { + rs.acceptChanges(); + rs.close(); + } + + /* + * Validate SyncProviderException is thrown when acceptChanges is called + * when null is passed as the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SyncProviderException.class) + public void commonCachedRowSetTest0001(CachedRowSet rs) throws Exception { + rs.acceptChanges(null); + rs.close(); + } + + /* + * Validate that that RIOPtimsticProvider is the default SyncProvider + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0002(CachedRowSet rs) throws SQLException { + SyncProvider sp = rs.getSyncProvider(); + assertTrue(sp instanceof com.sun.rowset.providers.RIOptimisticProvider); + rs.close(); + } + + /* + * Validate that you can specify a SyncProvider + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0003(CachedRowSet rs) throws SQLException { + + // Register a provider and make sure it is avaiable + SyncFactory.registerProvider(stubProvider); + rs.setSyncProvider(stubProvider); + SyncProvider sp = rs.getSyncProvider(); + assertTrue(sp instanceof StubSyncProvider); + SyncFactory.unregisterProvider(stubProvider); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged is called + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.release(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowSetChanged is called + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowChanged is called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0006(RowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.moveToInsertRow(); + rs.updateInt(1, 10024); + rs.updateString(2, "Sacramento"); + rs.updateInt(3, 1987); + rs.updateInt(4, 2341); + rs.updateInt(5, 4328); + rs.insertRow(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + rs.close(); + } + + /* + * Create a multiple RowSetListeners and validate that notifyRowChanged, + * notifiyMoved is called on all listners + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0007(RowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + TestRowSetListener rsl2 = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.addRowSetListener(rsl2); + rs.first(); + rs.updateInt(1, 1961); + rs.updateString(2, "Pittsburgh"); + rs.updateInt(3, 1987); + rs.updateInt(4, 2341); + rs.updateInt(5, 6689); + rs.updateRow(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED + | TestRowSetListener.ROW_CHANGED)); + assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED + | TestRowSetListener.ROW_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyRowChanged and + * notifyCursorMoved are called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + + rs.first(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); + rs.deleteRow(); + assertTrue( + rsl.isNotified(TestRowSetListener.ROW_CHANGED | TestRowSetListener.CURSOR_MOVED)); + rsl.resetFlag(); + rs.setShowDeleted(true); + rs.undoDelete(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + rs.close(); + } + + /* + * Create a RowSetListener and validate that notifyCursorMoved is called + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0009(RowSet rs) throws Exception { + TestRowSetListener rsl = new TestRowSetListener(); + rs.addRowSetListener(rsl); + rs.beforeFirst(); + assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED)); + rs.close(); + } + + /* + * Validate that getTableName() returns the proper values + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0010(CachedRowSet rs) throws Exception { + assertNull(rs.getTableName()); + rs.setTableName(COFFEE_HOUSES_TABLE); + assertTrue(rs.getTableName().equals(COFFEE_HOUSES_TABLE)); + rs.close(); + } + + /* + * Validate that getKeyColumns() returns the proper values + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0011(CachedRowSet rs) throws Exception { + int[] pkeys = {1, 3}; + assertNull(rs.getKeyColumns()); + rs.setKeyColumns(pkeys); + assertEquals(rs.getKeyColumns(), pkeys); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0012(CachedRowSet rs) throws Exception { + rs.setMatchColumn(-1); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0013(CachedRowSet rs) throws Exception { + int[] cols = {1, -1}; + rs.setMatchColumn(cols); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0014(CachedRowSet rs) throws Exception { + rs.setMatchColumn((String) null); + rs.close(); + } + + /* + * Validate that setMatchColumn throws a SQLException if the column + * index specified is out of range + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0015(CachedRowSet rs) throws Exception { + String[] cols = {"ID", null}; + rs.setMatchColumn(cols); + } + + /* + * Validate that getMatchColumn returns the same value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0016(CachedRowSet rs) throws Exception { + int[] expectedCols = {1}; + String[] expectedColNames = {"ID"}; + rs.setMatchColumn(1); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + for (int i = 0; i < actualCols.length; i++) { + System.out.println(actualCols[i]); + } + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + rs.close(); + } + + /* + * Validate that getMatchColumn returns the same value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0017(CachedRowSet rs) throws Exception { + int[] expectedCols = {1}; + String[] expectedColNames = {"ID"}; + rs.setMatchColumn(expectedColNames[0]); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + rs.close(); + } + + /* + * Validate that getMatchColumn returns the same valid value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0018(CachedRowSet rs) throws Exception { + int[] expectedCols = {1, 3}; + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedCols); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + assertEquals(actualCols, expectedCols); + rs.close(); + } + + /* + * Validate that getMatchColumn returns the same valid value specified by + * setMatchColumn + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", enabled = false) + public void commonCachedRowSetTest0019(CachedRowSet rs) throws Exception { + int[] expectedCols = {1, 3}; + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedColNames); + int[] actualCols = rs.getMatchColumnIndexes(); + String[] actualColNames = rs.getMatchColumnNames(); + assertEquals(actualCols, expectedCols); + assertEquals(actualColNames, expectedColNames); + rs.close(); + } + + /* + * Validate that getMatchColumnIndexes throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0020(CachedRowSet rs) throws Exception { + rs.setMatchColumn(1); + int[] actualCols = rs.getMatchColumnIndexes(); + assertTrue(actualCols != null); + rs.unsetMatchColumn(1); + actualCols = rs.getMatchColumnIndexes(); + rs.close(); + } + + /* + * Validate that getMatchColumnNames throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0021(CachedRowSet rs) throws Exception { + String matchColumn = "ID"; + rs.setMatchColumn(matchColumn); + String[] actualColNames = rs.getMatchColumnNames(); + assertTrue(actualColNames != null); + rs.unsetMatchColumn(matchColumn); + actualColNames = rs.getMatchColumnNames(); + rs.close(); + } + + /* + * Validate that getMatchColumnIndexes throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0022(CachedRowSet rs) throws Exception { + int[] expectedCols = {1, 3}; + rs.setMatchColumn(expectedCols); + int[] actualCols = rs.getMatchColumnIndexes(); + assertTrue(actualCols != null); + rs.unsetMatchColumn(expectedCols); + actualCols = rs.getMatchColumnIndexes(); + rs.close(); + } + + /* + * Validate that getMatchColumnNames throws a SQLException if + * unsetMatchColumn has been called + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0023(CachedRowSet rs) throws Exception { + String[] expectedColNames = {"COF_ID", "SUP_ID"}; + rs.setMatchColumn(expectedColNames); + String[] actualColNames = rs.getMatchColumnNames(); + assertTrue(actualColNames != null); + rs.unsetMatchColumn(expectedColNames); + actualColNames = rs.getMatchColumnNames(); + rs.close(); + } + + /* + * Validate size() returns the correct number of rows + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0024(CachedRowSet rs) throws Exception { + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + rs.close(); + } + + /* + * Validate that the correct rows are returned comparing the primary + * keys + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0025(RowSet rs) throws SQLException { + assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS); + rs.close(); + } + + /* + * Delete a row within the RowSet using its primary key + * Validate the visibility of the row depending on the value of + * setShowdelete + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception { + Object[] afterDelete = { + 10023, 33002, 10040, 32001, 10042, 10024, 10039, 10041, + 33005, 33010, 10037, 10034, 32004 + }; + int rowToDelete = 10035; + // All rows should be found + assertEquals(getPrimaryKeys(rs), COFFEE_HOUSES_PRIMARY_KEYS); + // Delete the row + assertTrue(deleteRowByPrimaryKey(rs, rowToDelete, 1)); + // With setShowDeleted(false) which is the default, + // the deleted row should not be visible + assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1)); + assertEquals(getPrimaryKeys(rs), afterDelete); + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // With setShowDeleted(true), the deleted row should be visible + rs.setShowDeleted(true); + assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.close(); + } + + /* + * Validate that there is no page size by default + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception { + assertTrue(rs.getPageSize() == 0); + rs.close(); + } + + /* + * Validate the value you set via setPageSize is returned by getPageSize + * then reset to having no limit + */ + @Test(dataProvider = "rowSetType") + public void commonCachedRowSetTest0028(CachedRowSet rs) throws Exception { + int rows = 100; + rs.setPageSize(rows); + assertTrue(rows == rs.getPageSize()); + rs.setPageSize(0); + assertTrue(rs.getPageSize() == 0); + rs.close(); + } + + /* + * Validate SQLException is thrown when an invalid value is specified + * for setPageSize + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0029(CachedRowSet rs) throws Exception { + rs.setPageSize(-1); + rs.close(); + } + + /* + * Validate SQLException is thrown when nextPage is called without a + * call to populate or execute + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0030(CachedRowSet rs) throws Exception { + rs.nextPage(); + rs.close(); + } + + /* + * Validate SQLException is thrown when previousPage is called without a + * call to populate or execute + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0031(CachedRowSet rs) throws Exception { + rs.previousPage(); + rs.close(); + } + + + /* + * Validate SQLException is thrown when execute is called + * but there is not a way to make a connection to the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0032(CachedRowSet rs) throws Exception { + rs.execute(null); + rs.close(); + } + + /* + * Validate SQLException is thrown when execute is called + * but there is not a way to make a connection to the datasource + */ + @Test(dataProvider = "rowSetType", expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0033(CachedRowSet rs) throws Exception { + rs.execute(); + rs.close(); + } + + /* + * Validate that toCollection() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0034(CachedRowSet rs) throws Exception { + Object[] cities = {"Mendocino", "Seattle", "SF", "Portland", "SF", + "Sacramento", "Carmel", "LA", "Olympia", "Seattle", "SF", + "LA", "San Jose", "Eugene"}; + rs.beforeFirst(); + assertEquals(rs.toCollection(2).toArray(), cities); + assertEquals(rs.toCollection("CITY").toArray(), cities); + rs.close(); + } + + /* + * Validate that toCollection() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0035(CachedRowSet rs) throws Exception { + Collection col = rs.toCollection(); + assertTrue(rs.size() == col.size()); + assertTrue(rs.toCollection().containsAll(col) + && col.containsAll(rs.toCollection())); + try ( // Validate that False is returned when compared to a different RowSet; + CachedRowSet crs1 = createCoffeesRowSet()) { + assertFalse(crs1.toCollection().containsAll(col) + && col.containsAll(crs1.toCollection())); + } + rs.close(); + + } + + /* + * Validate that createCopy() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0036(CachedRowSet rs) throws Exception { + try (CachedRowSet crs1 = rs.createCopy()) { + compareRowSets(rs, crs1); + } + rs.close(); + } + + /* + * Validate that createCopySchema() returns the proper values + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0037(CachedRowSet rs) throws Exception { + try (CachedRowSet crs1 = rs.createCopySchema()) { + assertTrue(crs1.size() == 0); + compareMetaData(crs1.getMetaData(), rs.getMetaData()); + } + rs.close(); + } + + /* + * Validate that createCopyNoConstraints() returns the proper values + * and getMatchColumnIndexes should throw a SQLException. This test + * specifies setMatchColumn(int) + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0038(CachedRowSet rs) throws Exception { + rs.setMatchColumn(1); + try (CachedRowSet crs1 = rs.createCopyNoConstraints()) { + assertTrue(crs1.size() == COFFEE_HOUSES_ROWS); + compareRowSets(rs, crs1); + boolean recievedSQE = false; + try { + int[] indexes = crs1.getMatchColumnIndexes(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + recievedSQE = false; + try { + String[] colNames = crs1.getMatchColumnNames(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + } + rs.close(); + } + + /* + * Validate that createCopyNoConstraints() returns the proper values + * and getMatchColumnIndexes should throw a SQLException. This test + * specifies setMatchColumn(String) + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0039(CachedRowSet rs) throws Exception { + rs.setMatchColumn("ID"); + try (CachedRowSet crs1 = rs.createCopyNoConstraints()) { + assertTrue(crs1.size() == COFFEE_HOUSES_ROWS); + compareRowSets(rs, crs1); + boolean recievedSQE = false; + try { + int[] indexes = crs1.getMatchColumnIndexes(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + recievedSQE = false; + try { + String[] colNames = crs1.getMatchColumnNames(); + } catch (SQLException e) { + recievedSQE = true; + } + assertTrue(recievedSQE); + } + rs.close(); + } + + /* + * Validate that columnUpdated works with the various datatypes specifying + * the column index + */ + @Test(dataProvider = "rowsetUsingDataTypes") + public void commonCachedRowSetTest0040(CachedRowSet rs, JDBCType type) throws Exception { + rs.beforeFirst(); + assertTrue(rs.next()); + switch (type) { + case INTEGER: + assertFalse(rs.columnUpdated(1)); + rs.updateInt(1, Integer.MIN_VALUE); + assertTrue(rs.columnUpdated(1)); + break; + case CHAR: + assertFalse(rs.columnUpdated(2)); + rs.updateString(2, "foo"); + assertTrue(rs.columnUpdated(2)); + break; + case VARCHAR: + assertFalse(rs.columnUpdated(3)); + rs.updateString(3, "foo"); + assertTrue(rs.columnUpdated(3)); + break; + case BIGINT: + assertFalse(rs.columnUpdated(4)); + rs.updateLong(4, Long.MIN_VALUE); + assertTrue(rs.columnUpdated(4)); + break; + case BOOLEAN: + assertFalse(rs.columnUpdated(5)); + rs.updateBoolean(5, false); + assertTrue(rs.columnUpdated(5)); + break; + case SMALLINT: + assertFalse(rs.columnUpdated(6)); + rs.updateShort(6, Short.MIN_VALUE); + assertTrue(rs.columnUpdated(6)); + break; + case DOUBLE: + assertFalse(rs.columnUpdated(7)); + rs.updateDouble(7, Double.MIN_VALUE); + assertTrue(rs.columnUpdated(7)); + break; + case DECIMAL: + assertFalse(rs.columnUpdated(8)); + rs.updateBigDecimal(8, BigDecimal.TEN); + assertTrue(rs.columnUpdated(8)); + break; + case REAL: + assertFalse(rs.columnUpdated(9)); + rs.updateFloat(9, Float.MIN_VALUE); + assertTrue(rs.columnUpdated(9)); + break; + case TINYINT: + assertFalse(rs.columnUpdated(10)); + rs.updateByte(10, Byte.MIN_VALUE); + assertTrue(rs.columnUpdated(10)); + break; + case DATE: + assertFalse(rs.columnUpdated(11)); + rs.updateDate(11, Date.valueOf(LocalDate.now())); + assertTrue(rs.columnUpdated(11)); + break; + case TIME: + assertFalse(rs.columnUpdated(12)); + rs.updateTime(12, Time.valueOf(LocalTime.now())); + assertTrue(rs.columnUpdated(12)); + break; + case TIMESTAMP: + assertFalse(rs.columnUpdated(13)); + rs.updateTimestamp(13, Timestamp.valueOf(LocalDateTime.now())); + assertTrue(rs.columnUpdated(13)); + break; + case VARBINARY: + assertFalse(rs.columnUpdated(14)); + rs.updateBytes(14, new byte[1]); + assertTrue(rs.columnUpdated(14)); + break; + case ARRAY: + assertFalse(rs.columnUpdated(15)); + rs.updateArray(15, new StubArray("VARCHAR", new Object[10])); + assertTrue(rs.columnUpdated(15)); + break; + case REF: + assertFalse(rs.columnUpdated(16)); + rs.updateRef(16, new StubRef("INTEGER", query)); + assertTrue(rs.columnUpdated(16)); + break; + case FLOAT: + assertFalse(rs.columnUpdated(17)); + rs.updateDouble(17, Double.MIN_NORMAL); + assertTrue(rs.columnUpdated(17)); + } + + } + + /* + * Validate that columnUpdated works with the various datatypes specifying + * the column name + */ + @Test(dataProvider = "rowsetUsingDataTypes") + public void commonCachedRowSetTest0041(CachedRowSet rs, JDBCType type) throws Exception { + rs.beforeFirst(); + assertTrue(rs.next()); + switch (type) { + case INTEGER: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[0])); + rs.updateInt(DATATYPES_COLUMN_NAMES[0], Integer.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[0])); + break; + case CHAR: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[1])); + rs.updateString(DATATYPES_COLUMN_NAMES[1], "foo"); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[1])); + break; + case VARCHAR: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[2])); + rs.updateString(DATATYPES_COLUMN_NAMES[2], "foo"); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[2])); + break; + case BIGINT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[3])); + rs.updateLong(DATATYPES_COLUMN_NAMES[3], Long.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[3])); + break; + case BOOLEAN: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[4])); + rs.updateBoolean(DATATYPES_COLUMN_NAMES[4], false); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[4])); + break; + case SMALLINT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[5])); + rs.updateShort(DATATYPES_COLUMN_NAMES[5], Short.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[5])); + break; + case DOUBLE: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[6])); + rs.updateDouble(DATATYPES_COLUMN_NAMES[6], Double.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[6])); + break; + case DECIMAL: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[7])); + rs.updateBigDecimal(DATATYPES_COLUMN_NAMES[7], BigDecimal.TEN); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[7])); + break; + case REAL: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[8])); + rs.updateFloat(DATATYPES_COLUMN_NAMES[8], Float.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[8])); + break; + case TINYINT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[9])); + rs.updateByte(DATATYPES_COLUMN_NAMES[9], Byte.MIN_VALUE); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[9])); + break; + case DATE: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[10])); + rs.updateDate(DATATYPES_COLUMN_NAMES[10], Date.valueOf(LocalDate.now())); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[10])); + break; + case TIME: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[11])); + rs.updateTime(DATATYPES_COLUMN_NAMES[11], Time.valueOf(LocalTime.now())); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[11])); + break; + case TIMESTAMP: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[12])); + rs.updateTimestamp(DATATYPES_COLUMN_NAMES[12], Timestamp.valueOf(LocalDateTime.now())); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[12])); + break; + case VARBINARY: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[13])); + rs.updateBytes(DATATYPES_COLUMN_NAMES[13], new byte[1]); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[13])); + break; + case ARRAY: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[14])); + rs.updateArray(DATATYPES_COLUMN_NAMES[14], new StubArray("VARCHAR", new Object[10])); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[14])); + break; + case REF: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[15])); + rs.updateRef(DATATYPES_COLUMN_NAMES[15], new StubRef("INTEGER", query)); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[15])); + break; + case FLOAT: + assertFalse(rs.columnUpdated(DATATYPES_COLUMN_NAMES[16])); + rs.updateDouble(DATATYPES_COLUMN_NAMES[16], Double.MIN_NORMAL); + assertTrue(rs.columnUpdated(DATATYPES_COLUMN_NAMES[16])); + break; + } + + } + + /* + * Validate isBeforeFirst(), isFirst() and first() return the correct + * results + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0042(RowSet rs) throws Exception { + assertFalse(rs.isBeforeFirst()); + assertFalse(rs.isFirst()); + rs.beforeFirst(); + assertTrue(rs.isBeforeFirst()); + assertFalse(rs.isFirst()); + rs.next(); + assertFalse(rs.isBeforeFirst()); + assertTrue(rs.isFirst()); + rs.next(); + assertFalse(rs.isBeforeFirst()); + assertFalse(rs.isFirst()); + rs.first(); + assertFalse(rs.isBeforeFirst()); + assertTrue(rs.isFirst()); + rs.close(); + } + + /* + * Validate isAfterLast(), isLast() and last() return the correct + * results + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0043(RowSet rs) throws Exception { + assertFalse(rs.isAfterLast()); + assertFalse(rs.isLast()); + rs.afterLast(); + assertTrue(rs.isAfterLast()); + assertFalse(rs.isLast()); + rs.previous(); + assertFalse(rs.isAfterLast()); + assertTrue(rs.isLast()); + rs.previous(); + assertFalse(rs.isAfterLast()); + assertFalse(rs.isLast()); + rs.last(); + assertFalse(rs.isAfterLast()); + assertTrue(rs.isLast()); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoDelete is called on the + * insertRow + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0044(CachedRowSet rs) throws Exception { + rs.insertRow(); + rs.undoDelete(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoDelete is called when + * cursor is before the first row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0045(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoDelete(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoDelete is called when + * cursor is after the last row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0046(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoDelete(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoUpdate is called on the + * insertRow + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0047(CachedRowSet rs) throws Exception { + rs.insertRow(); + rs.undoUpdate(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoUpdate is called when + * cursor is before the first row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0048(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoUpdate(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoUpdate is called when + * cursor is after the last row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0049(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoUpdate(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoInsert is called on the + * insertRow + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0050(CachedRowSet rs) throws Exception { + rs.insertRow(); + rs.undoInsert(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoInsert is called when + * cursor is before the first row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0051(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.beforeFirst(); + rs.undoInsert(); + rs.close(); + } + + /* + * Validate a SQLException is thrown when undoInsert is called when + * cursor is after the last row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses", + expectedExceptions = SQLException.class) + public void commonCachedRowSetTest0052(CachedRowSet rs) throws Exception { + rs.setShowDeleted(true); + rs.afterLast(); + rs.undoInsert(); + rs.close(); + } + + /* + * Insert a row, then call undoInsert to roll back the insert and validate + * the row is not there + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception { + int rowToInsert = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // Add new row + rs.moveToInsertRow(); + rs.updateInt(1, rowToInsert); + rs.updateString(2, "GOTHAM"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + rs.moveToCurrentRow(); + // check that the number of rows has increased + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.undoInsert(); + // Check to make sure the row is no longer there + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + assertFalse(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.close(); + } + + /* + * Insert a row, delete the row and then call undoDelete to make sure it + * is comes back + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception { + int rowToDelete = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // Add new row + rs.moveToInsertRow(); + rs.updateInt(1, rowToDelete); + rs.updateString(2, "GOTHAM"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + rs.moveToCurrentRow(); + // check that the number of rows has increased + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.absolute(COFFEE_HOUSES_ROWS + 1); + rs.deleteRow(); + // Check to make sure the row is no longer there + //assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + assertFalse(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.setShowDeleted(true); + rs.absolute(COFFEE_HOUSES_ROWS + 1); + rs.undoDelete(); + // check that the row is back + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToDelete, 1)); + rs.close(); + } + + /* + * Insert a row, modify a field and then call undoUpdate to revert the + * insert + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception { + int rowToInsert = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + // Add new row + rs.moveToInsertRow(); + rs.updateInt(1, rowToInsert); + rs.updateString(2, "GOTHAM"); + rs.updateInt(3, 3450); + rs.updateInt(4, 2005); + rs.updateInt(5, 5455); + rs.insertRow(); + rs.moveToCurrentRow(); + // check that the number of rows has increased + assertTrue(rs.size() == COFFEE_HOUSES_ROWS + 1); + assertTrue(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.absolute(COFFEE_HOUSES_ROWS + 1); + // Save off the original column values + String f2 = rs.getString(2); + int f3 = rs.getInt(3); + rs.updateString(2, "SMALLVILLE"); + rs.updateInt(3, 500); + // Validate the columns have been updated + assertTrue(rs.columnUpdated(2)); + assertTrue(rs.columnUpdated(3)); + // Undo the update and validate it has taken place + rs.absolute(COFFEE_HOUSES_ROWS + 1); + rs.undoUpdate(); + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + assertFalse(findRowByPrimaryKey(rs, rowToInsert, 1)); + rs.close(); + } + + /* + * Validate getOriginal returns a ResultSet which is a copy of the original + * RowSet + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void commonCachedRowSetTest0056(CachedRowSet rs) throws Exception { + String coffee = "Hazelnut"; + int sales = 100; + int id = 200; + Object[] updatedPkeys = {1, id, 3, 4, 5}; + // Change the coffee name and sales total for row 2 and save the + // previous values + rs.absolute(2); + int origId = rs.getInt(1); + String origCoffee = rs.getString(2); + int origSales = rs.getInt(5); + rs.updateInt(1, id); + rs.updateString(2, coffee); + rs.updateInt(5, sales); + // MetaData should match + try ( // Get the original original RowSet and validate that the changes + // are only made to the current, not the original + ResultSet rs1 = rs.getOriginal()) { + // MetaData should match + compareMetaData(rs.getMetaData(), rs1.getMetaData()); + assertTrue(rs1.isBeforeFirst()); + assertTrue(rs1.getConcurrency() == ResultSet.CONCUR_UPDATABLE); + assertTrue(rs1.getType() == ResultSet.TYPE_SCROLL_INSENSITIVE); + rs1.absolute(2); + // Check original rowset is not changed + assertTrue(rs1.getInt(1) == origId); + assertTrue(rs1.getString(2).equals(origCoffee)); + assertTrue(rs1.getInt(5) == origSales); + assertEquals(getPrimaryKeys(rs1), COFFEES_PRIMARY_KEYS); + // Check current rowset + assertTrue(rs.getInt(1) == id); + assertTrue(rs.getString(2).equals(coffee)); + assertTrue(rs.getInt(5) == sales); + assertEquals(getPrimaryKeys(rs), updatedPkeys); + } + rs.close(); + } + + /* + * Validate getOriginalRow returns a ResultSet which is a copy of the + * original row that was modified + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void commonCachedRowSetTest0057(CachedRowSet rs) throws Exception { + String coffee = "Hazelnut"; + int sales = 100; + int id = 200; + Object[] updatedPkeys = {1, id, 3, 4, 5}; + // Change the coffee name and sales total for row 2 and save the + // previous values + rs.absolute(2); + int origId = rs.getInt(1); + String origCoffee = rs.getString(2); + int origSales = rs.getInt(5); + rs.updateInt(1, id); + rs.updateString(2, coffee); + rs.updateInt(5, sales); + // MetaData should match + try ( // Get the original original row and validate that the changes + // are only made to the current, not the original + ResultSet rs1 = rs.getOriginalRow()) { + // MetaData should match + compareMetaData(rs.getMetaData(), rs1.getMetaData()); + assertTrue(rs1.isBeforeFirst()); + assertTrue(rs1.getConcurrency() == ResultSet.CONCUR_UPDATABLE); + assertTrue(rs1.getType() == ResultSet.TYPE_SCROLL_INSENSITIVE); + rs1.next(); + assertTrue(rs1.isFirst() && rs1.isLast()); + assertTrue(rs1.getRow() == 1); + // Check original row is not changed + assertTrue(rs1.getInt(1) == origId); + assertTrue(rs1.getString(2).equals(origCoffee)); + assertTrue(rs1.getInt(5) == origSales); + // Check current row + assertTrue(rs.getInt(1) == id); + assertTrue(rs.getString(2).equals(coffee)); + assertTrue(rs.getInt(5) == sales); + assertEquals(getPrimaryKeys(rs), updatedPkeys); + } + rs.close(); + } + + /* + * Validate that restoreOrginal will restore the RowSet to its + * state prior to the insert of a row + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0058(CachedRowSet rs) throws Exception { + int rowToInsert = 1961; + assertTrue(rs.size() == COFFEE_HOUSES_ROWS); + try ( // Add new row + CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + TestRowSetListener rsl = new TestRowSetListener(); + crs1.addRowSetListener(rsl); + crs1.moveToInsertRow(); + crs1.updateInt(1, rowToInsert); + crs1.updateString(2, "GOTHAM"); + crs1.updateInt(3, 3450); + crs1.updateInt(4, 2005); + crs1.updateInt(5, 5455); + crs1.insertRow(); + assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED)); + crs1.moveToCurrentRow(); + assertTrue(findRowByPrimaryKey(crs1, rowToInsert, 1)); + // Restore back to our original state and the + // previously inserted row should not be there + rsl.resetFlag(); + crs1.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(crs1.isBeforeFirst()); + crs1.last(); + assertFalse(crs1.rowInserted()); + assertFalse(findRowByPrimaryKey(crs1, rowToInsert, 1)); + } + rs.close(); + } + + /* + * Validate that restoreOrginal will restore the RowSet to its + * state prior to deleting a row + */ + @Test(dataProvider = "rowsetUsingCoffees", enabled = true) + public void commonCachedRowSetTest0059(CachedRowSet rs) throws Exception { + int rowToDelete = 2; + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + TestRowSetListener rsl = new TestRowSetListener(); + crs1.addRowSetListener(rsl); + // Delete a row, the PK is also the absolute position as a List + // backs the RowSet + crs1.absolute(rowToDelete); + crs1.deleteRow(); + assertTrue(crs1.rowDeleted()); + assertFalse(findRowByPrimaryKey(crs1, rowToDelete, 1)); + // Restore back to our original state and the + // previously deleted row should be there + rsl.resetFlag(); + crs1.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(crs1.isBeforeFirst()); + crs1.absolute(rowToDelete); + assertFalse(crs1.rowDeleted()); + assertTrue(findRowByPrimaryKey(crs1, rowToDelete, 1)); + } + rs.close(); + } + + /* + * Validate that restoreOrginal will restore the RowSet to its + * state prior to updating a row + */ + @Test(dataProvider = "rowsetUsingCoffees", enabled = true) + public void commonCachedRowSetTest0060(CachedRowSet rs) throws Exception { + int rowToUpdate = 2; + String coffee = "Hazelnut"; + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + TestRowSetListener rsl = new TestRowSetListener(); + crs1.addRowSetListener(rsl); + // Delete a row, the PK is also the absolute position as a List + // backs the RowSet + crs1.absolute(rowToUpdate); + String origCoffee = crs1.getString(2); + crs1.updateString(2, coffee); + assertTrue(crs1.columnUpdated(2)); + crs1.updateRow(); + assertTrue(crs1.rowUpdated()); + assertFalse(origCoffee.equals(crs1.getString(2))); + // Restore back to our original state and the + // previous value for the column within the row should be there + rsl.resetFlag(); + crs1.restoreOriginal(); + assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED)); + assertTrue(crs1.isBeforeFirst()); + // absolute() is failing for some reason so need to look at this later + crs1.next(); + crs1.next(); + assertFalse(crs1.columnUpdated(2)); + assertFalse(crs1.rowUpdated()); + assertTrue(origCoffee.equals(crs1.getString(2))); + } + rs.close(); + } + + /* + * Initialize a RowSet via the populate method. Validate it matches + * the original ResultSet + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0061(CachedRowSet rs) throws Exception { + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs); + compareRowSets(rs, crs1); + } + rs.close(); + } + + /* + * Initialize a RowSet via the populate method specifying a starting row. + * Validate it matches the original ResultSet starting for the specofied + * offset + */ + @Test(dataProvider = "rowsetUsingCoffeeHouses") + public void commonCachedRowSetTest0062(CachedRowSet rs) throws Exception { + Object[] expectedRows = { + 32001, 10042, 10024, 10039, 10041, 33005, 33010, 10035, 10037, + 10034, 32004 + }; + int startingRow = 4; + try (CachedRowSet crs1 = rsf.createCachedRowSet()) { + rs.beforeFirst(); + crs1.populate(rs, startingRow); + assertEquals(crs1.size(), COFFEE_HOUSES_ROWS - startingRow + 1); + assertEquals(getPrimaryKeys(crs1), expectedRows); + } + rs.close(); + } + +} --- /dev/null 2015-01-09 09:47:23.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/filteredrowset/CityFilter.java 2015-01-09 09:47:23.000000000 -0500 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.filteredrowset; + +import java.sql.SQLException; +import javax.sql.RowSet; +import javax.sql.rowset.Predicate; + +/* + * Simple implementation of Predicate which is used to filter rows based + * on a City. + */ +public class CityFilter implements Predicate { + + private final String[] cities; + private String colName = null; + private int colNumber = -1; + + public CityFilter(String[] cities, String colName) { + this.cities = cities; + this.colName = colName; + } + + public CityFilter(String[] cities, int colNumber) { + this.cities = cities; + this.colNumber = colNumber; + } + + public boolean evaluate(Object value, String colName) { + + if (colName.equalsIgnoreCase(this.colName)) { + for (String city : cities) { + if (city.equalsIgnoreCase((String) value)) { + return true; + } + } + } + return false; + } + + public boolean evaluate(Object value, int colNumber) { + + if (colNumber == this.colNumber) { + for (String city : this.cities) { + if (city.equalsIgnoreCase((String) value)) { + return true; + } + } + } + return false; + } + + public boolean evaluate(RowSet rs) { + + boolean result = false; + + if (rs == null) { + return false; + } + + try { + for (String city : cities) { + + String val = ""; + if (colNumber > 0) { + val = (String) rs.getObject(colNumber); + } else if (colName != null) { + val = (String) rs.getObject(colName); + } + + if (val.equalsIgnoreCase(city)) { + return true; + } + } + } catch (SQLException e) { + result = false; + } + return result; + } +} --- /dev/null 2015-01-09 09:47:24.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/filteredrowset/FilteredRowSetTests.java 2015-01-09 09:47:24.000000000 -0500 @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.filteredrowset; + +import java.sql.SQLException; +import javax.sql.RowSet; +import javax.sql.rowset.FilteredRowSet; +import javax.sql.rowset.Predicate; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import test.rowset.webrowset.CommonWebRowSetTests; + +public class FilteredRowSetTests extends CommonWebRowSetTests { + + private FilteredRowSet frs; + + @BeforeMethod + public void setUpMethod() throws Exception { + frs = createCoffeeHousesRowSet(); + } + + @AfterMethod + public void tearDownMethod() throws Exception { + frs.close(); + } + + protected FilteredRowSet newInstance() throws SQLException { + return rsf.createFilteredRowSet(); + } + + /* + * Validate getFilter returns null if setFilter has not been called + */ + @Test + public void FilteredRowSetTest0000() throws SQLException { + assertNull(frs.getFilter()); + } + + /* + * Call setFilter to set a Predicate and validate that getFilter + * returns the correct Predicate + */ + @Test + public void FilteredRowSetTest0001() throws SQLException { + Predicate p = new PrimaryKeyFilter(0, 100030, 1); + frs.setFilter(p); + assertTrue(frs.getFilter().equals(p)); + frs.setFilter(null); + assertNull(frs.getFilter()); + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column index is used + */ + @Test + public void FilteredRowSetTest0002() throws SQLException { + Object[] expectedKeys = { + 10023, 10040, 10042, 10024, 10039, 10041, 10035, 10037, 10034 + }; + frs.setFilter(new PrimaryKeyFilter(10000, 10999, 1)); + assertEquals(getPrimaryKeys(frs), expectedKeys); + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column Label is used + */ + @Test + public void FilteredRowSetTest0003() throws SQLException { + Object[] expectedKeys = { + 10023, 10040, 10042, 10024, 10039, 10041, 10035, 10037, 10034 + }; + frs.setFilter(new PrimaryKeyFilter(10000, 10999, "STORE_ID")); + assertEquals(getPrimaryKeys(frs), expectedKeys); + + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column index is used + */ + @Test + public void FilteredRowSetTest0004() throws SQLException { + Object[] expectedKeys = { + 10040, 10042, 10041, 10035, 10037 + }; + String[] cityArray = {"SF", "LA"}; + frs.setFilter(new CityFilter(cityArray, 2)); + assertEquals(getPrimaryKeys(frs), expectedKeys); + } + + /* + * Validate that the correct rows are returned when a Predicate using + * a column Label is used + */ + @Test + public void FilteredRowSetTest0005() throws SQLException { + Object[] expectedKeys = { + 10040, 10042, 10041, 10035, 10037 + }; + String[] cityArray = {"SF", "LA"}; + frs.setFilter(new CityFilter(cityArray, "CITY")); + assertEquals(getPrimaryKeys(frs), expectedKeys); + } + + + // Tests that are common but need to be disabled due to an implementation bug + + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0043(RowSet rs) throws Exception { + // Need to fix bug in FilteredRowSets + } + +} --- /dev/null 2015-01-09 09:47:29.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/filteredrowset/PrimaryKeyFilter.java 2015-01-09 09:47:27.000000000 -0500 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.filteredrowset; + +import javax.sql.RowSet; +import javax.sql.rowset.Predicate; + +/* + * Simple implementation of Predicate which is used to filter rows based + * on the Primary Key. + */ +public class PrimaryKeyFilter implements Predicate { + + private final int lo; + private final int hi; + private String colName = null; + private int colNumber = -1; + + public PrimaryKeyFilter(int lo, int hi, int colNumber) { + this.lo = lo; + this.hi = hi; + this.colNumber = colNumber; + } + + public PrimaryKeyFilter(int lo, int hi, String colName) { + this.lo = lo; + this.hi = hi; + this.colName = colName; + } + + public boolean evaluate(Object value, String columnName) { + + boolean result = false; + if (columnName.equalsIgnoreCase(this.colName)) { + int columnValue = ((Integer) value); + result = (columnValue >= this.lo) && (columnValue <= this.hi); + } + return result; + } + + public boolean evaluate(Object value, int columnNumber) { + + boolean result = false; + if (this.colNumber == columnNumber) { + int columnValue = (Integer) value; + result = (columnValue >= this.lo) && (columnValue <= this.hi); + } + return result; + } + + public boolean evaluate(RowSet rs) { + + boolean result = false; + try { + int columnValue = -1; + + if (this.colNumber > 0) { + columnValue = rs.getInt(this.colNumber); + } else if (this.colName != null) { + columnValue = rs.getInt(this.colName); + } + if ((columnValue >= this.lo) && (columnValue <= this.hi)) { + result = true; + } + + } catch (Exception e) { + System.out.println("Error:" + e.getMessage()); + result = false; + } + return result; + } + +} --- /dev/null 2015-01-09 09:47:36.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/joinrowset/JoinRowSetTests.java 2015-01-09 09:47:35.000000000 -0500 @@ -0,0 +1,324 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.joinrowset; + +import java.sql.SQLException; +import java.sql.Types; +import java.util.ArrayList; +import java.util.List; +import javax.sql.RowSet; +import javax.sql.rowset.CachedRowSet; +import javax.sql.rowset.JoinRowSet; +import javax.sql.rowset.RowSetMetaDataImpl; +import javax.sql.rowset.WebRowSet; +import static org.testng.Assert.assertEquals; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import test.rowset.webrowset.CommonWebRowSetTests; + +public class JoinRowSetTests extends CommonWebRowSetTests { + + private final String SUPPLIERS_TABLE = "SUPPLIERS"; + // Expected COF_IDs to be found + private final Object[] EXPECTED = {4, 1}; + // SUPPLIERS Primary Key to use to validate the joins + private final int SUP_ID = 101; + // Join Column between the SUPPLIERS and COFFEES table + private final String JOIN_COLNAME = "SUP_ID"; + // Column index in COFFEES table which contains SUP_ID + private final int COFFEES_JOIN_COLUMN_INDEX = 3; + // Column index in SUPPLIERS table which contains SUP_ID + private final int SUPPLIERS_JOIN_COLUMN_INDEX = 1; + + @Override + protected JoinRowSet newInstance() throws SQLException { + return rsf.createJoinRowSet(); + } + + /* + * Initializes the SUPPLIERS metadata + */ + private void initSuppliersMetaData(CachedRowSet crs) throws SQLException { + RowSetMetaDataImpl rsmd = new RowSetMetaDataImpl(); + + /* + * CREATE TABLE SUPPLIERS ( + * SUP_ID INTEGER NOT NULL, + * SUP_NAME VARCHAR(32) NOT NULL, + * STREET VARCHAR(32) NOT NULL, + * CITY VARCHAR(32) NOT NULL, + * STATE CHAR(2) NOT NULL, + * ZIP CHAR(5) NOT NULL, + * PRIMARY KEY (SUP_ID)) + */ + rsmd.setColumnCount(6); + rsmd.setColumnName(1, "SUP_ID"); + rsmd.setColumnName(2, "SUP_NAME"); + rsmd.setColumnName(3, "STREET"); + rsmd.setColumnName(4, "CITY"); + rsmd.setColumnName(5, "STATE"); + rsmd.setColumnName(6, "ZIP"); + + rsmd.setColumnType(1, Types.INTEGER); + rsmd.setColumnType(2, Types.VARCHAR); + rsmd.setColumnType(3, Types.VARCHAR); + rsmd.setColumnType(4, Types.VARCHAR); + rsmd.setColumnType(5, Types.CHAR); + rsmd.setColumnType(6, Types.CHAR); + crs.setMetaData(rsmd); + crs.setTableName(SUPPLIERS_TABLE); + } + + /* + * Add rows to SUPPLIERS table + */ + protected void createSuppiersRows(RowSet rs) throws SQLException { + + // insert into SUPPLIERS values(49, 'Superior Coffee', '1 Party Place', + // 'Mendocino', 'CA', '95460') + rs.moveToInsertRow(); + rs.updateInt(1, 49); + rs.updateString(2, "Superior Coffee"); + rs.updateString(3, "1 Party Place"); + rs.updateString(4, "Mendocino"); + rs.updateString(5, "CA"); + rs.updateString(6, "95460"); + rs.insertRow(); + + // insert into SUPPLIERS values(101, 'Acme, Inc.', '99 Market Street', + // 'Groundsville', 'CA', '95199') + rs.moveToInsertRow(); + rs.updateInt(1, 101); + rs.updateString(2, "Acme, Inc."); + rs.updateString(3, "99 Market Street"); + rs.updateString(4, "Groundsville"); + rs.updateString(5, "CA"); + rs.updateString(6, "95199"); + rs.insertRow(); + // insert into SUPPLIERS values(150, 'The High Ground', + // '100 Coffee Lane', 'Meadows', 'CA', '93966') + rs.moveToInsertRow(); + rs.updateInt(1, 150); + rs.updateString(2, "The High Ground"); + rs.updateString(3, "100 Coffee Lane"); + rs.updateString(4, "Meadows"); + rs.updateString(5, "CA"); + rs.updateString(6, "93966"); + rs.insertRow(); + // insert into SUPPLIERS values(456," 'Restaurant Supplies, Inc.', + // '200 Magnolia Street', 'Meadows', 'CA', '93966') + rs.moveToInsertRow(); + rs.updateInt(1, 456); + rs.updateString(2, "Restaurant Supplies, Inc."); + rs.updateString(3, "200 Magnolia Stree"); + rs.updateString(4, "Meadows"); + rs.updateString(5, "CA"); + rs.updateString(6, "93966"); + rs.insertRow(); + // insert into SUPPLIERS values(927, 'Professional Kitchen', + // '300 Daisy Avenue', 'Groundsville'," 'CA', '95199') + rs.moveToInsertRow(); + rs.updateInt(1, 927); + rs.updateString(2, "Professional Kitchen"); + rs.updateString(3, "300 Daisy Avenue"); + rs.updateString(4, "Groundsville"); + rs.updateString(5, "CA"); + rs.updateString(6, "95199"); + rs.insertRow(); + } + + /* + * DataProvider used to set parameters for basic types that are supported + */ + @DataProvider(name = "createCachedRowSetsToUse") + private Object[][] createCachedRowSetsToUse() throws SQLException { + CachedRowSet crs = rsf.createCachedRowSet(); + initCoffeesMetaData(crs); + createCoffeesRows(crs); + // Make sure you are not on the insertRow + crs.moveToCurrentRow(); + CachedRowSet crs1 = rsf.createCachedRowSet(); + initSuppliersMetaData(crs1); + createSuppiersRows(crs1); + // Make sure you are not on the insertRow + crs1.moveToCurrentRow(); + return new Object[][]{ + {crs, crs1} + }; + } + + /* + * Validate that the correct coffees are returned for SUP_ID + */ + private void validateResults(final JoinRowSet jrs) throws SQLException { + List 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); + } + + /* + * Join two CachedRowSets specifying a column name to join against + */ + @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(); + } + } + + /* + * Join two CachedRowSets specifying a column index to join against + */ + @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(); + } + } + + /* + * Join two CachedRowSets specifying a column name to join against + */ + @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(); + } + } + + /* + * Join two CachedRowSets specifying a column index to join against + */ + @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(); + } + } + + /* + * Join two CachedRowSets specifying a column name to join against + */ + @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(); + } + } + + /* + * Join two CachedRowSets specifying a column index to join against + */ + @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(); + } + } + + // Disabled tests due to bugs in JoinRowSet + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0004(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0005(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0008(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0026(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0027(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0053(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0054(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType", enabled = false) + public void commonCachedRowSetTest0055(CachedRowSet rs) throws Exception { + } + + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0009(WebRowSet wrs1) throws Exception { + } +} --- /dev/null 2015-01-09 09:47:37.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/webrowset/CommonWebRowSetTests.java 2015-01-09 09:47:36.000000000 -0500 @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.webrowset; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStreamWriter; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.util.Arrays; +import javax.sql.rowset.WebRowSet; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertEqualsNoOrder; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.Test; +import test.rowset.cachedrowset.CommonCachedRowSetTests; + +public abstract class CommonWebRowSetTests extends CommonCachedRowSetTests { + + protected final String XMLFILEPATH = System.getProperty("test.src", ".") + + File.separatorChar + "xml" + File.separatorChar; + protected final String COFFEE_ROWS_XML = XMLFILEPATH + "COFFEE_ROWS.xml"; + protected final String DELETED_COFFEE_ROWS_XML + = XMLFILEPATH + "DELETED_COFFEE_ROWS.xml"; + protected final String MODFIED_DELETED_COFFEE_ROWS_XML + = XMLFILEPATH + "MODFIED_DELETED_COFFEE_ROWS.xml"; + protected final String UPDATED_COFFEE_ROWS_XML + = XMLFILEPATH + "UPDATED_COFFEE_ROWS.xml"; + protected final String INSERTED_COFFEE_ROWS_XML + = XMLFILEPATH + "INSERTED_COFFEE_ROWS.xml"; + protected final String UPDATED_INSERTED_COFFEE_ROWS_XML + = XMLFILEPATH + "UPDATED_INSERTED_COFFEE_ROWS.xml"; + + + /* + * Utility method to write a WebRowSet XML file via an OutputStream + */ + protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { + rs.writeXml(oos); + } + return baos; + } + + /* + * Utility method to write a WebRowSet XML file via an OutputStream + * and populating the WebRowSet via a ResultSet + */ + 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; + } + + + /* + * Utility method to popoulate a WebRowSet via a InputStream + */ + 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; + } + + /* + * Utility method to write a WebRowSet XML file via an Writer + */ + protected ByteArrayOutputStream writeWebRowSetWithOutputStreamWithWriter(WebRowSet rs) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(baos); + rs.writeXml(osw); + return baos; + } + + /* + * 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; + } + + /* + * Utility method to popoulate a WebRowSet via a Readar + */ + protected WebRowSet readWebRowSetWithOInputStreamWithReader(ByteArrayOutputStream baos) throws Exception { + WebRowSet wrs1 = rsf.createWebRowSet(); + InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(baos.toByteArray())); + wrs1.readXml(isr); + return wrs1; + } + + /* + * Validate the expected Rows are contained within the RowSet + */ + @Test(dataProvider = "rowsetUsingCoffees") + public void WebRowSetTest0000(WebRowSet wrs) throws Exception { + assertEquals(getPrimaryKeys(wrs), COFFEES_PRIMARY_KEYS); + assertEquals(wrs.size(), COFFEES_ROWS); + wrs.close(); + } + + /* + * Validate the expected Rows are contained within the RowSet + * populated by readXML(Reader) + */ + @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(); + + } + + /* + * Validate the expected Rows are contained within the RowSet + * populated by readXML(InputStream) + */ + @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(); + } + + /* + * 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); + } + } + + /* + * 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); + } + } + + /* + * 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 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); + } + } + + /* + * 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); + } + } + + /* + * 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); + // With setShowDeleted(false) which is the default, + // 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)); + } + } + } + + /* + * Validate the expected Rows are contained within the RowSet + * that was populated by reading an xml file with all rows + * marked as a currentRow + */ + @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(); + } + + /* + * Read an XML file to populate a WebRowSet and validate that the rows + * that are marked as deleted are marked as such in the WebRowSet + * Also validate that they are or are not visible based on the + * setShowDeleted value + */ + @Test(dataProvider = "rowSetType") + public void WebRowSetTest0009(WebRowSet wrs1) throws Exception { + int[] rowsToDelete = {2, 4}; + Object[] expectedRows = {1, 3, 5}; + FileInputStream fis = new FileInputStream(DELETED_COFFEE_ROWS_XML); + wrs1.readXml(fis); + assertTrue(wrs1.size() == COFFEES_ROWS); + assertEquals(getPrimaryKeys(wrs1), expectedRows); + // With setShowDeleted(false) which is the default, + // the deleted row should not be visible + for (int row : rowsToDelete) { + assertFalse(findRowByPrimaryKey(wrs1, row, 1)); + } + // With setShowDeleted(true), the deleted row should be visible + wrs1.setShowDeleted(true); + for (int row : rowsToDelete) { + assertTrue(findRowByPrimaryKey(wrs1, row, 1)); + } + assertEquals(getPrimaryKeys(wrs1), COFFEES_PRIMARY_KEYS); + wrs1.close(); + + } + + /* + * Validate that the correct row in the WebRowSet that had been created + * from an xml file is marked as updated and contains the correct values + */ + @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(); + } + + /* + * Validate the correct row is marked as inserted in a WebRowSet + * that is read from an xml file + */ + @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(); + } + + /* + * Read an xml file which contains a row that was inserted and updated + */ + @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(); + } + +} --- /dev/null 2015-01-09 09:47:38.000000000 -0500 +++ new/test/javax/sql/testng/test/rowset/webrowset/WebRowSetTests.java 2015-01-09 09:47:37.000000000 -0500 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package test.rowset.webrowset; + +import java.sql.SQLException; +import javax.sql.rowset.WebRowSet; + +public class WebRowSetTests extends CommonWebRowSetTests { + + @Override + protected WebRowSet newInstance() throws SQLException { + return rsf.createWebRowSet(); + } + +} --- /dev/null 2015-01-09 09:47:39.000000000 -0500 +++ new/test/javax/sql/testng/xml/COFFEE_ROWS.xml 2015-01-09 09:47:38.000000000 -0500 @@ -0,0 +1,191 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + --- /dev/null 2015-01-09 09:47:40.000000000 -0500 +++ new/test/javax/sql/testng/xml/DELETED_COFFEE_ROWS.xml 2015-01-09 09:47:39.000000000 -0500 @@ -0,0 +1,191 @@ + + + + SELECT * FROM COFFEES + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + jdbc:derby://localhost:1527/testDB;create=true + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + --- /dev/null 2015-01-09 09:47:41.000000000 -0500 +++ new/test/javax/sql/testng/xml/INSERTED_COFFEE_ROWS.xml 2015-01-09 09:47:40.000000000 -0500 @@ -0,0 +1,207 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 15 + Hazelnut + 101 + 8.99 + 0 + 0 + + + 20 + French Vanilla + 49 + 9.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + --- /dev/null 2015-01-09 09:47:41.000000000 -0500 +++ new/test/javax/sql/testng/xml/MODFIED_DELETED_COFFEE_ROWS.xml 2015-01-09 09:47:41.000000000 -0500 @@ -0,0 +1,191 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + --- /dev/null 2015-01-09 09:47:42.000000000 -0500 +++ new/test/javax/sql/testng/xml/UPDATED_COFFEE_ROWS.xml 2015-01-09 09:47:42.000000000 -0500 @@ -0,0 +1,193 @@ + + + + SELECT * FROM COFFEES + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + jdbc:derby://localhost:1527/testDB;create=true + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 21 + 0 + 69 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + --- /dev/null 2015-01-09 09:47:43.000000000 -0500 +++ new/test/javax/sql/testng/xml/UPDATED_INSERTED_COFFEE_ROWS.xml 2015-01-09 09:47:43.000000000 -0500 @@ -0,0 +1,201 @@ + + + + + 1008 + + true + 1000 + 0 + 2 + + + + + 0 + 0 + 0 + true + ResultSet.TYPE_SCROLL_INSENSITIVE + false + COFFEES + + + com.sun.rowset.providers.RIOptimisticProvider + Oracle Corporation + 1.0 + 2 + 1 + + + + 6 + + 1 + false + false + false + 0 + false + false + 0 + + COF_NAME + + 0 + 0 + + + 4 + + + + 2 + false + false + false + 0 + false + false + 0 + + SUP_ID + + 0 + 0 + + + 12 + + + + 3 + false + false + false + 0 + false + false + 0 + + PRICE + + 0 + 0 + + + 4 + + + + 4 + false + false + false + 0 + false + false + 0 + + SALES + + 10 + 2 + + + 2 + + + + 5 + false + false + false + 0 + false + false + 0 + + TOTAL + + 0 + 0 + + + 4 + + + + 6 + false + false + false + 0 + false + false + 0 + + + + 0 + 0 + + + 4 + + + + + + 1 + Colombian + 101 + 7.99 + 0 + 0 + + + 2 + French_Roast + 49 + 8.99 + 0 + 0 + + + 3 + Espresso + 150 + 9.99 + 0 + 0 + + + 4 + Colombian_Decaf + 101 + 8.99 + 0 + 0 + + + 5 + French_Roast_Decaf + 49 + 9.99 + 0 + 0 + + + 100 + Mocha + 49 + 9.99 + 12.99 + 20 + 35 + 125 + + +