You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2006/10/19 19:48:46 UTC
svn commit: r465694 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests:
master/ master/j9_foundation/ suites/ tests/jdbcapi/
Author: kahatlen
Date: Thu Oct 19 10:48:44 2006
New Revision: 465694
URL: http://svn.apache.org/viewvc?view=rev&rev=465694
Log:
DERBY-1962: Convert jdbcapi/resultsetJdbc30.java to junit
Patch contributed by Fernanda Pizzorno.
Added:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetJDBC30Test.java (with props)
Removed:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_foundation/resultsetJdbc30.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/resultsetJdbc30.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30_app.properties
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30_sed.properties
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdk14.runall
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude?view=diff&rev=465694&r1=465693&r2=465694
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNet.exclude Thu Oct 19 10:48:44 2006
@@ -7,7 +7,6 @@
# excluding jdbcapi/SetQueryTimeoutTest.java because neither the JCC driver nor the ClientDriver support setQueryTimeout() yet.
# excluding lang/updatableResultSet.java because changes are required in JCC Driver for this test to run correctly
# excluding jdbcapi/rsgetXXXcolumnNames.java as it fails incorrectly, according to JDBC spec. Forwarding test case to JCC team.
-# excluding jdbcapi/resultsetJdbc30.java because the features tested are not implemented by JCC driver or ClientDriver
# excluding jdbcapi/checkDataSource30.java - Client behaves differently. Need to look into this
# excluding jdbcapi/statementJdbc30.java - Client behaves differently. Need to look into this
# excluding jdbcapi/holdCursorJava.java - JCC behaves differently with hold cursors.
@@ -25,7 +24,6 @@
jdbcapi/SetQueryTimeoutTest.java
lang/updatableResultSet.java
jdbcapi/blobSetBinaryStream.java
-jdbcapi/resultsetJdbc30.java
jdbcapi/checkDataSource30.java
jdbcapi/statementJdbc30.java
lang/holdCursorJava.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude?view=diff&rev=465694&r1=465693&r2=465694
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/DerbyNetClient.exclude Thu Oct 19 10:48:44 2006
@@ -2,7 +2,6 @@
# excluding scrollCursors2.java because updatable resultsets & scroll sensitive cursors are not supported
# excluding batchUpdate.java for it hits a problem in networkserver ('beetle' 5561)
# excluding statementJdbc20.java because this tests fetch_reverse throughout the test
-# excluding jdbcapi/resultsetJdbc30.java because the features tested are not implemented by Derby Client
# excluding jdbcapi/statementJdbc30.java - Client behaves differently. Need to look into this
# excluding jdbcapi/dataSourceReference.java - client side only tests, tests all data sources
# regardless of framework
@@ -17,7 +16,6 @@
#
jdbcapi/batchUpdate.java
jdbcapi/statementJdbc20.java
-jdbcapi/resultsetJdbc30.java
jdbcapi/statementJdbc30.java
jdbcapi/dataSourceReference.java
largedata/LobLimits.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdk14.runall
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdk14.runall?view=diff&rev=465694&r1=465693&r2=465694
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdk14.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdk14.runall Thu Oct 19 10:48:44 2006
@@ -4,7 +4,6 @@
jdbcapi/checkDataSource30.java
jdbcapi/parameterMetaDataJdbc30.java
lang/procedureJdbc30.java
-jdbcapi/resultsetJdbc30.java
jdbcapi/statementJdbc30.java
jdbcapi/savepointJdbc30_JSR169.java
jdbcapi/savepointJdbc30_XA.java
Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetJDBC30Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetJDBC30Test.java?view=auto&rev=465694
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetJDBC30Test.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetJDBC30Test.java Thu Oct 19 10:48:44 2006
@@ -0,0 +1,250 @@
+/*
+ *
+ * Derby - Class ResultSetJDBC30Test
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+package org.apache.derbyTesting.functionTests.tests.jdbcapi;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+
+import java.sql.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Test of additional methods in JDBC3.0 result set
+ */
+public class ResultSetJDBC30Test extends BaseJDBCTestCase {
+
+ /** Creates a new instance of ResultSetJDBC30Test */
+ public ResultSetJDBC30Test(String name) {
+ super(name);
+ }
+
+ /**
+ * Set up the connection to the database.
+ */
+ public void setUp() throws Exception {
+ getConnection().setAutoCommit(false);
+ Statement stmt = createStatement();
+ stmt.execute("create table t (i int, s smallint, r real, "+
+ "d double precision, dt date, t time, ts timestamp, "+
+ "c char(10), v varchar(40) not null, dc dec(10,2))");
+ stmt.execute("insert into t values(1,2,3.3,4.4,date('1990-05-05'),"+
+ "time('12:06:06'),timestamp('1990-07-07 07:07:07.07'),"+
+ "'eight','nine', 11.1)");
+ stmt.close();
+ commit();
+ }
+
+ protected void tearDown() throws Exception {
+ Statement stmt = createStatement();
+ stmt.executeUpdate("DROP TABLE t");
+ commit();
+ super.tearDown();
+ }
+
+ public static Test suite() {
+ return TestConfiguration.defaultSuite(ResultSetJDBC30Test.class);
+ }
+
+
+ public void testNotImplementedMethods() throws Exception {
+ Statement stmt = createStatement();
+
+ ResultSet rs = stmt.executeQuery("select * from t");
+ assertTrue("FAIL - row not found", rs.next());
+
+ try {
+ rs.getURL(8);
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ } catch (SQLException se) {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ }
+ try {
+ rs.getURL("c");
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ } catch (SQLException se) {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ }
+ try {
+ rs.updateRef(8, null);
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ } catch (SQLException se) {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ } catch (NoSuchMethodError nsme) {
+ assertTrue("FAIL - ResultSet.updateRef not present - correct for" +
+ " JSR169", JDBC.vmSupportsJSR169());
+ }
+ try {
+ rs.updateRef("c", null);
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ } catch (SQLException se) {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ } catch (NoSuchMethodError nsme) {
+ assertTrue("FAIL - ResultSet.updateRef not present - correct for" +
+ " JSR169", JDBC.vmSupportsJSR169());
+ }
+ try {
+ rs.updateBlob(8, null);
+ if (usingEmbedded()) {
+ fail("FAIL - Shouldn't reach here. Method is being invoked" +
+ " on a read only resultset.");
+ } else {
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ }
+ } catch (SQLException se) {
+ if (usingEmbedded()) {
+ assertSQLState(UPDATABLE_RESULTSET_API_DISALLOWED, se);
+ } else {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ }
+ }
+ try {
+ rs.updateBlob("c", null);
+ if (usingEmbedded()) {
+ fail("FAIL - Shouldn't reach here. Method is being invoked" +
+ " on a read only resultset.");
+ } else {
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ }
+ } catch (SQLException se) {
+ if (usingEmbedded()) {
+ assertSQLState(UPDATABLE_RESULTSET_API_DISALLOWED, se);
+ } else {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ }
+ }
+ try {
+ rs.updateClob(8, null);
+ if (usingEmbedded()) {
+ fail("FAIL - Shouldn't reach here. Method is being invoked" +
+ " on a read only resultset.");
+ } else {
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ }
+ } catch (SQLException se) {
+ if (usingEmbedded()) {
+ assertSQLState(UPDATABLE_RESULTSET_API_DISALLOWED, se);
+ } else {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ }
+ }
+ try {
+ rs.updateClob("c", null);
+ if (usingEmbedded()) {
+ fail("FAIL - Shouldn't reach here. Method is being invoked" +
+ " on a read only resultset.");
+ } else {
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ }
+ } catch (SQLException se) {
+ if (usingEmbedded()) {
+ assertSQLState(UPDATABLE_RESULTSET_API_DISALLOWED, se);
+ } else {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ }
+ }
+ try {
+ rs.updateArray(8, null);
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ } catch (SQLException se) {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ } catch (NoSuchMethodError nsme) {
+ assertTrue("FAIL - ResultSet.updateArray not present - correct" +
+ " for JSR169", JDBC.vmSupportsJSR169());
+ }
+ try {
+ rs.updateArray("c", null);
+ fail("FAIL - Shouldn't reach here. Method not implemented" +
+ " yet.");
+ } catch (SQLException se) {
+ assertSQLState(NOT_IMPLEMENTED, se);
+ } catch (NoSuchMethodError nsme) {
+ assertTrue("FAIL - ResultSet.updateArray not present - correct" +
+ " for JSR169", JDBC.vmSupportsJSR169());
+ }
+
+ rs.close();
+ stmt.close();
+ commit();
+ }
+
+ public void testCloseResultSetAutoCommit() throws Exception {
+ //
+ // Check our behavior around closing result sets when auto-commit
+ // is true. Test with both holdable and non-holdable result sets
+ //
+ getConnection().setAutoCommit(true);
+
+ // Create a non-updatable holdable result set, and then try to
+ // update it
+ getConnection().setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+ Statement stmt = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY);
+
+ ResultSet rs = stmt.executeQuery("select * from t");
+ rs.next();
+
+ checkForCloseOnException(rs, true);
+
+ rs.close();
+ stmt.close();
+
+ // Create a non-updatable non-holdable result set, and then try to
+ // update it
+ getConnection().setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT);
+ stmt = createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY);
+
+ rs = stmt.executeQuery("select * from t");
+ rs.next();
+
+ checkForCloseOnException(rs, false);
+
+ rs.close();
+ stmt.close();
+ commit();
+ }
+
+ private void checkForCloseOnException(ResultSet rs, boolean holdable)
+ throws Exception
+ {
+ try {
+ rs.updateBlob("c",null);
+ fail("FAIL - rs.updateBlob() on a read-only result set" +
+ "should not have succeeded");
+ } catch (SQLException ex) {}
+ // The result set should not be closed on exception, this call should
+ // not cause an exception
+ rs.beforeFirst();
+ }
+
+ private static final String NOT_IMPLEMENTED = "0A000";
+ private static final String UPDATABLE_RESULTSET_API_DISALLOWED = "XJ083";
+}
Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ResultSetJDBC30Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java?view=diff&rev=465694&r1=465693&r2=465694
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java Thu Oct 19 10:48:44 2006
@@ -74,6 +74,7 @@
{
suite.addTest(ScrollResultSetTest.suite());
suite.addTest(LobStreamsTest.suite());
+ suite.addTest(ResultSetJDBC30Test.suite());
}
return suite;
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml?view=diff&rev=465694&r1=465693&r2=465694
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml Thu Oct 19 10:48:44 2006
@@ -114,7 +114,7 @@
<exclude name="${this.dir}/checkDataSource30.java"/>
<exclude name="${this.dir}/dataSourcePermissions.java"/>
<exclude name="${this.dir}/parameterMetaDataJdbc30.java"/>
- <exclude name="${this.dir}/resultsetJdbc30.java"/>
+ <exclude name="${this.dir}/ResultSetJDBC30Test.java"/>
<exclude name="${this.dir}/statementJdbc30.java"/>
<exclude name="${this.dir}/savepointJdbc30_JSR169.java"/>
<exclude name="${this.dir}/savepointJdbc30_XA.java"/>
@@ -151,7 +151,7 @@
<include name="${this.dir}/savepointJdbc30_JSR169.java"/>
<include name="${this.dir}/savepointJdbc30_XA.java"/>
<include name="${this.dir}/parameterMetaDataJdbc30.java"/>
- <include name="${this.dir}/resultsetJdbc30.java"/>
+ <include name="${this.dir}/ResultSetJDBC30Test.java"/>
<include name="${this.dir}/statementJdbc30.java"/>
<include name="${this.dir}/LobStreamsTest.java"/>
<include name="${this.dir}/XATest.java"/>