harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r414791 - /incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
Date Fri, 16 Jun 2006 09:57:23 GMT
Author: smishura
Date: Fri Jun 16 02:57:23 2006
New Revision: 414791

URL: http://svn.apache.org/viewvc?rev=414791&view=rev
Log:
Fix policy file generating

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java?rev=414791&r1=414790&r2=414791&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
Fri Jun 16 02:57:23 2006
@@ -69,13 +69,15 @@
             fail("Unexpected IOException while creating policy file : " + e);
         }
 
+        URL signedBKS = getResourceURL("PermissionCollection/signedBKS.jar");
+        URL keystoreBKS = getResourceURL("PermissionCollection/keystore.bks");
+        
         // Create the policy file (and save the existing one if any)
         try {
             FileOutputStream fileOut = new FileOutputStream(policyFile);
             String linebreak = System.getProperty("line.separator");
             String towrite = "grant codeBase \""
-                    + classURL.toExternalForm()
-                    + "tests/resources/PermissionCollection/signedBKS.jar"
+                    + signedBKS.toExternalForm()
                     + "\" signedBy \"eleanor\" {"
                     + linebreak
                     + "permission java.io.FilePermission \"test1.txt\", \"write\";"
@@ -85,8 +87,7 @@
                     + "};"
                     + linebreak
                     + "grant codeBase \""
-                    + classURL.toExternalForm()
-                    + "tests/resources/PermissionCollection/signedBKS.jar"
+                    + signedBKS.toExternalForm()
                     + "\" signedBy \"eleanor\" {"
                     + linebreak
                     + "permission java.io.FilePermission \"test2.txt\", \"write\";"
@@ -95,8 +96,7 @@
             towrite += "\" {" + linebreak
                     + "permission java.security.AllPermission;" + linebreak
                     + "};" + linebreak + "keystore \""
-                    + classURL.toExternalForm()
-                    + "tests/resources/PermissionCollection/keystore.bks"
+                    + keystoreBKS.toExternalForm()
                     + "\",\"BKS\";";
             fileOut.write(towrite.getBytes());
             fileOut.flush();
@@ -142,8 +142,7 @@
         try {
             args[0] = "-Djava.security.policy=" + policyFile.toURL();
             args[1] = "tests.support.Support_PermissionCollection";
-            args[2] = classURL.toExternalForm()
-                    + "tests/resources/PermissionCollection/signedBKS.jar";
+            args[2] = signedBKS.toExternalForm();
         } catch (MalformedURLException e) {
             fail("Unexpected MalformedURLException while policy file to url : "
                     + e);
@@ -240,5 +239,17 @@
                 "testing permissionCollection-isREadOnly");
         assertNotNull("toString should have returned a string of elements",
                 permi.newPermissionCollection().toString());
+    }
+
+    // FIXME move me to Support_Resources
+    public static URL getResourceURL(String name) {
+
+        URL url = ClassLoader.getSystemClassLoader().getResource(name);
+
+        if (url == null) {
+            throw new RuntimeException("Failed to get resource url: " + name);
+        }
+
+        return url;
     }
 }



Mime
View raw message