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 ka...@apache.org on 2013/04/11 17:09:09 UTC

svn commit: r1466914 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/derbynet/ functionTests/tests/jdbcapi/ functionTests/tests/lang/ functionTests/tests/store/ unitTests/junit/

Author: kahatlen
Date: Thu Apr 11 15:09:09 2013
New Revision: 1466914

URL: http://svn.apache.org/r1466914
Log:
DERBY-6162: Simplify privileged actions in NetworkServerControlApiTest

Remove calls to deprecated method java.io.File.toURL().

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/SecurityPolicyReloadingTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3980DeadlockTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.java Thu Apr 11 15:09:09 2013
@@ -29,7 +29,6 @@ import org.apache.derby.drda.NetworkServ
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
 
 /**
  * This tests getCurrentProperties
@@ -37,18 +36,13 @@ import org.apache.derbyTesting.junit.Sup
  */
 public class GetCurrentPropertiesTest extends BaseJDBCTestCase {
     // create own policy file
-    private static String POLICY_FILE_NAME = 
-        "functionTests/tests/derbynet/GetCurrentPropertiesTest.policy";
-    private static String TARGET_POLICY_FILE_NAME = "server.policy";
+    private static final String POLICY_FILE_NAME =
+        "org/apache/derbyTesting/functionTests/tests/derbynet/GetCurrentPropertiesTest.policy";
 
     public GetCurrentPropertiesTest(String name) {
         super(name);
     }
 
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
     public static Test suite()
     {
         // Use a fixed order for the test cases so that we know the exact
@@ -60,49 +54,17 @@ public class GetCurrentPropertiesTest ex
         Test test =
                 TestConfiguration.orderedSuite(GetCurrentPropertiesTest.class);
         test = TestConfiguration.clientServerDecorator(test);
+
         // Install a security manager using the special policy file.
-        test = decorateWithPolicy(test);
+        // Grant ALL FILES execute, and getPolicy permissions,
+        // as well as write for the trace files.
+        test = new SecurityManagerSetup(test, POLICY_FILE_NAME);
+
         // return suite; to ensure that nothing interferes with setting of
         // properties, wrap in singleUseDatabaseDecorator 
         return TestConfiguration.singleUseDatabaseDecorator(test);
     }
-    /**
-     * Construct the name of the server policy file.
-     */
-    private static String makeServerPolicyName()
-    {
-        try {
-            
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            File      file = new File( fileName );
-            String  urlString = file.toURL().toExternalForm();
 
-            return urlString;
-        }
-        catch (Exception e)
-        {
-            fail("Exception in REading Server policy file",e);
-            return null;
-        }
-    }
-    // grant ALL FILES execute, and getPolicy permissions,
-    // as well as write for the trace files.
-    private static Test decorateWithPolicy(Test test) {
-        String serverPolicyName = makeServerPolicyName(); 
-        //
-        // Install a security manager using the initial policy file.
-        //
-        test = new SecurityManagerSetup(test,serverPolicyName );
-        // Copy over the policy file we want to use.
-        //
-        test = new SupportFilesSetup(
-                test, null, new String[] {POLICY_FILE_NAME},
-                null, new String[] {TARGET_POLICY_FILE_NAME}
-        );
-        return test;
-        
-    }
     /**
      * Testing the properties before connecting to a database
      * 
@@ -127,7 +89,7 @@ public class GetCurrentPropertiesTest ex
         p = NetworkServerTestSetup.getNetworkServerControl().getCurrentProperties();
 
         Enumeration expectedProps = expectedValues.propertyNames();
-        for ( expectedProps = expectedValues.propertyNames(); expectedProps.hasMoreElements();) {
+        while (expectedProps.hasMoreElements()) {
             String propName = (String)expectedProps.nextElement();
             String propVal = (String)p.get(propName);
             //for debug
@@ -165,7 +127,7 @@ public class GetCurrentPropertiesTest ex
         nsctrl.logConnections(true);
         p = NetworkServerTestSetup.getNetworkServerControl().getCurrentProperties();
         Enumeration expectedProps = expectedValues.propertyNames();
-        for ( expectedProps = expectedValues.propertyNames(); expectedProps.hasMoreElements();) {
+        while (expectedProps.hasMoreElements()) {
             String propName = (String) expectedProps.nextElement();
             String propVal = (String)p.get(propName);
             //for debug
@@ -201,7 +163,7 @@ public class GetCurrentPropertiesTest ex
         expectedValues.setProperty("derby.drda.traceAll","true");
         p = NetworkServerTestSetup.getNetworkServerControl().getCurrentProperties();
         Enumeration expectedProps = expectedValues.propertyNames();
-        for ( expectedProps = expectedValues.propertyNames(); expectedProps.hasMoreElements();) {
+        while (expectedProps.hasMoreElements()) {
             String propName = (String) expectedProps.nextElement();
             String propVal = (String)p.get(propName);
             //for debug

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.java Thu Apr 11 15:09:09 2013
@@ -28,7 +28,6 @@ import org.apache.derbyTesting.junit.Bas
 import org.apache.derbyTesting.junit.Derby;
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -48,8 +47,8 @@ import junit.framework.TestSuite;
 
 public class NetworkServerControlApiTest extends BaseJDBCTestCase {
 
-    private static String POLICY_FILE_NAME="functionTests/tests/derbynet/NetworkServerControlApiTest.policy";
-    private static String TARGET_POLICY_FILE_NAME="server.policy";
+    private static final String POLICY_FILE_NAME =
+            "org/apache/derbyTesting/functionTests/tests/derbynet/NetworkServerControlApiTest.policy";
     
     public NetworkServerControlApiTest(String name) {
         super(name);
@@ -213,28 +212,6 @@ public class NetworkServerControlApiTest
     }
     
     /**
-     * Construct the name of the server policy file.
-     */
-    private String makeServerPolicyName()
-    {
-        try {
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            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;
-        }
-    }
-    
-    
-    /**
      * Add decorators to a test run. Context is established in the reverse order
      * that decorators are declared here. That is, decorators compose in reverse
      * order. The order of the setup methods is:
@@ -247,9 +224,6 @@ public class NetworkServerControlApiTest
      */
     private static Test decorateTest()
     {
-        
-        String serverPolicyName = new NetworkServerControlApiTest("test").makeServerPolicyName();
-
         // Use a fixed ordering of the test cases. Some of the test cases set
         // properties that will be seen by subsequent test cases, but only if
         // they run in one particular order. Also, some test cases depend on
@@ -262,23 +236,7 @@ public class NetworkServerControlApiTest
         //
         // Install a security manager using the initial policy file.
         //
-        test = new SecurityManagerSetup( test,serverPolicyName );
-        
-        
-        //
-        // Copy over the policy file we want to use.
-        //
-        test = new SupportFilesSetup
-            (
-             test,
-             null,
-             new String[] { POLICY_FILE_NAME },
-             null,
-             new String[] { TARGET_POLICY_FILE_NAME}
-             );
-
-       
-        return test;
+        return new SecurityManagerSetup(test, POLICY_FILE_NAME);
     }
     
     public static Test suite()

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.java Thu Apr 11 15:09:09 2013
@@ -21,7 +21,6 @@
  */
 package org.apache.derbyTesting.functionTests.tests.derbynet;
 
-import java.io.File;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -36,7 +35,6 @@ import org.apache.derbyTesting.junit.Bas
 import org.apache.derbyTesting.junit.LocaleTestSetup;
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
@@ -55,13 +53,12 @@ public class RuntimeInfoTest extends Bas
 			"org.apache.derby.drda.NetworkServerControl", "runtimeinfo",
 			"-p", String.valueOf(TestConfiguration.getCurrent().getPort()) };
 	
