db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r560005 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests: master/ suites/ tests/jdbcapi/
Date Thu, 26 Jul 2007 21:45:39 GMT
Author: kmarsden
Date: Thu Jul 26 14:45:38 2007
New Revision: 560005

URL: http://svn.apache.org/viewvc?view=rev&rev=560005
Log:
DERBY-2942 Convert jdbcapi/statementJdbc30.java to JUnit

Contributed by Ramin Moazeni


Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc30Test.java
  (with props)
Removed:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/statementJdbc30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/statementJdbc30.java
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/tests/jdbcapi/JDBCHarnessJavaTest.java
    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=560005&r1=560004&r2=560005
==============================================================================
--- 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 Jul 26 14:45:38 2007
@@ -4,7 +4,6 @@
 # excluding jdbcapi/testRelative.java because this is a new test contributed by Shreyas Kaushik
and needs to be debugged with JCC  in order to get it running with network server
 # excluding jdbcapi/SetQueryTimeoutTest.java because neither the JCC driver nor the ClientDriver
support setQueryTimeout() yet.
 # excluding jdbcapi/rsgetXXXcolumnNames.java as it fails incorrectly, according to JDBC spec.
Forwarding test case to JCC team.
-# excluding jdbcapi/statementJdbc30.java - Client behaves differently. Need to look into
this
 #           regardless of framework
 # excluding largedata/LobLimits.java to run with the network server because currently lobs
are materialized and this test tests for 2G lobs.
 # 			see DERBY-326 and DERBY-550 issues
@@ -15,7 +14,6 @@
 jdbcapi/rsgetXXXcolumnNames.java
 jdbcapi/SetQueryTimeoutTest.java
 jdbcapi/blobSetBinaryStream.java
-jdbcapi/statementJdbc30.java
 #no XA for JCC
 jdbcapi/savepointJdbc30_XA.java
 # excluding jdbcapi/derbyStress.java - jcc runs out of memory with this test

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=560005&r1=560004&r2=560005
==============================================================================
--- 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 Jul 26 14:45:38 2007
@@ -1,13 +1,11 @@
 # excluding TestErrorStreamTarget.java since it's not relevant for clients
 # excluding statementJdbc20.java because this tests fetch_reverse throughout the test
-# excluding jdbcapi/statementJdbc30.java - Client behaves differently. Need to look into
this
 #           regardless of framework
 # excluding largedata/LobLimits.java to run with the network server because currently lobs
are materialized and this test tests for 2G lobs.
 # 			see DERBY-326 and DERBY-550 issues
 lang/errorStream.java
 #
 jdbcapi/statementJdbc20.java
-jdbcapi/statementJdbc30.java
 largedata/LobLimits.java
 #
 # This test brings the network server up and down by itself

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java?view=diff&rev=560005&r1=560004&r2=560005
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/JDBCHarnessJavaTest.java
Thu Jul 26 14:45:38 2007
@@ -62,7 +62,6 @@
             "rsgetXXXcolumnNames",
             
             // from old jdk14.runall
-            // "statementJdbc30", runs in embedded only
             // "savepointJdbc30_JSR169", TODO: convert - different canon for client
             // "savepointJdbc30_XA", TODO: convert - different canon for client
             
