river-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter_firmst...@apache.org
Subject svn commit: r928396 - in /incubator/river/jtsk/trunk: qa/build.xml qa/src/com/sun/jini/qa/resources/qaDefaults.properties test/src/net/jini/security/GrantPermissionTest.java
Date Sun, 28 Mar 2010 13:05:45 GMT
Author: peter_firmstone
Date: Sun Mar 28 13:05:45 2010
New Revision: 928396

URL: http://svn.apache.org/viewvc?rev=928396&view=rev
Log:
Note this commit may be reversed, it is primarily to allow other developers to participate
in my recent experiments utilising the compiler options source=5 and target=jsr14 and relates
to River-334

This commit also contains code relevant to River-323 to provide concurrency to DynamicPolicyProvider,
additional packages and junit tests have been included.

Added:
    incubator/river/jtsk/trunk/test/src/net/jini/security/GrantPermissionTest.java   (with
props)
Modified:
    incubator/river/jtsk/trunk/qa/build.xml
    incubator/river/jtsk/trunk/qa/src/com/sun/jini/qa/resources/qaDefaults.properties

Modified: incubator/river/jtsk/trunk/qa/build.xml
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/qa/build.xml?rev=928396&r1=928395&r2=928396&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/qa/build.xml (original)
+++ incubator/river/jtsk/trunk/qa/build.xml Sun Mar 28 13:05:45 2010
@@ -226,8 +226,8 @@
                 <jvmarg value="-Dcom.sun.jini.qa.harness.configs=${harness.configs}" />
                 <!-- VM args for each test run: include our JDK extension directories
                 $${com.sun.jini.qa.harness.globalvmargs},-Dcom.sun.jini.test.home=$${com.sun.jini.test.home},-Dcom.sun.jini.test.port=$${com.sun.jini.test.port},-Dcom.sun.jini.qa.harness.policies=&lt;url:
com/sun/jini/test/resources/jinitest.policy&gt;-Djava.security.debug=access-->
-                <jvmarg value="-Dcom.sun.jini.qa.harness.globalvmargs=$${com.sun.jini.qa.harness.globalvmargs},-Djava.ext.dirs=${ext.dirs},-Djava.security.debug=access"/>
-                <!--<jvmarg value="-Dcom.sun.jini.qa.harness.globalvmargs=$${com.sun.jini.qa.harness.globalvmargs},-Djava.ext.dirs=${ext.dirs}"/>-->
+                <!--<jvmarg value="-Dcom.sun.jini.qa.harness.globalvmargs=$${com.sun.jini.qa.harness.globalvmargs},-Djava.ext.dirs=${ext.dirs},-Djava.security.debug=access"/>-->
+                <jvmarg value="-Dcom.sun.jini.qa.harness.globalvmargs=$${com.sun.jini.qa.harness.globalvmargs},-Djava.ext.dirs=${ext.dirs}"/>
                 <arg path="${src.dir}/com/sun/jini/test/resources/qaHarness.prop" />
                 <arg value="-testJar"/>
                 <arg path="${lib.dir}/jinitests.jar" />

Modified: incubator/river/jtsk/trunk/qa/src/com/sun/jini/qa/resources/qaDefaults.properties
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/qa/src/com/sun/jini/qa/resources/qaDefaults.properties?rev=928396&r1=928395&r2=928396&view=diff
==============================================================================
--- incubator/river/jtsk/trunk/qa/src/com/sun/jini/qa/resources/qaDefaults.properties (original)
+++ incubator/river/jtsk/trunk/qa/src/com/sun/jini/qa/resources/qaDefaults.properties Sun
Mar 28 13:05:45 2010
@@ -210,11 +210,10 @@ com.sun.jini.qa.harness.actdeathdelay=5
 #   system property if that property is defined. The '-OD' marker flags this
 #   property as optional. If the property is not defined as a system property
 #   or in any configuration file, then the property will not be set on the VM.