-	private static String POLICY_FILE_NAME=
-    	"functionTests/tests/derbynet/RuntimeInfoTest.policy";
-    private static String TARGET_POLICY_FILE_NAME="runtimeinfo.policy";
-
-    private static Locale englishLocale = new Locale("en","US");
-	private static Locale germanLocale = new Locale("de","DE");
-	private static String stdout_err_tags = "<[^<>]*STD.*>";
+    private static final String POLICY_FILE_NAME =
+        "org/apache/derbyTesting/functionTests/tests/derbynet/RuntimeInfoTest.policy";
+
+    private static final Locale englishLocale = new Locale("en", "US");
+    private static final Locale germanLocale = new Locale("de", "DE");
+    private static final String stdout_err_tags = "<[^<>]*STD.*>";
 	
 	/**
 	 * Constructor
@@ -228,27 +225,7 @@ public class RuntimeInfoTest extends Bas
 		println(s);
 		println("<<<" + name + "<<<\n\n");
     }
-    
-    /**
-     * Construct the name of the server policy file.
-     */
-    private String makePolicyName()
-    {
-        try {
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            File      file = new File( fileName );
-            String  urlString = file.toURI().toURL().toExternalForm();
-
-            return urlString;
-        }
-        catch (Exception e)
-        {
-            fail(e.getMessage());
-            return null;
-        }
-    }
-	
+
 	/**
 	 * Decorate a test with SecurityManagerSetup, clientServersuite, and
 	 * SupportFilesSetup.
@@ -256,8 +233,6 @@ public class RuntimeInfoTest extends Bas
 	 * @return the decorated test
 	 */
 	private static Test decorateTest(Locale serverLocale) {
-        String policyName = new RuntimeInfoTest("test").makePolicyName();
-
         Test test = new TestSuite(RuntimeInfoTest.class);
         
         test = TestConfiguration.clientServerDecorator(test);
@@ -268,19 +243,7 @@ public class RuntimeInfoTest extends Bas
         test = TestConfiguration.singleUseDatabaseDecorator(test);
         test = new LocaleTestSetup(test, serverLocale);
         // Install a security manager using the initial policy file.
-        test = new SecurityManagerSetup(test, policyName);
-
-        // Copy over the policy file we want to use.
-        test = new SupportFilesSetup
-            (
-             test,
-             null,
-             new String[] { POLICY_FILE_NAME },
-             null,
-             new String[] { TARGET_POLICY_FILE_NAME}
-             );
-        
-        return test;
+        return new SecurityManagerSetup(test, POLICY_FILE_NAME);
     }
 	
 	private static final HashMap outputs;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.java Thu Apr 11 15:09:09 2013
