harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r421527 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/ test/api/java.injected/java/security/ test/api/java/org/apache/harmony/security/tests/java/security/ test/impl/java.injected/java/...
Date Thu, 13 Jul 2006 07:43:03 GMT
Author: mloenko
Date: Thu Jul 13 00:43:02 2006
New Revision: 421527

URL: http://svn.apache.org/viewvc?rev=421527&view=rev
Log:
fixes for HARMONY-733
[classlib][security] unexpected IllegalArgumentException for java.security.UnresolvedPermission("",
String, String,Certificate[] )

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java
      - copied, changed from r420901, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/UnresolvedPermissionTest.java
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/UnresolvedPermissionTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java?rev=421527&r1=421526&r2=421527&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/UnresolvedPermission.java
Thu Jul 13 00:43:02 2006
@@ -109,10 +109,15 @@
     private final void checkType(String type) {
         if (type == null) {
             throw new NullPointerException("type cannot be null");
-        }    
-        if (type.length() == 0) {
-            throw new IllegalArgumentException("type cannot be empty");
         }
+
+        // type is the class name of the Permission class.
+        // Empty string is inappropriate for class name.
+        // But this check is commented out for compatibility with RI.
+        // see JIRA issue HARMONY-733
+        // if (type.length() == 0) {
+        //     throw new IllegalArgumentException("type cannot be empty");
+        // }
     }
 
 	/**

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java?rev=421527&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java
Thu Jul 13 00:43:02 2006
@@ -0,0 +1,76 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.security.tests.java.security;
+
+import java.security.AllPermission;
+import java.security.SecurityPermission;
+import java.security.UnresolvedPermission;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>UnresolvedPermission</code> class fields and methods
+ * 
+ */
+
+public class UnresolvedPermissionTest extends TestCase {
+    
+    /**
+     * Creates an Object with given name, type, action, certificaties. 
+     * Empty or null type is not allowed - exception should be thrown.
+     */
+    public void testCtor()
+    {
+        String type = "laskjhlsdk 2345346";
+        String name = "^%#UHVKU^%V  887y";
+        String action = "JHB ^%(*&T klj3h4";
+        UnresolvedPermission up = new UnresolvedPermission(type, name, action, null);
+        assertEquals(type, up.getName());
+        assertEquals("", up.getActions());
+        assertEquals("(unresolved " + type + " " + name + " " + action + ")", up.toString());
+        
+        up = new UnresolvedPermission(type, null, null, null);
+        assertEquals(type, up.getName());
+        assertEquals("", up.getActions());
+        assertEquals("(unresolved " + type + " null null)", up.toString());
+        
+        up = new UnresolvedPermission(type, "", "", new java.security.cert.Certificate[0]);
+        assertEquals(type, up.getName());
+        assertEquals("", up.getActions());
+        assertEquals("(unresolved " + type + "  )", up.toString());
+        
+        try {
+            new UnresolvedPermission(null, name, action, null);
+            fail("exception is not thrown on null type");
+        }
+        catch (Exception ok) {}
+
+        //Regression for HARMONY-733
+        assertNotNull(new UnresolvedPermission("", name, action, null));
+    }
+    
+    /** 
+     * UnresolvedPermission never implies any other permission.
+     */
+    public void testImplies()
+    {
+        UnresolvedPermission up = new UnresolvedPermission("java.security.SecurityPermission",
"a.b.c", null, null);
+        assertFalse(up.implies(up));
+        assertFalse(up.implies(new AllPermission()));
+        assertFalse(up.implies(new SecurityPermission("a.b.c")));
+    }
+}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java
(from r420901, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/UnresolvedPermissionTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/UnresolvedPermissionTest.java&r1=420901&r2=421527&rev=421527&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/UnresolvedPermissionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java
Thu Jul 13 00:43:02 2006
@@ -14,11 +14,6 @@
  *  limitations under the License.
  */
 
-/**
-* @author Alexey V. Varlamov
-* @version $Revision$
-*/
-
 package java.security;
 
 import junit.framework.TestCase;
@@ -30,65 +25,6 @@
 
 public class UnresolvedPermissionTest extends TestCase {
 
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(UnresolvedPermissionTest.class);
-    }
-
-    /**
-     * Constructor for UnresolvedPermissionTest.
-     * @param arg0
-     */
-    public UnresolvedPermissionTest(String arg0) {
-        super(arg0);
-    }
-    
-    /**
-     * Creates an Object with given name, type, action, certificaties. 
-     * Empty or null type is not allowed - exception should be thrown.
-     */
-    public void testCtor()
-    {
-        String type = "laskjhlsdk 2345346";
-        String name = "^%#UHVKU^%V  887y";
-        String action = "JHB ^%(*&T klj3h4";
-        UnresolvedPermission up = new UnresolvedPermission(type, name, action, null);
-        assertEquals(type, up.getName());
-        assertEquals("", up.getActions());
-        assertEquals("(unresolved " + type + " " + name + " " + action + ")", up.toString());
-        
-        up = new UnresolvedPermission(type, null, null, null);
-        assertEquals(type, up.getName());
-        assertEquals("", up.getActions());
-        assertEquals("(unresolved " + type + " null null)", up.toString());
-        
-        up = new UnresolvedPermission(type, "", "", new java.security.cert.Certificate[0]);
-        assertEquals(type, up.getName());
-        assertEquals("", up.getActions());
-        assertEquals("(unresolved " + type + "  )", up.toString());
-        
-        try {
-            new UnresolvedPermission(null, name, action, null);
-            fail("exception is not thrown on null type");
-        }
-        catch (Exception ok) {}
-        /*try {
-            new UnresolvedPermission("", name, action, null);
-            fail("exception is not thrown on empty type");
-        }
-        catch (Exception ok) {}*/
-    }
-    
-    /** 
-     * UnresolvedPermission never implies any other permission.
-     */
-    public void testImplies()
-    {
-        UnresolvedPermission up = new UnresolvedPermission("java.security.SecurityPermission",
"a.b.c", null, null);
-        assertFalse(up.implies(up));
-        assertFalse(up.implies(new AllPermission()));
-        assertFalse(up.implies(new SecurityPermission("a.b.c")));
-    }
-    
     /**
      * newPermissionCollection() should return new BasicPermissionCollection on every invokation
      */



Mime
View raw message