db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1068451 - in /db/derby/code/trunk/java: engine/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Tue, 08 Feb 2011 15:50:04 GMT
Author: rhillegas
Date: Tue Feb  8 15:50:04 2011
New Revision: 1068451

URL: http://svn.apache.org/viewvc?rev=1068451&view=rev
Log:
DERBY-4869: Load the JDBC 4.0 exception factory when initializing the 4.0 autoloaded driver.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40UnbootedTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java?rev=1068451&r1=1068450&r2=1068451&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java Tue Feb
 8 15:50:04 2011
@@ -24,6 +24,7 @@ package org.apache.derby.jdbc;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.logging.Logger;
 
+import org.apache.derby.impl.jdbc.SQLExceptionFactory40;
 import org.apache.derby.impl.jdbc.Util;
 
 /**
@@ -34,6 +35,7 @@ public class AutoloadedDriver40 extends 
 	static
 	{
         registerMe( new AutoloadedDriver40() );
+        Util.setExceptionFactory (new SQLExceptionFactory40 ());
 	}
 
     ////////////////////////////////////////////////////////////////////

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40UnbootedTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40UnbootedTest.java?rev=1068451&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40UnbootedTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40UnbootedTest.java
Tue Feb  8 15:50:04 2011
@@ -0,0 +1,157 @@
+/*
+ 
+   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.Driver40UnbootedTest
+
+   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.jdbc4;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.junit.SpawnedProcess;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
+
+
+/**
+ * Test that getParentLogger() returns the correct kind of exception when
+ * the engine is not booted.
+ */
+
+public class Driver40UnbootedTest extends BaseJDBCTestCase
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private static  final   String  SUCCESS = "Success";
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public Driver40UnbootedTest(String name) { super( name ); }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // JUnit BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Return suite with all tests of the class.
+     */
+    public static Test suite()
+    {
+        Test test = TestConfiguration.embeddedSuite(Driver40UnbootedTest.class);
+
+        return SecurityManagerSetup.noSecurityManager( test );
+    }
+   
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // ENTRY POINT
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * This entry point is used to run a separate java process in order to verify
+     * that the correct exception is being raised by getParentLogger() when the
+     * engine hasn't been booted yet.
+     * </p>
+     */
+    public  static  void    main( String[] args )  throws Exception
+    {
+        Driver  embeddedDriver = DriverManager.getDriver( "jdbc:derby:" );
+        Wrapper41Driver embeddedWrapper = new Wrapper41Driver( embeddedDriver );
+
+        String  statusMessage = SUCCESS;
+        
+        try {
+            embeddedWrapper.getParentLogger();
+            statusMessage = "getParentLogger() unexpectedly succeeded";
+        }
+        catch (Exception se)
+        {
+            if ( !( se instanceof SQLFeatureNotSupportedException ) )
+            {
+                statusMessage = "Exception was not a SQLFeatureNotSupportedException. It
was a " + se.getClass().getName();
+            }
+        }
+
+        System.out.print( statusMessage );
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // TESTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * <p>
+     * Test that getParentLogger() raises the right exception even if the engine
+     * isn't booted.
+     * </p>
+     */
+    public void test_notBooted() throws Exception
+    {
+        if ( !getTestConfiguration().loadingFromJars() ) { return ; }
+        
+        StringBuffer    buffer = new StringBuffer();
+        String          classpath = getSystemProperty( "java.class.path" );
+
+        buffer.append( getJavaExecutableName() + " -classpath " );
+        buffer.append( classpath );
+        buffer.append( " -Demma.verbosity.level=silent ");
+        buffer.append( getClass().getName() );
+
+        final   String  command = buffer.toString();
+
+        println( "Server command is " + command );
+
+        Process     process = Runtime.getRuntime().exec( command );
+        
+        SpawnedProcess spawned = new SpawnedProcess( process, "UnbootedTest" );
+        
+        // Ensure it completes without failures.
+        assertEquals(0, spawned.complete(false));
+
+        assertEquals( SUCCESS, spawned.getFullServerOutput() );
+    }
+
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Driver40UnbootedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java?rev=1068451&r1=1068450&r2=1068451&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/_Suite.java
Tue Feb  8 15:50:04 2011
@@ -77,6 +77,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(Derby2017LayerBTest.suite());
         suite.addTest(AbortTest.suite());
         suite.addTest(Driver40Test.suite());
+        suite.addTest(Driver40UnbootedTest.suite());
 		
 		return suite;
 	}



Mime
View raw message