db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r326221 - in /db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests: harness/jvm.java util/copyfiles.ant util/derby_tests.policy
Date Tue, 18 Oct 2005 20:29:33 GMT
Author: djd
Date: Tue Oct 18 13:29:29 2005
New Revision: 326221

URL: http://svn.apache.org/viewcvs?rev=326221&view=rev
Log:
DERBY-615 Switch to a security manager policy file with permissions set on a per-jar
basis for improved testing under a security manager. First step in running all tests
under a security manager. This policy file replaces the nwsvr.policy file and currently
is used in the same way, for tests that invoke a separate JVM for the network server.
Merge from trunk revision 320762

Added:
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
  (props changed)
      - copied unchanged from r320762, db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
Modified:
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
    db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/copyfiles.ant

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java?rev=326221&r1=326220&r2=326221&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/harness/jvm.java
Tue Oct 18 13:29:29 2005
@@ -108,7 +108,7 @@
 
 	// security defaults relative to WS
 	// not used if jvmargs serverPolicyFile or serverCodeBase are set
-	private static String DEFAULT_POLICY="util/nwsvr.policy";
+	private static String DEFAULT_POLICY="util/derby_tests.policy";
 	private static String DEFAULT_CODEBASE="/classes";
 
     // constructors
@@ -294,7 +294,7 @@
 		return wshome;
 	}
 
-	protected static String findCodeBase()
+	protected static String findCodeBase(boolean[] isJar)
 	{
 		String classpath = System.getProperty("java.class.path");
 		char sep = '/';
@@ -306,11 +306,15 @@
 			String location = zip[i].getLocation().replace('\\','/');
 			if (location.indexOf("derbynet.jar") != -1)
 			{
+				isJar[0] = true;
 				return location.substring(0,location.lastIndexOf(sep));
 			}
 			else if ((location.indexOf("classes") != -1) &&
 					 location.indexOf(".jar") == -1)
+			{
+				isJar[0] = false;
 				return location;
+			}
 		}
 		return null;
 	}
@@ -333,18 +337,21 @@
 		}
 
 		String serverCodeBase = System.getProperty("serverCodeBase");
+		boolean[] isJar = new boolean[1];
 		if (serverCodeBase == null)
-			serverCodeBase = findCodeBase();
+			serverCodeBase = findCodeBase(isJar);
    
 		if (serverCodeBase == null)
 		{
 			String ws = guessWSHome();
 			serverCodeBase = ws + DEFAULT_CODEBASE;
 		}
+		
+		File pf = new File(policyFile);
+		File cb = new File(serverCodeBase);
 
 		if (policyFile.toLowerCase().equals("none") || 
-			(!(new File(policyFile)).exists()) ||
-			!(new File(policyFile)).exists())
+			(!pf.exists()))
 		{
 			System.out.println("WARNING: Running without Security manager." +
 							   "serverPolicy(" + policyFile + 
@@ -352,12 +359,23 @@
 							   ") not available");
 		return;
 		}
+		
 		this.D.addElement("java.security.manager");
 		this.D.addElement("java.security.policy=" + policyFile);
-		this.D.addElement("csinfo.codebase=" + serverCodeBase);
+		
+		String codebaseType = isJar[0] ? "csinfo.codejar" : "csinfo.codeclasses";
+		String unusedType = isJar[0] ? "csinfo.codeclasses" : "csinfo.codejar";
+
+		// URL of the codebase
+		this.D.addElement(codebaseType + "=" + cb.toURL());
+		// file path to the codebase
+		this.D.addElement("csinfo.codedir=" + cb.getAbsolutePath());
 		this.D.addElement("csinfo.serverhost=localhost");
 		this.D.addElement("csinfo.trustedhost=localhost");	 
-
+		
+		// add an invalid path to the unused type 
+		this.D.addElement(unusedType + "=file://unused/");
+		
 	}
 
 	/** Get the base file name from a resource name string

Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/copyfiles.ant?rev=326221&r1=326220&r2=326221&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/copyfiles.ant
(original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/copyfiles.ant
Tue Oct 18 13:29:29 2005
@@ -1,2 +1,3 @@
 nwsvr.policy
+derby_tests.policy
 testRoutines.sql

Propchange: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/util/derby_tests.policy
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message