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/09/05 17:34:45 UTC

svn commit: r440373 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/harness/ functionTests/tests/derbynet/ functionTests/tests/lang/ functionTests/util/ junit/

Author: djd
Date: Tue Sep  5 08:34:44 2006
New Revision: 440373

URL: http://svn.apache.org/viewvc?view=rev&rev=440373
Log:
DERBY-1791 Change the test Security Manager policy files to use a different variable for derbyTesting.jar and derbyclient.jar.
Allows these jars to be in different directories to the other derby jars (e.g. the new distribution layout with
top level test folder). Makes the old harness use the eisting variables set up by the new JUnit related class
SecurityManagerSetup.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/OutBufferedStream.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProtocol.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/useprocessfalse.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java Tue Sep  5 08:34:44 2006
@@ -21,12 +21,15 @@
 
 package org.apache.derbyTesting.functionTests.harness;
 
+import java.util.Enumeration;
+import java.util.Properties;
 import java.util.Vector;
 import java.util.StringTokenizer;
 import java.io.File;
 import java.io.IOException;
 
 import org.apache.derby.impl.tools.sysinfo.ZipInfoProperties;
+import org.apache.derbyTesting.junit.SecurityManagerSetup;
 
 
 /**
@@ -347,10 +350,12 @@
 		if (serverCodeBase == null)
 			serverCodeBase = findCodeBase(isJar);
    
+        
 		if (serverCodeBase == null)
 		{
 			String ws = guessWSHome();
 			serverCodeBase = ws + DEFAULT_CODEBASE;
+                 
 		}
 		
 		File pf = new File(policyFile);
@@ -367,12 +372,19 @@
 		
 		D.addElement("java.security.manager");
 		D.addElement("java.security.policy=" + pf.getAbsolutePath());
+ 
+        Properties jusetup =
+            SecurityManagerSetup.getPolicyFilePropertiesForOldHarness();
+        // Take the definitions from the way JUnit tests
+        // set them up. This then supports the jar files being
+        // in different locations.
+        for (Enumeration p = jusetup.keys(); p.hasMoreElements(); )
+        {
+            String key = (String) p.nextElement();
+            D.addElement(key + "=" + jusetup.getProperty(key));
+        }
 		
-		String codebaseType = isJar[0] ? "derbyTesting.codejar" : "derbyTesting.codeclasses";
-		String unusedType = isJar[0] ? "derbyTesting.codeclasses" : "derbyTesting.codejar";
 
-		// URL of the codebase
-		D.addElement(codebaseType + "=" + cb.toURL());
 		// file path to the codebase
 		D.addElement("derbyTesting.codedir=" + cb.getAbsolutePath());
 		String hostName = (System.getProperty("hostName"));
@@ -381,10 +393,7 @@
 		D.addElement("derbyTesting.serverhost=" + hostName);
 		// in the case of testing with a remote host, this is irrelevant, 
 		// when testing 'normal' it is also localhost:
-		D.addElement("derbyTesting.clienthost=" + hostName);	 
-		
-		// add an invalid path to the unused type 
-		D.addElement(unusedType + "=file://unused/");
+		D.addElement("derbyTesting.clienthost=" + hostName);	 	
 		
 		return D;
 		

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/OutBufferedStream.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/OutBufferedStream.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/OutBufferedStream.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/OutBufferedStream.policy Tue Sep  5 08:34:44 2006
@@ -2,7 +2,7 @@
 // test specific permissions for test:
 // lang/OutBufferedStream.java
 //
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   permission java.lang.RuntimePermission "setIO";
   
 };

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/dataSourcePermissions_net.policy Tue Sep  5 08:34:44 2006
@@ -2,7 +2,7 @@
 // test specific permissions for test:
 // lang/dataSourcePermissions_net.java
 //
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   permission java.lang.RuntimePermission "setIO";
   
 };

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo.policy Tue Sep  5 08:34:44 2006
@@ -2,7 +2,7 @@
 // test specific permissions for test:
 // derbynet/sysinfo.java
 //
-grant codeBase "${derbyTesting.codejar}/derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}/derbyTesting.jar" {
   //client side: test execs another jvm with relative path
   permission java.io.FilePermission "<<ALL FILES>>", "execute";
 };

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/sysinfo_withproperties.policy Tue Sep  5 08:34:44 2006
@@ -2,7 +2,7 @@
 // test specific permissions for test:
 // derbynet/sysinfo_withproperties.java
 //
-grant codeBase "${derbyTesting.codejar}/derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}/derbyTesting.jar" {
   //client side: test execs another jvm with relative path
   permission java.io.FilePermission "<<ALL FILES>>", "execute";
 };

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProtocol.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProtocol.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProtocol.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testProtocol.policy Tue Sep  5 08:34:44 2006
@@ -7,7 +7,7 @@
   permission java.io.FilePermission "${derby.system.home}${/}*", "write";  
 };
 
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   permission java.net.SocketPermission "127.0.0.1", "connect,resolve";
   permission java.net.SocketPermission "localhost", "connect,resolve";
   permission java.net.SocketPermission "${derbyTesting.serverhost}", "connect,resolve";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/testSecMec.policy Tue Sep  5 08:34:44 2006
@@ -2,7 +2,7 @@
 // test specific permissions for test:
 // lang/testSecMec.java
 //
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   permission java.lang.RuntimePermission "setIO";
   
 };

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/errorStream.policy Tue Sep  5 08:34:44 2006
@@ -2,7 +2,7 @@
 // test specific permissions for test:
 // lang/errorStream.java
 //
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   permission java.lang.RuntimePermission "setIO";
   
 };

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy Tue Sep  5 08:34:44 2006
@@ -70,7 +70,7 @@
 //
 // Permissions for the network client (derbyclient.jar)
 //
-grant codeBase "${derbyTesting.codejar}derbyclient.jar" {
+grant codeBase "${derbyTesting.clientjar}derbyclient.jar" {
   permission java.net.SocketPermission "127.0.0.1", "connect,resolve";
   permission java.net.SocketPermission "localhost", "connect,resolve";
   permission java.net.SocketPermission "${derbyTesting.serverhost}", "connect,resolve";
@@ -98,7 +98,7 @@
 // We are liberal here, it's not a goal to make the test harness
 // or tests secure.
 //
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   // Access all properties using System.getProperties
   permission java.util.PropertyPermission "*", "read, write";
   

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/useprocessfalse.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/useprocessfalse.policy?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/useprocessfalse.policy (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/useprocessfalse.policy Tue Sep  5 08:34:44 2006
@@ -1,7 +1,7 @@
 //
 // policy file for running with useprocess=false
 //
-grant codeBase "${derbyTesting.codejar}derbyTesting.jar" {
+grant codeBase "${derbyTesting.testjar}derbyTesting.jar" {
   // When running with useprocess=false need to install and uninstall
   // the security manager and allow setIO to change the system err and out
   // streams. Currently the nist suite runs with useprocess=false.

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?view=diff&rev=440373&r1=440372&r2=440373
==============================================================================
--- 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 Tue Sep  5 08:34:44 2006
@@ -54,6 +54,7 @@
 		// Determine what the set of properties
 		// describing the environment is.
 		externalSecurityManagerInstalled = determineClasspath();
+        
 	}
 	
 	private final String decoratorPolicyResource;
@@ -182,7 +183,7 @@
 	 * Looks for three items:
 	 * 
 	 * Location of derbyTesting.jar via this class
-	 * Location of derby.jar via org.apache.derby.jdbc.EmbeddedDataSource
+	 * Location of derby.jar via org.apache.derby.jdbc.EmbeddedSimpleDataSource
 	 * Location of derbyclient.jar via org.apache.derby.jdbc.ClientDataSource
 	 * 
 	 * Two options are supported, either all are in jar files or
@@ -243,6 +244,19 @@
 		
 		return false;
 	}
+    
+    /**
+     * Return the policy file system properties for use
+     * by the old test harness. This ensures a consistent
+     * approach to setting the properties. There are the
+     * properties used to define the jar file location in
+     * any policy files.
+     * @return
+     */
+    public static Properties getPolicyFilePropertiesForOldHarness()
+    {
+        return classPathSet;
+    }
 	
 	/**
 	 * Strip of the last token which will be the jar name.