harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r391912 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/javax/security/auth/SubjectDomainCombiner.java test/java/common/javax/security/auth/SubjectDomainCombinerTest.java
Date Thu, 06 Apr 2006 06:27:06 GMT
Author: smishura
Date: Wed Apr  5 23:27:03 2006
New Revision: 391912

URL: http://svn.apache.org/viewcvs?rev=391912&view=rev
Log:
Apply patch HARMONY-219 (new javax.security.auth.SubjectDomainCombiner(null) should throw
NPE)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/javax/security/auth/SubjectDomainCombiner.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/javax/security/auth/SubjectDomainCombinerTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/javax/security/auth/SubjectDomainCombiner.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/javax/security/auth/SubjectDomainCombiner.java?rev=391912&r1=391911&r2=391912&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/javax/security/auth/SubjectDomainCombiner.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/javax/security/auth/SubjectDomainCombiner.java
Wed Apr  5 23:27:03 2006
@@ -44,6 +44,8 @@
      * @com.intel.drl.spec_ref
      */
     public SubjectDomainCombiner(Subject subject) {
+        if (subject == null)
+            throw new NullPointerException();
         this.subject = subject;
     }
 
@@ -84,15 +86,9 @@
         int cur = 0;
         if (currentDomains != null) {
 
-            Principal[] p;
-            if (subject == null) {
-                p = new Principal[0];
-            } else {
-                Set s = subject.getPrincipals();
-
-                p = new Principal[s.size()];
-                s.toArray(p);
-            }
+            Set s = subject.getPrincipals();
+            Principal[] p = new Principal[s.size()];
+            s.toArray(p);
 
             for (cur = 0; cur < currentDomains.length; cur++) {
                 ProtectionDomain newPD;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/javax/security/auth/SubjectDomainCombinerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/javax/security/auth/SubjectDomainCombinerTest.java?rev=391912&r1=391911&r2=391912&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/javax/security/auth/SubjectDomainCombinerTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/javax/security/auth/SubjectDomainCombinerTest.java
Wed Apr  5 23:27:03 2006
@@ -46,9 +46,10 @@
     }
 
     /**
-     * Testing getSubject() & constructor
+     * @tests javax.security.auth.SubjectDomainCombiner#SubjectDomainCombiner(
+     *        javax.security.auth.Subject)
      */
-    public final void testGetSubject() {
+    public final void test_ConstructorLjavax_security_auth_Subject() {
 
         Subject subject = new Subject();
 
@@ -57,14 +58,11 @@
         assertTrue("Subject is not null", subject == combiner.getSubject());
 
         try {
-            combiner = new SubjectDomainCombiner(null);
+            // Regression for HARMONY-219
+            new SubjectDomainCombiner(null);
+            fail("Constructor should throw NullPointerException");
         } catch (NullPointerException e) {
-            if(!testing){
-                throw e;
-            }
-            return;
         }
-        assertNull("Subject is null", combiner.getSubject());
     }
 
     /**
@@ -120,38 +118,6 @@
         // check inherited domains
         pd = combiner.combine(null, new ProtectionDomain[] { domain });
         assertTrue("Inherited domain", domain == pd[0]);
-    }
-
-    public final void testCombine_NullSubject() throws Exception {
-
-        if(testing){
-            return;
-        }
-        
-        SubjectDomainCombiner combiner = new SubjectDomainCombiner(null);
-
-        // check assigned principals
-        URL url = new URL("file://foo.txt");
-
-        CodeSource source = new CodeSource(url, (Certificate[]) null);
-        PermissionCollection permissions = new Permissions();
-        ClassLoader classLoader = new URLClassLoader(new URL[] { url });
-
-        Principal p = new Principal() {
-            public String getName() {
-                return "p";
-            }
-        };
-        Principal[] principals = new Principal[] { p };
-
-        ProtectionDomain domain = new ProtectionDomain(source, permissions,
-                classLoader, principals);
-
-        ProtectionDomain[] pd = combiner.combine(
-                new ProtectionDomain[] { domain }, null);
-        
-        assertTrue("Size", pd[0].getPrincipals().length==0);
-
     }
 
     public final void testSecurityException() {



Mime
View raw message