diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2011-01-14 15:53:01 -0800 |
---|---|---|
committer | Jean-Baptiste Queru <jbq@google.com> | 2011-01-14 15:53:10 -0800 |
commit | bf06259a9b4394dc6b98812165a0ba2bc60cd0be (patch) | |
tree | 324e04d1139fea708c8136cfcc384fe5547a4e97 /luni | |
parent | 27020e1160e6b880d2f3448a4fc11a0527945cf9 (diff) | |
parent | a49d9caee4cd74c0d2cf83d79b8ecdc00453dff8 (diff) | |
download | libcore-bf06259a9b4394dc6b98812165a0ba2bc60cd0be.zip libcore-bf06259a9b4394dc6b98812165a0ba2bc60cd0be.tar.gz libcore-bf06259a9b4394dc6b98812165a0ba2bc60cd0be.tar.bz2 |
merge from gingerbread
Change-Id: I97045002f8f8282de101ba1869055dd4713cee2d
Diffstat (limited to 'luni')
9 files changed, 3 insertions, 1159 deletions
diff --git a/luni/src/test/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java b/luni/src/test/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java index 75767c0..7cf12b5 100644 --- a/luni/src/test/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java +++ b/luni/src/test/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java @@ -40,6 +40,7 @@ import java.security.cert.Certificate; import org.apache.harmony.security.tests.support.TestCertUtils; import junit.framework.TestCase; + @TestTargetClass(CodeSource.class) /** * Unit test for CodeSource. @@ -502,9 +503,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thizCS.implies(thatCS)); } - /** - * If this object's location equals codesource's location, then return true. - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -520,10 +518,6 @@ public class CodeSourceTest extends TestCase { } - /** - * This object's protocol (getLocation().getProtocol()) must be equal to - * codesource's protocol. - */ /* * FIXME * commented out for temporary, as there is no FTP:// protocol supported yet. @@ -549,11 +543,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thatCS.implies(thizCS)); } - /** - * If this object's host (getLocation().getHost()) is not null, then the - * SocketPermission constructed with this object's host must imply the - * SocketPermission constructed with codesource's host. - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -585,10 +574,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thatCS.implies(thizCS)); } - /** - * If this object's port (getLocation().getPort()) is not equal to -1 (that - * is, if a port is specified), it must equal codesource's port. - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -616,10 +601,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thizCS.implies(thatCS)); } - /** - * If this object's file (getLocation().getFile()) doesn't equal - * codesource's file, then the following checks are made: ... - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -632,10 +613,6 @@ public class CodeSourceTest extends TestCase { assertTrue(thizCS.implies(thatCS)); } - /** - * ... If this object's file ends with "/-", then codesource's file must - * start with this object's file (exclusive the trailing "-"). - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -654,11 +631,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thiz.implies(that)); } - /** - * ... If this object's file ends with a "/*", then codesource's file must - * start with this object's file and must not have any further "/" - * separators. - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -680,10 +652,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thiz.implies(that)); } - /** - * ... If this object's file doesn't end with a "/", then codesource's file - * must match this object's file with a '/' appended. - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", @@ -698,10 +666,6 @@ public class CodeSourceTest extends TestCase { assertFalse(thatCS.implies(thizCS)); } - /** - * If this object's reference (getLocation().getRef()) is not null, it must - * equal codesource's reference. - */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", diff --git a/luni/src/test/java/tests/api/javax/security/auth/SubjectTest.java b/luni/src/test/java/tests/api/javax/security/auth/SubjectTest.java index eac8edf..5ef39a3 100644 --- a/luni/src/test/java/tests/api/javax/security/auth/SubjectTest.java +++ b/luni/src/test/java/tests/api/javax/security/auth/SubjectTest.java @@ -39,9 +39,6 @@ import java.security.AccessControlContext; import java.security.AccessController; import java.security.ProtectionDomain; -import org.apache.harmony.security.tests.support.acl.PrincipalImpl; - - /** * Tests for <code>Subject</code> class constructors and methods. * @@ -71,82 +68,6 @@ public class SubjectTest extends TestCase { } /** - * @tests javax.security.auth.Subject#Subject(boolean readOnly, - * Set<? extends Principal> principals, - * Set<?> pubCredentials, - * Set<?> privCredentials) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "Subject", - args = {boolean.class, Set.class, Set.class, Set.class} - ) - public void test_Constructor_02() { - Set <Principal> principal = new HashSet<Principal>(); - Set <Object> pubCredentials = new HashSet<Object>(); - Set <Object> privCredentials = new HashSet<Object>(); - Principal pr1 = new PrincipalImpl("TestPrincipal1"); - Principal pr2 = new PrincipalImpl("TestPrincipal2"); - principal.add(pr1); - principal.add(pr2); - Object pubCredential1 = new Object(); - Object pubCredential2 = new Object(); - pubCredentials.add(pubCredential1); - pubCredentials.add(pubCredential2); - Object privCredential1 = new Object(); - Object privCredential2 = new Object(); - privCredentials.add(privCredential1); - privCredentials.add(privCredential2); - - try { - Subject s = new Subject(true, principal, pubCredentials, privCredentials); - assertNotNull("Null object returned", s); - assertTrue("Not read-only object", s.isReadOnly()); - assertFalse("Set of principal is empty", s.getPrincipals().isEmpty()); - assertFalse("Set of private credentials is empty", s.getPrivateCredentials().isEmpty()); - assertFalse("Set of public credentials is empty", s.getPublicCredentials().isEmpty()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - - try { - Subject s = new Subject(false, principal, pubCredentials, privCredentials); - assertNotNull("Null object returned", s); - assertFalse("Read-only object", s.isReadOnly()); - assertFalse("Set of principal is empty", s.getPrincipals().isEmpty()); - assertFalse("Set of private credentials is empty", s.getPrivateCredentials().isEmpty()); - assertFalse("Set of public credentials is empty", s.getPublicCredentials().isEmpty()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - - try { - Subject s = new Subject(true, null, pubCredentials, privCredentials); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - - try { - Subject s = new Subject(true, principal, null, privCredentials); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - - try { - Subject s = new Subject(true, principal, pubCredentials, null); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - - try { - Subject s = new Subject(true, null, null, null); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - } - - /** * @tests javax.security.auth.Subject#doAs(Subject subject, PrivilegedAction action) */ @TestTargetNew( @@ -309,161 +230,6 @@ public class SubjectTest extends TestCase { } /** - * @tests javax.security.auth.Subject#equals(Object o) - */ - @TestTargetNew( - level = TestLevel.SUFFICIENT, - notes = "SecurityException wasn't tested", - method = "equals", - args = {Object.class} - ) - public void test_equals() { - Set <Principal> principal = new HashSet<Principal>(); - Set <Principal> principal1 = new HashSet<Principal>(); - Set <Object> pubCredentials = new HashSet<Object>(); - Set <Object> privCredentials = new HashSet<Object>(); - Principal pr1 = new PrincipalImpl("TestPrincipal1"); - Principal pr2 = new PrincipalImpl("TestPrincipal2"); - principal.add(pr1); - principal.add(pr2); - principal1.add(pr1); - Object pubCredential1 = new Object(); - Object pubCredential2 = new Object(); - pubCredentials.add(pubCredential1); - pubCredentials.add(pubCredential2); - Object privCredential1 = new Object(); - Object privCredential2 = new Object(); - privCredentials.add(privCredential1); - privCredentials.add(privCredential2); - - Subject s1 = new Subject(true, principal, pubCredentials, privCredentials); - Subject s2 = new Subject(true, principal1, pubCredentials, privCredentials); - Subject s3 = new Subject(true, principal, pubCredentials, privCredentials); - - try { - assertTrue(s1.equals(s1)); - assertFalse(s1.equals(s2)); - assertTrue(s1.equals(s3)); - assertFalse(s1.equals(new Object())); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - } - - /** - * @tests javax.security.auth.Subject#getPrincipals() - * @tests javax.security.auth.Subject#getPrivateCredentials() - * @tests javax.security.auth.Subject#getPublicCredentials() - * @tests javax.security.auth.Subject#isReadOnly() - * @tests javax.security.auth.Subject#setReadOnly() - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPrincipals", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPrivateCredentials", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPublicCredentials", - args = {} - ) - }) - public void test_getPrincipals() { - Set <Principal> principal = new HashSet<Principal>(); - Set <Object> pubCredentials = new HashSet<Object>(); - Set <Object> privCredentials = new HashSet<Object>(); - Principal pr1 = new PrincipalImpl("TestPrincipal1"); - Principal pr2 = new PrincipalImpl("TestPrincipal2"); - principal.add(pr1); - principal.add(pr2); - Object pubCredential1 = new Object(); - pubCredentials.add(pubCredential1); - Object privCredential1 = new Object(); - Object privCredential2 = new Object(); - privCredentials.add(privCredential1); - privCredentials.add(privCredential2); - - Subject s = new Subject(false, principal, pubCredentials, privCredentials); - - try { - Set<Principal> pr = s.getPrincipals(); - assertNotNull(pr); - assertEquals(principal.size(), pr.size()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - - try { - Set<Object> privC = s.getPrivateCredentials(); - assertNotNull(privC); - assertEquals(privCredentials.size(), privC.size()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - - try { - Set<Object> pubC = s.getPublicCredentials(); - assertNotNull(pubC); - assertEquals(pubCredentials.size(), pubC.size()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - } - - /** - * @tests javax.security.auth.Subject#isReadOnly() - * @tests javax.security.auth.Subject#setReadOnly() - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isReadOnly", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setReadOnly", - args = {} - ) - }) - public void test_ReadOnly() { - Set <Principal> principal = new HashSet<Principal>(); - Set <Object> pubCredentials = new HashSet<Object>(); - Set <Object> privCredentials = new HashSet<Object>(); - Principal pr1 = new PrincipalImpl("TestPrincipal1"); - Principal pr2 = new PrincipalImpl("TestPrincipal2"); - principal.add(pr1); - principal.add(pr2); - Object pubCredential1 = new Object(); - pubCredentials.add(pubCredential1); - Object privCredential1 = new Object(); - Object privCredential2 = new Object(); - privCredentials.add(privCredential1); - privCredentials.add(privCredential2); - - Subject s = new Subject(false, principal, pubCredentials, privCredentials); - - try { - assertFalse(s.isReadOnly()); - s.setReadOnly(); - assertTrue(s.isReadOnly()); - } catch (Exception e) { - fail("Unexpected exception " + e); - } - } - - /** * @tests javax.security.auth.Subject#getSubject(AccessControlContext acc) */ @TestTargetNew( @@ -520,91 +286,6 @@ public class SubjectTest extends TestCase { fail("Unexpected exception: " + e); } } - - /** - * @tests javax.security.auth.Subject#getPrincipals(Class<T> c) - * @tests javax.security.auth.Subject#getPrivateCredentials(Class<T> c) - * @tests javax.security.auth.Subject#getPublicCredentials(Class<T> c) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPrincipals", - args = {Class.class} - ), - @TestTargetNew( - level = TestLevel.SUFFICIENT, - notes = "", - method = "getPrivateCredentials", - args = {Class.class} - ), - @TestTargetNew( - level = TestLevel.SUFFICIENT, - notes = "", - method = "getPublicCredentials", - args = {Class.class} - ) - }) - public void test_getPrincipals_Class() { - Set <Principal> principal = new HashSet<Principal>(); - Set <Object> pubCredentials = new HashSet<Object>(); - Set <Object> privCredentials = new HashSet<Object>(); - Principal pr1 = new PrincipalImpl("TestPrincipal1"); - Principal pr2 = new PrincipalImpl("TestPrincipal2"); - principal.add(pr1); - principal.add(pr2); - Object pubCredential1 = new Object(); - pubCredentials.add(pubCredential1); - Object privCredential1 = new Object(); - Object privCredential2 = new Object(); - privCredentials.add(privCredential1); - privCredentials.add(privCredential2); - - Subject s = new Subject(true, principal, pubCredentials, privCredentials); - - try { - Set<Principal> pr = s.getPrincipals(null); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - - try { - Set<Object> privC = s.getPrivateCredentials(null); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - - try { - Set<Object> pubC = s.getPublicCredentials(null); - fail("NullPointerException wasn't thrown"); - } catch (NullPointerException npe) { - } - - try { - Set<Principal> pr = s.getPrincipals(Principal.class); - assertNotNull(pr); - assertEquals(principal.size(), pr.size()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - - try { - Set<Object> privC = s.getPrivateCredentials(Object.class); - assertNotNull(privC); - assertEquals(privCredentials.size(), privC.size()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - - try { - Set<Object> pubC = s.getPublicCredentials(Object.class); - assertNotNull(pubC); - assertEquals(pubCredentials.size(), pubC.size()); - } catch (Exception e) { - fail("Unexpected exception: " + e); - } - } } diff --git a/luni/src/test/java/tests/security/acl/AllTests.java b/luni/src/test/java/tests/security/acl/AllTests.java index ef52a88..caf9675 100644 --- a/luni/src/test/java/tests/security/acl/AllTests.java +++ b/luni/src/test/java/tests/security/acl/AllTests.java @@ -34,11 +34,6 @@ public class AllTests { suite.addTestSuite(LastOwnerExceptionTest.class); suite.addTestSuite(NotOwnerException2Test.class); suite.addTestSuite(NotOwnerExceptionTest.class); - suite.addTestSuite(IPermissionTest.class); - suite.addTestSuite(IGroupTest.class); - suite.addTestSuite(IOwnerTest.class); - suite.addTestSuite(IAclEntryTest.class); - suite.addTestSuite(IAclTest.class); // $JUnit-END$ return suite; diff --git a/luni/src/test/java/tests/security/acl/IAclEntryTest.java b/luni/src/test/java/tests/security/acl/IAclEntryTest.java deleted file mode 100644 index 7547ee1..0000000 --- a/luni/src/test/java/tests/security/acl/IAclEntryTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 tests.security.acl; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.security.acl.AclEntry; -import java.security.acl.Permission; -import java.security.Principal; -import java.util.Enumeration; -import java.util.Vector; - -import org.apache.harmony.security.tests.support.acl.*; - -@TestTargetClass(AclEntry.class) -public class IAclEntryTest extends TestCase { - - class MyAclEntry extends AclEntryImpl { - public MyAclEntry() { - super(); - } - public MyAclEntry(Principal pr) { - super(pr); - } - } - - - /** - * @tests java.security.acl.AclEntry#addPermission(Permission permission) - * @tests java.security.acl.AclEntry#checkPermission(Permission permission) - * @tests java.security.acl.AclEntry#removePermission(Permission permission) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addPermission", - args = {java.security.acl.Permission.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "checkPermission", - args = {java.security.acl.Permission.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removePermission", - args = {java.security.acl.Permission.class} - ) - }) - public void test_AclEntry01() { - Permission perm = new PermissionImpl("Permission_1"); - MyAclEntry ae = new MyAclEntry(new PrincipalImpl("TestPrincipal")); - try { - assertTrue(ae.addPermission(perm)); - assertFalse(ae.addPermission(perm)); - assertTrue(ae.checkPermission(perm)); - assertTrue(ae.removePermission(perm)); - assertFalse(ae.removePermission(perm)); - assertFalse(ae.checkPermission(perm)); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.AclEntry#getPrincipal() - * @tests java.security.acl.AclEntry#setPrincipal(Principal user) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPrincipal", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setPrincipal", - args = {java.security.Principal.class} - ) - }) - public void test_AclEntry02() { - MyAclEntry ae = new MyAclEntry(); - Principal mp = new PrincipalImpl("TestPrincipal"); - try { - assertTrue(ae.setPrincipal(mp)); - Principal p = ae.getPrincipal(); - assertEquals("Names are not equal", p.getName(), mp.getName()); - assertFalse(ae.setPrincipal(mp)); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.AclEntry#setNegativePermissions() - * @tests java.security.acl.AclEntry#isNegative() - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setNegativePermissions", - args = {} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isNegative", - args = {} - ) - }) - public void test_AclEntry03() { - MyAclEntry ae = new MyAclEntry(new PrincipalImpl("TestPrincipal")); - try { - assertFalse("isNegative() returns TRUE",ae.isNegative()); - ae.setNegativePermissions(); - assertTrue("isNegative() returns FALSE", ae.isNegative()); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.AclEntry#permissions() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "permissions", - args = {} - ) - public void test_AclEntry04() { - MyAclEntry ae = new MyAclEntry(new PrincipalImpl("TestPrincipal")); - Permission perm = new PermissionImpl("Permission_1"); - try { - Enumeration en = ae.permissions(); - assertFalse("Not empty enumeration", en.hasMoreElements()); - ae.addPermission(perm); - en = ae.permissions(); - assertTrue("Eempty enumeration", en.hasMoreElements()); - Vector v = new Vector(); - while (en.hasMoreElements()) { - v.addElement(en.nextElement()); - } - assertEquals(v.size(), 1); - assertEquals(v.elementAt(0).toString(), perm.toString()); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.AclEntry#toString() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "toString", - args = {} - ) - public void test_AclEntry05() { - MyAclEntry ae = new MyAclEntry(new PrincipalImpl("TestPrincipal")); - try { - String res = ae.toString(); - assertTrue(res.contains("TestPrincipal")); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.AclEntry#clone() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "clone", - args = {} - ) - public void test_AclEntry06() { - MyAclEntry ae = new MyAclEntry(new PrincipalImpl("TestPrincipal")); - try { - assertEquals("Objects are not equal", ae.toString(), ae.clone().toString()); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } -}
\ No newline at end of file diff --git a/luni/src/test/java/tests/security/acl/IAclTest.java b/luni/src/test/java/tests/security/acl/IAclTest.java deleted file mode 100644 index 7ba31ec..0000000 --- a/luni/src/test/java/tests/security/acl/IAclTest.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 tests.security.acl; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.security.acl.Acl; -import java.security.acl.AclEntry; -import java.security.acl.NotOwnerException; -import java.security.acl.Permission; -import java.security.Principal; -import java.util.Enumeration; -import java.util.Vector; - -import org.apache.harmony.security.tests.support.acl.*; - -@TestTargetClass(Acl.class) -public class IAclTest extends TestCase { - - class MyAcl extends AclImpl { - public MyAcl(Principal principal, String str) { - super(principal, str); - } - } - - - /** - * @tests java.security.acl.Acl#addEntry(Principal caller, AclEntry entry) - * @tests java.security.acl.Acl#removeEntry(Principal caller, AclEntry entry) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addEntry", - args = {java.security.Principal.class, java.security.acl.AclEntry.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeEntry", - args = {java.security.Principal.class, java.security.acl.AclEntry.class} - ) - }) - public void test_Acl01() { - Principal pr = new PrincipalImpl("TestPrincipal"); - String str = "TestName"; - MyAcl acl = new MyAcl(pr, str); - AclEntry ae = new AclEntryImpl(pr); - try { - assertTrue(acl.addEntry(pr, ae)); - assertFalse(acl.addEntry(pr, ae)); - assertTrue(acl.removeEntry(pr, ae)); - assertFalse(acl.removeEntry(pr, ae)); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - - try { - acl.addEntry(new PrincipalImpl("NewPrincipal"), ae); - fail("NotOwnerException was not thrown"); - } catch (NotOwnerException noe) { - //expected - } - - try { - acl.removeEntry(new PrincipalImpl("NewPrincipal"), ae); - fail("NotOwnerException was not thrown"); - } catch (NotOwnerException noe) { - //expected - } - } - - /** - * @tests java.security.acl.Acl#setName(Principal caller, String name) - * @tests java.security.acl.Acl#getName() - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "setName", - args = {java.security.Principal.class, java.lang.String.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getName", - args = {} - ) - }) - public void test_Acl02() { - Principal pr = new PrincipalImpl("TestPrincipal"); - String str = "TestName"; - String newStr = "NewName"; - MyAcl acl = new MyAcl(pr, str); - try { - assertEquals("Names are not equal", str, acl.getName()); - acl.setName(pr, newStr); - assertEquals("Names are not equal", newStr, acl.getName()); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - - try { - acl.setName(new PrincipalImpl("NewPrincipal"), str); - fail("NotOwnerException was not thrown"); - } catch (NotOwnerException noe) { - //expected - } - } - - /** - * @tests java.security.acl.Acl#toString() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "toString", - args = {} - ) - public void test_Acl03() { - Principal pr = new PrincipalImpl("TestPrincipal"); - String str = "TestName"; - MyAcl acl = new MyAcl(pr, str); - AclEntry ae = new AclEntryImpl(pr); - Permission perm = new PermissionImpl("Permission_1"); - try { - ae.addPermission(perm); - acl.addEntry(pr, ae); - String res = acl.toString(); - assertTrue(res.contains(perm.toString())); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.Acl#entries() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "entries", - args = {} - ) - public void test_Acl04() { - Principal pr = new PrincipalImpl("TestPrincipal"); - String str = "TestName"; - MyAcl acl = new MyAcl(pr, str); - AclEntry ae1 = new AclEntryImpl(pr); - try { - ae1.addPermission(new PermissionImpl("Permission_1")); - acl.addEntry(pr, ae1); - Enumeration en = acl.entries(); - Vector v = new Vector(); - while (en.hasMoreElements()) { - v.addElement(en.nextElement()); - } - assertEquals(v.size(), 1); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.Acl#checkPermission(Principal principal, Permission permission) - * @tests java.security.acl.Acl#getPermissions(Principal principal) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "checkPermission", - args = {java.security.Principal.class, java.security.acl.Permission.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "getPermissions", - args = {java.security.Principal.class} - ) - }) - public void test_Acl05() { - Principal pr = new PrincipalImpl("TestPrincipal"); - String str = "TestName"; - MyAcl acl = new MyAcl(pr, str); - AclEntry ae = new AclEntryImpl(pr); - Permission perm = new PermissionImpl("Permission_1"); - try { - ae.addPermission(perm); - acl.addEntry(pr, ae); - - //checkPermission verification - assertTrue("Incorrect permission", acl.checkPermission(pr, perm)); - assertFalse(acl.checkPermission(pr, new PermissionImpl("Permission_2"))); - - //getPermissions - Enumeration en = acl.getPermissions(pr); - Vector v = new Vector(); - while (en.hasMoreElements()) { - v.addElement(en.nextElement()); - } - assertEquals(v.size(), 1); - assertEquals(v.elementAt(0).toString(), perm.toString()); - } catch (Exception ex) { - fail("Exception " + ex + " was thrown"); - } - } -}
\ No newline at end of file diff --git a/luni/src/test/java/tests/security/acl/IGroupTest.java b/luni/src/test/java/tests/security/acl/IGroupTest.java deleted file mode 100644 index 17dbd8c..0000000 --- a/luni/src/test/java/tests/security/acl/IGroupTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 tests.security.acl; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.security.acl.Group; -import java.security.Principal; -import java.util.Enumeration; - -import org.apache.harmony.security.tests.support.acl.*; - -@TestTargetClass(Group.class) -public class IGroupTest extends TestCase { - - class MyGroup extends GroupImpl { - public MyGroup(String str) { - super(str); - } - } - - /** - * @tests java.security.acl.Group#addMember(Principal user) - */ - @TestTargets({ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addMember", - args = {java.security.Principal.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isMember", - args = {java.security.Principal.class} - ), - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "removeMember", - args = {java.security.Principal.class} - ) - }) - public void test_addMember() { - MyGroup gr = new MyGroup("TestOwners"); - Principal pr = new PrincipalImpl("TestPrincipal"); - try { - assertTrue(gr.addMember(pr)); - assertFalse(gr.addMember(pr)); - assertTrue(gr.isMember(pr)); - assertTrue(gr.removeMember(pr)); - assertFalse(gr.isMember(pr)); - assertFalse(gr.removeMember(pr)); - } catch (Exception e) { - fail("Unexpected exception " + e); - } - } - - /** - * @tests java.security.acl.Group#members() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "members", - args = {} - ) - public void test_members() { - MyGroup gr = new MyGroup("TestOwners"); - Principal pr = new PrincipalImpl("TestPrincipal"); - try { - Enumeration en = gr.members(); - assertFalse("Not empty enumeration", en.hasMoreElements()); - assertTrue(gr.addMember(pr)); - assertTrue("Empty enumeration", en.hasMoreElements()); - } catch (Exception e) { - fail("Unexpected exception " + e); - } - } -}
\ No newline at end of file diff --git a/luni/src/test/java/tests/security/acl/IOwnerTest.java b/luni/src/test/java/tests/security/acl/IOwnerTest.java deleted file mode 100644 index c0707d0..0000000 --- a/luni/src/test/java/tests/security/acl/IOwnerTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 tests.security.acl; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.security.acl.Owner; -import java.security.Principal; -import java.security.acl.NotOwnerException; -import java.security.acl.LastOwnerException; - -import org.apache.harmony.security.tests.support.acl.*; - -@TestTargetClass(Owner.class) -public class IOwnerTest extends TestCase { - - class MyOwner extends OwnerImpl { - public MyOwner(Principal pr) { - super(pr); - } - } - - /** - * @tests java.security.acl.Owner#isOwner(Principal owner) - * - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "isOwner", - args = {java.security.Principal.class} - ) - public void test_isOwner() { - MyOwner mo = new MyOwner(new PrincipalImpl("NewOwner")); - try { - assertFalse("Method returns TRUE", mo.isOwner(new PrincipalImpl("TestOwner"))); - assertTrue("Method returns FALSE", mo.isOwner(new PrincipalImpl("NewOwner"))); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - } - - /** - * @tests java.security.acl.Owner#addOwner(Principal caller, Principal owner) - * - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "addOwner", - args = {java.security.Principal.class, java.security.Principal.class} - ) - public void test_addOwner() { - Principal p1 = new PrincipalImpl("Owner"); - Principal p2 = new PrincipalImpl("AclOwner"); - Principal pt = new PrincipalImpl("NewOwner"); - MyOwner mo = new MyOwner(p1); - try { - //add new owner - TRUE expected - assertTrue("Method returns FALSE", mo.addOwner(p1, pt)); - //add existent owner - FALSE expected - assertFalse("Method returns TRUE", mo.addOwner(p1, pt)); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - //exception case - try { - mo.addOwner(p2, pt); - fail("NotOwnerException was not thrown"); - } catch (NotOwnerException noe) { - //expected - } - } - - /** - * @tests java.security.acl.Owner#deleteOwner(Principal caller, Principal owner) - * - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "deleteOwner", - args = {java.security.Principal.class, java.security.Principal.class} - ) - public void test_deleteOwner() { - Principal caller = new PrincipalImpl("Owner"); - Principal owner1 = new PrincipalImpl("NewOwner1"); - Principal owner2 = new PrincipalImpl("NewOwner2"); - Principal notCaller = new PrincipalImpl("AclOwner"); - MyOwner mo = new MyOwner(caller); - - try { - if (!mo.isOwner(owner1)) mo.addOwner(caller, owner1); - if (!mo.isOwner(owner2)) mo.addOwner(caller, owner2); - } catch (Exception e) { - fail("Unexpected exception " + e + " was thrown for addOwner"); - } - - try { - //remove existent owner - TRUE expected - assertTrue("Method returns FALSE", mo.deleteOwner(caller, owner1)); - assertFalse("Object presents in the owner list", mo.isOwner(owner1)); - //remove owner which is not part of the list of owners - FALSE expected - assertFalse("Method returns TRUE", mo.deleteOwner(caller, owner1)); - assertTrue("Method returns FALSE", mo.deleteOwner(caller, owner2)); - } catch (Exception ex) { - fail("Unexpected exception " + ex); - } - //exception case - NotOwnerException - try { - mo.deleteOwner(notCaller, owner1); - fail("NotOwnerException was not thrown"); - } catch (NotOwnerException noe) { - //expected - } catch (Exception e) { - fail(e + " was thrown instead of NotOwnerException"); - } - //exception case - LastOwnerException - try { - mo.deleteOwner(caller, owner2); - fail("LastOwnerException was not thrown"); - } catch (LastOwnerException loe) { - //expected - } catch (Exception e) { - fail(e + " was thrown instead of LastOwnerException"); - } - } -}
\ No newline at end of file diff --git a/luni/src/test/java/tests/security/acl/IPermissionTest.java b/luni/src/test/java/tests/security/acl/IPermissionTest.java deleted file mode 100644 index 4a1e6f1..0000000 --- a/luni/src/test/java/tests/security/acl/IPermissionTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 tests.security.acl; - -import dalvik.annotation.TestTargets; -import dalvik.annotation.TestLevel; -import dalvik.annotation.TestTargetNew; -import dalvik.annotation.TestTargetClass; - -import junit.framework.TestCase; - -import java.security.acl.Permission; - -import org.apache.harmony.security.tests.support.acl.*; - -@TestTargetClass(Permission.class) -public class IPermissionTest extends TestCase { - - class MyPermission extends PermissionImpl { - public MyPermission(String str) { - super(str); - } - } - - /** - * @tests java.security.acl.Permission#equals(Object another) - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "equals", - args = {java.lang.Object.class} - ) - public void test_equals() { - try { - MyPermission mp1 = new MyPermission("TestPermission"); - MyPermission mp2 = new MyPermission("NewTestPermission"); - Object another = new Object(); - assertFalse(mp1.equals(another)); - assertFalse(mp1.equals(mp2)); - assertTrue(mp1.equals(new MyPermission("TestPermission"))); - } catch (Exception e) { - fail("Unexpected exception - subtest1"); - } - } - - /** - * @tests java.security.acl.Permission#toString() - */ - @TestTargetNew( - level = TestLevel.COMPLETE, - notes = "", - method = "toString", - args = {} - ) - public void test_toString() { - try { - MyPermission obj = new MyPermission("TestPermission"); - String res = obj.toString(); - assertEquals(res, "TestPermission"); - } catch (Exception e) { - fail("Unexpected exception - subtest2"); - } - } -}
\ No newline at end of file diff --git a/luni/src/test/java/tests/security/cert/CollectionCertStoreParametersTest.java b/luni/src/test/java/tests/security/cert/CollectionCertStoreParametersTest.java index 2ebd12b..b194c70 100644 --- a/luni/src/test/java/tests/security/cert/CollectionCertStoreParametersTest.java +++ b/luni/src/test/java/tests/security/cert/CollectionCertStoreParametersTest.java @@ -36,9 +36,9 @@ import java.util.Collection; import java.util.Vector; import org.apache.harmony.security.tests.support.cert.MyCertificate; + /** - * Tests for <code>CollectionCertStoreParameters</code> - * + * Tests for <code>CollectionCertStoreParameters</code>. */ @TestTargetClass(CollectionCertStoreParameters.class) public class CollectionCertStoreParametersTest extends TestCase { @@ -49,8 +49,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #1 for <code>CollectionCertStoreParameters()</code> constructor<br> - * Assertion: Creates an instance of CollectionCertStoreParameters - * with the default parameter values (an empty and immutable Collection) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -66,8 +64,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #2 for <code>CollectionCertStoreParameters</code> constructor<br> - * Assertion: Creates an instance of CollectionCertStoreParameters - * with the default parameter values (an empty and immutable Collection) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -93,7 +89,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #1 for <code>CollectionCertStoreParameters(Collection)</code> * constructor<br> - * Assertion: Creates an instance of CollectionCertStoreParameters */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -110,9 +105,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #2 for <code>CollectionCertStoreParameters(Collection)</code> * constructor<br> - * Assertion: If the specified <code>Collection</code> contains an object - * that is not a <code>Certificate</code> or <code>CRL</code>, that object - * will be ignored by the Collection <code>CertStore</code>. */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -132,11 +124,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #3 for <code>CollectionCertStoreParameters(Collection)</code> * constructor<br> - * Assertion: The Collection is not copied. Instead, a reference is used. - * This allows the caller to subsequently add or remove Certificates or - * CRLs from the Collection, thus changing the set of Certificates or CRLs - * available to the Collection CertStore. The Collection CertStore will - * not modify the contents of the Collection */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -163,8 +150,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #4 for <code>CollectionCertStoreParameters(Collection)</code> * constructor<br> - * Assertion: <code>NullPointerException</code> - if - * <code>collection</code> is <code>null</code> */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -182,7 +167,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #1 for <code>clone()</code> method<br> - * Assertion: Returns a copy of this object */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -203,8 +187,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #2 for <code>clone()</code> method<br> - * Assertion: ...only a reference to the <code>Collection</code> - * is copied, and not the contents */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -225,8 +207,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #3 for <code>clone()</code> method<br> - * Assertion: ...only a reference to the <code>Collection</code> - * is copied, and not the contents */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -248,7 +228,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #1 for <code>toString()</code> method<br> - * Assertion: returns the formatted string describing parameters */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -265,7 +244,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #2 for <code>toString()</code> method<br> - * Assertion: returns the formatted string describing parameters */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -284,7 +262,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #1 for <code>getCollection()</code> method<br> - * Assertion: returns the Collection (never null) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, @@ -299,7 +276,6 @@ public class CollectionCertStoreParametersTest extends TestCase { /** * Test #2 for <code>getCollection()</code> method<br> - * Assertion: returns the Collection (never null) */ @TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, |