@@ -75,7 +74,6 @@
     {
         // excluded from derby client in old harness
         "statementJdbc20",
-        "statementJdbc30",
         
         // Tests that run ok in embedded but have a different client master file.
         "savepointJdbc30_JSR169",

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc30Test.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc30Test.java?view=auto&rev=560005
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc30Test.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc30Test.java
Thu Jul 26 14:45:38 2007
@@ -0,0 +1,286 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.functionTests.tests.jdbcapi.StatementJdbc30Test
+
+ 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 java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derby.iapi.reference.JDBC30Translation;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.TestConfiguration;
+
+/**
+ * Test the Statement class in JDBC 30. This test converts the old
+ * jdbcapi/statementJdbc30.java test to JUnit.
+ */
+
+public class StatementJdbc30Test extends BaseJDBCTestCase {
+
+    /**
+     * Create a test with the given name.
+     * 
+     * @param name
+     *            name of the test.
+     */
+
+    public StatementJdbc30Test(String name) {
+        super(name);
+    }
+
+    /**
+     * Create suite containing client and embedded tests and to run all tests in
+     * this class
+     */
+    public static Test suite() {
+        TestSuite suite = new TestSuite("StatementJdbc30Test");
+
+        suite.addTest(baseSuite("StatementJdbc30Test:embedded"));
+        suite
+                .addTest(TestConfiguration
+                        .clientServerDecorator(baseSuite("StatementJdbc30Test:client")));
+
+        return suite;
+    }
+
+    private static Test baseSuite(String name) {
+        TestSuite suite = new TestSuite(name);
+
+        suite.addTestSuite(StatementJdbc30Test.class);
+
+        return new CleanDatabaseTestSetup(suite) {
+            /**
+             * Creates the tables used in the test cases.
+             * 
+             * @exception SQLException
+             *                if a database error occurs
+             */
+            protected void decorateSQL(Statement stmt) throws SQLException {
+
+                /**
+                 * Creates the table used in the test cases.
+                 * 
+                 */
+                stmt.execute("create table tab1 (i int, s smallint, r real)");
+                stmt.executeUpdate("insert into tab1 values(1, 2, 3.1)");
+            }
+        };
+    }
+
+    /**
+     * Tests reading data from database
+     * 
+     * @exception SQLException
+     *                if error occurs
+     */
+    public void testReadingData() throws SQLException {
+
+        Statement stmt = createStatement();
+        ResultSet rs;
+
+        // read the data just for the heck of it
+        rs = stmt.executeQuery("select * from tab1");
+        assertTrue(rs.next());
+
+        rs.close();
+    }
+
+    /**
+     * Tests stmt.getMoreResults(int)
+     * 
+     * @exception SQLException
+     *                if error occurs
+     */
+    public void testGetMoreResults() throws SQLException {
+
+        Statement stmt = createStatement();
+        assertFalse(stmt.getMoreResults(JDBC30Translation.CLOSE_CURRENT_RESULT));
+
+    }
+
+    /**
+     * Tests stmt.executeUpdate(String, int) with NO_GENERATED_KEYS.
+     * 
+     * @exception SQLException
+     *                if error occurs
+     */
+    public void testInsertNoGenKeys() throws SQLException {
+
+        Statement stmt = createStatement();
+        stmt.executeUpdate("insert into tab1 values(2, 3, 4.1)",
+                JDBC30Translation.NO_GENERATED_KEYS);
+        assertNull("Expected NULL ResultSet after stmt.execute()", stmt
+                .getGeneratedKeys());
+
+    }
+
+    /**
+     * Tests stmt.executeUpdate(String, int[]) After doing an insert into a
+     * table that doesn't have a generated column, the test should fail.
+     * 
+     * @throws SQLException
+     */
+    public void testExecuteUpdateNoAutoGenColumnIndex() throws SQLException {
+
+        Statement stmt = createStatement();
+
+        int[] columnIndexes = new int[2];
+        columnIndexes[0] = 1;
+        columnIndexes[1] = 2;
+        try {
+            stmt.executeUpdate("insert into tab1 values(2, 3, 4.1)",
+                    columnIndexes);
+            fail("FAIL -- executeUpdate should have failed...");
+        } catch (SQLException ex) {
+            assertFailedExecuteUpdate(ex);
+        }
+    }
+
+    /**
+     * Tests stmt.executeUpdate(String, String[]) After doing an insert into a
+     * table that doesn't have a generated column, the test should fail.
+     * 
+     * @throws SQLException
+     */
+    public void testExecuteUpdateNoAutoGenColumnName() throws SQLException {
+
+        Statement stmt = createStatement();
+
+        String[] columnNames = new String[2];
+        columnNames[0] = "I";
+        columnNames[1] = "S";
+        try {
+            stmt.executeUpdate("insert into tab1 values(2, 3, 4.1)",
+                    columnNames);
+            fail("FAIL -- executeUpdate should have failed...");
+        } catch (SQLException ex) {
+            assertFailedExecuteUpdate(ex);
+        }
+    }
+
+    /**
+     * Tests stmt.execute(String, int) with NO_GENERATED_KEYS.
+     * 
+     * @exception SQLException
+     *                if error occurs
+     */
+    public void testSelectNoGenKeys() throws SQLException {
+
+        Statement stmt = createStatement();
+        stmt.execute("select * from tab1", JDBC30Translation.NO_GENERATED_KEYS);
+        assertNull("Expected NULL ResultSet after stmt.execute()", stmt
+                .getGeneratedKeys());
+
+    }
+
+    /**
+     * After doing an insert into a table that doesn't have a generated column,
+     * the test should fail.
+     * 
+     * @throws SQLException
+     */
+    public void testExecuteNoAutoGenColumnIndex() throws SQLException {
+
+        Statement stmt = createStatement();
+
+        int[] columnIndexes = new int[2];
+        columnIndexes[0] = 1;
+        columnIndexes[1] = 2;
+        try {
+            stmt.execute("insert into tab1 values(2, 3, 4.1)", columnIndexes);
+            fail("FAIL -- executeUpdate should have failed...");
+        } catch (SQLException ex) {
+            assertFailedExecuteUpdate(ex);
+        }
+    }
+
+    /**
+     * Assert executeUpdate failed. There are different SQLStates for 
+     * client and server.
+     * 
+     * @param ex
+     */
+    private void assertFailedExecuteUpdate(SQLException ex) {
+        /*
+         * DERBY-2943 -- execute() and executeUpdate() return different
+         * SQLState in embedded and network client
+         * 
+         */
+        if (usingDerbyNetClient()) {
+            assertSQLState("0A000", ex);
+        } else {
+            assertSQLState("X0X0E", ex);
+        }
+    }
+
+    /**
+     * After doing an insert into a table that doesn't have a generated column,
+     * the test should fail.
+     * 
+     * @throws SQLException
+     */
+    public void testExecuteNoAutoGenColumnName() throws SQLException {
+
+        Statement stmt = createStatement();
+        
+            String[] columnNames = new String[2];
+            columnNames[0] = "I";
+            columnNames[1] = "S";
+            try {
+                stmt.executeUpdate("insert into tab1 values(2, 3, 4.1)",
+                        columnNames);
+                fail("FAIL -- executeUpdate should have failed...");
+            } catch (SQLException ex) {
+                assertFailedExecuteUpdate(ex);
+            }
+        
+    }
+
+    /**
+     * Testing stmt.getResultSetHoldability()
+     * 
+     * @throws SQLException
+     */
+    public void testGetResultSetHoldability() throws SQLException {
+
+        Statement stmt = createStatement();
+        assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, stmt
+                .getResultSetHoldability());
+
+    }
+
+    /**
+     * Testing stmt.getGeneratedKeys()
+     * 
+     * @throws SQLException
+     */
+    public void testGetGenerateKeys() throws SQLException {
+
+        Statement stmt = createStatement();
+        assertNull(stmt.getGeneratedKeys());
+
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/StatementJdbc30Test.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=560005&r1=560004&r2=560005
==============================================================================
--- 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 Jul 26 14:45:38 2007
@@ -76,6 +76,7 @@
 		suite.addTest(AuthenticationTest.suite());
 		suite.addTest(DriverTest.suite());
 		suite.addTest(NullSQLTextTest.suite());
+		suite.addTest(StatementJdbc30Test.suite());
         suite.addTest(ClobTest.suite());
         suite.addTest(BlobUpdatableStreamTest.suite());
         suite.addTest(AIjdbcTest.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=560005&r1=560004&r2=560005
==============================================================================
--- 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 Jul 26 14:45:38 2007
@@ -111,7 +111,7 @@
       <exclude name="${this.dir}/AutoGenJDBC30Test.java"/>
       <exclude name="${this.dir}/dbMetaDataJdbc30.java"/>
       <exclude name="${this.dir}/ResultSetJDBC30Test.java"/>
-      <exclude name="${this.dir}/statementJdbc30.java"/>
+      <exclude name="${this.dir}/StatementJdbc30Test.java"/>
       <exclude name="${this.dir}/savepointJdbc30_JSR169.java"/>
       <exclude name="${this.dir}/savepointJdbc30_XA.java"/>
       <include name="${this.dir}/ParameterMetaDataJdbc30Test.java"/>
@@ -151,7 +151,7 @@
       <include name="${this.dir}/savepointJdbc30_XA.java"/>
       <include name="${this.dir}/ParameterMetaDataJdbc30Test.java"/>
       <include name="${this.dir}/ResultSetJDBC30Test.java"/>
-      <include name="${this.dir}/statementJdbc30.java"/>
+      <include name="${this.dir}/StatementJdbc30Test.java"/>
       <include name="${this.dir}/LobStreamsTest.java"/>
       <include name="${this.dir}/XATest.java"/>
       <include name="${this.dir}/XATransactionTest.java"/>



Mime
View raw message