-#      
+#      -Djava.security.debug=access,\
 # no cosmetic whitespace
 com.sun.jini.qa.harness.globalvmargs=\
 -Djava.ext.dirs=${java.ext.dirs},\
--Djava.security.debug=access,\
 -Dcom.sun.jini.jsk.port=${com.sun.jini.jsk.port},\
 -Dcom.sun.jini.qa.port=${com.sun.jini.qa.port},\
 -Dcom.sun.jini.jsk.home=${com.sun.jini.jsk.home},\

Added: incubator/river/jtsk/trunk/test/src/net/jini/security/GrantPermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/river/jtsk/trunk/test/src/net/jini/security/GrantPermissionTest.java?rev=928396&view=auto
==============================================================================
--- incubator/river/jtsk/trunk/test/src/net/jini/security/GrantPermissionTest.java (added)
+++ incubator/river/jtsk/trunk/test/src/net/jini/security/GrantPermissionTest.java Sun Mar
28 13:05:45 2010
@@ -0,0 +1,232 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package net.jini.security;
+
+import java.io.FilePermission;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class GrantPermissionTest {
+
+    public GrantPermissionTest() {
+    }
+
+    @org.junit.BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @org.junit.AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @org.junit.Before
+    public void setUp() throws Exception {       
+    }
+
+    @org.junit.After
+    public void tearDown() throws Exception {
+    }
+
+    /**
+     * Test of getActions method, of class GrantPermission.
+     */
+//    @org.junit.Test
+//    public void getActions() {
+//        System.out.println("getActions");
+//        GrantPermission instance = null;
+//        String expResult = "";
+//        String result = instance.getActions();
+//        assertEquals(expResult, result);
+//        // TODO review the generated test code and remove the default call to fail.
+//        fail("The test case is a prototype.");
+//    }
+
+    /**
+     * Test of newPermissionCollection method, of class GrantPermission.
+     */
+//    @org.junit.Test
+//    public void newPermissionCollection() {
+//        System.out.println("newPermissionCollection");
+//        GrantPermission instance = null;
+//        PermissionCollection expResult = null;
+//        PermissionCollection result = instance.newPermissionCollection();
+//        assertEquals(expResult, result);
+//        // TODO review the generated test code and remove the default call to fail.
+//        fail("The test case is a prototype.");
+//    }
+
+    /**
+     * Test of implies method, of class GrantPermission.
+     */
+    @org.junit.Test
+    public void implies() {
+        System.out.println("implies");
+        /*
+         * Create three FilePermissions with "read", "write" and 
+         * "read,write" actions for the same file.
+         */
+        FilePermission fp01 = new FilePermission("foo", "read");
+        FilePermission fp02 = new FilePermission("foo", "write");
+        FilePermission fp03 = new FilePermission("foo", "read,write");
+
+        /*
+         * Create GrantPermission passing created FilePermissions
+         * with "read,write" actions.
+         */
+
+        GrantPermission gp03 = new GrantPermission(fp03);
+
+        /*
+         * Create GrantPermission passing array of two created
+         * GrantPermissions for "read" and "write" actions.
+         */
+        Permission[] pa = { fp01, fp02 };
+        GrantPermission gppa = new GrantPermission(pa);
+
+        /*
+         * Verify that last created GrantPermission implies
+         * GrantPermission that was created
+         * for "read,write" action.
+         */
+        boolean result = gppa.implies(gp03);
+        String msg = str(gppa) + ".implies(" + str(gp03) + ")";       
+        System.out.println(msg);
+        boolean expResult = true;
+        assertEquals(expResult, result);
+
+    }
+    
+    private String str(Permission p) {
+        String className = p.getClass().getName();
+        int lastIndex = className.lastIndexOf(".");
+
+        if (lastIndex > 0) {
+            className = className.substring(lastIndex + 1);
+        }
+        return className + "(" + p.getName() + ")";
+    }    
+
+    @org.junit.Test
+    public void doesNotImplyFilePermissionsRWTest(){
+        System.out.println("Verify that PermissionCollection does not imply FilePermissions
with \"read,write\" action.");
+        PermissionCollection pc = null;
+
+        /*
+         * Create three FilePermissions with "read", "write" and 
+         * "read,write" actions for the same file.
+         */
+        FilePermission fp01 = new FilePermission("foo", "read");
+        FilePermission fp02 = new FilePermission("foo", "write");
+        FilePermission fp03 = new FilePermission("foo", "read,write");
+
+        /*
+         * Create three GrantPermissions passing created FilePermissions
+         * with "read", "write" and "read,write" actions.
+         */
+        GrantPermission gp01 = new GrantPermission(fp01);
+        GrantPermission gp02 = new GrantPermission(fp02);
+
+        /*
+         * Get new PermissionCollection from GrantPermission for 
+         * "read" action and add GrantPermission for "read" action and
+         * GrantPermission for "write" action to this PermissionCollection.
+         */
+        pc = gp01.newPermissionCollection();
+        pc.add(gp01);
+        pc.add(gp02);
+
+        /*
+         * Verify that PermissionCollection does not imply
+         * FilePermissions with "read,write" action.
+         */
+        boolean result = checkImplies(pc, fp03, false, "(Grant)PermissionCollection");
+        assertEquals( result , true );
+    }    
+    
+    @org.junit.Test
+    public void verifyDoesImplyGrantPermissionTest(){
+        System.out.println("Verify that PermissionCollection implies GrantPermission for
\"read,write\" action.");
+        PermissionCollection pc = null;
+
+        /*
+         * Create three FilePermissions with "read", "write" and 
+         * "read,write" actions for the same file.
+         */
+        FilePermission fp01 = new FilePermission("foo", "read");
+        FilePermission fp02 = new FilePermission("foo", "write");
+        FilePermission fp03 = new FilePermission("foo", "read,write");
+
+        /*
+         * Create three GrantPermissions passing created FilePermissions
+         * with "read", "write" and "read,write" actions.
+         */
+        GrantPermission gp01 = new GrantPermission(fp01);
+        GrantPermission gp02 = new GrantPermission(fp02);
+        GrantPermission gp03 = new GrantPermission(fp03);
+
+        /*
+         * Get new PermissionCollection from GrantPermission for 
+         * "read" action and add GrantPermission for "read" action and
+         * GrantPermission for "write" action to this PermissionCollection.
+         */
+        pc = gp01.newPermissionCollection();
+        pc.add(gp01);
+        pc.add(gp02);
+
+        /*
+         * Verify that PermissionCollection implies
+         * GrantPermission for "read,write" action.
+         */
+        boolean result = checkImplies(pc, gp03, true, "(Grant)PermissionCollection");
+        assertEquals( result , true );
+    }
+    
+    protected boolean checkImplies(PermissionCollection pc, Permission p,
+            boolean exp, String msg){
+        boolean ret = pc.implies(p);
+        msg += ".implies(" + str(p) + ")";
+        System.out.println(msg);
+        return ret == exp;
+    }
+    
+    /**
+     * Test of equals method, of class GrantPermission.
+     */
+//    @org.junit.Test
+//    public void testequals() {
+//        System.out.println("equals");
+//        Object obj = null;
+//        GrantPermission instance = null;
+//        boolean expResult = false;
+//        boolean result = instance.equals(obj);
+//        assertEquals(expResult, result);
+//        // TODO review the generated test code and remove the default call to fail.
+//        fail("The test case is a prototype.");
+//    }
+
+    /**
+     * Test of hashCode method, of class GrantPermission.
+     */
+//    @org.junit.Test
+//    public void testhashCode() {
+//        System.out.println("hashCode");
+//        GrantPermission instance = null;
+//        int expResult = 0;
+//        int result = instance.hashCode();
+//        assertEquals(expResult, result);
+//        // TODO review the generated test code and remove the default call to fail.
+//        fail("The test case is a prototype.");
+//    }
+
+}
\ No newline at end of file

Propchange: incubator/river/jtsk/trunk/test/src/net/jini/security/GrantPermissionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message