db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1465866 - in /db/derby/code/branches/10.8.3.1_testcompat: ./ java/testing/org/apache/derbyTesting/functionTests/master/ java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ java/testing/org/apache/derbyTesting/functionTests/t...
Date Tue, 09 Apr 2013 02:58:31 GMT
Author: kmarsden
Date: Tue Apr  9 02:58:30 2013
New Revision: 1465866

URL: http://svn.apache.org/r1465866
Log:
DERBY-2601 SQLException error codes are not returned to client.

Merge tests for revision 1346833 


Modified:
    db/derby/code/branches/10.8.3.1_testcompat/   (props changed)
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java
    db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java

Propchange: db/derby/code/branches/10.8.3.1_testcompat/
------------------------------------------------------------------------------
  Merged /db/derby/code/trunk:r1346833

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/master/testclientij.out
Tue Apr  9 02:58:30 2013
@@ -44,18 +44,18 @@ ij(CONNECTION2)> connect 'wombat' USER '
 ij(CONNECTION3)> connect  'testij2;create=true;user=usr;password=pwd';
 ij(CONNECTION4)> connect 'testij2;upgrade=true;user=usr;password=pwd';
 ij(CONNECTION5)> connect 'testij2;shutdown=true;user=usr;password=pwd';
-ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'testij2'
shutdown.
+ERROR 08006: DERBY SQL error: ERRORCODE: 45000, SQLSTATE: 08006, SQLERRMC: Database 'testij2'
shutdown.
 ij(CONNECTION5)> connect './testij2;create=true;user=usr;password=pwd';
 ij(CONNECTION6)> connect './testij2;create=true;user=usr;password=pwd';
 ij(CONNECTION7)> connect  'testij2;create=true;user=usr;password=pwd';
 ij(CONNECTION8)> connect 'testij2;upgrade=true;user=usr;password=pwd';
 ij(CONNECTION9)> connect 'testij2;shutdown=true;user=usr;password=pwd';
-ERROR 08006: DERBY SQL error: SQLCODE: -1, SQLSTATE: 08006, SQLERRMC: Database 'testij2'
shutdown.
+ERROR 08006: DERBY SQL error: ERRORCODE: 45000, SQLSTATE: 08006, SQLERRMC: Database 'testij2'
shutdown.
 ij(CONNECTION9)> -- retrieveMessageText Testing
 connect 'testij2;create=true;user=usr;password=pwd;retrieveMessageText=false';
 ij(CONNECTION10)> -- Should not get message text
 select * from APP.notthere;
-ERROR 42X05: DERBY SQL error: SQLCODE: -1, SQLSTATE: 42X05, SQLERRMC: APP.NOTTHERE42X05
+ERROR 42X05: DERBY SQL error: ERRORCODE: 30000, SQLSTATE: 42X05, SQLERRMC: APP.NOTTHERE42X05
 ij(CONNECTION10)> connect 'testij2;create=true;user=usr;password=pwd;retrieveMessageText=true';
 ij(CONNECTION11)> -- Should see message text
 select * from APP.notthere;

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
Tue Apr  9 02:58:30 2013
@@ -57,7 +57,7 @@ public class BadConnectionTest extends B
             fail("Connection with no user or password succeeded");
 		} catch (SQLException e) {
 			assertSQLState("08004", e);
-			assertEquals(40000, e.getErrorCode());
+            assertErrorCode(40000, e);
 		}
 	}
 	
@@ -78,7 +78,7 @@ public class BadConnectionTest extends B
 		} catch (SQLException e)
 		{
 			assertSQLState("08004", e);
-			assertEquals(40000, e.getErrorCode());
+            assertErrorCode(40000, e);
 		}
 	}
 	
@@ -99,7 +99,7 @@ public class BadConnectionTest extends B
 		} catch (SQLException e)
 		{
 			assertSQLState("XJ05B", e);
-			assertEquals(-1, e.getErrorCode());
+            assertErrorCode(40000, e);
 		}
 	}
 

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/J2EEDataSourceTest.java
Tue Apr  9 02:58:30 2013
@@ -3425,7 +3425,7 @@ public class J2EEDataSourceTest extends 
         // HOLDABLE Statement in global xact " 
         assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, 
             s.getResultSetHoldability());
-        assertEquals(10000, conn.getWarnings().getErrorCode());
+        assertErrorCode(10000, conn.getWarnings());
         shxa.close();
 
         shxa = conn.prepareStatement("select id from hold_30",
@@ -3434,7 +3434,7 @@ public class J2EEDataSourceTest extends 
         // HOLDABLE PreparedStatement in global xact 
         assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT,
             s.getResultSetHoldability());
-        assertEquals(10000, conn.getWarnings().getErrorCode());
+        assertErrorCode(10000, conn.getWarnings());
         shxa.close();
 
         shxa = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()",
