summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2011-01-13 12:46:28 -0800
committerDan Bornstein <danfuzz@android.com>2011-01-13 12:46:28 -0800
commit80a30431fa6c92433d2602c159bc71dd81c62c8f (patch)
tree19b1fe52124459ed71c002176c6ebbcb31962ba8
parent886130bc7ff992940e152636f57072e58c91aa2e (diff)
downloaddalvik-80a30431fa6c92433d2602c159bc71dd81c62c8f.tar.gz
Remove some pointless tests.
Change-Id: Ibaaf74fbdffd6c08af48cac50ef62a05e8473899
-rw-r--r--libcore/security/src/test/java/tests/api/javax/security/auth/SubjectTest.java528
-rw-r--r--libcore/security/src/test/java/tests/security/acl/AllTests.java5
-rw-r--r--libcore/security/src/test/java/tests/security/acl/IAclEntryTest.java213
-rw-r--r--libcore/security/src/test/java/tests/security/acl/IAclTest.java230
-rw-r--r--libcore/security/src/test/java/tests/security/acl/IGroupTest.java101
-rw-r--r--libcore/security/src/test/java/tests/security/acl/IOwnerTest.java148
-rw-r--r--libcore/security/src/test/java/tests/security/acl/IPermissionTest.java80
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java118
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java51
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java211
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java112
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java69
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java49
-rw-r--r--libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java53
14 files changed, 30 insertions, 1938 deletions
diff --git a/libcore/security/src/test/java/tests/api/javax/security/auth/SubjectTest.java b/libcore/security/src/test/java/tests/api/javax/security/auth/SubjectTest.java
index 21929bf7a..f545276b2 100644
--- a/libcore/security/src/test/java/tests/api/javax/security/auth/SubjectTest.java
+++ b/libcore/security/src/test/java/tests/api/javax/security/auth/SubjectTest.java
@@ -39,16 +39,13 @@ 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.
- *
+ *
*/
-@TestTargetClass(Subject.class)
+@TestTargetClass(Subject.class)
public class SubjectTest extends TestCase {
-
+
SecurityManager old;
@Override
@@ -64,7 +61,7 @@ public class SubjectTest extends TestCase {
}
/**
- * @tests javax.security.auth.Subject#Subject()
+ * @tests javax.security.auth.Subject#Subject()
*/
@TestTargetNew(
level = TestLevel.COMPLETE,
@@ -83,83 +80,7 @@ public class SubjectTest extends TestCase {
fail("Unexpected exception: " + e);
}
}
-
- /**
- * @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)
*/
@@ -173,44 +94,26 @@ public class SubjectTest extends TestCase {
Subject subj = new Subject();
PrivilegedAction<Object> pa = new myPrivilegedAction();
PrivilegedAction<Object> paNull = null;
-
+
try {
Object obj = Subject.doAs(null, pa);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAs(subj, pa);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAs(subj, paNull);
fail("NullPointerException wasn't thrown");
} catch (NullPointerException npe) {
}
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "doAs".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- Object obj = Subject.doAs(subj, pa);
- fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- }
}
-
+
/**
* @tests javax.security.auth.Subject#doAs(Subject subject, PrivilegedExceptionAction action)
*/
@@ -224,19 +127,19 @@ public class SubjectTest extends TestCase {
Subject subj = new Subject();
PrivilegedExceptionAction<Object> pea = new myPrivilegedExceptionAction();
PrivilegedExceptionAction<Object> peaNull = null;
-
+
try {
Object obj = Subject.doAs(null, pea);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAs(subj, pea);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAs(subj, peaNull);
fail("NullPointerException wasn't thrown");
@@ -244,7 +147,7 @@ public class SubjectTest extends TestCase {
} catch (Exception e) {
fail(e + " was thrown instead of NullPointerException");
}
-
+
try {
Subject.doAs(subj, new PrivilegedExceptionAction<Object>(){
public Object run() throws PrivilegedActionException {
@@ -254,30 +157,10 @@ public class SubjectTest extends TestCase {
fail("PrivilegedActionException wasn't thrown");
} catch (PrivilegedActionException e) {
}
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "doAs".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- Object obj = Subject.doAs(subj, pea);
- fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- } catch (Exception e) {
- fail(e + " was thrown instead of SecurityException");
- }
}
-
+
/**
- * @tests javax.security.auth.Subject#doAsPrivileged(Subject subject,
+ * @tests javax.security.auth.Subject#doAsPrivileged(Subject subject,
* PrivilegedAction action,
* AccessControlContext acc)
*/
@@ -292,46 +175,28 @@ public class SubjectTest extends TestCase {
PrivilegedAction<Object> pa = new myPrivilegedAction();
PrivilegedAction<Object> paNull = null;
AccessControlContext acc = AccessController.getContext();
-
+
try {
Object obj = Subject.doAsPrivileged(null, pa, acc);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAsPrivileged(subj, pa, acc);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAsPrivileged(subj, paNull, acc);
fail("NullPointerException wasn't thrown");
} catch (NullPointerException npe) {
}
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "doAsPrivileged".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- Object obj = Subject.doAsPrivileged(subj, pa, acc);
- fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- }
}
-
+
/**
- * @tests javax.security.auth.Subject#doAsPrivileged(Subject subject,
+ * @tests javax.security.auth.Subject#doAsPrivileged(Subject subject,
* PrivilegedExceptionAction action,
* AccessControlContext acc)
*/
@@ -346,19 +211,19 @@ public class SubjectTest extends TestCase {
PrivilegedExceptionAction<Object> pea = new myPrivilegedExceptionAction();
PrivilegedExceptionAction<Object> peaNull = null;
AccessControlContext acc = AccessController.getContext();
-
+
try {
Object obj = Subject.doAsPrivileged(null, pea, acc);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAsPrivileged(subj, pea, acc);
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
+
try {
Object obj = Subject.doAsPrivileged(subj, peaNull, acc);
fail("NullPointerException wasn't thrown");
@@ -366,7 +231,7 @@ public class SubjectTest extends TestCase {
} catch (Exception e) {
fail(e + " was thrown instead of NullPointerException");
}
-
+
try {
Subject.doAsPrivileged(subj, new PrivilegedExceptionAction<Object>(){
public Object run() throws PrivilegedActionException {
@@ -376,220 +241,8 @@ public class SubjectTest extends TestCase {
fail("PrivilegedActionException wasn't thrown");
} catch (PrivilegedActionException e) {
}
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "doAsPrivileged".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- Object obj = Subject.doAsPrivileged(subj, pea, acc);
- fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- } catch (Exception e) {
- fail(e + " was thrown instead of SecurityException");
- }
- }
-
- /**
- * @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);
- }
-
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof PrivateCredentialPermission
- && "equals".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- s1.equals(s1);
- //fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- }
- }
-
- /**
- * @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);
- }
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "setReadOnly".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager ss = new TestSecurityManager();
- System.setSecurityManager(ss);
- try {
- s.setReadOnly();
- fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- }
}
-
+
/**
* @tests javax.security.auth.Subject#getSubject(AccessControlContext acc)
*/
@@ -602,32 +255,14 @@ public class SubjectTest extends TestCase {
public void test_getSubject() {
Subject subj = new Subject();
AccessControlContext acc = new AccessControlContext(new ProtectionDomain[0]);
-
+
try {
assertNull(Subject.getSubject(acc));
} catch (Exception e) {
fail("Unexpected exception " + e);
}
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "getSubject".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- Subject.getSubject(acc);
- fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- }
}
-
+
/**
* @tests javax.security.auth.Subject#toString()
*/
@@ -639,14 +274,14 @@ public class SubjectTest extends TestCase {
)
public void test_toString() {
Subject subj = new Subject();
-
+
try {
assertNotNull("Null returned", subj.toString());
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
}
-
+
/**
* @tests javax.security.auth.Subject#hashCode()
*/
@@ -658,115 +293,12 @@ public class SubjectTest extends TestCase {
)
public void test_hashCode() {
Subject subj = new Subject();
-
+
try {
assertNotNull("Null returned", subj.hashCode());
} catch (Exception e) {
fail("Unexpected exception: " + e);
}
-
- class TestSecurityManager extends SecurityManager {
- @Override
- public void checkPermission(Permission permission) {
- if (permission instanceof AuthPermission
- && "hashCode".equals(permission.getName())) {
- throw new SecurityException();
- }
- super.checkPermission(permission);
- }
- }
- TestSecurityManager s = new TestSecurityManager();
- System.setSecurityManager(s);
- try {
- subj.hashCode();
- //fail("SecurityException wasn't thrown");
- } catch (SecurityException se) {
- }
- }
-
- /**
- * @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/libcore/security/src/test/java/tests/security/acl/AllTests.java b/libcore/security/src/test/java/tests/security/acl/AllTests.java
index 4b939803e..e832f427c 100644
--- a/libcore/security/src/test/java/tests/security/acl/AllTests.java
+++ b/libcore/security/src/test/java/tests/security/acl/AllTests.java
@@ -39,11 +39,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/libcore/security/src/test/java/tests/security/acl/IAclEntryTest.java b/libcore/security/src/test/java/tests/security/acl/IAclEntryTest.java
deleted file mode 100644
index 94ddf1441..000000000
--- a/libcore/security/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/libcore/security/src/test/java/tests/security/acl/IAclTest.java b/libcore/security/src/test/java/tests/security/acl/IAclTest.java
deleted file mode 100644
index 65cb9717b..000000000
--- a/libcore/security/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/libcore/security/src/test/java/tests/security/acl/IGroupTest.java b/libcore/security/src/test/java/tests/security/acl/IGroupTest.java
deleted file mode 100644
index 47eac932c..000000000
--- a/libcore/security/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/libcore/security/src/test/java/tests/security/acl/IOwnerTest.java b/libcore/security/src/test/java/tests/security/acl/IOwnerTest.java
deleted file mode 100644
index 3cb222dfa..000000000
--- a/libcore/security/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/libcore/security/src/test/java/tests/security/acl/IPermissionTest.java b/libcore/security/src/test/java/tests/security/acl/IPermissionTest.java
deleted file mode 100644
index 17cd7a9f5..000000000
--- a/libcore/security/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/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java
deleted file mode 100644
index 3d922dfb0..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java
+++ /dev/null
@@ -1,118 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Additional class for verification AclEntry interface
- */
-public class AclEntryImpl implements AclEntry {
-
- private Principal user;
- private Vector permissionSet;
- private boolean negative;
-
- public AclEntryImpl(Principal principal) {
- user = null;
- permissionSet = new Vector(10, 10);
- negative = false;
- user = principal;
- }
-
- public AclEntryImpl() {
- user = null;
- permissionSet = new Vector(10, 10);
- negative = false;
- }
-
- public boolean setPrincipal(Principal principal) {
- if(user != null) {
- return false;
- } else {
- user = principal;
- return true;
- }
- }
-
- public void setNegativePermissions() {
- negative = true;
- }
-
- public boolean isNegative() {
- return negative;
- }
-
- public boolean addPermission(Permission permission) {
- if(permissionSet.contains(permission)) {
- return false;
- } else {
- permissionSet.addElement(permission);
- return true;
- }
- }
-
- public boolean removePermission(Permission permission) {
- return permissionSet.removeElement(permission);
- }
-
- public boolean checkPermission(Permission permission) {
- return permissionSet.contains(permission);
- }
-
- public Enumeration permissions() {
- return permissionSet.elements();
- }
-
- public String toString() {
- StringBuffer stringbuffer = new StringBuffer();
- if(negative)
- stringbuffer.append("-");
- else
- stringbuffer.append("+");
- if(user instanceof Group)
- stringbuffer.append("Group.");
- else
- stringbuffer.append("User.");
- stringbuffer.append((new StringBuilder()).append(user).append("=").toString());
- Enumeration enumeration = permissions();
- do {
- if(!enumeration.hasMoreElements())
- break;
- Permission permission = (Permission)enumeration.nextElement();
- stringbuffer.append(permission);
- if(enumeration.hasMoreElements())
- stringbuffer.append(",");
- } while(true);
- return new String(stringbuffer);
- }
-
- public synchronized Object clone() {
- AclEntryImpl aclentryimpl = new AclEntryImpl(user);
- aclentryimpl.permissionSet = (Vector)permissionSet.clone();
- aclentryimpl.negative = negative;
- return aclentryimpl;
- }
-
- public Principal getPrincipal() {
- return user;
- }
-} \ No newline at end of file
diff --git a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java
deleted file mode 100644
index df093cd35..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java
+++ /dev/null
@@ -1,51 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.acl.Acl;
-import java.util.*;
-
-final class AclEnumerator implements Enumeration {
-
- Acl acl;
- Enumeration u1;
- Enumeration u2;
- Enumeration g1;
- Enumeration g2;
-
- AclEnumerator(Acl acl1, Hashtable hashtable, Hashtable hashtable1, Hashtable hashtable2, Hashtable hashtable3) {
- acl = acl1;
- u1 = hashtable.elements();
- u2 = hashtable2.elements();
- g1 = hashtable1.elements();
- g2 = hashtable3.elements();
- }
-
- public boolean hasMoreElements() {
- return u1.hasMoreElements() || u2.hasMoreElements() || g1.hasMoreElements() || g2.hasMoreElements();
- }
-
- public Object nextElement() {
- Acl acl1 = acl;
- if(u2.hasMoreElements()) return u2.nextElement();
- if(g1.hasMoreElements()) return g1.nextElement();
- if(u1.hasMoreElements()) return u1.nextElement();
- if(g2.hasMoreElements()) return g2.nextElement();
- return acl1;
- }
-} \ No newline at end of file
diff --git a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java
deleted file mode 100644
index 17c20f9ed..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java
+++ /dev/null
@@ -1,211 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-import java.util.*;
-
-/**
- * Additional class for verification Acl interface
- */
-public class AclImpl extends OwnerImpl implements Acl {
-
- private Hashtable allowedUsersTable;
- private Hashtable allowedGroupsTable;
- private Hashtable deniedUsersTable;
- private Hashtable deniedGroupsTable;
- private String aclName;
- private Vector zeroSet;
-
- public AclImpl(Principal principal, String s) {
- super(principal);
- allowedUsersTable = new Hashtable(23);
- allowedGroupsTable = new Hashtable(23);
- deniedUsersTable = new Hashtable(23);
- deniedGroupsTable = new Hashtable(23);
- aclName = null;
- zeroSet = new Vector(1, 1);
- try {
- setName(principal, s);
- } catch(Exception exception) { }
- }
-
- public void setName(Principal principal, String s)
- throws NotOwnerException {
- if(!isOwner(principal)) {
- throw new NotOwnerException();
- } else {
- aclName = s;
- return;
- }
- }
-
- public String getName() {
- return aclName;
- }
-
- public synchronized boolean addEntry(Principal principal, AclEntry aclentry)
- throws NotOwnerException {
- if(!isOwner(principal)) throw new NotOwnerException();
- Hashtable hashtable = findTable(aclentry);
- Principal principal1 = aclentry.getPrincipal();
- if(hashtable.get(principal1) != null) {
- return false;
- } else {
- hashtable.put(principal1, aclentry);
- return true;
- }
- }
-
- public synchronized boolean removeEntry(Principal principal, AclEntry aclentry)
- throws NotOwnerException {
- if(!isOwner(principal)) {
- throw new NotOwnerException();
- } else {
- Hashtable hashtable = findTable(aclentry);
- Principal principal1 = aclentry.getPrincipal();
- Object obj = hashtable.remove(principal1);
- return obj != null;
- }
- }
-
- public synchronized Enumeration getPermissions(Principal principal) {
- Enumeration enumeration2 = subtract(getGroupPositive(principal), getGroupNegative(principal));
- Enumeration enumeration3 = subtract(getGroupNegative(principal), getGroupPositive(principal));
- Enumeration enumeration = subtract(getIndividualPositive(principal), getIndividualNegative(principal));
- Enumeration enumeration1 = subtract(getIndividualNegative(principal), getIndividualPositive(principal));
- Enumeration enumeration4 = subtract(enumeration2, enumeration1);
- Enumeration enumeration5 = union(enumeration, enumeration4);
- enumeration = subtract(getIndividualPositive(principal), getIndividualNegative(principal));
- enumeration1 = subtract(getIndividualNegative(principal), getIndividualPositive(principal));
- enumeration4 = subtract(enumeration3, enumeration);
- Enumeration enumeration6 = union(enumeration1, enumeration4);
- return subtract(enumeration5, enumeration6);
- }
-
- public boolean checkPermission(Principal principal, Permission permission) {
- for(Enumeration enumeration = getPermissions(principal); enumeration.hasMoreElements();) {
- Permission permission1 = (Permission)enumeration.nextElement();
- if(permission1.equals(permission))
- return true;
- }
- return false;
- }
-
- public synchronized Enumeration entries() {
- return new AclEnumerator(this, allowedUsersTable, allowedGroupsTable, deniedUsersTable, deniedGroupsTable);
- }
-
- public String toString() {
- StringBuffer stringbuffer = new StringBuffer();
- for(Enumeration enumeration = entries(); enumeration.hasMoreElements(); stringbuffer.append("\n")) {
- AclEntry aclentry = (AclEntry)enumeration.nextElement();
- stringbuffer.append(aclentry.toString().trim());
- }
- return stringbuffer.toString();
- }
-
- private Hashtable findTable(AclEntry aclentry) {
- Hashtable hashtable = null;
- Principal principal = aclentry.getPrincipal();
- if(principal instanceof Group) {
- if(aclentry.isNegative())
- hashtable = deniedGroupsTable;
- else
- hashtable = allowedGroupsTable;
- } else
- if(aclentry.isNegative())
- hashtable = deniedUsersTable;
- else
- hashtable = allowedUsersTable;
- return hashtable;
- }
-
- private static Enumeration union(Enumeration enumeration, Enumeration enumeration1) {
- Vector vector = new Vector(20, 20);
- for(; enumeration.hasMoreElements(); vector.addElement(enumeration.nextElement()));
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Object obj = enumeration1.nextElement();
- if(!vector.contains(obj))
- vector.addElement(obj);
- } while(true);
- return vector.elements();
- }
-
- private Enumeration subtract(Enumeration enumeration, Enumeration enumeration1) {
- Vector vector = new Vector(20, 20);
- for(; enumeration.hasMoreElements(); vector.addElement(enumeration.nextElement()));
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Object obj = enumeration1.nextElement();
- if(vector.contains(obj))
- vector.removeElement(obj);
- } while(true);
- return vector.elements();
- }
-
- private Enumeration getGroupPositive(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- Enumeration enumeration1 = allowedGroupsTable.keys();
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Group group = (Group)enumeration1.nextElement();
- if(group.isMember(principal)) {
- AclEntry aclentry = (AclEntry)allowedGroupsTable.get(group);
- enumeration = union(aclentry.permissions(), enumeration);
- }
- } while(true);
- return enumeration;
- }
-
- private Enumeration getGroupNegative(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- Enumeration enumeration1 = deniedGroupsTable.keys();
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Group group = (Group)enumeration1.nextElement();
- if(group.isMember(principal)) {
- AclEntry aclentry = (AclEntry)deniedGroupsTable.get(group);
- enumeration = union(aclentry.permissions(), enumeration);
- }
- } while(true);
- return enumeration;
- }
-
- private Enumeration getIndividualPositive(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- AclEntry aclentry = (AclEntry)allowedUsersTable.get(principal);
- if(aclentry != null)
- enumeration = aclentry.permissions();
- return enumeration;
- }
-
- private Enumeration getIndividualNegative(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- AclEntry aclentry = (AclEntry)deniedUsersTable.get(principal);
- if(aclentry != null)
- enumeration = aclentry.permissions();
- return enumeration;
- }
-} \ No newline at end of file
diff --git a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java
deleted file mode 100644
index fe910fbd9..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java
+++ /dev/null
@@ -1,112 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Additional class for verification Group interface
- */
-public class GroupImpl implements Group {
-
- private Vector groupMembers;
- private String group;
-
- public GroupImpl(String s) {
- groupMembers = new Vector(50, 100);
- group = s;
- }
-
- public boolean addMember(Principal principal) {
- if(groupMembers.contains(principal))
- return false;
- if(group.equals(principal.toString())) {
- throw new IllegalArgumentException();
- } else {
- groupMembers.addElement(principal);
- return true;
- }
- }
-
- public boolean removeMember(Principal principal) {
- return groupMembers.removeElement(principal);
- }
-
- public Enumeration members() {
- return groupMembers.elements();
- }
-
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(!(obj instanceof Group)) {
- return false;
- } else {
- Group group1 = (Group)obj;
- return group.equals(group1.toString());
- }
- }
-
- public boolean equals(Group group1) {
- return equals(group1);
- }
-
- public String toString() {
- return group;
- }
-
- public int hashCode() {
- return group.hashCode();
- }
-
- public boolean isMember(Principal principal) {
- if(groupMembers.contains(principal)) {
- return true;
- } else {
- Vector vector = new Vector(10);
- return isMemberRecurse(principal, vector);
- }
- }
-
- public String getName() {
- return group;
- }
-
- boolean isMemberRecurse(Principal principal, Vector vector) {
- for(Enumeration enumeration = members(); enumeration.hasMoreElements();) {
- boolean flag = false;
- Principal principal1 = (Principal)enumeration.nextElement();
- if(principal1.equals(principal))
- return true;
- if(principal1 instanceof GroupImpl) {
- GroupImpl groupimpl = (GroupImpl)principal1;
- vector.addElement(this);
- if(!vector.contains(groupimpl))
- flag = groupimpl.isMemberRecurse(principal, vector);
- } else if(principal1 instanceof Group) {
- Group group1 = (Group)principal1;
- if(!vector.contains(group1)) flag = group1.isMember(principal);
- }
- if(flag) return flag;
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java
deleted file mode 100644
index c3012b6d3..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java
+++ /dev/null
@@ -1,69 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-import java.util.Enumeration;
-
-/**
- * Additional class for verification Owner interface
- */
-public class OwnerImpl implements Owner {
-
- private Group ownerGroup;
-
- public OwnerImpl(Principal principal) {
- ownerGroup = new GroupImpl("AclOwners");
- ownerGroup.addMember(principal);
- }
-
- public synchronized boolean addOwner(Principal principal, Principal principal1)
- throws NotOwnerException {
-
- if(!isOwner(principal))
- {
- throw new NotOwnerException();
- } else {
- if (ownerGroup.isMember(principal1)) return false;
- if (!ownerGroup.isMember(principal1)) {
- ownerGroup.addMember(principal1);
- return true;
- }
- }
- return false;
- }
-
- public synchronized boolean deleteOwner(Principal principal, Principal principal1)
- throws NotOwnerException, LastOwnerException {
-
- if(!isOwner(principal)) throw new NotOwnerException();
- Enumeration enumeration = ownerGroup.members();
- Object obj = enumeration.nextElement();
- if(enumeration.hasMoreElements()) {
- return ownerGroup.removeMember(principal1);
- } else {
- throw new LastOwnerException();
- }
- }
-
- public synchronized boolean isOwner(Principal principal)
- {
- return ownerGroup.isMember(principal);
- }
-}
diff --git a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java
deleted file mode 100644
index 2d355f910..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java
+++ /dev/null
@@ -1,49 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.acl.Permission;
-
-/**
- * Additional class for verification Permission interface
- */
-public class PermissionImpl implements Permission {
-
- private String permission;
-
- public PermissionImpl(String s) {
- permission = s;
- }
-
- public boolean equals(Object obj) {
- if(obj instanceof Permission) {
- Permission permission1 = (Permission)obj;
- return permission.equals(permission1.toString());
- } else {
- return false;
- }
- }
-
- public String toString() {
- return permission;
- }
-
-/* public int hashCode() {
- return toString().hashCode();
- }*/
-} \ No newline at end of file
diff --git a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java b/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java
deleted file mode 100644
index f7dcba504..000000000
--- a/libcore/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java
+++ /dev/null
@@ -1,53 +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 org.apache.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-
-/**
- * Additional class for verification Principal interface
- */
-public class PrincipalImpl implements Principal {
-
- private String user;
-
- public PrincipalImpl(String s) {
- user = s;
- }
-
- public boolean equals(Object obj) {
- if(obj instanceof PrincipalImpl) {
- PrincipalImpl principalimpl = (PrincipalImpl)obj;
- return user.equals(principalimpl.toString());
- } else {
- return false;
- }
- }
-
- public String toString() {
- return user;
- }
-
- public int hashCode() {
- return user.hashCode();
- }
-
- public String getName() {
- return user;
- }
-}