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 rh...@apache.org on 2007/04/16 15:41:53 UTC

svn commit: r529241 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/lang/SecurityPolicyReloadingTest.java junit/SecurityManagerSetup.java

Author: rhillegas
Date: Mon Apr 16 06:41:52 2007
New Revision: 529241

URL: http://svn.apache.org/viewvc?view=rev&rev=529241
Log:
DERBY-2544: Let policy files for JUnit tests live outside the classpath and be identified by URLs.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java?view=diff&rev=529241&r1=529240&r2=529241
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java Mon Apr 16 06:41:52 2007
@@ -383,7 +383,20 @@
      */
     private String makeServerPolicyName()
     {
-        return  SupportFilesSetup.EXTINOUT + File.separator + makeTargetPolicyStub();
+        try {
+            String  userDir = getSystemProperty( "user.dir" );
+            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator + makeTargetPolicyStub();
+            File      file = new File( fileName );
+            String  urlString = file.toURL().toExternalForm();
+
+            return urlString;
+        }
+        catch (Exception e)
+        {
+            System.out.println( "Unexpected exception caught by makeServerPolicyName(): " + e );
+
+            return null;
+        }
     }
 
     /**

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=529241&r1=529240&r2=529241
==============================================================================
--- 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 Mon Apr 16 06:41:52 2007
@@ -159,6 +159,7 @@
 			if ( newPolicyProperty == null ) { newPolicyProperty = ""; } 
                                                    
 			String  oldPolicyProperty = BaseTestCase.getSystemProperty("java.security.policy");
+
 			if ( oldPolicyProperty == null ) { oldPolicyProperty = ""; }
 
 			if ( newPolicyProperty.equals( oldPolicyProperty ) ) { return; }
@@ -197,6 +198,13 @@
 			return;
 		}
 		URL policyURL = BaseTestCase.getTestResource(policyResource);
+
+		// maybe the passed in resource was an URL to begin with
+		if ( policyURL == null )
+		{
+			try { policyURL = new URL( policyResource ); }
+			catch (Exception e) { System.out.println( "Unreadable url: " + policyResource ); }
+		}
 
 		if (policyURL != null)
 			set.setProperty("java.security.policy",