@@ -3443,7 +3443,7 @@ public class J2EEDataSourceTest extends 
         // HOLDABLE CallableStatement in global xact:
         assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT,
             s.getResultSetHoldability());
-        assertEquals(10000, conn.getWarnings().getErrorCode());
+        assertErrorCode(10000, conn.getWarnings());
         shxa.close();
 
         // check we can use a holdable statement set up in local mode.

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/lang/ErrorCodeTest.java
Tue Apr  9 02:58:30 2013
@@ -48,7 +48,7 @@ public final class ErrorCodeTest extends
     {
         TestSuite suite = new TestSuite("errorcode Test");
         
-        suite.addTest(TestConfiguration.embeddedSuite(ErrorCodeTest.class));
+        suite.addTest(TestConfiguration.defaultSuite(ErrorCodeTest.class));
         
         return new LocaleTestSetup(suite, Locale.ENGLISH);
     }

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ReplicationRun.java
Tue Apr  9 02:58:30 2013
@@ -350,7 +350,7 @@ public class ReplicationRun extends Base
                 lastmsg = errCode + " " + sState + " " + lastmsg 
                         + ". Expected: "+ expectedState;
                 util.DEBUG("Got SQLException: " + lastmsg);
-                if ( (errCode == -1)
+                if ( (errCode == 40000)
                 && (sState.equalsIgnoreCase(expectedState) ) )
                 {
                     if (count++ >= 600) {
@@ -1005,7 +1005,7 @@ public class ReplicationRun extends Base
                     String expectedState = "XRE04";
                     util.DEBUG("startMaster Got SQLException: " 
                             + errCode + " " + sState + " " + msg + ". Expected " + expectedState);
-                    if ( (errCode == -1)
+                    if ( (errCode == 40000)
                     && (sState.equalsIgnoreCase(expectedState) ) )
                     {
                         if (count++ > 1200) {

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownMaster.java
Tue Apr  9 02:58:30 2013
@@ -144,8 +144,9 @@ public class ShutdownMaster extends Base
                         String msg = se.getMessage();
                         String state = se.getSQLState();
                         String expectedState = (dbOnly)? "08006": "XJ015";
+                        int expectedCode = dbOnly ? 45000 : 50000;
                         System.out.println("shutdown Got SQLException: " + errCode + " "
+ state + " " + msg);
-                        if ( (errCode == -1)
+                        if ( (errCode == expectedCode)
                         && (state.equalsIgnoreCase(expectedState) ) )
                         {
                             System.out.println("As expected.");

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/functionTests/tests/replicationTests/ShutdownSlave.java
Tue Apr  9 02:58:30 2013
@@ -168,8 +168,9 @@ public class ShutdownSlave extends BaseJ
                         String msg = se.getMessage();
                         String state = se.getSQLState();
                         String expectedState = (dbOnly)? "08004": "XJ015";
+                        int expectedCode = dbOnly ? 45000 : 50000;
                         System.out.println("shutdown Got SQLException: " + errCode + " "
+ state + " " + msg);
-                        if ( (errCode == -1)
+                        if ( (errCode == expectedCode)
                         && (state.equalsIgnoreCase(expectedState) ) )
                         {
                             System.out.println("As expected.");

Modified: db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java?rev=1465866&r1=1465865&r2=1465866&view=diff
==============================================================================
--- db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
(original)
+++ db/derby/code/branches/10.8.3.1_testcompat/java/testing/org/apache/derbyTesting/junit/BaseJDBCTestCase.java
Tue Apr  9 02:58:30 2013
@@ -864,7 +864,23 @@ public abstract class BaseJDBCTestCase
     public static void assertSQLState(String expected, SQLException exception) {
         assertSQLState("Unexpected SQL state.", expected, exception);
     }
-    
+
+    /**
+     * Assert that the error code is as expected.
+     *
+     * @param expected the expected error code
+     * @param exception the exception to check
+     * @throws AssertionFailedError if the error code is wrong
+     */
+    public static void assertErrorCode(int expected, SQLException exception) {
+        assertNotNull("Exception should not be null", exception);
+        int actual = exception.getErrorCode();
+        if (actual != expected) {
+            fail("Expected error code " + expected + ", got " + actual,
+                 exception);
+        }
+    }
+
     /**
      * Assert that the SQL statement does not compile and throws
      * a SQLException with the expected state.
@@ -1113,7 +1129,7 @@ public abstract class BaseJDBCTestCase
                 "' but no error was thrown.");
         } catch (SQLException se) {
             assertSQLState(sqlState, se);
-            assertEquals(errorCode,se.getErrorCode());
+            assertErrorCode(errorCode, se);
         }
         
     }



Mime
View raw message