@@ -25,7 +25,6 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.security.AccessController;
 import java.sql.SQLException;
-import java.util.Enumeration;
 import java.util.Locale;
 import java.util.Properties;
 
@@ -37,9 +36,7 @@ import org.apache.derbyTesting.junit.Bas
 import org.apache.derbyTesting.junit.Derby;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
-import org.apache.derbyTesting.junit.OsName;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 /** 
@@ -59,9 +56,8 @@ import org.apache.derbyTesting.junit.Tes
 public class ServerPropertiesTest  extends BaseJDBCTestCase {
     
     //create own policy file
-    private static String POLICY_FILE_NAME = 
-        "functionTests/tests/derbynet/ServerPropertiesTest.policy";
-    private static String TARGET_POLICY_FILE_NAME = "server.policy";
+    private static final String POLICY_FILE_NAME =
+        "org/apache/derbyTesting/functionTests/tests/derbynet/ServerPropertiesTest.policy";
     private int[] portsSoFar;
     private int basePort;
     
@@ -126,8 +122,6 @@ public class ServerPropertiesTest  exten
     
     public void tearDown() throws Exception {
         super.tearDown();
-        POLICY_FILE_NAME = null;
-        TARGET_POLICY_FILE_NAME = null;
         if (portsSoFar != null)
         {
             for (int i = 0 ; i < portsSoFar.length ; i++)
@@ -178,42 +172,13 @@ public class ServerPropertiesTest  exten
         return test;
     }   
     
-    /**
-     * Construct the name of the server policy file.
-     */
-    private String makeServerPolicyName()
-    {
-        try {
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            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;
-        }
-    }
-    
     // grant ALL FILES execute, and getPolicy permissions,
     // as well as write for the trace files.
     private static Test decorateWithPolicy(Test test) {
-        String serverPolicyName = new ServerPropertiesTest("test").makeServerPolicyName();
         //
         // Install a security manager using the initial policy file.
         //
-        test = new SecurityManagerSetup(test,serverPolicyName );
-        // Copy over the policy file we want to use.
-        //
-        test = new SupportFilesSetup(
-            test, null, new String[] {POLICY_FILE_NAME},
-            null, new String[] {TARGET_POLICY_FILE_NAME}
-        );
-        return test;
+        return new SecurityManagerSetup(test, POLICY_FILE_NAME);
     }
     
     private static Properties getTheProperties() {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.java Thu Apr 11 15:09:09 2013
@@ -21,7 +21,6 @@
  */
 package org.apache.derbyTesting.functionTests.tests.derbynet;
 
-import java.io.File;
 import java.net.URL;
 import java.security.AccessController;
 import java.util.ArrayList;
@@ -35,7 +34,6 @@ import org.apache.derbyTesting.junit.Der
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.NetworkServerTestSetup;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
@@ -46,7 +44,8 @@ import org.apache.derbyTesting.junit.Dat
 
 public class SysinfoTest extends BaseJDBCTestCase {
 
-    private static String TARGET_POLICY_FILE_NAME="sysinfo.policy";
+    private static final String POLICY_FILE_NAME=
+        "org/apache/derbyTesting/functionTests/tests/derbynet/SysinfoTest.policy";
     private ArrayList OUTPUT;
 
     /**
@@ -143,23 +142,6 @@ public class SysinfoTest extends BaseJDB
         return suite;
     }
 
-    private String makePolicyName() {
-        try {
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + 
-            SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            File      file = new File( fileName );
-            String  urlString = file.toURL().toExternalForm();
-
-            return urlString;
-        }
-        catch (Exception e) {
-            fail("Unexpected exception caught by " +
-                    "makeServerPolicyName(): " + e );
-            return null;
-        }
-    }
-
     /**
      * Decorate a test with SecurityManagerSetup, clientServersuite, and
      * SupportFilesSetup.
@@ -167,26 +149,11 @@ public class SysinfoTest extends BaseJDB
      * @return the decorated test
      */
     private static Test decorateTest() {
-        String policyName = new SysinfoTest("test").makePolicyName();
         Test test = TestConfiguration.clientServerSuite(SysinfoTest.class);
 
         // Install a security manager using the initial policy file.
-        test = TestConfiguration.singleUseDatabaseDecorator(
-                new SecurityManagerSetup(test, policyName));
-
-        // Copy over the policy file we want to use.
-        String POLICY_FILE_NAME=
-            "functionTests/tests/derbynet/SysinfoTest.policy";
-
-        test = new SupportFilesSetup
-        (
-                test,
-                null,
-                new String[] { POLICY_FILE_NAME },
-                null,
-                new String[] { TARGET_POLICY_FILE_NAME}
-        );
-        return test;
+        return TestConfiguration.singleUseDatabaseDecorator(
+                new SecurityManagerSetup(test, POLICY_FILE_NAME));
     }
 
     /**
@@ -252,7 +219,6 @@ public class SysinfoTest extends BaseJDB
 
     public void tearDown() throws Exception {
         super.tearDown();
-        TARGET_POLICY_FILE_NAME = null;
         OUTPUT = null;
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPAuthenticationTest.java Thu Apr 11 15:09:09 2013
@@ -22,7 +22,6 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbcapi;
 
-import java.io.File;
 import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.DriverManager;
@@ -41,8 +40,6 @@ import org.apache.derbyTesting.junit.Dat
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.JDBCDataSource;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
-import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 // tests that appropriate and invalid connections can be made to 
@@ -61,9 +58,8 @@ public class LDAPAuthenticationTest exte
         // if not passed in with -DderbyTesting.ldapContextFactory, uses sun's
 
     // create own policy file, so we can connect to the ldap server
-    private static String POLICY_FILE_NAME = 
-        "functionTests/tests/jdbcapi/LDAPTests.policy";
-    private static String TARGET_POLICY_FILE_NAME = "derby_tests.policy";
+    private static final String POLICY_FILE_NAME =
+        "org/apache/derbyTesting/functionTests/tests/jdbcapi/LDAPTests.policy";
     
     /** Creates a new instance of the Test */
     public LDAPAuthenticationTest(String name) {
@@ -113,8 +109,10 @@ public class LDAPAuthenticationTest exte
             "testLDAPConnection"));
         suite.addTest(TestConfiguration.clientServerDecorator(
             baseSuite("LDAPAuthenticationTest:client", "testLDAPConnection")));
-        Test test = decorateWithPolicy(suite);
-        return test;            
+
+        // Grant ALL FILES execute, and getPolicy permissions, as well as
+        // resolve/connect for the LDAP server identified with the property.
+        return new SecurityManagerSetup(suite, POLICY_FILE_NAME);
     }
 
     public static Test baseSuite(String name, String fixture) {
@@ -139,42 +137,6 @@ public class LDAPAuthenticationTest exte
         suite.addTest(new DatabasePropertyTestSetup (test, props, true));
     }
 
