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 dj...@apache.org on 2006/08/25 07:02:57 UTC

svn commit: r436660 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/jdbc4/AutoloadBooting.java functionTests/tests/jdbc4/AutoloadTest.java junit/SecurityManagerSetup.java junit/TestConfiguration.java

Author: djd
Date: Thu Aug 24 22:02:56 2006
New Revision: 436660

URL: http://svn.apache.org/viewvc?rev=436660&view=rev
Log:
Provide a consistent mechanism to test if the classes are being loaded by jars or
not in JUnit tests. Uses the SecurityManagerSetup class which basically already
determined this information at its startup.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java?rev=436660&r1=436659&r2=436660&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadBooting.java Thu Aug 24 22:02:56 2006
@@ -36,6 +36,7 @@
 import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.drda.NetworkServerControl;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 public	class	AutoloadBooting	extends	BaseJDBCTestCase
 {
@@ -355,7 +356,7 @@
         // This test is only run in JDBC 4 or higher which means the
         // drivers will always be auto-loading when the classes are
         // being loaded from the jars.
-		boolean		isAutoloading = getTestConfiguration().loadingFromJars();
+		boolean		isAutoloading = TestConfiguration.loadingFromJars();
 		
 		//
 		// Forcibly load the network client if we are not autoloading it.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java?rev=436660&r1=436659&r2=436660&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/AutoloadTest.java Thu Aug 24 22:02:56 2006
@@ -110,18 +110,18 @@
             } catch (PrivilegedActionException e) {
                 // can't read property, assume not autoloading.
             }
-            
+                        
             // Also auto loading if this is JDBC 4 and loading from the
             // jar files, due to the required manifest entry.
             if (JDBC.vmSupportsJDBC4() &&
-                    TestConfiguration.getCurrent().loadingFromJars())
+                    TestConfiguration.loadingFromJars())
                 autoloadingCurrentDriver = true;
           
             if (autoloadingCurrentDriver)
                 suite.addTestSuite(AutoloadTest.class);
 
         }
-        
+               
         return suite;
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?rev=436660&r1=436659&r2=436660&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java Thu Aug 24 22:02:56 2006
@@ -37,8 +37,12 @@
  */
 public final class SecurityManagerSetup extends TestSetup {
 	
-	
 	private static final Properties classPathSet = new Properties();
+    
+    /**
+     * True if the classes are loaded from jars.
+     */
+    static boolean isJars;
 	
 	/**
 	 * True if a security manager was installed outside of the
@@ -214,13 +218,15 @@
 		if (isClasspath) {
 			classPathSet.setProperty("derbyTesting.codeclasses",
 					testing.toExternalForm());
+            isJars = false;
 			return false;
 		}
 		classPathSet.setProperty("derbyTesting.testjar", stripJar(testing));
+        isJars = true;
 		
 		URL derby = null;
 		try {
-			derby = getURL(org.apache.derby.jdbc.EmbeddedDataSource.class);
+			derby = getURL(org.apache.derby.jdbc.EmbeddedSimpleDataSource.class);
 		} catch (java.lang.NoClassDefFoundError e) {
 			derby = testing;
 		}		

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=436660&r1=436659&r2=436660&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Thu Aug 24 22:02:56 2006
@@ -319,15 +319,9 @@
 	 * the server) comes out of a jar file.
 	 * </p>
 	 */
-	public	boolean	loadingFromJars()
+	public static boolean loadingFromJars()
 	{
-		//
-		// jvm.java sets this property to the build jar directory
-		// if we are using derbyTesting.jar.
-        // 
-		//
-		
-		return ( !UNUSED.equals( getSystemStartupProperty( "derbyTesting.codejar" ) ) );
+        return SecurityManagerSetup.isJars;
 	}
 
     /**