8064356: Add BaseRowSet, SQLInputImpl, and SQLOutputImpl tests
Reviewed-by: joehw, rriggs
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/BaseRowSetTests.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,1318 @@
+/*
+ * Copyright (c) 2014, 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.io.StringBufferInputStream;
+import java.io.StringReader;
+import java.math.BigDecimal;
+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.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.time.LocalDate;
+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.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 {
+
+ 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<String, Class<?>> 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 false by default
+ */
+ @Test
+ public void test08() throws Exception {
+ assertFalse(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);
+ }
+
+ /*
+ * 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
+ */
+ @Test()
+ public void test28() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.notifyRowSetChanged();
+ assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
+ }
+
+ /*
+ * Create a RowSetListener and validate that notifyRowChanged is called
+ */
+ @Test()
+ public void test29() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.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
+ */
+ @Test()
+ public void test31() 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));
+ }
+
+ /*
+ * Create multiple RowSetListeners and validate that notifyRowSetChanged
+ * is called on all listeners
+ */
+ @Test()
+ public void test32() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ TestRowSetListener rsl2 = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.addRowSetListener(rsl2);
+ brs.notifyRowSetChanged();
+ assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
+ assertTrue(rsl2.isNotified(TestRowSetListener.ROWSET_CHANGED));
+ }
+
+ /*
+ * Create multiple RowSetListeners and validate that notifyRowChanged
+ * is called on all listeners
+ */
+ @Test()
+ public void test33() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ TestRowSetListener rsl2 = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.addRowSetListener(rsl2);
+ brs.notifyRowChanged();
+ assertTrue(rsl.isNotified(TestRowSetListener.ROW_CHANGED));
+ assertTrue(rsl2.isNotified(TestRowSetListener.ROW_CHANGED));
+ }
+
+ /*
+ * Create multiple RowSetListeners and validate that notifyCursorMoved
+ * is called on all listeners
+ */
+ @Test()
+ public void test34() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ TestRowSetListener rsl2 = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.addRowSetListener(rsl2);
+ brs.notifyCursorMoved();
+ assertTrue(rsl.isNotified(TestRowSetListener.CURSOR_MOVED));
+ assertTrue(rsl2.isNotified(TestRowSetListener.CURSOR_MOVED));
+ }
+
+ /*
+ * Create multiple RowSetListeners and validate that notifyRowSetChanged,
+ * notifyRowChanged() and notifyCursorMoved are called on all listeners
+ */
+ @Test()
+ public void test35() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ TestRowSetListener rsl2 = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.addRowSetListener(rsl2);
+ brs.notifyRowSetChanged();
+ brs.notifyRowChanged();
+ brs.notifyCursorMoved();
+ assertTrue(rsl.isNotified(
+ TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED
+ | TestRowSetListener.ROW_CHANGED));
+ assertTrue(rsl2.isNotified(
+ TestRowSetListener.CURSOR_MOVED | TestRowSetListener.ROWSET_CHANGED
+ | TestRowSetListener.ROW_CHANGED));
+ }
+
+ /*
+ * Create a RowSetListener and validate that notifyRowSetChanged is called,
+ * remove the listener, invoke notifyRowSetChanged again and verify the
+ * listner is not called
+ */
+ @Test()
+ public void test36() throws Exception {
+ TestRowSetListener rsl = new TestRowSetListener();
+ brs.addRowSetListener(rsl);
+ brs.notifyRowSetChanged();
+ assertTrue(rsl.isNotified(TestRowSetListener.ROWSET_CHANGED));
+ // Clear the flag indicating the listener has been called
+ rsl.resetFlag();
+ brs.removeRowSetListener(rsl);
+ brs.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 {
+ assertTrue(getParam(pos, o).getClass().isInstance(o));
+ assertTrue(o.equals(getParam(pos, o)));
+ }
+
+ /*
+ * Set the complex parameters and validate that the value set is
+ * the correct type
+ */
+ @Test(dataProvider = "testAdvancedParameters")
+ public void test41(int pos, Object o) throws Exception {
+ assertTrue(getParam(pos, o).getClass().isInstance(o));
+ }
+
+ /*
+ * Validate setNull specifying the supported type values
+ */
+ @Test(dataProvider = "jdbcTypes")
+ public void test42(Integer type) throws Exception {
+ brs.setNull(1, type);
+ assertTrue(checkNullParam(1, type, null));
+ }
+
+ /*
+ * Validate setNull specifying the supported type values and that
+ * typeName is set internally
+ */
+ @Test(dataProvider = "jdbcTypes")
+ public void test43(Integer type) throws Exception {
+ brs.setNull(1, type, "SUPERHERO");
+ assertTrue(checkNullParam(1, type, "SUPERHERO"));
+ }
+
+ /*
+ * Validate that setDate sets the specified Calendar internally
+ */
+ @Test()
+ public void test44() throws Exception {
+ brs.setDate(1, aDate, cal);
+ assertTrue(checkCalendarParam(1, cal));
+ }
+
+ /*
+ * Validate that setTime sets the specified Calendar internally
+ */
+ @Test()
+ public void test45() throws Exception {
+ brs.setTime(1, aTime, cal);
+ assertTrue(checkCalendarParam(1, cal));
+ }
+
+ /*
+ * Validate that setTimestamp sets the specified Calendar internally
+ */
+ @Test()
+ public void test46() throws Exception {
+ brs.setTimestamp(1, ts, 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);
+ }
+
+ /*
+ * 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
+ */
+ @DataProvider(name = "testBaseParameters")
+ private Object[][] testBaseParameters() throws SQLException {
+ Integer aInt = 1;
+ Long aLong = Long.MAX_VALUE;
+ Short aShort = Short.MIN_VALUE;
+ BigDecimal bd = BigDecimal.ONE;
+ Double aDouble = Double.MAX_VALUE;
+ Boolean aBoolean = true;
+ Float aFloat = 1.5f;
+ Byte aByte = 1;
+
+ 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);
+
+ return new Object[][]{
+ {1, aInt},
+ {2, query},
+ {3, aLong},
+ {4, aBoolean},
+ {5, aShort},
+ {6, aDouble},
+ {7, bd},
+ {8, aFloat},
+ {9, aByte},
+ {10, aDate},
+ {11, aTime},
+ {12, ts},
+ {13, aDate},
+ {14, aTime},
+ {15, ts},
+ {16, query},
+ {17, query},
+ {18, query}
+
+ };
+ }
+
+ /*
+ * DataProvider used to set advanced parameters for types that are supported
+ */
+ @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());
+
+ return new Object[][]{
+ {1, bytes},
+ {2, is},
+ {3, aRef},
+ {4, aArray},
+ {5, aBlob},
+ {6, aClob},
+ {7, is},
+ {8, is},
+ {9, rdr}
+ };
+ }
+
+ /*
+ * Method that returns the specified parameter instance that was set via setXXX
+ * Note non-basic types are stored as an Object[] where the 1st element
+ * is the object instnace
+ */
+ @SuppressWarnings("unchecked")
+ private <T> T getParam(int pos, T o) throws SQLException {
+ Object[] params = brs1.getParams();
+ if (params[pos - 1] instanceof Object[]) {
+ Object[] param = (Object[]) params[pos - 1];
+ return (T) param[0];
+ } else {
+ return (T) params[pos - 1];
+ }
+ }
+
+ /*
+ * Utility method to validate parameters when the param is an Object[]
+ */
+ private boolean checkParam(int pos, int type, Object val) throws SQLException {
+ boolean result = false;
+ Object[] params = brs.getParams();
+ if (params[pos - 1] instanceof Object[]) {
+ Object[] param = (Object[]) params[pos - 1];
+
+ if (param[0] == null) {
+ // setNull was used
+ if (param.length == 2 && (Integer) param[1] == type) {
+ result = true;
+ } else {
+ if (param.length == 3 && (Integer) param[1] == type
+ && val.equals(param[2])) {
+ result = true;
+ }
+ }
+
+ } else if (param[0] instanceof java.util.Date) {
+ // setDate/Time/Timestamp with a Calendar object
+ if (param[1] instanceof Calendar && val.equals(param[1])) {
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ /*
+ * Wrapper method for validating that a null was set and the appropriate
+ * type and typeName if applicable
+ */
+ private boolean checkNullParam(int pos, int type, String typeName) throws SQLException {
+ return checkParam(pos, type, typeName);
+ }
+
+ /*
+ * Wrapper method for validating that a Calander was set
+ */
+ private boolean checkCalendarParam(int pos, Calendar cal) throws SQLException {
+ // 2nd param is ignored when instanceof java.util.Date
+ return checkParam(pos, Types.DATE, cal);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/serial/SQLInputImplTests.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2014, 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.serial;
+
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Ref;
+import java.sql.SQLException;
+import java.sql.Struct;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import javax.sql.rowset.serial.SQLInputImpl;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import util.BaseTest;
+import util.StubArray;
+import util.StubBlob;
+import util.StubClob;
+import util.StubRef;
+import util.StubStruct;
+import util.SuperHero;
+import util.TestSQLDataImpl;
+
+public class SQLInputImplTests extends BaseTest {
+
+ // Copy of the array of data type values
+ private Object[] typeValues;
+ private TestSQLDataImpl impl;
+ private Map<String, Class<?>> map ;
+ private SuperHero hero;
+ private final String sqlType = "SUPERHERO";
+
+ @BeforeMethod
+ @Override
+ public void setUpMethod() throws Exception {
+ map = new HashMap<>();
+ impl = new TestSQLDataImpl("TestSQLData");
+ typeValues = Arrays.copyOf(TestSQLDataImpl.attributes,
+ TestSQLDataImpl.attributes.length);
+ hero = new SuperHero(sqlType, "Bruce", "Wayne",
+ 1939, "Batman");
+ }
+
+ /*
+ * Validate that a SQLException is thrown if the attribute value is
+ * null
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test() throws Exception {
+ SQLInputImpl x = new SQLInputImpl(null, map);
+ }
+
+ /*
+ * Validate that a SQLException is thrown if the map value is
+ * null
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test02() throws Exception {
+ SQLInputImpl x = new SQLInputImpl(typeValues, null);
+ }
+
+ /*
+ * Read in the various datatypes via readSQL (which will exercise the
+ * various readXXX methods and validate that results are as expected
+ */
+ @Test()
+ public void test03() throws Exception {
+ impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
+ assertTrue(Arrays.equals(impl.toArray(), typeValues));
+ // Null out a field and make sure the arrays do not match
+ typeValues[2] = null;
+ assertFalse(Arrays.equals(impl.toArray(), typeValues));
+ }
+
+ /*
+ * Validate that wasNull indicates if a null was read in
+ */
+ @Test()
+ public void test04() throws Exception {
+ Object[] values = {"Hello", null, 1};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ String s = sqli.readString();
+ assertFalse(sqli.wasNull());
+ s = sqli.readString();
+ assertTrue(sqli.wasNull());
+ int i = sqli.readInt();
+ assertFalse(sqli.wasNull());
+ }
+
+ /*
+ * Validate that readObject returns the correct value
+ */
+ @Test()
+ public void test05() throws Exception {
+ Object[] values = {hero};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ Object o = sqli.readObject();
+ assertTrue(hero.equals(o));
+
+ }
+
+ /*
+ * Validate a Array can be read
+ */
+ @Test(enabled = true)
+ public void test06() throws Exception {
+ Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
+ "Cappuccino"};
+ Array a = new StubArray("VARCHAR", coffees);
+ Object[] values = {a};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ Array a2 = sqli.readArray();
+ assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray()));
+ assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName()));
+ }
+
+ /*
+ * Validate a Blob can be read
+ */
+ @Test(enabled = true)
+ public void test07() throws Exception {
+ Blob b = new StubBlob();
+ Object[] values = {b};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ Blob b2 = sqli.readBlob();
+ assertTrue(Arrays.equals(
+ b.getBytes(1, (int) b.length()),
+ b2.getBytes(1, (int) b2.length())));
+ }
+
+ /*
+ * Validate a Clob can be read
+ */
+ @Test(enabled = true)
+ public void test08() throws Exception {
+ Clob c = new StubClob();
+ Object[] values = {c};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ Clob c2 = sqli.readClob();
+ assertTrue(c.getSubString(1,
+ (int) c.length()).equals(c2.getSubString(1, (int) c2.length())));
+ }
+
+ /*
+ * Validate a Ref can be read
+ */
+ @Test(enabled = true)
+ public void test09() throws Exception {
+ Ref ref = new StubRef(sqlType, hero);
+ Object[] values = {ref};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ Ref ref2 = sqli.readRef();
+ assertTrue(ref.getObject().equals(ref2.getObject()));
+ assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
+ }
+
+ /*
+ * Validate a URL can be read
+ */
+ @Test(enabled = true)
+ public void test10() throws Exception {
+ URL u = new URL("http://www.oracle.com/");;
+ Object[] values = {u};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ URL u2 = sqli.readURL();
+ assertTrue(u2.equals(u));
+ assertTrue(u2.sameFile(u));
+ }
+
+ /*
+ * Validate that readObject returns the correct value when a Struct is
+ * next on the stream
+ */
+ @Test()
+ public void test11() throws Exception {
+ Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
+ "Batman"};
+ map.put(sqlType, Class.forName("util.SuperHero"));
+ Struct struct = new StubStruct(sqlType, attributes);
+ Object[] values = {struct};
+ SQLInputImpl sqli = new SQLInputImpl(values, map);
+ Object o = sqli.readObject();
+
+ assertTrue(hero.equals(o));
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/test/rowset/serial/SQLOutputImplTests.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2014, 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.serial;
+
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Ref;
+import java.sql.SQLException;
+import java.sql.Struct;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+import javax.sql.rowset.serial.SQLInputImpl;
+import javax.sql.rowset.serial.SQLOutputImpl;
+import javax.sql.rowset.serial.SerialArray;
+import javax.sql.rowset.serial.SerialBlob;
+import javax.sql.rowset.serial.SerialClob;
+import javax.sql.rowset.serial.SerialDatalink;
+import javax.sql.rowset.serial.SerialRef;
+import javax.sql.rowset.serial.SerialStruct;
+import static org.testng.Assert.*;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import util.BaseTest;
+import util.StubArray;
+import util.StubBlob;
+import util.StubClob;
+import util.StubRef;
+import util.StubStruct;
+import util.SuperHero;
+import util.TestSQLDataImpl;
+
+public class SQLOutputImplTests extends BaseTest {
+
+ // Copy of the array of data type values
+ private Object[] typeValues;
+ private TestSQLDataImpl impl;
+ private Map<String, Class<?>> map = new HashMap<>();
+ private Vector results;
+ private final String sqlType = "SUPERHERO";
+ private SuperHero hero;
+ private SQLOutputImpl outImpl;
+
+ @BeforeMethod
+ @Override
+ public void setUpMethod() throws Exception {
+ results = new Vector();
+ impl = new TestSQLDataImpl("TestSQLData");
+ typeValues = Arrays.copyOf(TestSQLDataImpl.attributes,
+ TestSQLDataImpl.attributes.length);
+ hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman");
+ outImpl = new SQLOutputImpl(results, map);
+ }
+
+ /*
+ * Validate that a SQLException is thrown if the attribute value is
+ * null
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test() throws Exception {
+ SQLOutputImpl x = new SQLOutputImpl(null, map);
+ }
+
+ /*
+ * Validate that a SQLException is thrown if the map value is
+ * null
+ */
+ @Test(expectedExceptions = SQLException.class)
+ public void test02() throws Exception {
+ SQLOutputImpl x = new SQLOutputImpl(results, null);
+ }
+
+ /*
+ * Read in the various datatypes via readSQL (which will exercise the
+ * various readXXX methods and validate that results are as expected
+ */
+ @Test()
+ public void test03() throws Exception {
+ impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
+ impl.writeSQL(outImpl);
+ assertTrue(Arrays.equals(results.toArray(), typeValues));
+ // Null out a field and make sure the arrays do not match
+ typeValues[2] = null;
+ assertFalse(Arrays.equals(results.toArray(), typeValues));
+ }
+
+ /*
+ * Validate a Array can be written and returned
+ */
+ @Test(enabled = true)
+ public void test04() throws Exception {
+ Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
+ "Cappuccino"};
+ Array a = new StubArray("VARCHAR", coffees);
+ outImpl.writeArray(a);
+ SerialArray sa = (SerialArray) results.get(0);
+ assertTrue(Arrays.equals(coffees, (Object[]) sa.getArray()));
+ assertTrue(a.getBaseTypeName().equals(sa.getBaseTypeName()));
+ }
+
+ /*
+ * Validate a Blob can be written and returned
+ */
+ @Test(enabled = true)
+ public void test05() throws Exception {
+ Blob b = new StubBlob();
+ outImpl.writeBlob(b);
+ SerialBlob sb = (SerialBlob) results.get(0);
+ assertTrue(Arrays.equals(
+ b.getBytes(1, (int) b.length()),
+ sb.getBytes(1, (int) sb.length())));
+ }
+
+ /*
+ * Validate a Clob can be written and returned
+ */
+ @Test(enabled = true)
+ public void test06() throws Exception {
+ Clob c = new StubClob();
+ outImpl.writeClob(c);
+ SerialClob sc = (SerialClob) results.get(0);
+ assertTrue(c.getSubString(1,
+ (int) c.length()).equals(sc.getSubString(1, (int) sc.length())));
+ }
+
+ /*
+ * Validate a Ref can be written and returned
+ */
+ @Test(enabled = true)
+ public void test07() throws Exception {
+ Ref ref = new StubRef(sqlType, hero);
+ outImpl.writeRef(ref);
+ SerialRef sr = (SerialRef) results.get(0);
+ assertTrue(hero.equals(sr.getObject()));
+ }
+
+ /*
+ * Validate a Struct can be written and returned
+ */
+ @Test(enabled = true)
+ public void test08() throws Exception {
+ Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
+ "Batman"};
+ Struct s = new StubStruct(sqlType, attributes);
+ outImpl.writeStruct(s);
+ SerialStruct ss = (SerialStruct) results.get(0);
+ assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes()));
+ assertTrue(sqlType.equals(ss.getSQLTypeName()));
+ }
+
+ /*
+ * Validate a DataLink can be written and returned
+ */
+ @Test(enabled = true)
+ public void test09() throws Exception {
+ URL u = new URL("http://www.oracle.com/");
+ outImpl.writeURL(u);
+ SerialDatalink sdl = (SerialDatalink) results.get(0);
+ URL u2 = sdl.getDatalink();
+ assertTrue(u2.equals(u));
+ assertTrue(u2.sameFile(u));
+ }
+
+ /*
+ * Validate an Object implementing SQLData can be written and returned
+ */
+ @Test(enabled = true)
+ public void test10() throws Exception {
+ Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
+ "Batman"};
+ outImpl.writeObject(hero);
+ SerialStruct ss = (SerialStruct) results.get(0);
+ assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes()));
+ assertTrue(sqlType.equals(ss.getSQLTypeName()));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubBaseRowSet.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,1001 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+import javax.sql.RowSet;
+import javax.sql.rowset.BaseRowSet;
+
+public class StubBaseRowSet extends BaseRowSet implements RowSet {
+
+ public StubBaseRowSet() {
+ super();
+ // Must call initParams() as part of initialization
+ super.initParams();
+ }
+
+ public void notifyCursorMoved() throws SQLException {
+ super.notifyCursorMoved();
+ }
+
+ public void notifyRowChanged() throws SQLException {
+ super.notifyRowChanged();
+ }
+
+ public void notifyRowSetChanged() throws SQLException {
+ super.notifyRowSetChanged();
+ }
+
+ public void initParams() {
+ super.initParams();
+ }
+
+ // Methods required by RowSet interace, not used
+ @Override
+ public void execute() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean next() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void close() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean wasNull() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte getByte(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public short getShort(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getInt(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public long getLong(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public float getFloat(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public double getDouble(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean getBoolean(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte getByte(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public short getShort(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getInt(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public long getLong(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public float getFloat(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public double getDouble(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public byte[] getBytes(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getCursorName() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public ResultSetMetaData getMetaData() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int findColumn(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isAfterLast() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isFirst() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isLast() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void beforeFirst() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void afterLast() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean first() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean last() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean absolute(int row) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean relative(int rows) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean previous() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean rowUpdated() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean rowInserted() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean rowDeleted() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNull(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateByte(int columnIndex, byte x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateShort(int columnIndex, short x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateInt(int columnIndex, int x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateLong(int columnIndex, long x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateFloat(int columnIndex, float x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDouble(int columnIndex, double x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateString(int columnIndex, String x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDate(int columnIndex, Date x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTime(int columnIndex, Time x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNull(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBoolean(String columnLabel, boolean x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateByte(String columnLabel, byte x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateShort(String columnLabel, short x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateInt(String columnLabel, int x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateLong(String columnLabel, long x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateFloat(String columnLabel, float x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDouble(String columnLabel, double x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateString(String columnLabel, String x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateDate(String columnLabel, Date x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTime(String columnLabel, Time x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void insertRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void deleteRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void refreshRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void cancelRowUpdates() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void moveToInsertRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void moveToCurrentRow() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Statement getStatement() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Ref getRef(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Blob getBlob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Clob getClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array getArray(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Ref getRef(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Blob getBlob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Clob getClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Array getArray(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public java.net.URL getURL(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public java.net.URL getURL(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateArray(int columnIndex, Array x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateArray(String columnLabel, Array x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public RowId getRowId(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNString(int columnIndex, String nString) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNString(String columnLabel, String nString) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public NClob getNClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getNString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getNString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubNClob.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.NClob;
+
+public class StubNClob extends StubClob implements NClob {
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubRowId.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.sql.RowId;
+
+public class StubRowId implements RowId {
+
+ @Override
+ public byte[] getBytes() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/StubSQLXML.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+
+public class StubSQLXML implements SQLXML{
+
+ @Override
+ public void free() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public InputStream getBinaryStream() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public OutputStream setBinaryStream() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Reader getCharacterStream() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Writer setCharacterStream() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getString() throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setString(String value) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public <T extends Result> T setResult(Class<T> resultClass) throws SQLException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
--- a/jdk/test/javax/sql/testng/util/SuperHero.java Thu Nov 06 13:18:44 2014 -0800
+++ b/jdk/test/javax/sql/testng/util/SuperHero.java Sun Nov 09 17:59:06 2014 -0500
@@ -32,10 +32,14 @@
private String first;
private String last;
- private final String type;
+ private String type = "SUPERHERO";
private Integer firstYear;
private String secretIdentity;
+ public SuperHero() {
+
+ }
+
public SuperHero(String sqlType, String fname, String lname, Integer year,
String identity) {
first = fname;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/TestRowSetListener.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import javax.sql.RowSetEvent;
+import javax.sql.RowSetListener;
+
+public class TestRowSetListener implements RowSetListener {
+
+ // Flags to indicate which listener events should have been notified
+ public final static int ROWSET_CHANGED = 1;
+ public final static int ROW_CHANGED = 2;
+ public final static int CURSOR_MOVED = 4;
+ private int flag;
+
+ @Override
+ public void rowSetChanged(RowSetEvent event) {
+ flag |= ROWSET_CHANGED;
+ }
+
+ @Override
+ public void rowChanged(RowSetEvent event) {
+ flag |= ROW_CHANGED;
+ }
+
+ @Override
+ public void cursorMoved(RowSetEvent event) {
+ flag |= CURSOR_MOVED;
+ }
+
+ /*
+ * Clear the flag indicating which events we were notified for
+ */
+ public void resetFlag() {
+ flag = 0;
+ }
+
+ /*
+ * Method used to validate that the correct event was notified
+ */
+ public boolean isNotified( int val) {
+ return flag == val;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sql/testng/util/TestSQLDataImpl.java Sun Nov 09 17:59:06 2014 -0500
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2014, 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 util;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.SQLData;
+import java.sql.SQLException;
+import java.sql.SQLInput;
+import java.sql.SQLOutput;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.Arrays;
+
+public class TestSQLDataImpl implements SQLData {
+
+ private final int stringPos = 0;
+ private final int datePos = 1;
+ private final int timePos = 2;
+ private final int timestampPos = 3;
+ private final int intPos = 4;
+ private final int longPos = 5;
+ private final int shortPos = 6;
+ private final int bigDecimalPos = 7;
+ private final int doublePos = 8;
+ private final int booleanPos = 9;
+ private final int floatPos = 10;
+ private final int bytePos = 11;
+ private final int bytesPos = 12;
+ private final int MAX_TYPES = bytesPos + 1;
+ private final Object[] types = new Object[MAX_TYPES];
+
+ private final static byte[] b = {1, 2, 3};
+
+ // attributes entries must line up with the ordering of the reading and
+ // writing of the fields in readSQL and writeSQL
+ public final static Object[] attributes = {"The Dark Knight",
+ Date.valueOf(LocalDate.now()), Time.valueOf(LocalTime.now()),
+ Timestamp.valueOf(LocalDateTime.now()), Integer.MAX_VALUE,
+ Long.MAX_VALUE, Short.MIN_VALUE, BigDecimal.ONE,
+ Double.MAX_VALUE, true, 1.5f, Byte.MAX_VALUE, b};
+
+ private String sqlType;
+
+ public TestSQLDataImpl(String type) {
+ sqlType = type;
+ }
+
+ @Override
+ public String getSQLTypeName() throws SQLException {
+ return sqlType;
+ }
+
+ @Override
+ public void readSQL(SQLInput stream, String typeName) throws SQLException {
+
+ sqlType = typeName;
+ types[stringPos] = stream.readString();
+ types[datePos] = stream.readDate();
+ types[timePos] = stream.readTime();
+ types[timestampPos] = stream.readTimestamp();
+ types[intPos] = stream.readInt();
+ types[longPos] = stream.readLong();
+ types[shortPos] = stream.readShort();
+ types[bigDecimalPos] = stream.readBigDecimal();
+ types[doublePos] = stream.readDouble();
+ types[booleanPos] = stream.readBoolean();
+ types[floatPos] = stream.readFloat();
+ types[bytePos] = stream.readByte();
+ types[bytesPos] = stream.readBytes();
+ }
+
+ @Override
+ public void writeSQL(SQLOutput stream) throws SQLException {
+
+ stream.writeString((String) types[stringPos]);
+ stream.writeDate((Date) types[datePos]);
+ stream.writeTime((Time) types[timePos]);
+ stream.writeTimestamp((Timestamp) types[timestampPos]);
+ stream.writeInt((Integer) types[intPos]);
+ stream.writeLong((Long) types[longPos]);
+ stream.writeShort((Short) types[shortPos]);
+ stream.writeBigDecimal((BigDecimal) types[bigDecimalPos]);
+ stream.writeDouble((Double) types[doublePos]);
+ stream.writeBoolean((Boolean) types[booleanPos]);
+ stream.writeFloat((Float) types[floatPos]);
+ stream.writeByte((Byte) types[bytePos]);
+ stream.writeBytes((byte[]) types[bytesPos]);
+ }
+
+ public Object[] toArray() {
+
+ Object[] result = Arrays.copyOf(types, types.length);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "[" + sqlType + " " + types + "]";
+ }
+
+}