-    // grant ALL FILES execute, and getPolicy permissions, as well
-    // as resolve/connect for the ldap server identified with the property
-    private static Test decorateWithPolicy(Test test) {
-        String ldapPolicyName = new LDAPAuthenticationTest("test").makeServerPolicyName();
-        //
-        // Install a security manager using the initial policy file.
-        //
-        test = new SecurityManagerSetup(test,ldapPolicyName );
-        // Copy over the policy file we want to use.
-        //
-        test = new SupportFilesSetup(
-            test, null, new String[] {POLICY_FILE_NAME},
-            null, new String[] {TARGET_POLICY_FILE_NAME}
-        );
-        return test;
-    }
-    
-    /**
-     * Construct the name of the server policy file.
-     */
-    private String makeServerPolicyName()
-    {
-        try {
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            File      file = new File( fileName );
-            String  urlString = file.toURL().toExternalForm();
-
-            return urlString;
-        }
-        catch (Exception e)
-        {
-            return null;
-        }
-    }
-    
     protected void tearDown() throws Exception {
         removeSystemProperty("derby.connection.requireAuthentication");
         super.tearDown();

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?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- 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 Thu Apr 11 15:09:09 2013
@@ -144,13 +144,12 @@ public class SecurityPolicyReloadingTest
      */
     private static Test decorateTest()
     {
-        SecurityPolicyReloadingTest undecoratedTest = new SecurityPolicyReloadingTest();
-        Test                                        test = undecoratedTest;
+        Test test = new SecurityPolicyReloadingTest();
 
         //
         // Install a security manager using the initial policy file.
         //
-        test = new SecurityManagerSetup( test, undecoratedTest.makeServerPolicyName() );
+        test = new SecurityManagerSetup(test, makeServerPolicyName());
         
         //
         // Set up authorization with a DBO and non-DBO user
@@ -169,9 +168,9 @@ public class SecurityPolicyReloadingTest
             (
              test,
              null,
-             new String[] { undecoratedTest.getSourcePolicy() },
+             new String[] { getSourcePolicy() },
              null,
-             new String[] { undecoratedTest.makeTargetPolicyStub() }
+             new String[] { makeTargetPolicyStub() }
              );
 
         // No need to run with default testing policy file because we install our 
@@ -373,15 +372,13 @@ public class SecurityPolicyReloadingTest
     /**
      * Construct the name of the server policy file.
      */
-    private String makeServerPolicyName()
+    private static String makeServerPolicyName()
     {
         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;
+            return file.toURI().toURL().toExternalForm();
         }
         catch (Exception e)
         {
@@ -394,7 +391,7 @@ public class SecurityPolicyReloadingTest
     /**
      * Get the stub name (no directory spec) for the server policy file we create.
      */
-    private String makeTargetPolicyStub()
+    private static String makeTargetPolicyStub()
     {
         return TARGET_POLICY;
    }
@@ -402,7 +399,7 @@ public class SecurityPolicyReloadingTest
     /**
      * Get the source file which has the correct permissions.
      */
-    private String getSourcePolicy()
+    private static String getSourcePolicy()
     {
         return RELOADABLE_INITIAL_SOURCE_POLICY;
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3980DeadlockTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3980DeadlockTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3980DeadlockTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/store/Derby3980DeadlockTest.java Thu Apr 11 15:09:09 2013
@@ -30,14 +30,12 @@ import java.util.LinkedList;
 import java.util.Properties;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.BaseTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
 import org.apache.derbyTesting.junit.SecurityManagerSetup;
-import org.apache.derbyTesting.junit.SupportFilesSetup;
 import org.apache.derbyTesting.junit.SystemPropertyTestSetup;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
@@ -49,11 +47,12 @@ import org.apache.derbyTesting.junit.Tes
  */
 public class Derby3980DeadlockTest extends BaseJDBCTestCase {
     private final int THREAD_COUNT = 2;
-    private LinkedList  listExceptions = new LinkedList();
-    private Object syncObject = new Object();
+    private final LinkedList listExceptions = new LinkedList();
+    private final Object syncObject = new Object();
     private int startedCount = 0;
-    private String fprefix = "javacore";
-    private static String TARGET_POLICY_FILE_NAME="derby3980deadlock.policy";
+    private static final String fprefix = "javacore";
+    private static final String POLICY_FILE_NAME =
+        "org/apache/derbyTesting/functionTests/tests/store/Derby3980DeadlockTest.policy";
     
     public Derby3980DeadlockTest(String name) {
         super(name);
@@ -88,7 +87,6 @@ public class Derby3980DeadlockTest exten
      * @return the decorated test
      */
     private static Test decorateTest() {
-        String policyName = new Derby3980DeadlockTest("test").makePolicyName();
         Test test = TestConfiguration.clientServerSuite(Derby3980DeadlockTest.class);
         Properties diagProperties = new Properties();
         diagProperties.setProperty("derby.stream.error.extendedDiagSeverityLevel", "30000");
@@ -96,41 +94,7 @@ public class Derby3980DeadlockTest exten
         test = new SystemPropertyTestSetup(test, diagProperties, true);
      
         // Install a security manager using the initial policy file.
-        test = new SecurityManagerSetup(test, policyName);
-
-        // Copy over the policy file we want to use.
-        String POLICY_FILE_NAME=
-            "functionTests/tests/store/Derby3980DeadlockTest.policy";
-
-        test = new SupportFilesSetup
-        (
-                test,
-                null,
-                new String[] { POLICY_FILE_NAME },
-                null,
-                new String[] { TARGET_POLICY_FILE_NAME}
-        );
-        return test;
-    }
-    /**
-     * Generate the name of the local policy file
-     * @return the name of the local testing policy file
-     **/
-    private String makePolicyName() {
-        try {
-            String  userDir = getSystemProperty( "user.dir" );
-            String  fileName = userDir + File.separator + 
-            SupportFilesSetup.EXTINOUT + File.separator + TARGET_POLICY_FILE_NAME;
-            File      file = new File( fileName );
-            String  urlString = file.toURL().toExternalForm();
-
-            return urlString;
-        }
-        catch (Exception e) {
-            fail("Unexpected exception caught by " +
-                    "makePolicyName(): " + e );
-            return null;
-        }
+        return new SecurityManagerSetup(test, POLICY_FILE_NAME);
     }
     
     private void waitForThreads(Thread[] t) {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java?rev=1466914&r1=1466913&r2=1466914&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.java Thu Apr 11 15:09:09 2013
@@ -53,13 +53,13 @@ public class SystemPrivilegesPermissionT
     /**
      * The policy file name for the subject authorization tests.
      */
-    static private String POLICY_FILE_NAME
+    private static final String POLICY_FILE_NAME
         = "org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest.policy";
 
     /**
      * The policy file name for the DatabasePermission API test.
      */
-    static private String POLICY_FILE_NAME1
+    private static final String POLICY_FILE_NAME1
         = "org/apache/derbyTesting/unitTests/junit/SystemPrivilegesPermissionTest1.policy";
 
     /**