summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2011-06-06 15:02:36 -0700
committerElliott Hughes <enh@google.com>2011-06-06 15:02:36 -0700
commitd81553c5788bae814e44e8e40df1e79b1aaaf618 (patch)
tree2dcc9119b16f574a35726481663cc9e01aab2075
parent8b407ab9c0a9708562d5289c56a0ad88d24dfea6 (diff)
downloadapache-harmony-d81553c5788bae814e44e8e40df1e79b1aaaf618.tar.gz
Remove dead tests.
Change-Id: Ia6f0d3a1d7e4390f992ccad64d595118edff52d0
-rw-r--r--auth/src/test/java/common/javax/security/auth/AuthPermissionTest.java95
-rw-r--r--auth/src/test/java/common/javax/security/auth/PolicyTest.java303
-rw-r--r--auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java919
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/DelegationPermissionTest.java219
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/ServicePermissionTest.java304
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.java41
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.java50
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.java49
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.java41
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.java39
-rw-r--r--auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.java39
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.0.serbin196 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.1.serbin196 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.0.serbin333 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.1.serbin525 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.2.serbin567 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.0.serbin330 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.1.serbin516 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.2.serbin562 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.0.serbin181 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.1.serbin183 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.2.serbin190 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.3.serbin190 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.golden.0.serbin173 -> 0 bytes
-rw-r--r--auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.golden.0.serbin472 -> 0 bytes
-rw-r--r--logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java77
-rw-r--r--logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.serbin177 -> 0 bytes
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java222
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializablePermissionTest.java59
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java6
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest2.java60
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest3.java71
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest4.java703
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java44
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ReflectPermissionTest.java59
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetPermissionTest.java60
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java52
-rw-r--r--luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.java146
-rw-r--r--luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.golden.serbin190 -> 0 bytes
-rw-r--r--security/src/test/api/java.injected/java/security/AllPermissionTest.java87
-rw-r--r--security/src/test/api/java.injected/java/security/BasicPermissionTest.java137
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java100
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java138
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java102
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java618
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java112
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java105
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java81
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java159
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java159
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java94
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java199
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java47
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java78
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java121
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.java44
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.java44
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.java51
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.java36
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java193
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.java40
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.java40
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.java49
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.java43
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.java58
-rw-r--r--security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java66
-rw-r--r--security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java241
-rw-r--r--security/src/test/impl/java.injected/java/security/AllPermissionCollection_ImplTest.java112
-rw-r--r--security/src/test/impl/java.injected/java/security/BasicPermissionCollection_ImplTest.java214
-rw-r--r--security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java197
-rw-r--r--security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java40
-rw-r--r--security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java238
-rw-r--r--security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java585
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/PolicyEntryTest.java315
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java104
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java174
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/fortress/PolicyUtilsTest.java330
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java222
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java75
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Permissions_ImplTest.java98
-rw-r--r--security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Policy_ImplTest.java108
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.serbin226 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.0.serbin135 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.1.serbin135 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.golden.0.serbin135 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.0.serbin288 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.1.serbin528 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.2.serbin499 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.golden.0.serbin199 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.0.serbin248 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.1.serbin248 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.2.serbin1028 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.3.serbin241 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.0.serbin146 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.1.serbin146 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.0.serbin143 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.1.serbin157 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.0.serbin276 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.1.serbin737 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.0.serbin171 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.1.serbin179 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.0.serbin245 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.1.serbin658 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.2.serbin751 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.0.serbin245 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.1.serbin230 -> 0 bytes
-rw-r--r--security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.serbin1040 -> 0 bytes
-rw-r--r--sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java73
-rw-r--r--x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPermissionTest.java43
109 files changed, 0 insertions, 9828 deletions
diff --git a/auth/src/test/java/common/javax/security/auth/AuthPermissionTest.java b/auth/src/test/java/common/javax/security/auth/AuthPermissionTest.java
deleted file mode 100644
index a261b0b..0000000
--- a/auth/src/test/java/common/javax/security/auth/AuthPermissionTest.java
+++ /dev/null
@@ -1,95 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package javax.security.auth;
-
-import junit.framework.TestCase;
-
-/**
- * Tests AuthPermission class
- */
-public class AuthPermissionTest extends TestCase {
-
- private AuthPermission ap;
- private AuthPermission ap1;
-
-
- @Override
- protected void setUp() throws Exception {
- ap = new AuthPermission("name");
- ap1 = new AuthPermission("createLoginContext");
- }
-
- /**
- * Constructor for AuthPermissionTest.
- *
- * @param name
- */
- public AuthPermissionTest(String name) {
- super(name);
- }
-
- /**
- * The target name "createLoginContext" is deprecated
- * and it should be replaced by "createLoginContext.*"
- */
- public void testConstructor_01() {
- assertEquals("createLoginContext.*",ap1.getName());
- }
-
- /**
- * Checks that target name is correct
- */
- public void testConstructor_02() {
- assertEquals("name",ap.getName());
- }
-
- /**
- * Target name should not be null
- */
- public void testConstructor_03() {
- try {
- ap = new AuthPermission(null);
- fail("no expected NPE");
- } catch (NullPointerException e) {}
- }
-
- /**
- * Action should be ignored
- */
- public void testConstructor_04() {
- try {
- ap = new AuthPermission("name", null);
- ap = new AuthPermission("name", "read");
- } catch (NullPointerException e) {
- fail("action is not ignored");
- }
- }
-
- /**
- * the target name "createLoginContext.{name}" is correct
- */
- public void testConstructor_05() {
- ap1 = new AuthPermission("createLoginContext.name");
- assertEquals("createLoginContext.name",ap1.getName());
- }
-
-}
diff --git a/auth/src/test/java/common/javax/security/auth/PolicyTest.java b/auth/src/test/java/common/javax/security/auth/PolicyTest.java
deleted file mode 100644
index b0b9c32..0000000
--- a/auth/src/test/java/common/javax/security/auth/PolicyTest.java
+++ /dev/null
@@ -1,303 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package javax.security.auth;
-
-import java.io.FilePermission;
-import java.net.URL;
-import java.security.AllPermission;
-import java.security.CodeSigner;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Security;
-import java.security.cert.Certificate;
-import java.util.Enumeration;
-import junit.framework.TestCase;
-import org.apache.harmony.auth.tests.support.TestUtils;
-import tests.support.resource.Support_Resources;
-
-/**
- * Tests Policy class
- */
-@SuppressWarnings("deprecation")
-public class PolicyTest extends TestCase {
-
- public static class TestProvider extends Policy {
- @Override
- public PermissionCollection getPermissions(Subject subject, CodeSource cs) {
- return null;
- }
-
- @Override
- public void refresh() {
- }
- }
-
- public static class FakePolicy {
- // This is not policy class
- }
- /**
- * Tests loading of a default provider, both valid and invalid class
- * references.
- */
- public void testGetPolicy_LoadDefaultProvider() {
- Policy oldPolicy = null;
- try {
- oldPolicy = Policy.getPolicy();
- } catch (Throwable ignore) {
- }
- String POLICY_PROVIDER = "auth.policy.provider";
- String oldProvider = Security.getProperty(POLICY_PROVIDER);
- try {
- Security.setProperty(POLICY_PROVIDER, TestProvider.class.getName());
- Policy.setPolicy(null);
- Policy p = Policy.getPolicy();
- assertNotNull(p);
- assertEquals(TestProvider.class.getName(), p.getClass().getName());
-
- // absent class
- Security.setProperty(POLICY_PROVIDER, "a.b.c.D");
- Policy.setPolicy(null);
- try {
- p = Policy.getPolicy();
- fail("No SecurityException on failed provider");
- } catch (SecurityException ok) {
- }
-
- // not a policy class
- Security.setProperty(POLICY_PROVIDER, FakePolicy.class.getName());
- Policy.setPolicy(null);
- try {
- p = Policy.getPolicy();
- fail("No expected SecurityException");
- } catch (SecurityException ok) {
- }
- } finally {
- TestUtils.setSystemProperty(POLICY_PROVIDER, oldProvider);
- Policy.setPolicy(oldPolicy);
- }
- }
-
- //
- //
- //
- //
- //
-
- static String inputFile1 = Support_Resources
- .getAbsoluteResourcePath("auth_policy1.txt");
-
- static String inputFile2 = Support_Resources
- .getAbsoluteResourcePath("auth_policy2.txt");
-
- private static final String POLICY_PROP = "java.security.auth.policy";
-
- public void test_GetPermissions() throws Exception {
-
- PermissionCollection c;
- Permission per;
- Subject subject;
-
- CodeSource source;
-
- String oldProp = System.getProperty(POLICY_PROP);
- try {
- System.setProperty(POLICY_PROP, inputFile1);
-
- Policy p = Policy.getPolicy();
- p.refresh();
-
- //
- // Both parameters are null
- //
-
- c = p.getPermissions(null, null);
- assertFalse("Read only for empty", c.isReadOnly());
- assertFalse("Elements for empty", c.elements().hasMoreElements());
-
- //
- // Subject parameter is provided (CodeBase is not important)
- //
- // Principal javax.security.auth.MyPrincipal "duke"
- //
-
- // no principals at all
- subject = new Subject();
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- // different name "kuke" not "duke"
- subject.getPrincipals().add(new MyPrincipal("kuke"));
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- // different class with required principal's name
- subject.getPrincipals().add(new OtherPrincipal("duke"));
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- // subclass with required principal's name
- subject.getPrincipals().add(new FakePrincipal("duke"));
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- // add required principal's name
- subject.getPrincipals().add(new MyPrincipal("duke"));
-
- Enumeration<Permission> e = p.getPermissions(subject, null).elements();
-
- per = e.nextElement();
- assertFalse("Elements: ", e.hasMoreElements());
- assertEquals("Permission: ", per, new FilePermission("/home/duke",
- "read, write"));
-
- // check: CodeBase is not important
- source = new CodeSource(new URL("http://dummy.xxx"),
- (Certificate[]) null);
- c = p.getPermissions(subject, source);
- assertTrue("Elements: ", c.elements().hasMoreElements());
-
- source = new CodeSource(new URL("http://dummy.xxx"),
- (CodeSigner[]) null);
- c = p.getPermissions(subject, source);
- assertTrue("Elements: ", c.elements().hasMoreElements());
-
- //
- // Subject and CodeBase parameter are provided
- //
- // Principal javax.security.auth.MyPrincipal "dummy"
- // CodeBase "http://dummy.xxx"
- //
- source = new CodeSource(new URL("http://dummy.xxx"),
- (Certificate[]) null);
- subject = new Subject();
- subject.getPrincipals().add(new MyPrincipal("dummy"));
-
- e = p.getPermissions(subject, source).elements();
- per = e.nextElement();
- assertFalse("Elements: ", e.hasMoreElements());
- assertEquals("Permission: ", per, new RuntimePermission(
- "createClassLoader"));
-
- // reset subject : no principals at all
- subject = new Subject();
- c = p.getPermissions(subject, source);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- // different name "kuke" not "dummy"
- subject.getPrincipals().add(new MyPrincipal("kuke"));
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- // different class with required principal's name
- subject.getPrincipals().add(new OtherPrincipal("dummy"));
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- //
- // Principal javax.security.auth.MyPrincipal "my"
- // Principal javax.security.auth.OtherPrincipal "other"
- //
- subject = new Subject();
- subject.getPrincipals().add(new MyPrincipal("my"));
- c = p.getPermissions(subject, null);
- assertFalse("Elements: ", c.elements().hasMoreElements());
-
- subject.getPrincipals().add(new OtherPrincipal("other"));
- e = p.getPermissions(subject, null).elements();
- per = e.nextElement();
- assertFalse("Elements: ", e.hasMoreElements());
- assertEquals("Permission: ", per, new AllPermission());
-
- //
- // Principal javax.security.auth.MyPrincipal "bunny"
- //
- subject = new Subject();
- subject.getPrincipals().add(new MyPrincipal("bunny"));
-
- e = p.getPermissions(subject, null).elements();
-
- Permission[] get = new Permission[2];
- get[0] = e.nextElement();
- get[1] = e.nextElement();
- assertFalse("Elements: ", e.hasMoreElements());
-
- Permission[] set = new Permission[2];
- set[0] = new FilePermission("/home/bunny", "read, write");
- set[1] = new RuntimePermission("stopThread");
-
- if (get[0].equals(set[0])) {
- assertEquals("Permission: ", set[1], get[1]);
- } else {
- assertEquals("Permission: ", set[0], get[1]);
- assertEquals("Permission: ", set[1], get[0]);
- }
-
- } finally {
- TestUtils.setSystemProperty(POLICY_PROP, oldProp);
- }
- }
-
- public void test_Refresh() {
-
- Permission per;
- Subject subject;
- Enumeration<?> e;
-
- String oldProp = System.getProperty(POLICY_PROP);
- try {
- //
- // first policy file to be read
- //
- System.setProperty(POLICY_PROP, inputFile1);
-
- Policy p = Policy.getPolicy();
- p.refresh();
-
- subject = new Subject();
- subject.getPrincipals().add(new MyPrincipal("duke"));
-
- e = p.getPermissions(subject, null).elements();
-
- per = (Permission) e.nextElement();
- assertFalse("Elements: ", e.hasMoreElements());
- assertEquals("Permission: ", per, new FilePermission("/home/duke",
- "read, write"));
-
- //
- // second policy file to be read
- //
- System.setProperty(POLICY_PROP, inputFile2);
-
- p.refresh();
-
- e = p.getPermissions(subject, null).elements();
-
- per = (Permission) e.nextElement();
- assertFalse("Elements: ", e.hasMoreElements());
- assertEquals("Permission: ", per, new RuntimePermission(
- "createClassLoader"));
- } finally {
- TestUtils.setSystemProperty(POLICY_PROP, oldProp);
- }
- }
-}
diff --git a/auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java b/auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java
deleted file mode 100644
index 9845ec5..0000000
--- a/auth/src/test/java/common/javax/security/auth/PrivateCredentialPermissionTest.java
+++ /dev/null
@@ -1,919 +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.
- */
-/**
-* @author Maxim V. Makarov
-*/
-
-package javax.security.auth;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.security.Principal;
-import java.util.HashSet;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests PrivateCredentialPermission class implementation.
- */
-public class PrivateCredentialPermissionTest extends TestCase {
-
- private PrivateCredentialPermission p_that;
-
- private PrivateCredentialPermission p_this;
-
- String s_that;
-
- String s_this;
-
- /**
- * Constructor for PrivateCredentialPermissionTest.
- *
- * @param name
- */
- public PrivateCredentialPermissionTest(String name) {
- super(name);
- }
-
- /**
- * [C1 P1 "duke"] implies [C1 P1 "duke" P2 "nuke"].
- */
- public final void testImplies_01() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.implies(p_that));
- assertTrue(p_this.implies(p_this));
- }
-
- /**
- * [C1 P1 "nuke"] implies [C1 P1 "duke" P2 "nuke"].
- */
- public final void testImplies_02() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.c.Principal \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.implies(p_that));
-
- }
-
- /**
- * [* P1 "duke"] implies [C1 P1 "duke"]
- */
- public final void testImplies_03() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "* a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.implies(p_that));
-
- }
-
- /**
- * [C1P1 "duke"] implies [C1 P1 "*"]
- */
- public final void testImplies_04() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.c.Principal \"*\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.implies(p_that));
-
- }
-
- /**
- * [C1 P1 "duke" P2 "nuke"] implies [C1 * "*"]
- */
- public final void testImplies_05() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential * \"*\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.implies(p_that));
-
- }
-
- /**
- * [C1 P1 "duke" P2 "nuke"] implies [C1 P1 "duke" P2 "nuke" P3 "duke"]
- */
- public final void testImplies_06() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\" a.d.Principal \"duke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.implies(p_that));
-
- }
-
- /**
- * [C2 P1 "duke" ] does not imply [C1 P1 "duke" P2 "nuke" ]
- */
- public final void testImplies_07() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.c.Credential a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [C1 P3 "duke" ] does not imply [C1 P1 "duke" P2 "nuke" ]
- */
- public final void testImplies_08() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.d.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [C1 P1 "nuke" ] does not imply [C1 P1 "duke" P3 "nuke" ]
- */
- public final void testImplies_09() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.b.Principal \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
-
- }
-
- /**
- * [C1 P1 "nuke" P2 "buke"] does not imply [C1 P1 "duke" P2 "nuke" ]
- */
- public final void testImplies_10() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- p_this.implies(p_that);
- assertFalse(p_this.implies(p_that));
-
- }
-
- /**
- * [C1 P1 "nuke" P2 "nuke" P3 "buke"] does not imply [C1 P1 "duke" P2 "nuke" P3 "kuke"]
- */
- public final void testImplies_110() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\" a.d.Principal \"kuke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\" a.d.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [C1 P1 "duke" P2 "buke"] does not imply [C1 P1 "*" ]
- */
- public final void testImplies_11() {
- s_that = "a.b.Credential a.b.Principal \"*\"";
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
-
- }
-
- /**
- * [C1 P2 "*"] does not imply [C1 P1 "*" ]
- */
- public final void testImplies_12() {
- s_that = "a.b.Credential a.b.Principal \"*\"";
- s_this = "a.b.Credential a.c.Principal \"*\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
-
- }
-
- /**
- * [* P3 "duke"] does not imply [C1 P1 "duke" P2 "nuke"]
- */
- public final void testImplies_13() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "* a.d.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [* P2 "buke"] does not imply [C1 P1 "duke" P2 "nuke"]
- */
- public final void testImplies_14() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "* a.c.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [C1 P1 "buke"] does not imply [C1 P1 "*"]
- */
- public final void testImplies_15() {
- s_that = "a.b.Credential a.b.Principal \"*\"";
- s_this = "a.b.Credential a.b.Principal \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [C1 * "*"] does not imply [C1 P1 "duke" P2 "nuke"]
- */
- public final void testImplies_16() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential * \"*\" a.b.Principal \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.implies(p_that));
- }
-
- /**
- * [C1 a.c* "nuke"] not implies [C1 P1 "duke" a.c.P2 "nuke"]
- */
- public final void testImplies_17() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.c.* \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- //try {
- assertFalse(p_this.implies(p_that));
- //} catch (AssertionFailedError e){
- // fail("It seems to me this test should be pass, so \"principalClass\"" +
- // " should be has a name like 'a.b.*'");
- //}
- }
-
- /**
- * A permission is not an instance of PrivateCredentialPermission
- */
- public final void testImplies_18() {
- AuthPermission p_this = new AuthPermission("name", "read");
- s_that = "a.b.Credential a.c.* \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- assertFalse(p_that.implies(p_this));
- assertFalse(p_that.implies(null));
- }
-
- /**
- * Create a correct ctor
- *
- * @throws IllegalArgumentException
- */
- public final void testPCP_01() throws IllegalArgumentException {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal \"duke\" a.b.Principal \"nuke\"",
- "read");
- }
-
- /**
- * Create a incorrect ctor without string of Principal class and Principal name,
- * expected IAE
- */
- public final void testPCP_02() {
- try {
- p_this = new PrivateCredentialPermission("a.b.Credential", "read");
- fail("new PrivateCredentialPermission('a.b.Credential', 'read') should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Create a incorrect ctor without string of Principal name,
- * expected IAE
- */
- public final void testPCP_03() {
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal", "read");
- fail("new PrivateCredentialPermission('a.b.Credential a.b.Principal', 'read') should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Create a incorrect ctor without string of Principal class,
- * expected IAE
- */
- public final void testPCP_04() {
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential \"duke\" a.b.Principal \"nuke\"", "read");
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Create a incorrect ctor. Principal Class can not be a wildcard (*)
- * value if Principal Name is not a wildcard (*) value,
- * expected IAE
- */
- public final void testPCP_05() {
-
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential * \"nuke\"", "read");
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * "Action must be "read" only,
- * expected IAE
- */
- public final void testPCP_06() throws IllegalArgumentException {
-
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal \"nuke\"", "write");
- fail("Action can be \"read\" only, IllegalArgumentException should be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Principal name must be enveloped by quotes,
- * expected IAE
- */
- public final void testPCP_07() throws IllegalArgumentException {
-
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal a.c.Principal", "read");
- fail("IllegalArgumentException should be thrown");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Principal name must be enveloped by quotes,
- * expected IAE
- */
- public final void testPCP_08() throws IllegalArgumentException {
-
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal \"duke\" a.c.Principal",
- "read");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Principal name must be enveloped by quotes,
- * expected IAE
- */
- public final void testPCP_09() throws IllegalArgumentException {
-
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal duke\"", "read");
- fail("should be throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Principal name must be enveloped by quotes,
- * expected IAE
- */
- public final void testPCP_10() throws IllegalArgumentException {
-
- try {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.Principal \"duke", "read");
- fail("should be throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * Create a ctor. Code to support a principal class as a.c.*
- *
- * @throws IllegalArgumentException
- */
- public final void testPCP_11() throws IllegalArgumentException {
- p_this = new PrivateCredentialPermission(
- "a.b.Credential a.b.* \"duke\"", "read");
- }
-
- /**
- * Create a ctor. [* * "*"]
- *
- * @throws IllegalArgumentException
- */
- public final void testPCP_12() throws IllegalArgumentException {
- p_this = new PrivateCredentialPermission("* * \"*\"", "read");
- }
-
- /**
- * a target name should not be empty
- * @throws IllegalArgumentException
- */
- public final void testPCP_13() throws IllegalArgumentException {
- try {
- p_this = new PrivateCredentialPermission(new String(), "read");
- fail("should be throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * a target name should not be null
- */
- public final void testPCP_14() {
- try {
- new PrivateCredentialPermission(null, "read");
- fail("should be throw NullPointerException");
- } catch (NullPointerException e) {
- }
- }
-
- /**
- * test empty principal/name pairs
- */
- public final void testPCP_15() {
- try {
- p_this = new PrivateCredentialPermission("java.lang.Object", "read");
- fail("new PrivateCredentialPermission('java.lang.Object', 'read') should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- /**
- * [C1 P1 "nuke" P2 "nuke"] equals [C1 P1 "duke" P2 "nuke"]
- */
- public final void testEquals_01() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.equals(p_that));
- assertTrue(p_this.equals(p_this));
- assertEquals(p_this.hashCode(), p_that.hashCode());
- }
-
- /**
- * two permissions are equal if the order of the Principals in
- * the respective target names is not relevant.
- */
- public final void testEquals_02() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.c.Principal \"nuke\" a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.equals(p_that));
- assertEquals(p_this.hashCode(), p_that.hashCode());
- }
-
- /**
- * two permissions are not equal even if its have the same credential class
- * and a different number of principals.
- */
- public final void testEquals_03() {
-
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.equals(p_that));
- }
-
- /**
- * two permissions are not equal if either of them has not the same
- * credential class, principal class and principal name
- */
- public final void testEquals_04() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.c.Credential a.d.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.equals(p_that));
- }
-
- /**
- * two permissions are not equal if either of them has not the same
- * principal class and principal name
- */
- public final void testEquals_05() {
- s_that = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- s_this = "a.b.Credential a.d.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.equals(p_that));
- }
-
- /**
- * [C1 P1 "duke"] equals [C1 P1 "duke"] and
- * hashCode of them equals too.
- */
- public final void testEquals_06() {
- s_that = "a.b.Credential a.b.Principal \"duke\"";
- s_this = "a.b.Credential a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.equals(p_that));
- assertTrue(p_that.equals(p_this));
- assertEquals(p_this.hashCode(), p_that.hashCode());
- }
-
- /**
- * two permissions are not equal if either of them has not the same principal name
- */
- public final void testEquals_07() {
- s_that = "a.b.Credential a.b.Principal \"duke\"";
- s_this = "a.b.Credential a.b.Principal \"buke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.equals(p_that));
- }
-
- /**
- * Verifies that a permission object is equal to itself
- */
- public final void testEquals_08() {
- s_this = "a.b.Credential a.b.Principal \"buke\"";
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertTrue(p_this.equals(p_this));
- }
-
- /**
- * [C1 P1 "duke"] does not equal NULL
- */
- public final void testEquals_09() {
- s_this = "a.b.Credential a.b.Principal \"buke\"";
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.equals(null));
- AuthPermission other = new AuthPermission("some");
- assertFalse(p_this.implies(other));
- }
-
- /**
- * two permissions are not equals if either of them has not the same credential class
- */
- public final void testEquals_10() {
- s_that = "a.b.Credential a.b.Principal \"duke\"";
- s_this = "a.c.Credential a.b.Principal \"duke\"";
- p_that = new PrivateCredentialPermission(s_that, "read");
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertFalse(p_this.equals(p_that));
- assertFalse(p_that.equals(p_this));
- }
-
- /**
- * the method newPermissionCollection() always returns null,
- * the method getActions() always returns "read" and
- * the method getCredentialClass() returns the name of the CredentialClass.
- */
- public final void testGetCredentialClassAndGetAction() {
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- p_this = new PrivateCredentialPermission(s_this, "read");
- assertEquals("read", p_this.getActions());
- assertEquals("a.b.Credential", p_this.getCredentialClass());
- assertNull(p_this.newPermissionCollection());
- }
-
- /**
- * Returns the set of principals which to represent like array[x][y]
- * Implementation specific.
- */
- public final void testGetPrincipals_01() {
- s_this = "a.b.Credential a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- p_this = new PrivateCredentialPermission(s_this, "read");
- String p[][] = p_this.getPrincipals();
- assertEquals("a.b.Principal", p[0][0]);
- assertEquals("duke", p[0][1]);
- assertEquals("a.c.Principal", p[1][0]);
- assertEquals("nuke", p[1][1]);
- }
-
- /**
- * the same as the method testGetPrincipals_01()
- */
- public final void testGetPrincipals_02() {
- s_this = "a.b.Credential a.d.Principal \"buke\" a.b.Principal \"duke\" a.c.Principal \"nuke\"";
- p_this = new PrivateCredentialPermission(s_this, "read");
- String p[][] = p_this.getPrincipals();
- assertEquals("a.d.Principal", p[0][0]);
- assertEquals("buke", p[0][1]);
- assertEquals("a.b.Principal", p[1][0]);
- assertEquals("duke", p[1][1]);
- assertEquals("a.c.Principal", p[2][0]);
- assertEquals("nuke", p[2][1]);
- }
-
- public final void testCtor() {
-
- class MyPrincipal implements Principal {
- String name;
-
- MyPrincipal(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
- }
-
- MyPrincipal mp = new MyPrincipal("duke");
- MyPrincipal mp1 = new MyPrincipal("nuke");
- HashSet<Principal> hash = new HashSet<Principal>();
- hash.add(mp);
- hash.add(mp1);
-
- PrivateCredentialPermission p1 = new PrivateCredentialPermission(
- "java.lang.Object", hash);
-
- PrivateCredentialPermission p2 = new PrivateCredentialPermission(
- "java.lang.Object " + MyPrincipal.class.getName() + " \"duke\"",
- "read");
- assertFalse(p1.implies(p2));
- assertTrue(p2.implies(p1));
-
- PrivateCredentialPermission p3 = new PrivateCredentialPermission(
- "java.lang.Object", new HashSet<Principal>());
-
- PrivateCredentialPermission p4 = new PrivateCredentialPermission(
- "java.lang.Object * \"*\"", "read");
-
- assertTrue(p4.implies(p3));
- }
-
- public final void testDuplicates() {
-
- // string contains duplicate entries: b "c"
- PrivateCredentialPermission p = new PrivateCredentialPermission(
- "a b \"c\" b \"c\"", "read");
-
- assertEquals("Size", p.getPrincipals().length, 1);
- }
-
- public final void testImmutability() {
- PrivateCredentialPermission p = new PrivateCredentialPermission(
- "a b \"c\"", "read");
-
- assertTrue("Array reference", p.getPrincipals() != p.getPrincipals());
- }
-
- public final void testWhiteSpaces() {
-
- String[] illegalTargetNames = new String[] { "a\nb \"c\"", // \n - delimiter
- "a\tb \"c\"", // \t - delimiter
- "a\rb \"c\"", // \r - delimiter
- "a b\n\"c\"", // \n - delimiter
- "a b\t\"c\"", // \t - delimiter
- "a b\r\"c\"", // \r - delimiter
- "a b \"c\"", // two spaces between credential and principal
- "a b \"c\"" // two spaces between principal class and name
- };
-
- for (String element : illegalTargetNames) {
- try {
- new PrivateCredentialPermission(element, "read");
- fail("No expected IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- }
-
- // principal name has a space
- PrivateCredentialPermission p = new PrivateCredentialPermission(
- "a b \"c c\"", "read");
-
- assertEquals("Principal name:", "c c", p.getPrincipals()[0][1]);
- }
-
- public final void testSerialization_Wildcard() throws Exception {
-
- PrivateCredentialPermission all = new PrivateCredentialPermission(
- "* * \"*\"", "read");
- PrivateCredentialPermission p = new PrivateCredentialPermission(
- "a b \"c\"", "read");
-
- assertTrue(all.implies(p));
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ObjectOutputStream oOut = new ObjectOutputStream(out);
-
- oOut.writeObject(all);
- oOut.flush();
- oOut.close();
-
- ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
- ObjectInputStream oIn = new ObjectInputStream(in);
-
- PrivateCredentialPermission newAll = (PrivateCredentialPermission) oIn
- .readObject();
-
- assertTrue("New implies", newAll.implies(p));
- assertEquals("Equals", all, newAll);
- }
-
- public final void testSerialization_Golden() throws Exception {
-
- new PrivateCredentialPermission("a b \"c\" d \"e\"", "read");
-
- ByteArrayInputStream in = new ByteArrayInputStream(gForm);
- ObjectInputStream sIn = new ObjectInputStream(in);
-
- PrivateCredentialPermission p = (PrivateCredentialPermission) sIn
- .readObject();
-
- assertEquals("CredentialClass ", "a", p.getCredentialClass());
-
- String[][] principals = p.getPrincipals();
- assertEquals("Size:", 1, principals.length);
- assertEquals("PrincipalClass:", "b", principals[0][0]);
- assertEquals("PrincipalName:", "c", principals[0][1]);
- }
-
- public final void testSerialization_Self() throws Exception {
-
- ByteArrayInputStream in = new ByteArrayInputStream(selfForm);
- ObjectInputStream sIn = new ObjectInputStream(in);
-
- PrivateCredentialPermission p = (PrivateCredentialPermission) sIn
- .readObject();
-
- assertEquals("CredentialClass ", "a", p.getCredentialClass());
-
- String[][] principals = p.getPrincipals();
- assertEquals("Size:", 1, principals.length);
- assertEquals("PrincipalClass:", "b", principals[0][0]);
- assertEquals("PrincipalName:", "c", principals[0][1]);
- }
-
- // Golden: PrivateCredentialPermission("a b \"c\"","read");
- // generated using public API
- public static final byte[] gForm = new byte[] { (byte) 0xac, (byte) 0xed,
- (byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72, (byte) 0x00,
- (byte) 0x2f, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x78, (byte) 0x2e, (byte) 0x73, (byte) 0x65, (byte) 0x63,
- (byte) 0x75, (byte) 0x72, (byte) 0x69, (byte) 0x74, (byte) 0x79,
- (byte) 0x2e, (byte) 0x61, (byte) 0x75, (byte) 0x74, (byte) 0x68,
- (byte) 0x2e, (byte) 0x50, (byte) 0x72, (byte) 0x69, (byte) 0x76,
- (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x72,
- (byte) 0x65, (byte) 0x64, (byte) 0x65, (byte) 0x6e, (byte) 0x74,
- (byte) 0x69, (byte) 0x61, (byte) 0x6c, (byte) 0x50, (byte) 0x65,
- (byte) 0x72, (byte) 0x6d, (byte) 0x69, (byte) 0x73, (byte) 0x73,
- (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x49, (byte) 0x55,
- (byte) 0xdc, (byte) 0x77, (byte) 0x7b, (byte) 0x50, (byte) 0x7f,
- (byte) 0x4c, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x5a,
- (byte) 0x00, (byte) 0x07, (byte) 0x74, (byte) 0x65, (byte) 0x73,
- (byte) 0x74, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x4c,
- (byte) 0x00, (byte) 0x0f, (byte) 0x63, (byte) 0x72, (byte) 0x65,
- (byte) 0x64, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x69,
- (byte) 0x61, (byte) 0x6c, (byte) 0x43, (byte) 0x6c, (byte) 0x61,
- (byte) 0x73, (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x12,
- (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67,
- (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,
- (byte) 0x6e, (byte) 0x67, (byte) 0x3b, (byte) 0x4c, (byte) 0x00,
- (byte) 0x0a, (byte) 0x70, (byte) 0x72, (byte) 0x69, (byte) 0x6e,
- (byte) 0x63, (byte) 0x69, (byte) 0x70, (byte) 0x61, (byte) 0x6c,
- (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x0f, (byte) 0x4c,
- (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f,
- (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2f,
- (byte) 0x53, (byte) 0x65, (byte) 0x74, (byte) 0x3b, (byte) 0x78,
- (byte) 0x72, (byte) 0x00, (byte) 0x18, (byte) 0x6a, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x65,
- (byte) 0x63, (byte) 0x75, (byte) 0x72, (byte) 0x69, (byte) 0x74,
- (byte) 0x79, (byte) 0x2e, (byte) 0x50, (byte) 0x65, (byte) 0x72,
- (byte) 0x6d, (byte) 0x69, (byte) 0x73, (byte) 0x73, (byte) 0x69,
- (byte) 0x6f, (byte) 0x6e, (byte) 0xb1, (byte) 0xc6, (byte) 0xe1,
- (byte) 0x3f, (byte) 0x28, (byte) 0x57, (byte) 0x51, (byte) 0x7e,
- (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x4c, (byte) 0x00,
- (byte) 0x04, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
- (byte) 0x74, (byte) 0x00, (byte) 0x12, (byte) 0x4c, (byte) 0x6a,
- (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c,
- (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53,
- (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67,
- (byte) 0x3b, (byte) 0x78, (byte) 0x70, (byte) 0x74, (byte) 0x00,
- (byte) 0x07, (byte) 0x61, (byte) 0x20, (byte) 0x62, (byte) 0x20,
- (byte) 0x22, (byte) 0x63, (byte) 0x22, (byte) 0x00, (byte) 0x74,
- (byte) 0x00, (byte) 0x01, (byte) 0x61, (byte) 0x70 };
-
- // Self generated: PrivateCredentialPermission("a b \"c\"","read");
- // Note: Set principals = new LinkedHashSet()
- // generated using public API
- public static final byte[] selfForm = { (byte) 0xac, (byte) 0xed,
- (byte) 0x00, (byte) 0x05, (byte) 0x73, (byte) 0x72, (byte) 0x00,
- (byte) 0x2f, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x78, (byte) 0x2e, (byte) 0x73, (byte) 0x65, (byte) 0x63,
- (byte) 0x75, (byte) 0x72, (byte) 0x69, (byte) 0x74, (byte) 0x79,
- (byte) 0x2e, (byte) 0x61, (byte) 0x75, (byte) 0x74, (byte) 0x68,
- (byte) 0x2e, (byte) 0x50, (byte) 0x72, (byte) 0x69, (byte) 0x76,
- (byte) 0x61, (byte) 0x74, (byte) 0x65, (byte) 0x43, (byte) 0x72,
- (byte) 0x65, (byte) 0x64, (byte) 0x65, (byte) 0x6e, (byte) 0x74,
- (byte) 0x69, (byte) 0x61, (byte) 0x6c, (byte) 0x50, (byte) 0x65,
- (byte) 0x72, (byte) 0x6d, (byte) 0x69, (byte) 0x73, (byte) 0x73,
- (byte) 0x69, (byte) 0x6f, (byte) 0x6e, (byte) 0x49, (byte) 0x55,
- (byte) 0xdc, (byte) 0x77, (byte) 0x7b, (byte) 0x50, (byte) 0x7f,
- (byte) 0x4c, (byte) 0x02, (byte) 0x00, (byte) 0x03, (byte) 0x5a,
- (byte) 0x00, (byte) 0x07, (byte) 0x74, (byte) 0x65, (byte) 0x73,
- (byte) 0x74, (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x4c,
- (byte) 0x00, (byte) 0x0f, (byte) 0x63, (byte) 0x72, (byte) 0x65,
- (byte) 0x64, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x69,
- (byte) 0x61, (byte) 0x6c, (byte) 0x43, (byte) 0x6c, (byte) 0x61,
- (byte) 0x73, (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x12,
- (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61,
- (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e, (byte) 0x67,
- (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x72, (byte) 0x69,
- (byte) 0x6e, (byte) 0x67, (byte) 0x3b, (byte) 0x4c, (byte) 0x00,
- (byte) 0x0a, (byte) 0x70, (byte) 0x72, (byte) 0x69, (byte) 0x6e,
- (byte) 0x63, (byte) 0x69, (byte) 0x70, (byte) 0x61, (byte) 0x6c,
- (byte) 0x73, (byte) 0x74, (byte) 0x00, (byte) 0x0f, (byte) 0x4c,
- (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f,
- (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2f,
- (byte) 0x53, (byte) 0x65, (byte) 0x74, (byte) 0x3b, (byte) 0x78,
- (byte) 0x72, (byte) 0x00, (byte) 0x18, (byte) 0x6a, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x2e, (byte) 0x73, (byte) 0x65,
- (byte) 0x63, (byte) 0x75, (byte) 0x72, (byte) 0x69, (byte) 0x74,
- (byte) 0x79, (byte) 0x2e, (byte) 0x50, (byte) 0x65, (byte) 0x72,
- (byte) 0x6d, (byte) 0x69, (byte) 0x73, (byte) 0x73, (byte) 0x69,
- (byte) 0x6f, (byte) 0x6e, (byte) 0xb1, (byte) 0xc6, (byte) 0xe1,
- (byte) 0x3f, (byte) 0x28, (byte) 0x57, (byte) 0x51, (byte) 0x7e,
- (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x4c, (byte) 0x00,
- (byte) 0x04, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
- (byte) 0x74, (byte) 0x00, (byte) 0x12, (byte) 0x4c, (byte) 0x6a,
- (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c,
- (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53,
- (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67,
- (byte) 0x3b, (byte) 0x78, (byte) 0x70, (byte) 0x74, (byte) 0x00,
- (byte) 0x07, (byte) 0x61, (byte) 0x20, (byte) 0x62, (byte) 0x20,
- (byte) 0x22, (byte) 0x63, (byte) 0x22, (byte) 0x00, (byte) 0x74,
- (byte) 0x00, (byte) 0x01, (byte) 0x61, (byte) 0x73, (byte) 0x72,
- (byte) 0x00, (byte) 0x17, (byte) 0x6a, (byte) 0x61, (byte) 0x76,
- (byte) 0x61, (byte) 0x2e, (byte) 0x75, (byte) 0x74, (byte) 0x69,
- (byte) 0x6c, (byte) 0x2e, (byte) 0x4c, (byte) 0x69, (byte) 0x6e,
- (byte) 0x6b, (byte) 0x65, (byte) 0x64, (byte) 0x48, (byte) 0x61,
- (byte) 0x73, (byte) 0x68, (byte) 0x53, (byte) 0x65, (byte) 0x74,
- (byte) 0xd8, (byte) 0x6c, (byte) 0xd7, (byte) 0x5a, (byte) 0x95,
- (byte) 0xdd, (byte) 0x2a, (byte) 0x1e, (byte) 0x02, (byte) 0x00,
- (byte) 0x00, (byte) 0x78, (byte) 0x72, (byte) 0x00, (byte) 0x11,
- (byte) 0x6a, (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2e,
- (byte) 0x75, (byte) 0x74, (byte) 0x69, (byte) 0x6c, (byte) 0x2e,
- (byte) 0x48, (byte) 0x61, (byte) 0x73, (byte) 0x68, (byte) 0x53,
- (byte) 0x65, (byte) 0x74, (byte) 0xba, (byte) 0x44, (byte) 0x85,
- (byte) 0x95, (byte) 0x96, (byte) 0xb8, (byte) 0xb7, (byte) 0x34,
- (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x78, (byte) 0x70,
- (byte) 0x77, (byte) 0x0c, (byte) 0x00, (byte) 0x00, (byte) 0x00,
- (byte) 0x10, (byte) 0x3f, (byte) 0x40, (byte) 0x00, (byte) 0x00,
- (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x73,
- (byte) 0x72, (byte) 0x00, (byte) 0x39, (byte) 0x6a, (byte) 0x61,
- (byte) 0x76, (byte) 0x61, (byte) 0x78, (byte) 0x2e, (byte) 0x73,
- (byte) 0x65, (byte) 0x63, (byte) 0x75, (byte) 0x72, (byte) 0x69,
- (byte) 0x74, (byte) 0x79, (byte) 0x2e, (byte) 0x61, (byte) 0x75,
- (byte) 0x74, (byte) 0x68, (byte) 0x2e, (byte) 0x50, (byte) 0x72,
- (byte) 0x69, (byte) 0x76, (byte) 0x61, (byte) 0x74, (byte) 0x65,
- (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x64, (byte) 0x65,
- (byte) 0x6e, (byte) 0x74, (byte) 0x69, (byte) 0x61, (byte) 0x6c,
- (byte) 0x50, (byte) 0x65, (byte) 0x72, (byte) 0x6d, (byte) 0x69,
- (byte) 0x73, (byte) 0x73, (byte) 0x69, (byte) 0x6f, (byte) 0x6e,
- (byte) 0x24, (byte) 0x43, (byte) 0x72, (byte) 0x65, (byte) 0x64,
- (byte) 0x4f, (byte) 0x77, (byte) 0x6e, (byte) 0x65, (byte) 0x72,
- (byte) 0xb2, (byte) 0x2e, (byte) 0x56, (byte) 0x16, (byte) 0xb9,
- (byte) 0x03, (byte) 0x74, (byte) 0x36, (byte) 0x02, (byte) 0x00,
- (byte) 0x02, (byte) 0x4c, (byte) 0x00, (byte) 0x0e, (byte) 0x70,
- (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x63, (byte) 0x69,
- (byte) 0x70, (byte) 0x61, (byte) 0x6c, (byte) 0x43, (byte) 0x6c,
- (byte) 0x61, (byte) 0x73, (byte) 0x73, (byte) 0x74, (byte) 0x00,
- (byte) 0x12, (byte) 0x4c, (byte) 0x6a, (byte) 0x61, (byte) 0x76,
- (byte) 0x61, (byte) 0x2f, (byte) 0x6c, (byte) 0x61, (byte) 0x6e,
- (byte) 0x67, (byte) 0x2f, (byte) 0x53, (byte) 0x74, (byte) 0x72,
- (byte) 0x69, (byte) 0x6e, (byte) 0x67, (byte) 0x3b, (byte) 0x4c,
- (byte) 0x00, (byte) 0x0d, (byte) 0x70, (byte) 0x72, (byte) 0x69,
- (byte) 0x6e, (byte) 0x63, (byte) 0x69, (byte) 0x70, (byte) 0x61,
- (byte) 0x6c, (byte) 0x4e, (byte) 0x61, (byte) 0x6d, (byte) 0x65,
- (byte) 0x74, (byte) 0x00, (byte) 0x12, (byte) 0x4c, (byte) 0x6a,
- (byte) 0x61, (byte) 0x76, (byte) 0x61, (byte) 0x2f, (byte) 0x6c,
- (byte) 0x61, (byte) 0x6e, (byte) 0x67, (byte) 0x2f, (byte) 0x53,
- (byte) 0x74, (byte) 0x72, (byte) 0x69, (byte) 0x6e, (byte) 0x67,
- (byte) 0x3b, (byte) 0x78, (byte) 0x70, (byte) 0x74, (byte) 0x00,
- (byte) 0x01, (byte) 0x62, (byte) 0x74, (byte) 0x00, (byte) 0x01,
- (byte) 0x63, (byte) 0x78 };
-}
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/DelegationPermissionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/DelegationPermissionTest.java
deleted file mode 100644
index 4a6345b..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/DelegationPermissionTest.java
+++ /dev/null
@@ -1,219 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.kerberos;
-
-import java.security.AllPermission;
-import java.security.BasicPermission;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.SecurityPermission;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import javax.security.auth.kerberos.DelegationPermission;
-import javax.security.auth.kerberos.ServicePermission;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests DelegationPermission class implementation.
- */
-public class DelegationPermissionTest extends TestCase {
-
- /**
- * testing of a correct ctor
- */
- public void testCtor() {
- String name1 = "\"aaa.bbb.com@CCC.COM\" \"ccc.ddd.com@DDD.COM\"";
- DelegationPermission dp;
- dp = new DelegationPermission(name1);
- assertEquals(name1, dp.getName());
- assertEquals("",dp.getActions());
- dp = new DelegationPermission(name1, "action");
- assertEquals("",dp.getActions());
- dp = new DelegationPermission(name1, null);
- assertEquals("",dp.getActions());
- }
-
- /**
- * testing of a incorrect ctor
- */
- public void testFailCtor() {
- try {
- new DelegationPermission(null);
- fail("no expected NPE");
- } catch(NullPointerException e){
- }
- try {
- new DelegationPermission("");
- fail("no expected IAE");
- } catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\"aaa.bbb.com\" ccc.ddd.com");
- fail("Target name must be enveloped by quotes");
- } catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\"aaa.bbb.com\" ccc.ddd.com\"");
- fail("Target name must be enveloped by quotes");
- } catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\"aaa.bbb.com\" \"ccc.ddd.com");
- fail("Target name must be enveloped by quotes");
- } catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\" \" \" \"");
- //TODO: fail("Target name is empty");
- }catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\"\"");
- fail("Target name is incorrect");
- } catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\"aaa.bbb.com\" \"\"");
- fail("service principal is empty");
- } catch(IllegalArgumentException e){
- }
- try {
- new DelegationPermission("\"\" \"aaa.bbb.com\"");
- fail("subordinate service principal is empty");
- } catch(IllegalArgumentException e){
- }
-
- }
-
- public void testFailCtor_2() {
- try {
- new DelegationPermission("\"AAA\"");
- fail("target name should be specifies a pair of kerberos service principals");
- } catch (IllegalArgumentException e) {
- }
- }
-
- // testing of the equals method
- @SuppressWarnings("serial")
- public void testEquals() {
- DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
- DelegationPermission dp2 = new DelegationPermission("\"AAA\" \"BBB\"");
-
- assertTrue(dp1.equals(dp1));
- assertFalse(dp1.equals(new DelegationPermission("\"aaa\" \"bbb\"")));
- assertTrue(dp2.equals(dp1));
- assertTrue(dp1.equals(dp2));
- assertTrue(dp1.hashCode() == dp2.hashCode());
- assertFalse(dp1.equals(new BasicPermission("\"AAA\""){}));
- }
- // testing of the implies method
- public void testImplies() {
- DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
- DelegationPermission dp2 = new DelegationPermission("\"BBB\" \"AAA\"");
- assertFalse(dp1.implies(dp2));
- assertFalse(dp2.implies(dp1));
- assertTrue(dp1.implies(dp1));
- assertFalse(dp1.implies(new ServicePermission("aaa", "accept")));
- assertFalse(dp1.implies(null));
- }
-
- // testing of the KrbDelegationPermissionCollection
-
-
- // testing of the add collection method
- public void testAddCollection() {
- DelegationPermission dp = new DelegationPermission("\"AAA\" \"BBB\"");
- PermissionCollection pc1 = dp.newPermissionCollection();
- PermissionCollection pc2 = dp.newPermissionCollection();
- assertNotSame(pc1, pc2);
- pc1.add(new DelegationPermission("\"BBB\" \"AAA\""));
- try {
- pc1.add(new SecurityPermission("aaa"));
- fail("should not add non DelegationPermission");
- } catch (IllegalArgumentException e){
- }
- try {
- pc1.add(null);
- fail("permission is null");
- } catch (IllegalArgumentException e) {
- }
- pc1.setReadOnly();
- try {
- pc1.add(new DelegationPermission("\"CCC\" \"AAA\""));
- fail("read-only flag is ignored");
- } catch (SecurityException e) {
- }
- }
-
- public void testImpliesCollection(){
-
- Permission ap = new AllPermission();
- Permission p = new DelegationPermission("\"AAA\" \"BBB\"");
- PermissionCollection pc = p.newPermissionCollection();
- assertFalse(pc.implies(ap));
- assertFalse(pc.implies(p));
- pc.add(p);
- assertTrue(pc.implies(p));
- assertFalse(pc.implies(null));
- DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
- assertTrue(dp1.implies(dp1));
- DelegationPermission dp2 = new DelegationPermission("\"BBB\" \"AAA\"");
- assertFalse(dp1.implies(dp2));
- assertFalse(dp1.implies(null));
- assertFalse(dp1.implies(new ServicePermission("aaa", "accept")));
- }
-
- public void testElements() throws Exception {
- Permission p = new DelegationPermission("\"AAA\" \"BBB\"");
- PermissionCollection pc = p.newPermissionCollection();
- try {
- pc.elements().nextElement();
- fail("expected NoSuchElementException");
- } catch (NoSuchElementException e) {
- }
- Enumeration<Permission> en = pc.elements();
- assertNotNull(en);
- assertFalse(en.hasMoreElements());
- Permission sp1 = new DelegationPermission("\"DDD\" \"BBB\"");
- Permission sp2 = new DelegationPermission("\"CCC\" \"BBB\"");
- pc.add(sp1);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(sp1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
- pc.add(sp2);
- en = pc.elements();
- Collection<Permission> c = new ArrayList<Permission>();
- while (en.hasMoreElements()) {
- c.add(en.nextElement());
- }
- assertFalse(en.hasMoreElements());
- assertEquals(2, c.size());
- assertTrue(c.contains(sp1) && c.contains(sp2));
- }
-
- }
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/ServicePermissionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/ServicePermissionTest.java
deleted file mode 100644
index d7e575e..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/ServicePermissionTest.java
+++ /dev/null
@@ -1,304 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.kerberos;
-
-import java.security.AllPermission;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import javax.security.auth.kerberos.DelegationPermission;
-import javax.security.auth.kerberos.ServicePermission;
-
-import junit.framework.TestCase;
-
-/**
- * Tests ServicePermission class implementation.
- */
-public class ServicePermissionTest extends TestCase {
-
-
- /**
- * @tests javax.security.auth.kerberos.ServicePermission#ServicePermission(
- * java.lang.String,java.lang.String)
- */
- public void testCtor() {
- ServicePermission sp = new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate");
- ServicePermission sp1 = new ServicePermission("host/AAA.COM@BBB.COM", "accept");
- assertEquals("krbtgt/AAA.COM@BBB.COM",sp.getName());
- assertEquals("initiate",sp.getActions());
- assertEquals("host/AAA.COM@BBB.COM",sp1.getName());
- assertEquals("accept",sp1.getActions());
- ServicePermission sp2 = new ServicePermission("host/AAA.COM@BBB.COM", "accept, initiate");
- assertEquals("initiate,accept", sp2.getActions());
-
- try {
- // Regression for HARMONY-769
- // checks exception order: action parameter is verified first
- new ServicePermission(null, "initiate accept");
- fail("No expected IllegalArgumentException");
- } catch(IllegalArgumentException e){
- }
- }
-
- public void testFailedCtor() {
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "read");
- fail("incorrect actions");
- } catch(IllegalArgumentException e){
- }
-
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "");
- fail("actions is empty");
- } catch(IllegalArgumentException e){
- }
-
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", null);
- fail("actions is null");
- } catch(NullPointerException e){
- } catch(IllegalArgumentException e){}
-
- try {
- new ServicePermission(null, "accept");
- fail("permission is null");
- } catch(NullPointerException e){
- }
- try {
- new ServicePermission("", "accept");
- //TODO: fail("No expected IAE"); //
- } catch(IllegalArgumentException e){}
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "accept, read");
- fail("Incorrect actions");
- } catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, read");
- fail("Incorrect actions");
- } catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "read, initiate ");
- fail("Incorrect actions");
- } catch(Exception e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "read, accept ");
- fail("Incorrect actions");
- }catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", ", accept ");
- //TODO: fail("No expected IAE");
- } catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, accept, read");
- fail("Incorrect actions");
- } catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, read, accept");
- fail("Incorrect actions");
- } catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, accept, accept");
- //TODO: fail("Incorrect actions");
- } catch(IllegalArgumentException e){
- }
- try {
- new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate accept");
- fail("Incorrect actions");
- } catch(IllegalArgumentException e){
- }
- }
-
- public void testEquals() {
- ServicePermission sp = new ServicePermission("host/AAA.COM@BBB.COM", "accept");
- ServicePermission sp1 = new ServicePermission("host/AAA.COM@BBB.COM", "initiate");
- ServicePermission sp2 = new ServicePermission("host/AAA.COM@BBB.COM", "initiate, accept");
- assertTrue(sp.equals(sp));
- assertTrue(sp.hashCode() == sp.hashCode());
- assertFalse(sp.equals(sp1));
- assertFalse(sp.hashCode() == sp1.hashCode());
- assertFalse(sp.equals(sp2));
- assertFalse(sp1.equals(sp2));
- assertTrue(sp2.equals(sp2));
- assertFalse(sp.equals(new DelegationPermission("\"AAA\" \"BBB\"", "action")));
- assertFalse(sp.equals(null));
- }
-
- public void testImplies() {
- ServicePermission sp1;
- ServicePermission sp = new ServicePermission("host/AAA.COM@BBB.COM", "accept");
- sp1 = new ServicePermission("*", "initiate, accept");
- assertTrue(sp.implies(sp));
- assertFalse(sp.implies(sp1));
- assertTrue(sp1.implies(sp));
- assertTrue(sp1.implies(sp1));
- sp1 = new ServicePermission("*", "accept");
- assertTrue(sp1.implies(sp));
- sp1 = new ServicePermission("*", "initiate");
- assertFalse(sp1.implies(sp));
- assertFalse(sp1.implies(new ServicePermission("*", "accept, initiate")));
- assertTrue(new ServicePermission("host/AAA.COM@BBB.COM", "initiate, accept").implies(sp));
- assertTrue(new ServicePermission("host/AAA.COM@BBB.COM", "accept").implies(sp));
- assertFalse(new ServicePermission("host/AAA.COM@BBB.COM", "initiate").implies(sp));
- assertFalse(sp1.implies(null));
- }
-
- // tests for KrbServicePermissionCollection
-
- public void testAddCollection() {
- ServicePermission sp = new ServicePermission("AAA", "accept");
- PermissionCollection pc = sp.newPermissionCollection();
-
- try {
- pc.add(new DelegationPermission("\"aaa\" \"bbb\""));
- fail("Should not add non DelegationPermission");
- } catch (IllegalArgumentException e) {
- }
-
- try {
- pc.add(null);
- fail("no expected IAE");
- } catch (IllegalArgumentException e) {
- }
-
- pc.add(new ServicePermission("AAA", "accept"));
- pc.add(new ServicePermission("BBB", "accept, initiate"));
-
- pc.setReadOnly();
- try {
- pc.add(sp);
- fail("read-only flag is ignored");
- } catch (SecurityException e) {
- }
- }
-
- public void testImpliesCollection(){
-
- Permission ap = new AllPermission();
- Permission p = new ServicePermission("AAA", "accept");
- PermissionCollection pc = p.newPermissionCollection();
- assertFalse(pc.implies(ap));
- assertFalse(pc.implies(p));
- pc.add(p);
- assertTrue(pc.implies(p));
- assertFalse(pc.implies(null));
- assertFalse(pc.implies(new ServicePermission("BBB", "initiate")));
- assertFalse(pc.implies(new ServicePermission("CCC", "accept")));
- pc.add(new ServicePermission("*", "accept, initiate"));
- assertTrue(pc.implies(new ServicePermission("*", "accept")));
- assertTrue(pc.implies(new ServicePermission("*", "initiate")));
- assertTrue(pc.implies(new ServicePermission("BBB", "initiate")));
- assertTrue(pc.implies(new ServicePermission("CCC", "accept")));
-
-
- }
-
- public void testElements() {
- Permission p = new ServicePermission("AAA", "accept");
- PermissionCollection pc = p.newPermissionCollection();
-
- try {
- pc.elements().nextElement();
- fail("expected NoSuchElementException");
- } catch (NoSuchElementException e) {
- }
-
- Enumeration<Permission> en = pc.elements();
- assertNotNull(en);
- assertFalse(en.hasMoreElements());
-
- Permission sp1 = new ServicePermission("BBB", "accept, initiate");
- Permission sp2 = new ServicePermission("CCC", "initiate");
- Permission sp3 = new ServicePermission("DDD", "accept");
-
- pc.add(sp1);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(sp1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
- pc.add(sp2);
- pc.add(sp3);
- en = pc.elements();
- Collection<Permission> c = new ArrayList<Permission>();
- while (en.hasMoreElements())
- {
- c.add(en.nextElement());
- }
- assertFalse(en.hasMoreElements());
- assertEquals(3, c.size());
- assertTrue(c.contains(sp1) && c.contains(sp2) && c.contains(sp3));
- }
-
- public void testActions() {
-
- String[] validActions = new String[] { " accept ", // spaces
- "accept,ACCEPT,accept",
- "initiate,INITIATE,initiate",
- "\naccept,accept,accept\n", // leading & trailing \n
- "\naccept,accept,accept\n", // leading & trailing \n
- "\naccept,initiate,accept\n", // leading & trailing \n
- "\ninitiate\n,\raccept,initiate\n", // leading & trailing \n
- "\naccept\n", // leading & trailing \n
- "\naccept\n", // leading & trailing \n
- "\taccept\t", // leading & trailing \t
- "\taccept\t", // leading & trailing \r
- "accept , initiate", // spaces
- "accept\n,\ninitiate", // \n
- "accept\t,\tinitiate", // \t
- "accept\r,\rinitiate", // \r
- "AccepT", // first & last upper case
- "InitiatE", // first & last upper case
- "Accept, initiatE" // first & last upper case
- };
-
- for (String element : validActions) {
- new ServicePermission("*", element);
- }
-
- String[] invalidActions = new String[] { "accept initiate", // space
- "accept\ninitiate", // delimiter \n
- "accept\tinitiate", // delimiter \t
- "accept\tinitiate", // delimiter \r
- "accept, ", // ','
- "accept,", // ','
- " ,accept" // ','
- };
- for (String element : invalidActions) {
- try {
- new ServicePermission("*", element);
- fail("No expected IllegalArgumentException for action: "
- + element);
- } catch (IllegalArgumentException e) {
- }
- }
- }
-}
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.java
deleted file mode 100644
index 4304219..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.java
+++ /dev/null
@@ -1,41 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization;
-
-import javax.security.auth.kerberos.DelegationPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-
-/**
- * Serialization test for DelegationPermission class
- */
-public class DelegationPermissionTest extends SerializationTest {
-
- @Override
- protected Object[] getData() {
- return new Object[] {
- new DelegationPermission("\"AAA\" \"BBB\"", "action"),
- new DelegationPermission("\"AAA\" \"CCC\"") };
- }
-} \ No newline at end of file
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.java
deleted file mode 100644
index cc5445a..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.java
+++ /dev/null
@@ -1,50 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import javax.security.auth.kerberos.DelegationPermission;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-
-/**
- * Serialization test for KrbDelegationPermissionCollection class
- */
-public class KrbDelegationPermissionCollectionTest extends SerializationTest {
-
- @Override
- protected Object[] getData() {
- Permission p1 = new DelegationPermission("\"AAA\" \"BBB\"", "action");
- Permission p2 = new DelegationPermission("\"AAA\" \"CCC\"");
- Permission p3 = new DelegationPermission("\"BBB\" \"CCC\"");
- PermissionCollection pc1 = p1.newPermissionCollection();
- PermissionCollection pc2 = p1.newPermissionCollection();
- pc2.add(p3);
- PermissionCollection pc3 = p1.newPermissionCollection();
- pc3.add(p1);
- pc3.add(p2);
- pc3.add(p3);
- return new Object[] { pc1, pc2, pc3 };
- }
-}
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.java
deleted file mode 100644
index e2ce200..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import javax.security.auth.kerberos.ServicePermission;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Serialization test for KrbServicePermissionCollection class
- */
-public class KrbServicePermissionCollectionTest extends SerializationTest {
-
- @Override
- protected Object[] getData() {
- Permission p1 = new ServicePermission("AAA", "accept");
- Permission p2 = new ServicePermission("BBB", "initiate");
- Permission p3 = new ServicePermission("CCC", "initiate, accept");
- PermissionCollection pc1 = p1.newPermissionCollection();
- PermissionCollection pc2 = p1.newPermissionCollection();
- pc2.add(p3);
- PermissionCollection pc3 = p1.newPermissionCollection();
- pc3.add(p1);
- pc3.add(p2);
- pc3.add(p3);
- return new Object[] { pc1, pc2, pc3 };
- }
-
-}
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.java
deleted file mode 100644
index ff6b515..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.java
+++ /dev/null
@@ -1,41 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization;
-
-import javax.security.auth.kerberos.ServicePermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization test for ServicePermission class
- */
-public class ServicePermissionTest extends SerializationTest {
-
- @Override
- protected Object[] getData() {
- return new Object[] { new ServicePermission("AAA", "accept"),
- new ServicePermission("BBB", "initiate"),
- new ServicePermission("CCC", "initiate, accept"),
- new ServicePermission("CCC", "accept, initiate ") };
- }
-} \ No newline at end of file
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.java
deleted file mode 100644
index aa1261a..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.serialization;
-
-import javax.security.auth.AuthPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization test for AuthPermission class
- */
-
-public class AuthPermissionTest extends SerializationTest {
-
- @Override
- protected Object[] getData() {
- return new Object[] {new AuthPermission("name", "read")};
- }
-} \ No newline at end of file
diff --git a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.java b/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.java
deleted file mode 100644
index effa17c..0000000
--- a/auth/src/test/java/common/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.java
+++ /dev/null
@@ -1,39 +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.
- */
-
-/**
-* @author Maxim V. Makarov
-*/
-
-package org.apache.harmony.auth.tests.javax.security.auth.serialization;
-
-import javax.security.auth.PrivateCredentialPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization test for PrivateCredentialPermission class
- */
-
-public class PrivateCredentialPermissionTest extends SerializationTest {
-
- @Override
- protected Object[] getData() {
- return new Object[] {new PrivateCredentialPermission("a.b.Cred a.c.Princ \"duke\"", "read")};
- }
-} \ No newline at end of file
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.0.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.0.ser
deleted file mode 100644
index e01699c..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.1.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.1.ser
deleted file mode 100644
index 486a183..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/DelegationPermissionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.0.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.0.ser
deleted file mode 100644
index 010e855..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.1.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.1.ser
deleted file mode 100644
index 79ed054..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.2.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.2.ser
deleted file mode 100644
index 12d7693..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbDelegationPermissionCollectionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.0.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.0.ser
deleted file mode 100644
index 201c4b1..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.1.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.1.ser
deleted file mode 100644
index 3457fd0..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.2.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.2.ser
deleted file mode 100644
index ba251c3..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/KrbServicePermissionCollectionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.0.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.0.ser
deleted file mode 100644
index eed9897..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.1.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.1.ser
deleted file mode 100644
index 4a827d0..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.2.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.2.ser
deleted file mode 100644
index ea7f1eb..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.3.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.3.ser
deleted file mode 100644
index ea7f1eb..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/kerberos/serialization/ServicePermissionTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.golden.0.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.golden.0.ser
deleted file mode 100644
index 61c29b0..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/AuthPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.golden.0.ser b/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.golden.0.ser
deleted file mode 100644
index f7f9c78..0000000
--- a/auth/src/test/resources/serialization/org/apache/harmony/auth/tests/javax/security/auth/serialization/PrivateCredentialPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java b/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java
deleted file mode 100644
index aa8f7fa..0000000
--- a/logging/src/test/java/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.java
+++ /dev/null
@@ -1,77 +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.logging.tests.java.util.logging;
-
-import java.util.logging.LoggingPermission;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-public class LoggingPermissionTest extends TestCase {
-
- /**
- * @tests serialization/deserialization compatibility.
- */
- public void testSerializationSelf() throws Exception {
- SerializationTest.verifySelf(new LoggingPermission("control", ""));
- }
-
- /**
- * @tests serialization/deserialization compatibility with RI.
- */
- public void testSerializationCompatibility() throws Exception {
-
- SerializationTest.verifyGolden(this, new LoggingPermission("control",
- ""));
- }
-
- public void testLoggingPermission() {
- try {
- new LoggingPermission(null, null);
- fail("should throw IllegalArgumentException");
- } catch (NullPointerException e) {
- }
- try {
- new LoggingPermission("", null);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- new LoggingPermission("bad name", null);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- new LoggingPermission("Control", null);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
- try {
- new LoggingPermission("control",
- "bad action");
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- new LoggingPermission("control", "");
-
- new LoggingPermission("control", null);
- }
-
-}
diff --git a/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.ser b/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.ser
deleted file mode 100644
index f4cdced..0000000
--- a/logging/src/test/resources/serialization/org/apache/harmony/logging/tests/java/util/logging/LoggingPermissionTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java
deleted file mode 100644
index 5b5a759..0000000
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/FilePermissionTest.java
+++ /dev/null
@@ -1,222 +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.luni.tests.java.io;
-
-import java.io.File;
-import java.io.FilePermission;
-import java.security.PermissionCollection;
-
-import junit.framework.TestCase;
-
-public class FilePermissionTest extends TestCase {
-
- FilePermission readAllFiles = new FilePermission("<<ALL FILES>>", "read");
-
- FilePermission alsoReadAllFiles = new FilePermission("<<ALL FILES>>",
- "read");
-
- FilePermission allInCurrent = new FilePermission("*",
- "read, write, execute,delete");
-
- FilePermission readInCurrent = new FilePermission("*", "read");
-
- FilePermission readInFile = new FilePermission("aFile.file", "read");
-
- FilePermission readInSubdir = new FilePermission("-", "read");
-
- /**
- * @tests java.io.FilePermission#FilePermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- assertTrue("Used to test", true);
- FilePermission constructFile = new FilePermission("test constructor",
- "write");
- assertEquals(
- "action given to the constructor did not correspond - constructor failed",
- "write", constructFile.getActions());
- assertTrue(
- "name given to the constructor did not correspond - constructor failed",
- constructFile.getName() == "test constructor");
-
- // Regression test for HARMONY-1050
- try {
- new FilePermission(null, "drink");
- fail("Expected IAE");
- } catch (IllegalArgumentException e) {
- // Expected
- }
-
- try {
- new FilePermission(null, "read");
- fail("Expected NPE");
- } catch (NullPointerException e) {
- // Expected
- }
-
- try {
- new FilePermission(null, null);
- fail("Expected IAE");
- } catch (IllegalArgumentException e) {
- // Expected
- }
- }
-
- /**
- * @tests java.io.FilePermission#getActions()
- */
- public void test_getActions() {
- assertEquals("getActions should have returned only read", "read",
- readAllFiles.getActions());
- assertEquals("getActions should have returned all actions",
- "read,write,execute,delete", allInCurrent.getActions());
- }
-
- /**
- * @tests java.io.FilePermission#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() {
- assertTrue(
- "Should not returned false when two instance of FilePermission is equal",
- readAllFiles.equals(alsoReadAllFiles));
- assertFalse(
- "Should not returned true when two instance of FilePermission is not equal",
- readInCurrent.equals(readInFile));
- }
-
- /**
- * @tests java.io.FilePermission#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() {
- assertFalse("Should not return true for non-subset of actions", readAllFiles
- .implies(allInCurrent));
- assertFalse("Should not return true for non-subset of files", allInCurrent
- .implies(readAllFiles));
- assertTrue("Should not return false for subset of actions", allInCurrent
- .implies(readInCurrent));
- assertTrue("Should not return false for subset of files", readAllFiles
- .implies(readInCurrent));
- assertTrue("Should not return false for subset of files and actions",
- allInCurrent.implies(readInFile));
- assertTrue("Should not return false for equal FilePermissions", readAllFiles
- .implies(alsoReadAllFiles));
- assertTrue("Should not return false for subdir self", readInSubdir.implies(readInSubdir));
- assertTrue("Should not return false for current self", readInCurrent.implies(readInCurrent));
- assertTrue("Should not return false for subdir", readInSubdir.implies(readInCurrent));
-
- FilePermission fp13 = new FilePermission(File.separator, "read");
- FilePermission fp14 = new FilePermission(File.separator + "*", "read");
- assertFalse("/ should not imply /*", fp13.implies(fp14));
- fp14 = new FilePermission(File.separator + "-", "read");
- assertFalse("/ should not imply /-", fp13.implies(fp14));
-
- FilePermission fp3 = new FilePermission("/bob/*".replace('/',
- File.separatorChar), "read,write");
- FilePermission fp4 = new FilePermission("/bob/".replace('/',
- File.separatorChar), "write");
- assertFalse("Should not return true for same dir using * and not *", fp3
- .implies(fp4));
- FilePermission fp5 = new FilePermission("/bob/file".replace('/',
- File.separatorChar), "write");
- assertTrue("Should not return false for same dir using * and file", fp3
- .implies(fp5));
-
- FilePermission fp6 = new FilePermission("/bob/".replace('/',
- File.separatorChar), "read,write");
- FilePermission fp7 = new FilePermission("/bob/*".replace('/',
- File.separatorChar), "write");
- assertFalse("Should not return true for same dir using not * and *", fp6
- .implies(fp7));
- assertTrue("Should not return false for same subdir", fp6.implies(fp4));
-
- FilePermission fp8 = new FilePermission("/".replace('/',
- File.separatorChar), "read,write");
- FilePermission fp9 = new FilePermission("/".replace('/',
- File.separatorChar), "write");
- assertTrue("Should not return false for same dir", fp8.implies(fp9));
-
- FilePermission fp10 = new FilePermission("/".replace('/',
- File.separatorChar), "read,write");
- FilePermission fp11 = new FilePermission("/".replace('/',
- File.separatorChar), "write");
- assertTrue("Should not return false for same dir", fp10.implies(fp11));
-
- FilePermission fp12 = new FilePermission("/*".replace('/',
- File.separatorChar), "read,write");
- assertFalse("Should not return true for same dir using * and dir", fp12
- .implies(fp10));
-
- // Regression for HARMONY-47
- char separator = File.separatorChar;
- char nonSeparator = (separator == '/') ? '\\' : '/';
-
- FilePermission fp1 = new FilePermission(nonSeparator + "*", "read");
- FilePermission fp2 = new FilePermission(separator + "a", "read");
- assertFalse("Assert 0: non-separator worked", fp1.implies(fp2));
- fp1 = new FilePermission(nonSeparator + "-", "read");
- assertFalse("Assert 1: non-separator worked", fp1.implies(fp2));
- }
-
- /**
- * @tests java.io.FilePermission#newPermissionCollection()
- */
- public void test_newPermissionCollection() {
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[4];
- perm[0] = readAllFiles;
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
-
- PermissionCollection collect = perm[0].newPermissionCollection();
- for (int i = 0; i < perm.length; i++) {
- collect.add(perm[i]);
- }
- assertTrue("Should not return false for subset of files", collect
- .implies(new FilePermission("*", "write")));
- assertTrue("Should not return false for subset of name and action", collect
- .implies(new FilePermission(s + "tmp", "read")));
- assertTrue("Should not return false for non subset of file and action", collect
- .implies(readInFile));
-
- FilePermission fp1 = new FilePermission("/tmp/-".replace('/',
- File.separatorChar), "read");
- PermissionCollection fpc = fp1.newPermissionCollection();
- fpc.add(fp1);
- fpc.add(new FilePermission("/tmp/scratch/foo/*".replace('/',
- File.separatorChar), "write"));
- FilePermission fp2 = new FilePermission("/tmp/scratch/foo/file"
- .replace('/', File.separatorChar), "read,write");
- assertTrue("collection does not collate", fpc.implies(fp2));
- }
-
- /**
- * @tests java.io.FilePermission#hashCode()
- */
- public void test_hashCode() {
- assertTrue(
- "two equal filePermission instances returned different hashCode",
- readAllFiles.hashCode() == alsoReadAllFiles.hashCode());
- assertTrue(
- "two filePermission instances with same permission name returned same hashCode",
- readInCurrent.hashCode() != allInCurrent.hashCode());
-
- }
-}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializablePermissionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializablePermissionTest.java
deleted file mode 100644
index 0589e9f..0000000
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializablePermissionTest.java
+++ /dev/null
@@ -1,59 +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.luni.tests.java.io;
-
-import java.io.SerializablePermission;
-
-public class SerializablePermissionTest extends junit.framework.TestCase {
-
- /**
- * @tests java.io.SerializablePermission#SerializablePermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.io.SerializablePermission(java.lang.String)
- assertEquals("permission ill-formed",
- "enableSubclassImplementation", new SerializablePermission(
- "enableSubclassImplementation").getName());
- }
-
- /**
- * @tests java.io.SerializablePermission#SerializablePermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.io.SerializablePermission(java.lang.String,
- // java.lang.String)
- assertEquals("permission ill-formed",
- "enableSubclassImplementation", new SerializablePermission(
- "enableSubclassImplementation", "").getName());
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java
index 952b403..308b0af 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest.java
@@ -133,11 +133,6 @@ public class SerializationStressTest extends junit.framework.TestCase implements
static final Set<String> SET = new HashSet<String>(Arrays.asList(new String[] { "one",
"two", "three" }));
- static final Permission PERM = new PropertyPermission("file.encoding",
- "write");
-
- static final PermissionCollection PERMCOL = PERM.newPermissionCollection();
-
static final SortedSet<String> SORTSET = new TreeSet<String>(Arrays.asList(new String[] {
"one", "two", "three" }));
@@ -180,7 +175,6 @@ public class SerializationStressTest extends junit.framework.TestCase implements
TREE.put("one", "1");
TREE.put("two", "2");
TREE.put("three", "3");
- PERMCOL.add(PERM);
// To make sure they all use the same Calendar
CALENDAR.setTimeZone(new SimpleTimeZone(0, "GMT"));
CALENDAR.set(1999, Calendar.JUNE, 23, 15, 47, 13);
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest2.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest2.java
index 362bf6f..5ee4353 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest2.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest2.java
@@ -1055,66 +1055,6 @@ public class SerializationStressTest2 extends SerializationStressTest {
}
}
- public void test_18_49_writeObject() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.lang.Object)
-
- Object objToSave = null;
- Object objLoaded;
-
- try {
- java.net.SocketPermission p = new java.net.SocketPermission(
- "www.yahoo.com", "connect");
- objToSave = p;
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
- assertTrue("SocketPermissions are not the same: " + p + "\t,\t"
- + objLoaded, p.equals(objLoaded));
-
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
- }
-
- public void test_18_50_writeObject() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.lang.Object)
-
- Object objToSave = null;
- Object objLoaded;
-
- try {
- java.net.SocketPermission p = new java.net.SocketPermission(
- "www.yahoo.com", "ReSoLVe, ConNecT");
- objToSave = p;
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
- assertTrue("SocketPermissions are not the same: " + p + "\t,\t"
- + objLoaded, p.equals(objLoaded));
-
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
- }
-
public void test_18_51_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest3.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest3.java
index 3e71daa..f9ed99a 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest3.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest3.java
@@ -1399,77 +1399,6 @@ public class SerializationStressTest3 extends SerializationStressTest {
}
}
- public void test_18_117_writeObject() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.lang.Object)
-
- Object objToSave = null;
- Object objLoaded;
-
- try {
- objToSave = PERM;
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, PERM.equals(objLoaded));
-
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
- }
-
- public void test_18_118_writeObject() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.lang.Object)
-
- Object objToSave = null;
- Object objLoaded;
-
- try {
- objToSave = PERMCOL;
- Enumeration elementsBefore = PERMCOL.elements();
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
- // Has to have worked
- Enumeration elementsAfter = ((PermissionCollection) objLoaded)
- .elements();
- boolean equals = true;
- while (elementsBefore.hasMoreElements()) {
- // To make sure elements are the same
- Object oBefore = elementsBefore.nextElement();
- Object oAfter = elementsAfter.nextElement();
- equals &= oBefore.equals(oAfter);
-
- }
- // To make sure sizes are the same
- equals &= elementsBefore.hasMoreElements() == elementsAfter
- .hasMoreElements();
-
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
-
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
- }
-
public void test_18_119_writeObject() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Object)
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest4.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest4.java
index 3b6170d..947e2a1 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest4.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/SerializationStressTest4.java
@@ -18,7 +18,6 @@
package org.apache.harmony.luni.tests.java.io;
import java.io.File;
-import java.io.FilePermission;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
@@ -26,8 +25,6 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URI;
import java.net.URISyntaxException;
-import java.security.AllPermission;
-import java.security.PermissionCollection;
import java.security.cert.Certificate;
import java.text.DateFormat;
import java.text.MessageFormat;
@@ -87,59 +84,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
}
- public void test_writeObject_PermissionCollection() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.PermissionCollection)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = null;
- objToSave = new PermissionCollection() {
- boolean added = false;
-
- public void add(java.security.Permission p1) {
- added = true;
- }
-
- public Enumeration elements() {
- return (new Vector()).elements();
- }
-
- public boolean implies(java.security.Permission p1) {
- return added;
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof java.security.PermissionCollection))
- return false;
- return implies(null) == ((PermissionCollection) obj)
- .implies(null);
- }
- };
-
- ((java.security.PermissionCollection) objToSave).add(null);
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Collections_EmptySet() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Collections.EmptySet)
@@ -206,84 +150,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_BasicPermissionCollection() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.BasicPermissionCollection)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = (new RuntimePermission("test"))
- .newPermissionCollection();
- ((java.security.PermissionCollection) objToSave)
- .add(new RuntimePermission("test"));
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
- .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
- .elements();
-
- equals = true;
- while (enum1.hasMoreElements() && equals) {
- if (enum2.hasMoreElements())
- equals = enum1.nextElement().equals(enum2.nextElement());
- else
- equals = false;
- }
-
- if (equals)
- equals = !enum2.hasMoreElements();
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
- public void test_writeObject_UnresolvedPermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.UnresolvedPermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.security.UnresolvedPermission("type", "name",
- "actions", null);
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- equals = objToSave.toString().equals(objLoaded.toString());
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Character() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.Character)
@@ -431,55 +297,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_UnresolvedPermissionCollection() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.UnresolvedPermissionCollection)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = (new java.security.UnresolvedPermission("type", "name",
- "actions", null)).newPermissionCollection();
- ((java.security.PermissionCollection) objToSave)
- .add(new java.security.UnresolvedPermission("type", "name",
- "actions", null));
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
- .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
- .elements();
-
- equals = true;
- while (enum1.hasMoreElements() && equals) {
- if (enum2.hasMoreElements())
- equals = enum1.nextElement().toString().equals(
- enum2.nextElement().toString());
- else
- equals = false;
- }
-
- if (equals)
- equals = !enum2.hasMoreElements();
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_SecureRandomSpi() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.security.SecureRandomSpi)
@@ -670,36 +487,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_ReflectPermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.lang.reflect.ReflectPermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.lang.reflect.ReflectPermission(
- "TestSerialization", "test");
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("IOException serializing " + objToSave + " : "
- + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type : "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_StringBuffer() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.lang.StringBuffer)
@@ -760,52 +547,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_AllPermissionCollection() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.AllPermissionCollection)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = (new java.security.AllPermission())
- .newPermissionCollection();
- ((java.security.PermissionCollection) objToSave)
- .add(new java.security.AllPermission());
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
- .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
- .elements();
-
- equals = true;
- while (enum1.hasMoreElements() && equals) {
- if (enum2.hasMoreElements())
- equals = enum1.nextElement().equals(enum2.nextElement());
- else
- equals = false;
- }
-
- if (equals)
- equals = !enum2.hasMoreElements();
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_BitSet() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.BitSet)
@@ -927,35 +668,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_SerializablePermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.io.SerializablePermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.io.SerializablePermission("TestSerialization",
- "Test");
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Properties() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Properties)
@@ -1001,38 +713,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- // TODO : requires working security implementation
- // public void test_writeObject_BasicPermission() {
- // // Test for method void
- // //
- // java.io.ObjectOutputStream.writeObject(tests.java.security.Test_BasicPermission.BasicPermissionSubclass)
- //
- // Object objToSave = null;
- // Object objLoaded = null;
- //
- // try {
- // objToSave = new
- // tests.java.security.Test_BasicPermission.BasicPermissionSubclass(
- // "TestSerialization");
- // if (DEBUG)
- // System.out.println("Obj = " + objToSave);
- // objLoaded = dumpAndReload(objToSave);
- //
- // // Has to have worked
- // assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- // } catch (IOException e) {
- // fail("Exception serializing " + objToSave + " : "
- // + e.getMessage());
- // } catch (ClassNotFoundException e) {
- // fail("ClassNotFoundException reading Object type : " + e.getMessage());
- // } catch (Error err) {
- // System.out.println("Error when obj = " + objToSave);
- // // err.printStackTrace();
- // throw err;
- // }
- //
- // }
-
public void test_writeObject_Collections_UnmodifiableMap_UnmodifiableEntrySet() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Collections.UnmodifiableMap.UnmodifiableEntrySet)
@@ -1273,34 +953,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_AllPermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.AllPermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.security.AllPermission();
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Collections_ReverseComparator() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Collections.ReverseComparator)
@@ -1529,54 +1181,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_FilePermission_FilePermissionCollection() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.io.FilePermission.FilePermissionCollection)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = (new java.io.FilePermission("<<ALL FILES>>", "read"))
- .newPermissionCollection();
- ((java.security.PermissionCollection) objToSave)
- .add(new FilePermission("<<ALL FILES>>", "read"));
- ((java.security.PermissionCollection) objToSave)
- .add(new FilePermission("d:\\", "read"));
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- java.util.Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
- .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
- .elements();
-
- equals = true;
- while (enum1.hasMoreElements() && equals) {
- if (enum2.hasMoreElements())
- equals = enum1.nextElement().equals(enum2.nextElement());
- else
- equals = false;
- }
-
- if (equals)
- equals = !enum2.hasMoreElements();
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_SecureRandom() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.security.SecureRandom)
@@ -1608,34 +1212,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_FilePermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.io.FilePermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.io.FilePermission("<<ALL FILES>>", "read");
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_InetAddress() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.net.InetAddress)
@@ -1693,102 +1269,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_RuntimePermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.lang.RuntimePermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.lang.RuntimePermission("TestSerialization",
- "Test");
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void test_writeObject_Permissions() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.Permissions)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.security.Permissions();
- ((java.security.Permissions) objToSave).add(new AllPermission());
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
- .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
- .elements();
- java.util.Vector vec1 = new java.util.Vector(), vec2 = new java.util.Vector();
-
- while (enum1.hasMoreElements())
- vec1.add(enum1.nextElement());
- while (enum2.hasMoreElements())
- vec2.add(enum2.nextElement());
-
- equals = vec1.size() == vec2.size();
- if (equals) {
- int length = vec1.size();
- Object[] perms1 = new Object[length], perms2 = new Object[length];
- for (int i = 0; i < length; ++i) {
- perms1[i] = vec1.elementAt(i);
- perms2[i] = vec2.elementAt(i);
- }
-
- Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- return o1.toString().compareTo(o2.toString());
- }
-
- public boolean equals(Object o1, Object o2) {
- return o1.toString().equals(o2.toString());
- }
- };
-
- Arrays.sort(perms1, comparator);
- Arrays.sort(perms2, comparator);
-
- for (int i = 0; i < length && equals; ++i)
- equals = perms1[i].equals(perms2[i]);
- }
-
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Date() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Date)
@@ -1846,82 +1326,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_SecurityPermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.SecurityPermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.security.SecurityPermission(
- "TestSerialization", "Test");
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
- public void test_writeObject_SocketPermission_SocketPermissionCollection() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.net.SocketPermission.SocketPermissionCollection)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = (new java.net.SocketPermission("www.yahoo.com",
- "connect")).newPermissionCollection();
- ((java.security.PermissionCollection) objToSave)
- .add(new java.net.SocketPermission("www.yahoo.com",
- "connect"));
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- boolean equals;
- Enumeration enum1 = ((java.security.PermissionCollection) objToSave)
- .elements(), enum2 = ((java.security.PermissionCollection) objLoaded)
- .elements();
-
- equals = true;
- while (enum1.hasMoreElements() && equals) {
- if (enum2.hasMoreElements())
- equals = enum1.nextElement().equals(enum2.nextElement());
- else
- equals = false;
- }
-
- if (equals)
- equals = !enum2.hasMoreElements();
- assertTrue(MSG_TEST_FAILED + objToSave, equals);
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Stack() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Stack)
@@ -1992,33 +1396,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_NetPermission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.net.NetPermission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = new java.net.NetPermission("TestSerialization", "Test");
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
- }
-
public void test_writeObject_AttributedCharacterIterator_Attribute() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.text.AttributedCharacterIterator.Attribute)
@@ -2074,38 +1451,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_CodeSource() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.CodeSource)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = null;
- objToSave = new java.security.CodeSource(new java.net.URL(
- "http://localhost/a.txt"),
- (Certificate[])null);
-
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Collections_SynchronizedCollection() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Collections.SynchronizedCollection)
@@ -2144,54 +1489,6 @@ public class SerializationStressTest4 extends SerializationStressTest {
}
- public void test_writeObject_Permission() {
- // Test for method void
- // java.io.ObjectOutputStream.writeObject(java.security.Permission)
-
- Object objToSave = null;
- Object objLoaded = null;
-
- try {
- objToSave = null;
- objToSave = new java.security.Permission("test") {
- public boolean equals(Object p1) {
- if (!(p1 instanceof java.security.Permission))
- return false;
- return getName().equals(
- ((java.security.Permission) p1).getName());
- }
-
- public int hashCode() {
- return 0;
- }
-
- public String getActions() {
- return null;
- }
-
- public boolean implies(java.security.Permission p1) {
- return false;
- }
- };
- if (DEBUG)
- System.out.println("Obj = " + objToSave);
- objLoaded = dumpAndReload(objToSave);
-
- // Has to have worked
- assertTrue(MSG_TEST_FAILED + objToSave, objToSave.equals(objLoaded));
- } catch (IOException e) {
- fail("Exception serializing " + objToSave + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- fail("ClassNotFoundException reading Object type: "
- + e.getMessage());
- } catch (Error err) {
- System.out.println("Error when obj = " + objToSave);
- // err.printStackTrace();
- throw err;
- }
-
- }
-
public void test_writeObject_Random() {
// Test for method void
// java.io.ObjectOutputStream.writeObject(java.util.Random)
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java
deleted file mode 100644
index ebe3a40..0000000
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/RuntimePermissionTest.java
+++ /dev/null
@@ -1,44 +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.luni.tests.java.lang;
-
-public class RuntimePermissionTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.RuntimePermission(java.lang.String)
- RuntimePermission r = new RuntimePermission("createClassLoader");
- assertEquals("Returned incorrect name",
- "createClassLoader", r.getName());
-
- }
-
- /**
- * @tests java.lang.RuntimePermission#RuntimePermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.lang.RuntimePermission(java.lang.String,
- // java.lang.String)
- RuntimePermission r = new RuntimePermission("createClassLoader", null);
- assertEquals("Returned incorrect name",
- "createClassLoader", r.getName());
- }
-}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ReflectPermissionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ReflectPermissionTest.java
deleted file mode 100644
index 30b3174..0000000
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/lang/reflect/ReflectPermissionTest.java
+++ /dev/null
@@ -1,59 +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.luni.tests.java.lang.reflect;
-
-import java.lang.reflect.ReflectPermission;
-
-public class ReflectPermissionTest extends junit.framework.TestCase {
-
- /**
- * @tests java.lang.reflect.ReflectPermission#ReflectPermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.lang.reflect.ReflectPermission(java.lang.String)
- String permString = new ReflectPermission("Blah").toString();
- assertTrue("Incorrect permission constructed", permString.indexOf(
- "java.lang.reflect.ReflectPermission Blah") >= 0);
- }
-
- /**
- * @tests java.lang.reflect.ReflectPermission#ReflectPermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.lang.reflect.ReflectPermission(java.lang.String,
- // java.lang.String)
- assertTrue("Incorrect permission constructed", new ReflectPermission(
- "Blah", "suppressAccessChecks").toString().indexOf(
- "java.lang.reflect.ReflectPermission Blah") >= 0);
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetPermissionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetPermissionTest.java
deleted file mode 100644
index da665a7..0000000
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/NetPermissionTest.java
+++ /dev/null
@@ -1,60 +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.luni.tests.java.net;
-
-import java.net.NetPermission;
-
-public class NetPermissionTest extends junit.framework.TestCase {
-
- /**
- * @tests java.net.NetPermission#NetPermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.net.NetPermission(java.lang.String)
- NetPermission n = new NetPermission("requestPasswordAuthentication");
- assertEquals("Returned incorrect name",
- "requestPasswordAuthentication", n.getName());
- }
-
- /**
- * @tests java.net.NetPermission#NetPermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.net.NetPermission(java.lang.String,
- // java.lang.String)
- NetPermission n = new NetPermission("requestPasswordAuthentication",
- null);
- assertEquals("Returned incorrect name",
- "requestPasswordAuthentication", n.getName());
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-}
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
index 64d314b..9a69613 100644
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
+++ b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
@@ -478,58 +478,6 @@ public class URLConnectionTest extends junit.framework.TestCase {
}
/**
- * @tests java.net.URLConnection#getPermission()
- */
- public void test_getPermission() throws Exception {
- java.security.Permission p = uc.getPermission();
- assertTrue("Permission of wrong type: " + p.toString(),
- p instanceof java.net.SocketPermission);
- assertTrue("Permission has wrong name: " + p.getName(), p.getName()
- .contains("localhost:80"));
-
- URL fileUrl = new URL("file:myfile");
- Permission perm = new FilePermission("myfile", "read");
- Permission result = fileUrl.openConnection().getPermission();
- assertTrue("Wrong file: permission 1:" + perm + " , " + result, result
- .equals(perm));
-
- fileUrl = new URL("file:/myfile/");
- perm = new FilePermission("/myfile", "read");
- result = fileUrl.openConnection().getPermission();
- assertTrue("Wrong file: permission 2:" + perm + " , " + result, result
- .equals(perm));
-
- fileUrl = new URL("file:///host/volume/file");
- perm = new FilePermission("/host/volume/file", "read");
- result = fileUrl.openConnection().getPermission();
- assertTrue("Wrong file: permission 3:" + perm + " , " + result, result
- .equals(perm));
-
- URL httpUrl = new URL("http://home/myfile/");
- assertTrue("Wrong http: permission", httpUrl.openConnection()
- .getPermission().equals(
- new SocketPermission("home:80", "connect")));
- httpUrl = new URL("http://home2:8080/myfile/");
- assertTrue("Wrong http: permission", httpUrl.openConnection()
- .getPermission().equals(
- new SocketPermission("home2:8080", "connect")));
- URL ftpUrl = new URL("ftp://home/myfile/");
- assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
- .getPermission().equals(
- new SocketPermission("home:21", "connect")));
- ftpUrl = new URL("ftp://home2:22/myfile/");
- assertTrue("Wrong ftp: permission", ftpUrl.openConnection()
- .getPermission().equals(
- new SocketPermission("home2:22", "connect")));
-
- URL jarUrl = new URL("jar:file:myfile!/");
- perm = new FilePermission("myfile", "read");
- result = jarUrl.openConnection().getPermission();
- assertTrue("Wrong jar: permission:" + perm + " , " + result, result
- .equals(new FilePermission("myfile", "read")));
- }
-
- /**
* @tests java.net.URLConnection#getRequestProperties()
*/
public void test_getRequestProperties() {
diff --git a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.java b/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.java
deleted file mode 100644
index 3a305ca..0000000
--- a/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.java
+++ /dev/null
@@ -1,146 +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.luni.tests.java.util;
-
-import java.io.Serializable;
-import java.util.Enumeration;
-import java.util.PropertyPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-public class PropertyPermissionTest extends junit.framework.TestCase {
-
- static PropertyPermission javaPP = new PropertyPermission("java.*", "read");
-
- static PropertyPermission userPP = new PropertyPermission("user.name",
- "read,write");
-
- /**
- * @tests java.util.PropertyPermission#PropertyPermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.util.PropertyPermission(java.lang.String,
- // java.lang.String)
- assertTrue("Used to test", true);
- }
-
- /**
- * @tests java.util.PropertyPermission#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() {
- // Test for method boolean
- // java.util.PropertyPermission.equals(java.lang.Object)
- PropertyPermission equalToJavaPP = new PropertyPermission("java.*",
- "read");
- PropertyPermission notEqualToJavaPP = new PropertyPermission("java.*",
- "read, write");
- PropertyPermission alsoNotEqualToJavaPP = new PropertyPermission(
- "java.home", "read");
-
- assertTrue("Equal returned false for equal objects", javaPP
- .equals(equalToJavaPP));
- assertTrue("Equal returned true for objects with different names",
- !javaPP.equals(notEqualToJavaPP));
- assertTrue(
- "Equal returned true for objects with different permissions",
- !javaPP.equals(alsoNotEqualToJavaPP));
- }
-
- /**
- * @tests java.util.PropertyPermission#getActions()
- */
- public void test_getActions() {
- // Test for method java.lang.String
- // java.util.PropertyPermission.getActions()
- assertEquals("getActions did not return proper action", "read", javaPP
- .getActions());
- assertEquals("getActions did not return proper canonical representation of actions",
- "read,write", userPP.getActions());
- }
-
- /**
- * @tests java.util.PropertyPermission#hashCode()
- */
- public void test_hashCode() {
- // Test for method int java.util.PropertyPermission.hashCode()
- assertTrue("javaPP returned wrong hashCode",
- javaPP.hashCode() == javaPP.getName().hashCode());
- assertTrue("userPP returned wrong hashCode",
- userPP.hashCode() == userPP.getName().hashCode());
- }
-
- /**
- * @tests java.util.PropertyPermission#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() {
- // Test for method boolean
- // java.util.PropertyPermission.implies(java.security.Permission)
- PropertyPermission impliedByJavaPP = new PropertyPermission(
- "java.home", "read");
- PropertyPermission notImpliedByJavaPP = new PropertyPermission(
- "java.home", "read,write");
- PropertyPermission impliedByUserPP = new PropertyPermission(
- "user.name", "read,write");
- PropertyPermission alsoImpliedByUserPP = new PropertyPermission(
- "user.name", "write");
- assertTrue("Returned false for implied permission (subset of .*)",
- javaPP.implies(impliedByJavaPP));
- assertTrue("Returned true for unimplied permission", !javaPP
- .implies(notImpliedByJavaPP));
- assertTrue("Returned false for implied permission (equal)", userPP
- .implies(impliedByUserPP));
- assertTrue("Returned false for implied permission (subset of actions)",
- userPP.implies(alsoImpliedByUserPP));
- }
-
- /**
- * @tests java.util.PropertyPermission#newPermissionCollection()
- */
- public void test_newPermissionCollection() {
- // Test for method java.security.PermissionCollection
- // java.util.PropertyPermission.newPermissionCollection()
- java.security.PermissionCollection pc = javaPP
- .newPermissionCollection();
- pc.add(javaPP);
- Enumeration elementEnum = pc.elements();
- assertTrue("Invalid PermissionCollection returned", elementEnum
- .nextElement().equals(javaPP));
- }
-
- /**
- * @tests java.util.PropertyPermission#readObject(ObjectInputStream)
- * @tests java.util.PropertyPermission#writeObject(ObjectOutputStream)
- */
- public void test_serialization() throws Exception{
- PropertyPermission pp = new PropertyPermission("test", "read");
- SerializationTest.verifySelf(pp, comparator);
- SerializationTest.verifyGolden(this, pp, comparator);
- }
-
- private static final SerializableAssert comparator = new SerializableAssert() {
-
- public void assertDeserialized(Serializable initial, Serializable deserialized) {
- PropertyPermission initialPP = (PropertyPermission) initial;
- PropertyPermission deseriaPP = (PropertyPermission) deserialized;
- assertEquals("should be equal", initialPP, deseriaPP);
- }
-
- };
-}
diff --git a/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.golden.ser b/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.golden.ser
deleted file mode 100644
index ffa3060..0000000
--- a/luni/src/test/resources/serialization/org/apache/harmony/luni/tests/java/util/PropertyPermissionTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/api/java.injected/java/security/AllPermissionTest.java b/security/src/test/api/java.injected/java/security/AllPermissionTest.java
deleted file mode 100644
index f3a6fa3..0000000
--- a/security/src/test/api/java.injected/java/security/AllPermissionTest.java
+++ /dev/null
@@ -1,87 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package java.security;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>AllPermission</code>
- *
- */
-public class AllPermissionTest extends TestCase {
-
- /**
- * Constructor for AllPermissionsTest.
- * @param arg0
- */
- public AllPermissionTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Test all constructors: an object is created, name and actions are ignored
- */
- public void testCtor()
- {
- AllPermission a1 = new AllPermission();
- assertEquals("<all permissions>", a1.getName());
- assertEquals("<all actions>", a1.getActions());
-
- a1 = new AllPermission("sdfsdfwe&^$", "*&IUGJKHVB764");
- assertEquals("<all permissions>", a1.getName());
- assertEquals("<all actions>", a1.getActions());
-
- a1 = new AllPermission(null, "");
- assertEquals("<all permissions>", a1.getName());
- assertEquals("<all actions>", a1.getActions());
- }
-
- /** Any of AllPermission instances are equal and have the same hash code */
- public void testEquals()
- {
- AllPermission a1 = new AllPermission();
- AllPermission a2 = new AllPermission();
- assertTrue(a1.equals(a2));
- assertTrue(a1.hashCode() == a2.hashCode());
- assertFalse(a1.equals(null));
- assertFalse(a1.equals(new BasicPermission("hgf"){}));
- }
-
- /** AllPermission implies any other permission */
- public void testImplies()
- {
- AllPermission a1 = new AllPermission();
- assertTrue(a1.implies(new AllPermission()));
- assertTrue(a1.implies(new BasicPermission("2323"){}));
- assertTrue(a1.implies(new UnresolvedPermission("2323", "", "", null)));
- }
-
- /** newPermissionCollection() returns a new AllPermissionCollection on every invocation. */
- public void testCollection()
- {
- AllPermission a1 = new AllPermission();
- PermissionCollection pc1 = a1.newPermissionCollection();
- PermissionCollection pc2 = a1.newPermissionCollection();
- assertTrue((pc1 instanceof AllPermissionCollection) && (pc2 instanceof AllPermissionCollection));
- assertNotSame(pc1, pc2);
- }
-}
diff --git a/security/src/test/api/java.injected/java/security/BasicPermissionTest.java b/security/src/test/api/java.injected/java/security/BasicPermissionTest.java
deleted file mode 100644
index 3fbe894..0000000
--- a/security/src/test/api/java.injected/java/security/BasicPermissionTest.java
+++ /dev/null
@@ -1,137 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package java.security;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>BasicPermission</code>
- *
- */
-
-public class BasicPermissionTest extends TestCase {
-
- /**
- * Constructor for BasicPermissionTest.
- * @param arg0
- */
- public BasicPermissionTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Check all constructors: an object is created with the specified valid name.
- * If name equal null then NPE should be thrown.
- * If name is empty then IAE should be thrown.
- * Action is ignored.
- */
- public void testCtor()
- {
- String name = "basic123*$%#";
- BasicPermission test = new BasicPermission(name){};
- assertEquals(name, test.getName());
- assertEquals("", test.getActions());
- test = new BasicPermission(name, "#$!#12435"){};
- assertEquals(name, test.getName());
- assertEquals("", test.getActions());
- try{
- new BasicPermission(null){};
- fail("NPE is not thrown");
- }
- catch (NullPointerException ok){}
-
- try{
- new BasicPermission(null, "ds235"){};
- fail("NPE is not thrown");
- }
- catch (NullPointerException ok){}
-
- try{
- new BasicPermission(""){};
- fail("IAE is not thrown");
- }
- catch (IllegalArgumentException ok){}
- try{
- new BasicPermission("", "ertre 3454"){};
- fail("IAE is not thrown");
- }
- catch (IllegalArgumentException ok){}
- }
-
- private final class BasicPermissionImpl extends BasicPermission
- {
- public BasicPermissionImpl(String name)
- {
- super(name);
- }
- }
-
- /**
- * two BasicPermissions are equal if name and class are equal;
- * equal permissions should have the same hash code
- */
- public void testEquals()
- {
- BasicPermission b1 = new BasicPermissionImpl("abc");
- BasicPermission b2 = null;
- assertTrue(b1.equals(b1));
- assertFalse(b1.equals(null));
- assertFalse(b1.equals(new Object()));
- assertFalse(b1.equals("abc"));
- assertTrue(b1.equals(b2 = new BasicPermissionImpl("abc")));
- assertTrue(b1.hashCode() == b2.hashCode());
- assertFalse(b1.equals(new BasicPermission("abc"){}));
- assertFalse(b1.equals(new BasicPermissionImpl("abc.*")));
- }
-
- /**
- * implies() should return true if a permission is equal to or is implied
- * by wildcarded permission, false otherwise.
- */
- public void testImplies()
- {
- BasicPermission b1 = new BasicPermissionImpl("a.b.c");
- assertTrue(b1.implies(b1));
- assertTrue(b1.implies(new BasicPermissionImpl("a.b.c")));
- assertFalse(b1.implies(new BasicPermissionImpl("a.b.c.*")));
- assertFalse(b1.implies(new BasicPermission("a.b.c"){}));
- assertTrue(new BasicPermissionImpl("a.b.*").implies(b1));
- assertTrue(new BasicPermissionImpl("a.*").implies(b1));
- assertTrue(new BasicPermissionImpl("*").implies(b1));
- assertFalse(new BasicPermissionImpl("a.b*").implies(b1));
- assertFalse(new BasicPermissionImpl("a.b.c.*").implies(b1));
- assertTrue(new BasicPermissionImpl("1.*").implies(new BasicPermissionImpl("1.234.*")));
- assertTrue(new BasicPermissionImpl("*").implies(new BasicPermissionImpl("*")));
- }
-
- /**
- * newPermissionCollection() should return new BasicPermissionCollection on every invocation
- */
- public void testCollection()
- {
- BasicPermission b1 = new BasicPermissionImpl("a.b.c");
- PermissionCollection pc1 = b1.newPermissionCollection();
- PermissionCollection pc2 = b1.newPermissionCollection();
- assertTrue((pc1 instanceof BasicPermissionCollection) && (pc2 instanceof BasicPermissionCollection));
- assertNotSame(pc1, pc2);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java
deleted file mode 100644
index 5052c26..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AllPermission2Test.java
+++ /dev/null
@@ -1,100 +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.java.security;
-
-import java.security.AllPermission;
-import java.security.SecurityPermission;
-
-public class AllPermission2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.AllPermission#AllPermission()
- */
- public void test_Constructor() {
- // Test for method java.security.AllPermission()
- AllPermission ap = new AllPermission();
- assertEquals("Bogus name for AllPermission \"" + ap.getName() + "\".",
- "<all permissions>", ap.getName());
- }
-
- /**
- * @tests java.security.AllPermission#AllPermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.security.AllPermission(java.lang.String,
- // java.lang.String)
- AllPermission ap = new AllPermission("Don't remember this stupid name",
- "or this action");
- assertEquals("Bogus name for AllPermission \"" + ap.getName() + "\".",
- "<all permissions>", ap.getName());
- assertEquals(
- "AllPermission constructed with actions didn't ignore them.",
- "<all actions>", ap.getActions());
- }
-
- /**
- * @tests java.security.AllPermission#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() {
- // Test for method boolean
- // java.security.AllPermission.equals(java.lang.Object)
- assertTrue("Two AllPermissions not equal to each other.",
- new AllPermission().equals(new AllPermission()));
- assertTrue("AllPermission equals a SecurityPermission.",
- !(new AllPermission().equals(new SecurityPermission("ugh!"))));
- }
-
- /**
- * @tests java.security.AllPermission#getActions()
- */
- public void test_getActions() {
- AllPermission ap = new AllPermission();
- // Test for method java.lang.String
- // java.security.AllPermission.getActions()
- assertTrue("AllPermission has non-empty actions. (" + ap.getActions()
- + ")", ap.getActions().equals("<all actions>"));
- }
-
- /**
- * @tests java.security.AllPermission#hashCode()
- */
- public void test_hashCode() {
- final int ALLPERMISSION_HASH = 1;
- // Test for method int java.security.AllPermission.hashCode()
- AllPermission TestAllPermission = new AllPermission();
- assertTrue("AllPermission hashCode is wrong. Should have been "
- + ALLPERMISSION_HASH + " but was "
- + TestAllPermission.hashCode(),
- TestAllPermission.hashCode() == ALLPERMISSION_HASH);
- }
-
- /**
- * @tests java.security.AllPermission#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() {
- // Test for method boolean
- // java.security.AllPermission.implies(java.security.Permission)
- assertTrue("AllPermission does not imply a AllPermission.",
- new AllPermission().implies(new AllPermission()));
- assertTrue("AllPermission does not imply a SecurityPermission.",
- new AllPermission().implies(new SecurityPermission("ugh!")));
- assertTrue("SecurityPermission implies AllPermission.",
- !(new SecurityPermission("ugh!").implies(new AllPermission())));
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java
deleted file mode 100644
index e173d5f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/BasicPermission2Test.java
+++ /dev/null
@@ -1,138 +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.java.security;
-
-import java.security.BasicPermission;
-import java.security.Permission;
-import java.security.PermissionCollection;
-
-public class BasicPermission2Test extends junit.framework.TestCase {
-
- public static class BasicPermissionSubclass extends BasicPermission {
- public BasicPermissionSubclass(String name) {
- super(name);
- }
-
- public BasicPermissionSubclass(String name, String actions) {
- super(name, actions);
- }
- }
-
- BasicPermission bp = new BasicPermissionSubclass("aName");
-
- BasicPermission bp2 = new BasicPermissionSubclass("aName", "anAction");
-
- BasicPermission bp3 = new BasicPermissionSubclass("*");
-
- BasicPermission bp4 = new BasicPermissionSubclass("this.that");
-
- BasicPermission bp5 = new BasicPermissionSubclass("this.*");
-
- /**
- * @tests java.security.BasicPermission#BasicPermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.security.BasicPermission(java.lang.String)
- assertEquals("Incorrect name returned", "aName", bp.getName());
- }
-
- /**
- * @tests java.security.BasicPermission#BasicPermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.security.BasicPermission(java.lang.String,
- // java.lang.String)
- assertEquals("Incorrect name returned", "aName", bp2.getName());
- }
-
- /**
- * @tests java.security.BasicPermission#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() {
- // Test for method boolean
- // java.security.BasicPermission.equals(java.lang.Object)
- assertTrue("a) Equal objects returned non-equal", bp.equals(bp2));
- assertTrue("b) Equal objects returned non-equal", bp2.equals(bp));
- assertTrue("a) Unequal objects returned equal", !bp.equals(bp3));
- assertTrue("b) Unequal objects returned equal", !bp4.equals(bp5));
- }
-
- /**
- * @tests java.security.BasicPermission#getActions()
- */
- public void test_getActions() {
- // Test for method java.lang.String
- // java.security.BasicPermission.getActions()
- assertTrue("a) Incorrect actions returned, wanted the empty String", bp
- .getActions().equals(""));
- assertTrue("b) Incorrect actions returned, wanted the empty String",
- bp2.getActions().equals(""));
- }
-
- /**
- * @tests java.security.BasicPermission#hashCode()
- */
- public void test_hashCode() {
- // Test for method int java.security.BasicPermission.hashCode()
- assertTrue("Equal objects should return same hash",
- bp.hashCode() == bp2.hashCode());
- }
-
- /**
- * @tests java.security.BasicPermission#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() {
- // Test for method boolean
- // java.security.BasicPermission.implies(java.security.Permission)
- assertTrue("Equal objects should imply each other", bp.implies(bp2));
- assertTrue("a) should not imply", !bp.implies(bp3));
- assertTrue("b) should not imply", !bp4.implies(bp5));
- assertTrue("a) should imply", bp3.implies(bp5));
- assertTrue("b) should imply", bp5.implies(bp4));
-
- }
-
- /**
- * @tests java.security.BasicPermission#newPermissionCollection()
- */
- public void test_newPermissionCollection() {
- // Test for method java.security.PermissionCollection
- // java.security.BasicPermission.newPermissionCollection()
- PermissionCollection bpc = bp.newPermissionCollection();
- bpc.add(bp5);
- bpc.add(bp);
- assertTrue("Should imply", bpc.implies(bp4));
- assertTrue("Should not imply", !bpc.implies(bp3));
- }
-
- //Special treat with RuntimePermission exitVM in Java 6, which equals RuntimePermission exitVM.*
- public void test_RuntimePermissionExitVM(){
- Permission permission_exitVM = new RuntimePermission("exitVM");
- Permission permission_exitVM_ALL = new RuntimePermission("exitVM.*");
- Permission permission_exitVM_0 = new RuntimePermission("exitVM.0");
- Permission permission_exitVM_a = new RuntimePermission("exitVM.a");
- assertTrue(permission_exitVM.implies(permission_exitVM_ALL));
- assertTrue(permission_exitVM.implies(permission_exitVM));
- assertTrue(permission_exitVM.implies(permission_exitVM_0));
- assertTrue(permission_exitVM.implies(permission_exitVM_a));
- assertTrue(permission_exitVM_ALL.implies(permission_exitVM));
- assertTrue(permission_exitVM_ALL.implies(permission_exitVM_0));
- assertTrue(permission_exitVM_ALL.implies(permission_exitVM_a));
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java
deleted file mode 100644
index 2b82c7a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSource2Test.java
+++ /dev/null
@@ -1,102 +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.java.security;
-
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.cert.Certificate;
-
-public class CodeSource2Test extends junit.framework.TestCase {
-
- /**
- * @throws Exception
- * @tests java.security.CodeSource#CodeSource(java.net.URL,
- * java.security.cert.Certificate[])
- */
- public void test_ConstructorLjava_net_URL$Ljava_security_cert_Certificate() throws Exception {
- // Test for method java.security.CodeSource(java.net.URL,
- // java.security.cert.Certificate [])
- new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- }
-
- /**
- * @tests java.security.CodeSource#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() throws Exception {
- // Test for method boolean
- // java.security.CodeSource.equals(java.lang.Object)
- CodeSource cs1 = new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- CodeSource cs2 = new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- assertTrue("Identical objects were not equal()!", cs1.equals(cs2));
- }
-
- /**
- * @tests java.security.CodeSource#hashCode()
- */
- public void test_hashCode() throws Exception {
- URL url = new java.net.URL("file:///test");
- CodeSource cs = new CodeSource(url, (Certificate[]) null);
- assertEquals("Did not get expected hashCode!", cs.hashCode(), url
- .hashCode());
- }
-
- /**
- * @tests java.security.CodeSource#getCertificates()
- */
- public void test_getCertificates() throws Exception {
- CodeSource cs = new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- assertNull("Should have gotten null certificate list.", cs
- .getCertificates());
- }
-
- /**
- * @tests java.security.CodeSource#getLocation()
- */
- public void test_getLocation() throws Exception {
- // Test for method java.net.URL java.security.CodeSource.getLocation()
- CodeSource cs = new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- assertEquals("Did not get expected location!", "file:/test", cs
- .getLocation().toString());
- assertNotNull("Host should not be null", cs.getLocation().getHost());
- }
-
- /**
- * @tests java.security.CodeSource#implies(java.security.CodeSource)
- */
- public void test_impliesLjava_security_CodeSource() throws Exception {
- // Test for method boolean
- // java.security.CodeSource.implies(java.security.CodeSource)
- CodeSource cs1 = new CodeSource(new URL("file:/d:/somedir"),
- (Certificate[]) null);
- CodeSource cs2 = new CodeSource(new URL("file:/d:/somedir/"),
- (Certificate[]) null);
- assertTrue("Does not add /", cs1.implies(cs2));
-
- cs1 = new CodeSource(new URL("file", null, -1, "/d:/somedir/"),
- (Certificate[]) null);
- cs2 = new CodeSource(new URL("file:/d:/somedir/"), (Certificate[]) null);
- assertTrue("null host should imply host", cs1.implies(cs2));
- assertFalse("host should not imply null host", cs2.implies(cs1));
- }
-
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
deleted file mode 100644
index 8bcd58c..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/CodeSourceTest.java
+++ /dev/null
@@ -1,618 +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.
- */
-
-/**
-* @author Alexander V. Astapchuk
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.*;
-import java.io.File;
-import java.net.URL;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.UnknownHostException;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-
-import org.apache.harmony.security.tests.support.TestCertUtils;
-
-import junit.framework.TestCase;
-
-
-/**
- * Unit test for CodeSource.
- *
- */
-
-public class CodeSourceTest extends TestCase {
-
- private java.security.cert.Certificate[] chain = null;
-
- /* Below are various URLs used during the testing */
- private static URL urlSite;
-
- private static URL urlDir; // must NOT end with '/'
-
- private static URL urlDirOtherSite; // same as urlDir, but another site
-
- private static URL urlDir_port80, urlDir_port81;
-
- /* must be exactly the same as urlDir, but with slash added */
- private static URL urlDirWithSlash;
-
- //private static URL urlDirFtp;
- private static URL urlDir_FileProtocol;
-
- private static URL urlDirIP;
-
- private static URL urlFile, urlFileWithAdditionalDirs, urlFileDirOtherDir;
-
- private static URL urlFileDirMinus;
-
- private static URL urlFileDirStar;
-
- private static URL urlRef1, urlRef2;
-
- static {
- try {
- String siteName = "www.intel.com";
- InetAddress addr = InetAddress.getByName(siteName);
- String siteIP = addr.getHostAddress();
-
- urlSite = new URL("http://"+siteName+"");
- urlDir = new URL("http://"+siteName+"/drl_test");
- urlDirOtherSite = new URL("http://www.any-other-site-which-is-not-siteName.com/drl_test");
-
- urlDir_port80 = new URL("http://"+siteName+":80/drl_test");
- urlDir_port81 = new URL("http://"+siteName+":81/drl_test");
- urlDirWithSlash = new URL(urlDir + "/");
-
- //urlDirFtp = new URL("ftp://www.intel.com/drl_test");
- urlDir_FileProtocol = new URL("file://"+siteName+"/drl_test");
-
- urlDirIP = new URL("http://"+siteIP+"/drl_test");
-
- urlFile = new URL("http://"+siteName+"/drl_test/empty.jar");
- urlFileWithAdditionalDirs = new URL(
- "http://"+siteName+"/drl_test/what/ever/here/empty.jar");
-
- urlFileDirMinus = new URL("http://"+siteName+"/drl_test/-");
- urlFileDirStar = new URL("http://"+siteName+"/drl_test/*");
- urlFileDirOtherDir = new URL("http://"+siteName+"/_test_drl_/*");
-
- urlRef1 = new URL("http://"+siteName+"/drl_test/index.html#ref1");
- urlRef2 = new URL("http://"+siteName+"/drl_test/index.html#ref2");
- } catch (MalformedURLException ex) {
- throw new Error(ex);
- } catch (UnknownHostException ex) {
- throw new Error(ex);
- }
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- chain = TestCertUtils.getCertChain();
- }
-
- /**
- * Tests hashCode().<br>
- * javadoc says nothing, so test DRL-specific implementation.
- */
- public void testHashCode() {
- // when nothing is specified, then hashCode obviously must be 0.
- assertTrue(new CodeSource(null, (Certificate[]) null).hashCode() == 0);
- // only URL.hashCode is taken into account...
- assertTrue(new CodeSource(urlSite, (Certificate[]) null).hashCode() == urlSite
- .hashCode());
- // ... and certs[] does not affect it
- assertTrue(new CodeSource(urlSite, chain).hashCode() == urlSite
- .hashCode());
- }
-
- /**
- * Tests CodeSource(URL, Certificate[]).
- */
- public void testCodeSourceURLCertificateArray() {
- new CodeSource(null, (Certificate[]) null);
- new CodeSource(urlSite, (Certificate[]) null);
- new CodeSource(null, chain);
- new CodeSource(urlSite, chain);
- }
-
- /**
- * Tests CodeSource(URL, CodeSigner[]).
- */
- public void testCodeSourceURLCodeSignerArray() {
- if (!has_15_features()) {
- return;
- }
- new CodeSource(null, (CodeSigner[]) null);
-
- }
-
- /**
- * equals(Object) must return <code>false</code> for null
- */
- public void testEqualsObject_00() {
- CodeSource thiz = new CodeSource(urlSite, (Certificate[]) null);
- assertFalse(thiz.equals(null));
-
- }
-
- /**
- * equals(Object) must return <code>true</code> for the same object
- */
- public void testEqualsObject_01() {
- CodeSource thiz = new CodeSource(urlSite, (Certificate[]) null);
- assertTrue(thiz.equals(thiz));
- }
-
- /**
- * Test for equals(Object)<br>
- * The signer certificate chain must contain the same set of certificates, but
- * the order of the certificates is not taken into account.
- */
- public void testEqualsObject_02() {
- Certificate cert0 = new TestCertUtils.TestCertificate();
- Certificate cert1 = new TestCertUtils.TestCertificate();
- Certificate[] certs0 = new Certificate[] { cert0, cert1 };
- Certificate[] certs1 = new Certificate[] { cert1, cert0 };
- CodeSource thiz = new CodeSource(urlSite, certs0);
- CodeSource that = new CodeSource(urlSite, certs1);
- assertTrue(thiz.equals(that));
- }
-
- /**
- * Test for equals(Object)<br>
- * Checks that both 'null' and not-null URLs are taken into account - properly.
- */
- public void testEqualsObject_04() {
- CodeSource thiz = new CodeSource(urlSite, (Certificate[]) null);
- CodeSource that = new CodeSource(null, (Certificate[]) null);
- assertFalse(thiz.equals(that));
- assertFalse(that.equals(thiz));
-
- that = new CodeSource(urlFile, (Certificate[]) null);
- assertFalse(thiz.equals(that));
- assertFalse(that.equals(thiz));
- }
-
- /**
- * Tests CodeSource.getCertificates().
- */
- public void testGetCertificates_00() {
- assertNull(new CodeSource(null, (Certificate[]) null).getCertificates());
- java.security.cert.Certificate[] got = new CodeSource(null, chain)
- .getCertificates();
- // The returned array must be clone()-d ...
- assertNotSame(got, chain);
- // ... but must represent the same set of certificates
- assertTrue(checkEqual(got, chain));
- }
-
- /**
- * Tests whether the getCertificates() returns certificates obtained from
- * the signers.
- */
- public void testGetCertificates_01() {
- if (!has_15_features()) {
- return;
- }
- CertPath cpath = TestCertUtils.getCertPath();
- Certificate[] certs = (Certificate[]) cpath.getCertificates().toArray();
- CodeSigner[] signers = { new CodeSigner(cpath, null) };
- CodeSource cs = new CodeSource(null, signers);
- Certificate[] got = cs.getCertificates();
- // The set of certificates must be exactly the same,
- // but the order is not specified
- assertTrue(presented(certs, got));
- assertTrue(presented(got, certs));
- }
-
- /**
- * Checks whether two arrays of certificates represent the same same set of
- * certificates - in the same order.
- * @param one first array
- * @param two second array
- * @return <code>true</code> if both arrays represent the same set of
- * certificates,
- * <code>false</code> otherwise.
- */
- private static boolean checkEqual(java.security.cert.Certificate[] one,
- java.security.cert.Certificate[] two) {
-
- if (one == null) {
- return two == null;
- }
-
- if (two == null) {
- return false;
- }
-
- if (one.length != two.length) {
- return false;
- }
-
- for (int i = 0; i < one.length; i++) {
- if (one[i] == null) {
- if (two[i] != null) {
- return false;
- }
- } else {
- if (!one[i].equals(two[i])) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Performs a test whether the <code>what</code> certificates are all
- * presented in <code>where</code> certificates.
- *
- * @param what - first array of Certificates
- * @param where - second array of Certificates
- * @return <code>true</code> if each and every certificate from 'what'
- * (including null) is presented in 'where' <code>false</code> otherwise
- */
- private static boolean presented(Certificate[] what, Certificate[] where) {
- boolean whereHasNull = false;
- for (int i = 0; i < what.length; i++) {
- if (what[i] == null) {
- if (whereHasNull) {
- continue;
- }
- for (int j = 0; j < where.length; j++) {
- if (where[j] == null) {
- whereHasNull = true;
- break;
- }
- }
- if (!whereHasNull) {
- return false;
- }
- } else {
- boolean found = false;
- for (int j = 0; j < where.length; j++) {
- if (what[i].equals(where[j])) {
- found = true;
- break;
- }
- }
- if (!found) {
- return false;
- }
- }
-
- }
- return true;
- }
-
- /**
- * Tests CodeSource.getCodeSigners().
- */
- public void testGetCodeSigners_00() {
- if (!has_15_features()) {
- return;
- }
- CodeSigner[] signers = { new CodeSigner(TestCertUtils.getCertPath(),
- null) };
- CodeSource cs = new CodeSource(null, signers);
- CodeSigner[] got = cs.getCodeSigners();
- assertNotNull(got);
- assertTrue(signers.length == got.length);
- // not sure whether they must be in the same order
- for (int i = 0; i < signers.length; i++) {
- CodeSigner s = signers[i];
- boolean found = false;
- for (int j = 0; j < got.length; j++) {
- if (got[j] == s) {
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
- }
-
- public void testGetCoderSignersNull() throws Exception{
- assertNull(new CodeSource(new URL("http://url"), (Certificate[])null).getCodeSigners()); //$NON-NLS-1$
- }
-
- /**
- * Tests CodeSource.getLocation()
- */
- public void testGetLocation() {
- assertTrue(new CodeSource(urlSite, (Certificate[]) null).getLocation() == urlSite);
- assertTrue(new CodeSource(urlSite, chain).getLocation() == urlSite);
- assertNull(new CodeSource(null, (Certificate[]) null).getLocation());
- assertNull(new CodeSource(null, chain).getLocation());
- }
-
- /**
- * Tests CodeSource.toString()
- */
- public void testToString() {
- // Javadoc keeps silence about String's format,
- // just make sure it can be invoked.
- new CodeSource(urlSite, chain).toString();
- new CodeSource(null, chain).toString();
- new CodeSource(null, (Certificate[]) null).toString();
- }
-
- /**
- * Tests whether we are running with the 1.5 features.<br>
- * The test is preformed by looking for (via reflection) the CodeSource's
- * constructor {@link CodeSource#CodeSource(URL, CodeSigner[])}.
- * @return <code>true</code> if 1.5 feature is presented, <code>false</code>
- * otherwise.
- */
- private static boolean has_15_features() {
- Class klass = CodeSource.class;
- Class[] ctorArgs = { URL.class, new CodeSigner[] {}.getClass() };
- try {
- klass.getConstructor(ctorArgs);
- } catch (NoSuchMethodException ex) {
- // NoSuchMethod == Not RI.v1.5 and not DRL
- return false;
- }
- return true;
- }
-
- /**
- * must not imply null CodeSource
- */
- public void testImplies_00() {
- CodeSource cs0 = new CodeSource(null, (Certificate[]) null);
- assertFalse(cs0.implies(null));
- }
-
- /**
- * CodeSource with location=null && Certificate[] == null implies any other
- * CodeSource
- */
- public void testImplies_01() throws Exception {
- CodeSource thizCS = new CodeSource(urlSite, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(null, (Certificate[]) null);
- assertTrue(thatCS.implies(thizCS));
- assertTrue(thatCS.implies(thatCS));
-
- assertFalse(thizCS.implies(thatCS));
- }
-
- /**
- * If this object's location equals codesource's location, then return true.
- */
- public void testImplies_02() throws Exception {
- CodeSource thizCS = new CodeSource(urlSite, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(thizCS.getLocation(),
- (Certificate[]) null);
- assertTrue(thizCS.implies(thatCS));
- assertTrue(thatCS.implies(thizCS));
-
- }
-
- /**
- * 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.
- * to be uncommented back.
- public void testImplies_03() throws Exception {
- CodeSource thizCS = new CodeSource(urlDir, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlDirFtp, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
- assertFalse(thatCS.implies(thizCS));
- }
- */
-
- public void testImplies_03_tmp() throws Exception {
- CodeSource thizCS = new CodeSource(urlDir, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlDir_FileProtocol,
- (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
- 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.
- */
- public void testImplies_04() throws Exception {
- CodeSource thizCS = new CodeSource(urlDir, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlDirIP, (Certificate[]) null);
-
- assertTrue(thizCS.implies(thatCS));
- assertTrue(thatCS.implies(thizCS));
-
- //
- // Check for another site - force to create SocketPermission
- //
- thatCS = new CodeSource(urlDirOtherSite, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
-
- //
- // also check for getHost() == null
- //
- thizCS = new CodeSource(new URL("http", null, "file1"),
- (Certificate[]) null);
- thatCS = new CodeSource(new URL("http", "another.host.com", "file1"),
- (Certificate[]) null);
- // well, yes, this is accordint to the spec...
- assertTrue(thizCS.implies(thatCS));
- 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.
- */
- public void testImplies_05() throws Exception {
- CodeSource thizCS = new CodeSource(urlDir_port80, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlDir, (Certificate[]) null);
-
- assertTrue(thizCS.implies(thatCS));
- assertTrue(thatCS.implies(thizCS));
-
- thizCS = new CodeSource(urlDir, (Certificate[]) null);
- thatCS = new CodeSource(urlDir_port81, (Certificate[]) null);
- //assert*True* because thizCS has 'port=-1'
- assertTrue(thizCS.implies(thatCS));
-
- thizCS = new CodeSource(urlDir_port81, (Certificate[]) null);
- thatCS = new CodeSource(urlDir, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
- //
- thizCS = new CodeSource(urlDir_port80, (Certificate[]) null);
- thatCS = new CodeSource(urlDir_port81, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
- }
-
- /**
- * If this object's file (getLocation().getFile()) doesn't equal
- * codesource's file, then the following checks are made: ...
- */
- public void testImplies_06() throws Exception {
- CodeSource thizCS = new CodeSource(urlFile, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlFile, (Certificate[]) null);
- 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 "-").
- */
- public void testImplies_07() throws Exception {
- CodeSource thiz = new CodeSource(urlFileDirMinus, (Certificate[]) null);
- CodeSource that = new CodeSource(urlFile, (Certificate[]) null);
- assertTrue(thiz.implies(that));
-
- that = new CodeSource(urlFileWithAdditionalDirs, (Certificate[]) null);
- assertTrue(thiz.implies(that));
-
- that = new CodeSource(urlFileDirOtherDir, (Certificate[]) null);
- 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.
- */
- public void testImplies_08() throws Exception {
- CodeSource thiz = new CodeSource(urlFileDirStar, (Certificate[]) null);
- CodeSource that = new CodeSource(urlFile, (Certificate[]) null);
- assertTrue(thiz.implies(that));
- that = new CodeSource(urlFileWithAdditionalDirs, (Certificate[]) null);
- assertFalse(thiz.implies(that));
- //
- that = new CodeSource(urlFileDirOtherDir, (Certificate[]) null);
- assertFalse(thiz.implies(that));
- // must not have any further '/'
- that = new CodeSource(new URL(urlFile.toString() + "/"),
- (Certificate[]) null);
- 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.
- */
- public void testImplies_09() throws Exception {
- CodeSource thizCS = new CodeSource(urlDir, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlDirWithSlash,
- (Certificate[]) null);
- assertTrue(thizCS.implies(thatCS));
- assertFalse(thatCS.implies(thizCS));
- }
-
- /**
- * If this object's reference (getLocation().getRef()) is not null, it must
- * equal codesource's reference.
- */
- public void testImplies_0A() throws Exception {
- CodeSource thizCS = new CodeSource(urlRef1, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(urlRef1, (Certificate[]) null);
- assertTrue(thizCS.implies(thatCS));
-
- thizCS = new CodeSource(urlRef1, (Certificate[]) null);
- thatCS = new CodeSource(urlRef2, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
-
- }
-
- /**
- * If this certificates are not null, then all of this certificates should
- * be presented in certificates of that codesource.
- */
- public void testImplies_0B() {
-
- Certificate c0 = new TestCertUtils.TestCertificate("00");
- Certificate c1 = new TestCertUtils.TestCertificate("01");
- Certificate c2 = new TestCertUtils.TestCertificate("02");
- Certificate[] thizCerts = { c0, c1 };
- Certificate[] thatCerts = { c1, c0, c2 };
-
- CodeSource thiz = new CodeSource(urlSite, thizCerts);
- CodeSource that = new CodeSource(urlSite, thatCerts);
- // two CodeSource-s with different set of certificates
- assertTrue(thiz.implies(that));
-
- //
- that = new CodeSource(urlSite, (Certificate[]) null);
- // 'thiz' has set of certs, while 'that' has no certs. URL-s are the
- // same.
- assertFalse(thiz.implies(that));
- assertTrue(that.implies(thiz));
- }
-
- /**
- * Testing with special URLs like 'localhost', 'file://' scheme ...
- * These special URLs have a special processing in implies(),
- * so they need to be covered and performance need to be checked
- */
- public void testImplies_0C() throws Exception {
- URL url0 = new URL("http://localhost/someDir");
- URL url1 = new URL("http://localhost/someOtherDir");
-
- CodeSource thizCS = new CodeSource(url0, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(url1, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
- assertFalse(thatCS.implies(thizCS));
- }
-
- /**
- * Testing with special URLs like 'localhost', 'file://' scheme ...
- * These special URLs have a special processing in implies(),
- * so they need to be covered and performance need to be checked
- */
- public void testImplies_0D() throws Exception {
- URL url0 = new URL("file:///" + System.getProperty("user.home")
- + File.separator + "someDir");
- URL url1 = new URL("file:///" + System.getProperty("user.home")
- + File.separator + "someOtherDir");
- CodeSource thizCS = new CodeSource(url0, (Certificate[]) null);
- CodeSource thatCS = new CodeSource(url1, (Certificate[]) null);
- assertFalse(thizCS.implies(thatCS));
- assertFalse(thatCS.implies(thizCS));
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java
deleted file mode 100644
index c9cca11..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.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.java.security;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.SecurityPermission;
-
-public class Permission2Test extends junit.framework.TestCase {
- static class ConcretePermission extends Permission {
- public ConcretePermission() {
- super("noname");
- }
-
- public boolean equals(Object obj) {
- return true;
- }
-
- public String getActions() {
- return "none";
- }
-
- public int hashCode() {
- return 1;
- }
-
- public boolean implies(Permission p) {
- return true;
- }
- }
-
- /**
- * @tests java.security.Permission#Permission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // test method java.security.permission.Permission(string)
- SecurityPermission permi = new SecurityPermission(
- "Testing the permission abstract class");
- String name = permi.getName();
- assertEquals("Permission Constructor failed",
- "Testing the permission abstract class", name);
- }
-
- /**
- * @tests java.security.Permission#checkGuard(java.lang.Object)
- */
- public void test_checkGuardLjava_lang_Object() {
- // test method java.security.permission.checkGuard(object)
- SecurityPermission permi = new SecurityPermission(
- "Testing the permission abstract class");
- String name = permi.getName();
- try {
- permi.checkGuard(name);
- } catch (SecurityException e) {
- fail("security not granted when it is suppose to be : " + e);
- }
- }
-
- /**
- * @tests java.security.Permission#getName()
- */
- public void test_getName() {
- // test method java.security.permission.getName()
- SecurityPermission permi = new SecurityPermission("testing getName()");
- String name = permi.getName();
- assertEquals("getName failed to obtain the correct name",
- "testing getName()", name);
-
- SecurityPermission permi2 = new SecurityPermission("93048Helloworld");
- assertEquals("getName failed to obtain correct name",
- "93048Helloworld", permi2.getName());
- }
-
- /**
- * @tests java.security.Permission#newPermissionCollection()
- */
- public void test_newPermissionCollection() {
- // test method java.security.permission.newPermissionCollection
- Permission permi = new ConcretePermission();
- PermissionCollection permiCollect = permi.newPermissionCollection();
- assertNull("newPermissionCollector of the abstract class "
- + "permission did not return a null instance "
- + "of permissionCollection", permiCollect);
- }
-
- /**
- * @tests java.security.Permission#toString()
- */
- public void test_toString() {
- // test method java.security.permission.toString
- // test for permission with no action
- SecurityPermission permi = new SecurityPermission("testing toString");
- String toString = permi.toString();
- assertNotNull("toString should have returned a string of elements",
- toString);
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
deleted file mode 100644
index 2b9f552..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
+++ /dev/null
@@ -1,105 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.*;
-import java.util.*;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PermissionCollection</code>
- *
- */
-
-public class PermissionCollectionTest extends TestCase {
-
- /**
- * Constructor for PermissionCollectionTest.
- * @param arg0
- */
- public PermissionCollectionTest(String arg0) {
- super(arg0);
- }
-
- // Bare extension to instantiate abstract PermissionCollection class
- private static final class RealPermissionCollection extends PermissionCollection
- {
- final private Collection col;
- public RealPermissionCollection(Collection col)
- {
- this.col = col;
- }
-
- public void add(Permission permission) {}
-
- public Enumeration elements()
- {
- return col == null ? null : Collections.enumeration(col);
- }
-
- public boolean implies(Permission permission)
- {
- return false;
- }
- }
-
- /** Test read-only flag. Should be false by default and can be set once forever. */
- public void testReadOnly()
- {
- PermissionCollection pc = new RealPermissionCollection(null);
- assertFalse("should not be read-only by default", pc.isReadOnly());
- pc.setReadOnly();
- assertTrue("explicitly set read-only", pc.isReadOnly());
- pc.setReadOnly();
- assertTrue("more calls to setReadOnly() should not harm", pc.isReadOnly());
- }
-
- // Regression test for "exitVM' special treatement in Java 6.
- public void test_implies_exitVM() {
-
- RuntimePermission runtimePermission = new RuntimePermission("exitVM");
- PermissionCollection permissionCollection = runtimePermission
- .newPermissionCollection();
- permissionCollection.add(runtimePermission);
- assertFalse(permissionCollection.implies(new RuntimePermission(
- "exitVM.")));
- assertTrue(permissionCollection.implies(new RuntimePermission(
- "exitVM.1")));
- assertTrue(permissionCollection.implies(new RuntimePermission(
- "exitVM.teststring")));
-
- runtimePermission = new RuntimePermission("exitVM.*");
- permissionCollection = runtimePermission.newPermissionCollection();
- permissionCollection.add(runtimePermission);
- assertTrue(permissionCollection
- .implies(new RuntimePermission("exitVM")));
- assertFalse(permissionCollection.implies(new RuntimePermission(
- "exitVMteststring")));
- assertFalse(permissionCollection.implies(new RuntimePermission(
- "exitVM.")));
- assertTrue(permissionCollection.implies(new RuntimePermission(
- "exitVM.1")));
- assertTrue(permissionCollection.implies(new RuntimePermission(
- "exitVM.teststring")));
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java
deleted file mode 100644
index 7cca36f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java
+++ /dev/null
@@ -1,81 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.*;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Permission</code>
- */
-
-public class PermissionTest extends TestCase {
-
- /**
- * Constructor for PermissionTest.
- *
- * @param arg0
- */
- public PermissionTest(String arg0) {
- super(arg0);
- }
-
- // Bare extension to instantiate abstract Permission class
- static final class RealPermission extends Permission {
-
- public RealPermission(String name) {
- super(name);
- }
-
- public boolean equals(Object obj) {
- return false;
- }
-
- public String getActions() {
- return null;
- }
-
- public int hashCode() {
- return 0;
- }
-
- public boolean implies(Permission permission) {
- return false;
- }
- }
-
- /**
- * Test that a permission object is created with the specified name and is
- * properly converted to String
- */
- public void testCtor() {
- String name = "testCtor123^%$#&^ &^$";
- Permission test = new RealPermission(name);
- assertEquals(name, test.getName());
- assertEquals("(" + test.getClass().getName() + " " + name + ")", test
- .toString());
- }
-
- /** newPermissionCollection() should return null */
- public void testCollection() {
- assertNull(new RealPermission("123").newPermissionCollection());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java
deleted file mode 100644
index 740934f..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java
+++ /dev/null
@@ -1,159 +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.java.security;
-
-import java.io.File;
-import java.io.FilePermission;
-import java.security.Permissions;
-import java.util.Enumeration;
-
-public class Permissions2Test extends junit.framework.TestCase {
- FilePermission readAllFiles = new FilePermission("<<ALL FILES>>", "read");
-
- FilePermission alsoReadAllFiles = new FilePermission("<<ALL FILES>>",
- "read");
-
- FilePermission allInCurrent = new FilePermission("*",
- "read, write, execute,delete");
-
- FilePermission readInCurrent = new FilePermission("*", "read");
-
- FilePermission readInFile = new FilePermission("aFile.file", "read");
-
- /**
- * @tests java.security.Permissions#Permissions()
- */
- public void test_Constructor() {
- // Test for method java.security.Permissions()
- new Permissions();
- }
-
- /**
- * @tests java.security.Permissions#add(java.security.Permission)
- */
- public void test_addLjava_security_Permission() {
- // Test for method void
- // java.security.Permissions.add(java.security.Permission)
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[7];
- perm[0] = readAllFiles;
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
- perm[4] = alsoReadAllFiles;
- perm[5] = readInFile;
- perm[6] = new FilePermission("hello.file", "write");
- Permissions perms = new Permissions();
- for (int i = 0; i < perm.length; i++) {
- perms.add(perm[i]);
- }
-
- Enumeration e = perms.elements();
- FilePermission perm2[] = new FilePermission[10];
- int i = 0;
- while (e.hasMoreElements()) {
- perm2[i] = (FilePermission) e.nextElement();
- i++;
- }
- assertEquals("Permissions.elements did not return the correct number "
- + "of permission - called in add() test ", i, perm.length);
- }
-
- /**
- * @tests java.security.Permissions#elements()
- */
- public void test_elements() {
- // Test for method java.util.Enumeration
- // java.security.Permissions.elements()
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[7];
- perm[0] = readAllFiles;
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
- perm[4] = alsoReadAllFiles;
- perm[5] = readInFile;
- perm[6] = new FilePermission("hello.file", "write");
- Permissions perms = new Permissions();
- for (int i = 0; i < perm.length; i++) {
- perms.add(perm[i]);
- }
- Enumeration e = perms.elements();
- FilePermission perm2[] = new FilePermission[10];
- int i = 0;
- while (e.hasMoreElements()) {
- perm2[i] = (FilePermission) e.nextElement();
- i++;
- }
- assertEquals("Permissions.elements did not return the correct "
- + "number of permission - called in element() test", i,
- perm.length);
- }
-
- /**
- * @tests java.security.Permissions#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() {
- // Test for method boolean
- // java.security.Permissions.implies(java.security.Permission)
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[7];
- perm[0] = new FilePermission("test1.file", "write");
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
- perm[4] = new FilePermission(s + "windows" + "*", "delete");
- perm[5] = readInFile;
- perm[6] = new FilePermission("hello.file", "write");
- Permissions perms = new Permissions();
- for (int i = 0; i < perm.length; i++) {
- perms.add(perm[i]);
- }
- assertTrue("Returned true for non-subset of files", !perms
- .implies(new FilePermission("<<ALL FILES>>", "execute")));
- assertTrue("Returned true for non-subset of action", !perms
- .implies(new FilePermission(s + "tmp" + s + "test" + s + "*",
- "execute")));
- assertTrue("Returned false for subset of actions", perms
- .implies(new FilePermission("*", "write")));
- assertTrue("Returned false for subset of files", perms
- .implies(new FilePermission(s + "tmp" + s + "test" + s
- + "test.file", "read")));
- assertTrue("Returned false for subset of files and actions", perms
- .implies(new FilePermission(s + "tmp" + s + "test" + s
- + "test2.file", "write")));
- }
-
- public void test_RuntimePermission_exitVM(){
- Permissions permissions = new Permissions();
- permissions.add(new RuntimePermission("exitVM"));
- assertTrue(permissions.implies(new RuntimePermission("exitVM.*")));
- assertTrue(permissions.implies(new RuntimePermission("exitVM.0")));
-
- permissions = new Permissions();
- permissions.add(new RuntimePermission("exitVM.*"));
- assertTrue(permissions.implies(new RuntimePermission("exitVM")));
- assertTrue(permissions.implies(new RuntimePermission("exitVM.0")));
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java
deleted file mode 100644
index c29af58..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java
+++ /dev/null
@@ -1,159 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.*;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>Permissions</code>
- *
- */
-
-public class PermissionsTest extends TestCase {
-
- /**
- * Can add any type of permissions. Cannot add if collection is read-only.
- */
- public void testAdd() {
- Permissions ps = new Permissions();
- Permission ap = new AllPermission();
- Permission bp = new BasicPermission("jhb23jhg5") {
- };
- Permission sp0 = new SecurityPermission("abc");
- Permission sp1 = new SecurityPermission("a.b.c");
- Permission sp2 = new SecurityPermission("a.b.*");
- Permission sp3 = new SecurityPermission("a.*");
- Permission up1 = new UnresolvedPermission("131234", null, null, null);
- Permission up2 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456",
- "26r ytf", new java.security.cert.Certificate[0]);
- Permission[] arr = new Permission[] {
- up1, up2, ap, bp, sp0, sp1, sp2, sp3, };
- for (int i = 0; i < arr.length; i++) {
- ps.add(arr[i]);
- }
-
- //test add duplicate
- ps.add(up1);
- ps.add(sp0);
-
- ps.setReadOnly();
- try {
- ps.add(up1);
- fail("read-only flag is ignored");
- } catch (SecurityException ok) {
- }
- }
-
- /**
- * Should return non-null empty enumeration for empty collection. For
- * non-empty collection, should always return enumeration over unique
- * elements.
- */
- public void testElements() {
- Permissions ps = new Permissions();
- Permission ap = new AllPermission();
- Permission bp = new BasicPermission("jhb23jhg5") {
-
- public PermissionCollection newPermissionCollection() {
- return null;
- }
- };
- Permission sp = new SecurityPermission("abc");
- Permission up1 = new UnresolvedPermission("131234", null, null, null);
- Permission up2 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456",
- "26r ytf", new java.security.cert.Certificate[0]);
-
- Enumeration en = ps.elements();
- assertNotNull(en);
- assertFalse(en.hasMoreElements());
-
- ps.add(up1);
- en = ps.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(up1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
-
- ps.add(up1);
- en = ps.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(up1.equals(en.nextElement()));
- //assertFalse(en.hasMoreElements());
-
- Permission[] arr = new Permission[] {
- ap, bp, sp, up1, up2 };
- for (int i = 0; i < arr.length; i++) {
- ps.add(arr[i]);
- }
- en = ps.elements();
- Collection els = new ArrayList();
- while (en.hasMoreElements()) {
- els.add(en.nextElement());
- }
- //assertEquals(5, els.size());
- assertTrue(els.containsAll(Arrays.asList(arr)));
- }
-
-
- /**
- * input parameter is null
- */
- public void testNull(){
- Permissions ps = new Permissions();
- try {
- ps.elements().nextElement();
- fail("should throw NoSuchElementException");
- } catch (NoSuchElementException e) {}
- try {
- ps.implies(null);
- fail("should throw NPE");
- } catch (NullPointerException e){
- }
-
- try {
- ps.add(null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e){}
-
- }
-
- public void test_toString() {
- Permissions ps = new Permissions();
- String address = getAddress(ps.toString());
- String expectedResult = "java.security.Permissions@" + address
- + " (\n)\n";
- assertEquals(expectedResult, ps.toString());
- }
-
- private String getAddress(String s) {
- int startIndex = s.indexOf('@') + 1;
- int endIndex = s.indexOf(' ');
- return s.substring(startIndex, endIndex);
- }
-
- }
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
deleted file mode 100644
index f0e3b23..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
+++ /dev/null
@@ -1,94 +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.java.security;
-
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.PolicySpi;
-import java.security.ProtectionDomain;
-
-import junit.framework.TestCase;
-
-public class PolicySpiTest extends TestCase {
-
- class MockPolicySpi extends PolicySpi {
-
- @Override
- protected boolean engineImplies(ProtectionDomain domain,
- Permission permission) {
- return false;
- }
-
- public PermissionCollection testEngineGetPermissionsCodeSource() {
- return super.engineGetPermissions((CodeSource) null);
- }
-
- public PermissionCollection testEngineGetPermissionsProtectionDomain() {
- return super.engineGetPermissions((ProtectionDomain) null);
- }
-
- public void engineRefresh() {
- //do nothing.
- return;
- }
-
-
- }
-
- /**
- * @tests java.security.PolicySpi#engineGetPermissions(CodeSource)
- * @since 1.6
- */
- public void test_engineGetPermissions_LCodeSource() {
- MockPolicySpi spi = new MockPolicySpi();
- assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
- .testEngineGetPermissionsCodeSource());
- }
-
- /**
- * @tests java.security.PolicySpi#engineGetPermissions(ProtectionDomain)
- * @since 1.6
- */
- public void test_engineGetPermissions_LProtectionDomain() {
- MockPolicySpi spi = new MockPolicySpi();
- assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
- .testEngineGetPermissionsProtectionDomain());
- }
-
- /**
- * @tests java.security.PolicySpi#engineRefresh()
- * @since 1.6
- */
- public void test_engineRefresh()
- {
- MockPolicySpi spi = new MockPolicySpi();
- assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
- .testEngineGetPermissionsCodeSource());
- assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
- .testEngineGetPermissionsCodeSource());
-
- // Nothing should be done according to java doc.
- spi.engineRefresh();
- assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
- .testEngineGetPermissionsCodeSource());
- assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
- .testEngineGetPermissionsCodeSource());
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
deleted file mode 100644
index ae08bae..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
+++ /dev/null
@@ -1,199 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.Security;
-import java.security.SecurityPermission;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.TestUtils;
-
-import tests.support.resource.Support_Resources;
-
-/**
- * Tests for <code>Policy</code>
- */
-public class PolicyTest extends TestCase {
-
- public static final String JAVA_SECURITY_POLICY = "java.security.policy";
-
- public static class TestProvider extends Policy {
-
- PermissionCollection pc;
-
- public PermissionCollection getPermissions(CodeSource cs) {
- return pc;
- }
-
- public void refresh() {
- }
- }
-
- /**
- * Tests that getPermissions() does proper permission evaluation.
- */
- public void testGetPermissions() {
- SecurityPermission sp = new SecurityPermission("abc");
- SecurityPermission sp2 = new SecurityPermission("fbdf");
- PermissionCollection spc = sp.newPermissionCollection();
- spc.add(sp2);
- ProtectionDomain pd = new ProtectionDomain(null, null);
- ProtectionDomain pd2 = new ProtectionDomain(null, spc);
- TestProvider policy = new TestProvider();
- policy.pc = sp.newPermissionCollection();
-
- //case1: empty policy, no static permissions in PD
- PermissionCollection pc4pd = policy.getPermissions(pd);
- assertNotNull(pc4pd);
- Enumeration en = pc4pd.elements();
- assertFalse(en.hasMoreElements());
-
- //case2: empty policy, some static permissions in PD
- pc4pd = policy.getPermissions(pd2);
- assertNotNull(pc4pd);
- //no check for static permissions
-
- //case3: non-empty policy, no static permissions in PD
- policy.pc.add(sp);
- pc4pd = policy.getPermissions(pd);
- assertNotNull(pc4pd);
- Collection c = new HashSet();
- for (en = pc4pd.elements();en.hasMoreElements(); c.add(en.nextElement())) {
- }
-
- assertTrue(c.contains(sp));
-
- //case4: non-empty policy, some static permissions in PD
- pc4pd = policy.getPermissions(pd2);
- assertNotNull(pc4pd);
- c = new HashSet();
- for (en = pc4pd.elements();en.hasMoreElements(); c.add(en.nextElement())) {
- }
-
- assertTrue(c.contains(sp));
- //no check for static permissions
- }
-
- /**
- * @tests java.security.Policy#getPolicy()
- * @tests java.security.Policy#setPolicy()
- */
- public void testResetingPolicyToDefault() {
-
- Policy oldPolicy = Policy.getPolicy();
- assertNotNull("Got a null system security policy", oldPolicy);
-
- try {
-
- Policy.setPolicy(null); // passing null resets policy
- Policy newPolicy = Policy.getPolicy();
-
- assertNotNull(newPolicy);
- assertNotSame(oldPolicy, newPolicy);
-
- assertEquals("Policy class name", Security
- .getProperty("policy.provider"), newPolicy.getClass()
- .getName());
- } finally {
- Policy.setPolicy(oldPolicy);
- }
- }
-
- /**
- * Test property expansion in policy files
- */
- public void testPropertyExpansion() throws Exception {
-
- // Regression for HARMONY-1963 and HARMONY-2910
- String policyFile = Support_Resources
- .getAbsoluteResourcePath("PolicyTest.txt");
- String oldJavaPolicy = System.getProperty(JAVA_SECURITY_POLICY);
- Policy oldPolicy = Policy.getPolicy();
-
- try {
- System.setProperty(JAVA_SECURITY_POLICY, policyFile);
-
- // test: absolute paths
- assertCodeBasePropertyExpansion("/11111/*", "/11111/-");
- assertCodeBasePropertyExpansion("/22222/../22222/*", "/22222/-");
- assertCodeBasePropertyExpansion("/33333/*", "/33333/../33333/-");
- assertCodeBasePropertyExpansion("/44444/../44444/-", "/44444/*");
- assertCodeBasePropertyExpansion("/55555/../55555/-", "/55555/../55555/-");
- assertCodeBasePropertyExpansion("/666 66 66/-", "/666 66 66/-");
-
- // test: relative paths
- assertCodeBasePropertyExpansion("11111/*", "11111/-");
- assertCodeBasePropertyExpansion("22222/../22222/*", "22222/-");
- assertCodeBasePropertyExpansion("33333/*", "33333/../33333/-");
- assertCodeBasePropertyExpansion("44444/../44444/-", "44444/*");
- assertCodeBasePropertyExpansion("55555/../55555/-", "55555/../55555/-");
- assertCodeBasePropertyExpansion("666 66 66/-", "666 66 66/-");
- } finally {
- TestUtils.setSystemProperty(JAVA_SECURITY_POLICY, oldJavaPolicy);
- Policy.setPolicy(oldPolicy);
- }
- }
-
- /**
- * Asserts codeBase property expansion in policy file
- *
- * @param codeSourceURL -
- * code source for policy object
- * @param codeBaseURL -
- * system propery value for expansion in policy file
- */
- private void assertCodeBasePropertyExpansion(String codeSourceURL,
- String codeBaseURL) throws Exception {
-
- Policy.setPolicy(null); //reset policy
- System.setProperty("test.bin.dir", codeBaseURL);
-
- Policy p = Policy.getPolicy();
- CodeSource codeSource = new CodeSource(
- new URL("file:" + codeSourceURL),
- (java.security.cert.Certificate[]) null);
-
- PermissionCollection pCollection = p.getPermissions(codeSource);
- Enumeration<Permission> elements = pCollection.elements();
-
- SecurityPermission perm = new SecurityPermission(
- "codeBaseForPolicyTest");
-
- while (elements.hasMoreElements()) {
- if (elements.nextElement().equals(perm)) {
- return; // passed
- }
- }
- fail("Failed to find SecurityPermission for codeSource="
- + codeSourceURL + ", codeBase=" + codeBaseURL);
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java
deleted file mode 100644
index 63e10ea..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermission2Test.java
+++ /dev/null
@@ -1,47 +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.java.security;
-
-import java.security.SecurityPermission;
-
-public class SecurityPermission2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.SecurityPermission#SecurityPermission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method java.security.SecurityPermission(java.lang.String)
- assertEquals("create securityPermission constructor(string) failed",
- "SecurityPermission(string)", new SecurityPermission("SecurityPermission(string)").getName()
- );
-
- }
-
- /**
- * @tests java.security.SecurityPermission#SecurityPermission(java.lang.String,
- * java.lang.String)
- */
- public void test_ConstructorLjava_lang_StringLjava_lang_String() {
- // Test for method java.security.SecurityPermission(java.lang.String,
- // java.lang.String)
- SecurityPermission sp = new SecurityPermission("security.file", "write");
- assertEquals("creat securityPermission constructor(string,string) failed",
- "security.file", sp.getName());
-
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java
deleted file mode 100644
index afb3c03..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityPermissionTest.java
+++ /dev/null
@@ -1,78 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.*;
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SecurityPermission</code>
- *
- */
-public class SecurityPermissionTest extends TestCase {
-
- /**
- * Constructor for SecurityPermissionTest.
- * @param arg0
- */
- public SecurityPermissionTest(String arg0) {
- super(arg0);
- }
-
- /**
- * Check all constructors: an object is created with the specified valid name.
- * If name equal null then NPE should be thrown.
- * If name is empty then IAE should be thrown.
- * Action is ignored.
- */
- public void testCtor()
- {
- String name = "basic123*$%#";
- SecurityPermission test = new SecurityPermission(name);
- assertEquals(name, test.getName());
- assertEquals("", test.getActions());
- test = new SecurityPermission(name, "#$!#12435");
- assertEquals(name, test.getName());
- assertEquals("", test.getActions());
- try{
- new SecurityPermission(null);
- fail("NPE is not thrown");
- }
- catch (NullPointerException ok){}
-
- try{
- new SecurityPermission(null, "ds235");
- fail("NPE is not thrown");
- }
- catch (NullPointerException ok){}
-
- try{
- new SecurityPermission("");
- fail("IAE is not thrown");
- }
- catch (IllegalArgumentException ok){}
- try{
- new SecurityPermission("", "ertre 3454");
- fail("IAE is not thrown");
- }
- catch (IllegalArgumentException ok){}
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java
deleted file mode 100644
index ef3be24..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.java
+++ /dev/null
@@ -1,121 +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.java.security;
-
-import java.io.Serializable;
-import java.security.AllPermission;
-import java.security.SecurityPermission;
-import java.security.UnresolvedPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
-
-import tests.util.SerializationTester;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>UnresolvedPermission</code> class fields and methods
- *
- */
-
-public class UnresolvedPermissionTest extends TestCase {
-
- /**
- * Creates an Object with given name, type, action, certificates.
- * Empty or null type is not allowed - exception should be thrown.
- */
- public void testCtor()
- {
- String type = "laskjhlsdk 2345346";
- String name = "^%#UHVKU^%V 887y";
- String action = "JHB ^%(*&T klj3h4";
- UnresolvedPermission up = new UnresolvedPermission(type, name, action, null);
- assertEquals(type, up.getName());
- assertEquals("", up.getActions());
- assertEquals("(unresolved " + type + " " + name + " " + action + ")", up.toString());
-
- up = new UnresolvedPermission(type, null, null, null);
- assertEquals(type, up.getName());
- assertEquals("", up.getActions());
- assertEquals("(unresolved " + type + " null null)", up.toString());
-
- up = new UnresolvedPermission(type, "", "", new java.security.cert.Certificate[0]);
- assertEquals(type, up.getName());
- assertEquals("", up.getActions());
- assertEquals("(unresolved " + type + " )", up.toString());
-
- try {
- new UnresolvedPermission(null, name, action, null);
- fail("No expected NullPointerException");
- } catch (NullPointerException ok) {
- }
-
- //Regression for HARMONY-733
- up = new UnresolvedPermission("", "name", "action", null);
- assertEquals("", up.getName());
- }
-
- /**
- * UnresolvedPermission never implies any other permission.
- */
- public void testImplies()
- {
- UnresolvedPermission up = new UnresolvedPermission("java.security.SecurityPermission", "a.b.c", null, null);
- assertFalse(up.implies(up));
- assertFalse(up.implies(new AllPermission()));
- assertFalse(up.implies(new SecurityPermission("a.b.c")));
- }
-
- public void testSerialization() throws Exception {
- UnresolvedPermission up = new UnresolvedPermission(
- "java.security.SecurityPermission", "a.b.c", "actions", null);
- assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
- assertEquals("a.b.c", up.getUnresolvedName());
- assertEquals("actions", up.getUnresolvedActions());
- assertNull(up.getUnresolvedCerts());
-
- UnresolvedPermission deserializedUp = (UnresolvedPermission) SerializationTester
- .getDeserilizedObject(up);
- assertEquals("java.security.SecurityPermission", deserializedUp
- .getUnresolvedType());
- assertEquals("a.b.c", deserializedUp.getUnresolvedName());
- assertEquals("actions", deserializedUp.getUnresolvedActions());
- assertNull(deserializedUp.getUnresolvedCerts());
- }
-
- public void testSerialization_Compatibility() throws Exception {
- UnresolvedPermission up = new UnresolvedPermission(
- "java.security.SecurityPermission", "a.b.c", "actions", null);
- assertEquals("java.security.SecurityPermission", up.getUnresolvedType());
- assertEquals("a.b.c", up.getUnresolvedName());
- assertEquals("actions", up.getUnresolvedActions());
- assertNull(up.getUnresolvedCerts());
-
- SerializationTest.verifyGolden(this, up, new SerializableAssert() {
- public void assertDeserialized(Serializable orig, Serializable ser) {
- UnresolvedPermission deserializedUp = (UnresolvedPermission) ser;
- assertEquals("java.security.SecurityPermission", deserializedUp
- .getUnresolvedType());
- assertEquals("a.b.c", deserializedUp.getUnresolvedName());
- assertEquals("actions", deserializedUp.getUnresolvedActions());
- assertNull(deserializedUp.getUnresolvedCerts());
- }
- });
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.java
deleted file mode 100644
index a67299e..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.java
+++ /dev/null
@@ -1,44 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.AllPermission;
-import java.security.PermissionCollection;
-import java.util.Enumeration;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization tests for <code>AllPermissionCollection</code>
- *
- */
-
-public class AllPermissionCollectionTest extends SerializationTest {
-
- protected Object[] getData() {
- PermissionCollection c1 = new AllPermission().newPermissionCollection();
- PermissionCollection c2 = new AllPermission().newPermissionCollection();
- c2.add(new AllPermission());
- return new Object[] { c1, c2 };
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.java
deleted file mode 100644
index bdf4658..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.java
+++ /dev/null
@@ -1,44 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.AllPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-
-/**
- * Serialization tests for <code>AllPermission</code>
- *
- */
-
-public class AllPermissionTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- return new Object[] {new AllPermission()};
- }
-
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.java
deleted file mode 100644
index bd1a145..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.PermissionCollection;
-
-import org.apache.harmony.security.tests.support.MyBasicPermission;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Serialization tests for <code>BasicPermissionCollection</code>
- */
-
-public class BasicPermissionCollectionTest extends SerializationTest {
-
- protected Object[] getData() {
-
- PermissionCollection c1 = new MyBasicPermission("234")
- .newPermissionCollection();
-
- PermissionCollection c2 = new MyBasicPermission("1.4.kjhgj.*")
- .newPermissionCollection();
- c2.add(new MyBasicPermission("1.4.kjhgj.sdlvjb3o4i578"));
- c2.add(new MyBasicPermission("1.4"));
-
- PermissionCollection c3 = new MyBasicPermission("*")
- .newPermissionCollection();
- c3.add(new MyBasicPermission("1.4.kjhgj.*"));
-
- return new Object[] { c1, c2, c3 };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.java
deleted file mode 100644
index 5ea30d9..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.java
+++ /dev/null
@@ -1,36 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import org.apache.harmony.security.tests.support.MyBasicPermission;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Serialization tests for <code>BasicPermission</code>
- */
-
-public class BasicPermissionTest extends SerializationTest {
-
- protected Object[] getData() {
- return new Object[] { new MyBasicPermission("kjhgj") };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java
deleted file mode 100644
index d46e837..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.java
+++ /dev/null
@@ -1,193 +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.
- */
-/**
-* @author Alexander V. Astapchuk
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-import java.io.ObjectStreamField;
-import java.net.URL;
-import java.security.CodeSigner;
-import java.security.CodeSource;
-import java.security.Timestamp;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.util.Date;
-
-import org.apache.harmony.security.tests.support.TestCertUtils;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization test for CodeSource.
- *
- */
-
-public class CodeSourceTest extends SerializationTest {
-
- protected void setUp() throws Exception {
- super.setUp();
- TestCertUtils.install_test_x509_factory();
- }
-
- protected void tearDown() throws Exception {
- TestCertUtils.uninstall_test_x509_factory();
- super.tearDown();
- }
-
- public void testGolden() throws Throwable {
- super.testGolden();
- // do special testing to cover Exceptions in the {read/write}Data
-
- //
- // test writeObject()
- //
-
- {//~
-
- Certificate[] certs = new Certificate[] { new InvalidX509Certificate_00() };
- CodeSource cs = new CodeSource(null, certs);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- try {
- oos.writeObject(cs);
- fail("must not be here");
- }
- catch( IOException ex ) {
- // ok
- }
-
- }//~
-
- //
- // test readObject
- //
- {//~
- Certificate[] certs = new Certificate[] { new CertificateOfUnsupportedType() };
- CodeSource cs = new CodeSource(null, certs);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
-
- oos.writeObject(cs);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
-
- try {
- ois.readObject();
- fail("must not pass here");
- }
- catch(ClassNotFoundException ex) {
- // ok
- }
- }//~
-
- // test readObject, force the CertFactory to throw an Exception from
- // inside the generateCertificate
-
- {//~
- Certificate[] certs = new Certificate[] { new InvalidX509Certificate_01() };
- CodeSource cs = new CodeSource(null, certs);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
-
- oos.writeObject(cs);
-
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bais);
-
- try {
- ois.readObject();
- fail("must not pass here");
- }
- catch(IOException ex) {
- // ok
- }
- }//~
- }
-
- private class InvalidX509Certificate_00 extends TestCertUtils.TestX509Certificate {
- InvalidX509Certificate_00() {
- super(TestCertUtils.rootPrincipal, TestCertUtils.rootPrincipal);
- }
- public byte[] getEncoded() throws CertificateEncodingException {
- // simply throw an exception
- throw new CertificateEncodingException("CEE");
- }
- }
-
- private class InvalidX509Certificate_01 extends TestCertUtils.TestX509Certificate {
- InvalidX509Certificate_01() {
- super(TestCertUtils.rootPrincipal, TestCertUtils.rootPrincipal);
- }
- public byte[] getEncoded() throws CertificateEncodingException {
- // this is invalid encoding for TestX509Certificate
- return new byte[] {1,2,3,4,5};
- }
- }
-
-
- private class CertificateOfUnsupportedType extends TestCertUtils.TestCertificate {
- CertificateOfUnsupportedType() {
- super(null, "this is indeed unsupported type of certificates. I do believe so.");
- }
- }
-
- protected Object[] getData() {
- URL url;
- CodeSigner[] signers = null;
- CertPath cpath = TestCertUtils.getCertPath();
- Date now = new Date();
- Timestamp ts = new Timestamp(now, cpath);
-
- try {
- url = new URL("http://localhost");
- signers = new CodeSigner[] { new CodeSigner(cpath, ts) };
- } catch (Exception ex) {
- throw new Error(ex);
- }
- Certificate[] x509chain = new Certificate[] {
- TestCertUtils.rootCA
- };
-
- Object[] data = new Object[] {
- new CodeSource(url, (Certificate[])null),
- new CodeSource(url, new Certificate[0]),
- new CodeSource(url, signers),
- new CodeSource(null, x509chain),
- };
- return data;
- }
-
- public void testSerilizationDescriptor() throws Exception {
-
- // Regression for HARMONY-2787
- ObjectStreamClass objectStreamClass = ObjectStreamClass
- .lookup(CodeSource.class);
- ObjectStreamField objectStreamField = objectStreamClass
- .getField("location");
- assertEquals("Ljava/net/URL;", objectStreamField.getTypeString());
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.java
deleted file mode 100644
index 2d15b41..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.java
+++ /dev/null
@@ -1,40 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import org.apache.harmony.security.tests.support.MyPermissionCollection;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Serialization tests for <code>PermissionCollection</code>
- */
-
-public class PermissionCollectionTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- return new Object[] { new MyPermissionCollection(false),
- new MyPermissionCollection(true) };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.java
deleted file mode 100644
index 0671548..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.java
+++ /dev/null
@@ -1,40 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import org.apache.harmony.security.tests.support.MyPermission;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-/**
- * Serialization tests for <code>Permission</code>
- */
-
-public class PermissionTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- return new Object[] { new MyPermission(null),
- new MyPermission("IYF&*%^sd 43") };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.java
deleted file mode 100644
index 7097444..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.AllPermission;
-import java.security.Permissions;
-import java.security.SecurityPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization tests for <code>Permissions</code>
- *
- */
-
-public class PermissionsTest extends SerializationTest {
-
- /**
- * Returns array containing empty and non-empty Permissions.
- */
- protected Object[] getData() {
- Permissions ps = new Permissions();
-
- ps.add(new AllPermission());
- ps.add(new SecurityPermission("abc"));
-
- return new Object[] { new Permissions(), ps };
- }
-}
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.java
deleted file mode 100644
index 5177a0a..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.java
+++ /dev/null
@@ -1,43 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.SecurityPermission;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization tests for <code>SecurityPermission</code>
- *
- */
-
-public class SecurityPermissionTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- return new Object[] { new SecurityPermission("%&#C"),
- new SecurityPermission("jlkhb.3465.*", "sf"), };
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.java
deleted file mode 100644
index 9c691f1..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.java
+++ /dev/null
@@ -1,58 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.UnresolvedPermission;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-/**
- * Serialization tests for <code>UnresolvedPermissionCollection</code>
- *
- */
-public class UnresolvedPermissionCollectionTest extends SerializationTest {
-
- /**
- * Return array holding 3 collections: empty, single- and multi-element.
- */
- protected Object[] getData() {
- Permission up1 = new UnresolvedPermission("131234", null, null, null);
- Permission up2 = new UnresolvedPermission("131234", "ui23rjh", null,
- null);
- Permission up3 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456",
- "26r ytf", new java.security.cert.Certificate[0]);
- PermissionCollection pc1 = up1.newPermissionCollection();
- PermissionCollection pc2 = up1.newPermissionCollection();
- pc2.add(up3);
- PermissionCollection pc3 = up1.newPermissionCollection();
- pc3.add(up1);
- pc3.add(up2);
- pc3.add(up3);
- return new Object[] { pc1, pc2, pc3 };
- }
-} \ No newline at end of file
diff --git a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java b/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java
deleted file mode 100644
index 01565b2..0000000
--- a/security/src/test/api/java/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.java
+++ /dev/null
@@ -1,66 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security.serialization;
-
-import java.io.ByteArrayInputStream;
-import java.security.UnresolvedPermission;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
-
-import org.apache.harmony.security.tests.support.cert.TestUtils;
-import org.apache.harmony.testframework.serialization.SerializationTest;
-
-
-
-/**
- * Serialization tests for <code>UnresolvedPermission</code>
- *
- */
-
-public class UnresolvedPermissionTest extends SerializationTest {
-
- /**
- * @see com.intel.drl.test.SerializationTest#getData()
- */
- protected Object[] getData() {
- // test with real certificates ?
- return new Object[] {
- new UnresolvedPermission("type", "name", "actions", null),
- new UnresolvedPermission("type", null, null, new Certificate[0]) };
- }
-
- public void testSerializationWithCertificates() throws Exception {
-
- // Regression for HARMONY-2762
- CertificateFactory certificateFactory = CertificateFactory
- .getInstance("X.509");
- Certificate certificate = certificateFactory
- .generateCertificate(new ByteArrayInputStream(TestUtils
- .getEncodedX509Certificate()));
-
- UnresolvedPermission unresolvedPermission = new UnresolvedPermission(
- "java.security.SecurityPermission", "a.b.c", "action",
- new Certificate[] { certificate });
- SerializationTest.verifySelf(unresolvedPermission);
- SerializationTest.verifyGolden(this, unresolvedPermission);
- }
-}
diff --git a/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java b/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
deleted file mode 100644
index f18fede..0000000
--- a/security/src/test/api/java/tests/api/java/security/PermissionCollectionTest.java
+++ /dev/null
@@ -1,241 +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.api.java.security;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.PermissionCollection;
-import java.security.SecurityPermission;
-import java.util.StringTokenizer;
-
-import tests.support.Support_Exec;
-import tests.support.Support_GetLocal;
-import tests.support.resource.Support_Resources;
-
-public class PermissionCollectionTest extends junit.framework.TestCase {
-
- // The below test is known to fail. Haven't got to the bottom of
- // it yet but here is what has been determined :-
- //
- // * the Support_PermissionCollection application that is forked off
- // near the end of this test needs to verify a signed jar (signedBKS.jar).
- // This means that com.ibm.oti.util.JarUtils.verifySignature() ends up
- // getting called. But at present that exists as just a lightweight/stub
- // implementation which simply returns NULL. That behaviour causes a
- // security exception inside java.util.jar.JarVerifier.
- //
- // * the above problem was fixed by rebuilding Harmony with the STUB
- // IMPLEMENTATION of com.ibm.oti.util.JarUtils.verifySignature() replaced
- // with one that delegates to
- // org.apache.harmony.security.utils.JarUtils.verifySignature().
- //
- // * unfortunately, a NPE is raised in line 103 of Harmony's JarUtils class.
- //
- // * the cause of that NPE has still not been determined. Could it be
- // related to Harmony's current stub implementation of BigInteger ?
- /**
- * @tests java.security.PermissionCollection#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() throws Exception{
-
- // Look for the tests classpath
- URL classURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
- assertNotNull("Could not get this class' location", classURL);
-
- File policyFile = Support_GetLocal.createTempFile(".policy");
- policyFile.deleteOnExit();
-
- URL signedBKS = getResourceURL("PermissionCollection/signedBKS.jar");
- String signedBKSPath = new File(signedBKS.getFile()).getCanonicalPath();
- signedBKSPath = signedBKSPath.replace('\\', '/');
- URL keystoreBKS = getResourceURL("PermissionCollection/keystore.bks");
-
- // Create the policy file (and save the existing one if any)
- FileOutputStream fileOut = null;
- try {
- fileOut = new FileOutputStream(policyFile);
- String linebreak = System.getProperty("line.separator");
- StringBuilder towrite = new StringBuilder();
- towrite.append("grant {");
- towrite.append(linebreak);
- towrite.append(" permission java.io.FilePermission \"");
- towrite.append(signedBKSPath);
- towrite.append("\", \"read\";");
- towrite.append(linebreak);
- towrite.append(" permission java.lang.RuntimePermission \"getProtectionDomain\";");
- towrite.append(linebreak);
- towrite.append(" permission java.security.SecurityPermission \"getPolicy\";");
- towrite.append(linebreak);
- towrite.append("};");
- towrite.append(linebreak);
- towrite.append(linebreak);
- towrite.append("grant codeBase \"");
- towrite.append(signedBKS.toExternalForm());
- towrite.append("\" signedBy \"eleanor\" {");
- towrite.append(linebreak);
- towrite.append(" permission java.io.FilePermission \"test1.txt\", \"write\";");
- towrite.append(linebreak);
- towrite.append(" permission mypackage.MyPermission \"essai\", signedBy \"eleanor,dylan\";");
- towrite.append(linebreak);
- towrite.append("};");
- towrite.append(linebreak);
- towrite.append(linebreak);
- towrite.append("grant codeBase \"");
- towrite.append(signedBKS.toExternalForm());
- towrite.append("\" signedBy \"eleanor\" {");
- towrite.append(linebreak);
- towrite.append(" permission java.io.FilePermission \"test2.txt\", \"write\";");
- towrite.append(linebreak);
- towrite.append("};");
- towrite.append(linebreak);
- towrite.append(linebreak);
- towrite.append("grant codeBase \"");
- towrite.append(classURL.toExternalForm());
- towrite.append("\" {");
- towrite.append(linebreak);
- towrite.append(" permission java.security.AllPermission;");
- towrite.append(linebreak);
- towrite.append("};");
- towrite.append(linebreak);
- towrite.append(linebreak);
- towrite.append("keystore \"");
- towrite.append(keystoreBKS.toExternalForm());
- towrite.append("\",\"BKS\";");
- towrite.append(linebreak);
- fileOut.write(towrite.toString().getBytes());
- fileOut.flush();
- } finally {
- if (fileOut != null) {
- fileOut.close();
- }
- }
-
- // Copy mypermissionBKS.jar to the user directory so that it can be put
- // in the classpath.
- File jarFile = null;
- FileOutputStream fout = null;
- InputStream jis = null;
- try {
- jis = Support_Resources.getResourceStream("PermissionCollection/mypermissionBKS.jar");
- jarFile = Support_GetLocal.createTempFile(".jar");
- jarFile.deleteOnExit();
- fout = new FileOutputStream(jarFile);
- int c = jis.read();
- while (c != -1) {
- fout.write(c);
- c = jis.read();
- }
- fout.flush();
- } finally {
- if (fout != null) {
- fout.close();
- }
- if (jis != null) {
- jis.close();
- }
- }
-
- String classPath = new File(classURL.getFile()).getPath();
-
- // Execute Support_PermissionCollection in another VM
- String[] classPathArray = new String[2];
- classPathArray[0] = classPath;
- classPathArray[1] = jarFile.getPath();
- String[] args = { "-Djava.security.policy=" + policyFile.toURL(),
- "tests.support.Support_PermissionCollection",
- signedBKS.toExternalForm() };
-
- String result = Support_Exec.execJava(args, classPathArray, true);
-
- StringTokenizer resultTokenizer = new StringTokenizer(result, ",");
-
- // Check the test result from the new VM process
- assertEquals("Permission should be granted for test1.txt", "true", resultTokenizer.nextToken());
- assertEquals("Signed Permission should be granted for my permission", "true", resultTokenizer.nextToken());
- assertEquals("signed Permission should be granted for text2.txt", "true", resultTokenizer.nextToken());
- assertEquals("Permission should not be granted for text3.txt", "false", resultTokenizer.nextToken());
- }
-
- /**
- * @tests java.security.PermissionCollection#PermissionCollection()
- */
- public void test_Constructor() {
- // test java.security.permissionCollection.PermissionCollection()
- SecurityPermission permi = new SecurityPermission(
- "testing permissionCollection-isReadOnly");
- PermissionCollection permCollect = permi.newPermissionCollection();
- assertNotNull("creat permissionCollection constructor returned a null",
- permCollect);
- }
-
- /**
- * @tests java.security.PermissionCollection#isReadOnly()
- */
- public void test_isReadOnly() {
- // test java.security.permissionCollection.isReadOnly()
- SecurityPermission permi = new SecurityPermission(
- "testing permissionCollection-isREadOnly");
- PermissionCollection permCollect = permi.newPermissionCollection();
- assertTrue("readOnly has not been set, but isReadOnly returned true",
- !permCollect.isReadOnly());
- permCollect.setReadOnly();
- assertTrue("readOnly is set, but isReadonly returned false",
- permCollect.isReadOnly());
- }
-
- /**
- * @tests java.security.PermissionCollection#setReadOnly()
- */
- public void test_setReadOnly() {
- // test java.security.permissionCollection.setReadOnly()
- SecurityPermission permi = new SecurityPermission(
- "testing permissionCollection-setReadOnly");
- PermissionCollection permCollect = permi.newPermissionCollection();
- assertTrue("readOnly has not been set, but isReadOnly returned true",
- !permCollect.isReadOnly());
- permCollect.setReadOnly();
- assertTrue("readOnly is set, but isReadonly returned false",
- permCollect.isReadOnly());
- }
-
- /**
- * @tests java.security.PermissionCollection#toString()
- */
- public void test_toString() {
- // test java.security.permissionCollection.toString()
- SecurityPermission permi = new SecurityPermission(
- "testing permissionCollection-isREadOnly");
- assertNotNull("toString should have returned a string of elements",
- permi.newPermissionCollection().toString());
- assertTrue(permi.newPermissionCollection().toString().endsWith("\n"));
- }
-
- // FIXME move me to Support_Resources
- public static URL getResourceURL(String name) {
-
- URL url = ClassLoader.getSystemClassLoader().getResource(name);
-
- if (url == null) {
- throw new RuntimeException("Failed to get resource url: " + name);
- }
-
- return url;
- }
-} \ No newline at end of file
diff --git a/security/src/test/impl/java.injected/java/security/AllPermissionCollection_ImplTest.java b/security/src/test/impl/java.injected/java/security/AllPermissionCollection_ImplTest.java
deleted file mode 100644
index a483c9f..0000000
--- a/security/src/test/impl/java.injected/java/security/AllPermissionCollection_ImplTest.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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package java.security;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>AllPermissionCollection</code>
- *
- */
-
-public class AllPermissionCollection_ImplTest extends TestCase {
-
- /**
- * Empty collection implies nothing, non-empty collection implies
- * everything.
- */
- public void testImplies() {
- PermissionCollection pc = new AllPermissionCollection();
- Permission ap = new AllPermission();
- Permission sp = new SecurityPermission("abc");
- assertFalse(pc.implies(ap));
- assertFalse(pc.implies(sp));
- pc.add(ap);
- assertTrue(pc.implies(ap));
- assertTrue(pc.implies(sp));
- }
-
- /**
- * Can add any number of AllPermission instances, but no any other
- * permissions. Cannot add if collection is read-only.
- */
- public void testAdd() {
- PermissionCollection pc = new AllPermissionCollection();
- Permission ap = new AllPermission();
- Permission sp = new SecurityPermission("abc");
- try {
- pc.add(sp);
- fail("Should not add non-AllPermission");
- } catch (IllegalArgumentException ok) {
- }
- pc.add(ap);
- pc.add(ap);
- pc.add(new AllPermission());
-
- pc.setReadOnly();
- try {
- pc.add(ap);
- fail("read-only flag is ignored");
- } catch (SecurityException ok) {
- }
- }
-
- /**
- * Should return non-null empty enumeration for empty collection. For
- * non-empty collection, should always return 1-element enumeration.
- */
- public void testElements() {
- PermissionCollection pc = new AllPermissionCollection();
- Permission ap = new AllPermission();
- Enumeration en = pc.elements();
- assertNotNull(en);
- assertFalse(en.hasMoreElements());
-
- pc.add(ap);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(ap.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
-
- ap = new AllPermission();
- pc.add(ap);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(ap.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
- }
-
- /**
- * If nothing to enumerate, should throw NoSuchElementException
- */
- public void testElements_NoElements() {
- PermissionCollection pc = new AllPermissionCollection();
- try {
- pc.elements().nextElement();
- fail("should throw NoSuchElementException");
- } catch (NoSuchElementException ok) {}
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/BasicPermissionCollection_ImplTest.java b/security/src/test/impl/java.injected/java/security/BasicPermissionCollection_ImplTest.java
deleted file mode 100644
index a2ac249..0000000
--- a/security/src/test/impl/java.injected/java/security/BasicPermissionCollection_ImplTest.java
+++ /dev/null
@@ -1,214 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package java.security;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>BasicPermissionCollection</code>
- *
- */
-
-public class BasicPermissionCollection_ImplTest extends TestCase {
-
- /**
- * Can add only BasicPermissions of the same type as the first added. Cannot
- * add if collection is read-only.
- */
- public void testAdd() {
- PermissionCollection pc = new BasicPermissionCollection();
- Permission ap = new AllPermission();
- Permission sp1 = new SecurityPermission("a.b.c");
- Permission sp2 = new SecurityPermission("a.b.*");
- try {
- pc.add(ap);
- fail("Should not add non-BasicPermission");
- } catch (IllegalArgumentException ok) {
- }
- pc.add(sp1);
- pc.add(sp2);
- try {
- pc.add(new BasicPermission("123") {
- });
- fail("Should not add BasicPermission of different type");
- } catch (IllegalArgumentException ok) {
- }
-
- pc.setReadOnly();
- try {
- pc.add(sp1);
- fail("read-only flag is ignored");
- } catch (SecurityException ok) {
- }
- }
-
- /**
- * Empty collection implies nothing. Non-empty collection should imply all
- * contained permissions, and should consider contained wildcards (if any).
- */
- public void testImplies() {
- PermissionCollection pc = new BasicPermissionCollection();
- Permission ap = new AllPermission();
- Permission up = new UnresolvedPermission("safds", null, null, null);
- Permission sp1 = new SecurityPermission("a.b.c");
- Permission sp11 = new SecurityPermission("a.b.");
- Permission sp2 = new SecurityPermission("a.b.*");
- Permission sp3 = new SecurityPermission("a.*");
- Permission sp4 = new SecurityPermission("*");
-
- assertFalse(pc.implies(ap));
- assertFalse(pc.implies(up));
- assertFalse(pc.implies(sp1));
-
- pc.add(sp3);
- assertTrue(pc.implies(sp2));
- assertTrue(pc.implies(sp1));
- assertTrue(pc.implies(sp11));
- assertTrue(pc.implies(sp3));
- assertFalse(pc.implies(sp4));
-
- pc.add(sp4);
- assertTrue(pc.implies(sp4));
- assertFalse(pc.implies(ap));
- assertFalse(pc.implies(up));
- assertTrue(pc.implies(new SecurityPermission("skjdnkwje wefkwjef")));
- }
-
- /**
- * Should return non-null empty enumeration for empty collection. For
- * non-empty collection, should always return enumeration over unique
- * elements.
- */
- public void testElements() {
- PermissionCollection pc = new BasicPermissionCollection();
- Permission sp1 = new SecurityPermission("a.b.c");
- Permission sp2 = new SecurityPermission("a.b.*");
- Permission sp3 = new SecurityPermission("*");
- Enumeration en = pc.elements();
- assertNotNull(en);
- assertFalse(en.hasMoreElements());
-
- try {
- pc.add(null);
- fail("should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- }
-
- pc.add(sp1);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(sp1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
-
- pc.add(sp1);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(sp1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
-
- pc.add(sp3);
- pc.add(sp2);
- en = pc.elements();
- Collection els = new ArrayList();
- while (en.hasMoreElements()) {
- els.add(en.nextElement());
- }
- assertEquals(3, els.size());
- assertTrue(els.containsAll(Arrays.asList(new Permission[] {
- sp1, sp2, sp3 })));
- }
-
- /**
- * test on deserialization of incorrect object
- */
- public void testNegDeserialization_01() throws Exception {
-
- SecurityPermission sp = new SecurityPermission("a.b.c");
- BasicPermissionCollection pc = new BasicPermissionCollection();
- pc.add(sp);
- setField(pc, "permClass", BasicPermission.class);
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(pc);
- oos.flush();
-
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
- baos.toByteArray()));
- try {
- in.readObject();
- fail("should throw InvalidObjectException");
- } catch (java.io.InvalidObjectException e) {
- } finally {
- oos.close();
- in.close();
- }
- }
-
- /**
- * test on deserialization of incorrect object
- */
- public void testNegDeserialization_02() throws Exception {
-
- SecurityPermission sp = new SecurityPermission("a.b.c");
- BasicPermissionCollection pc = new BasicPermissionCollection();
- pc.add(sp);
- setField(pc, "allEnabled", new Boolean(true));
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(pc);
- oos.flush();
-
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
- baos.toByteArray()));
- try {
- in.readObject();
- fail("should throw InvalidObjectException");
- } catch (java.io.InvalidObjectException e) {
- } finally {
- oos.close();
- in.close();
- }
- }
-
- /**
- * setup a private field
- */
- private void setField(Object obj, String name, Object newval)
- throws Exception {
- Field f = obj.getClass().getDeclaredField(name);
- f.setAccessible(true);
- f.set(obj, newval);
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java b/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java
deleted file mode 100644
index 4401a07..0000000
--- a/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java
+++ /dev/null
@@ -1,197 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package java.security;
-
-import java.util.*;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>UnresolvedPermissionCollection</code> class fields and methods
- *
- */
-
-public class UnresolvedPermissionCollection_ImplTest extends TestCase {
-
- /**
- * Can add any number of UnresolvedPermission instances, but no any other permissions.
- * Cannot add if collection is read-only.
- */
- public void testAdd()
- {
- PermissionCollection pc = new UnresolvedPermissionCollection();
- Permission sp = new SecurityPermission("abc");
- Permission up1 = new UnresolvedPermission("131234", null, null, null);
- Permission up2 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456", "26r ytf",
- new java.security.cert.Certificate[0]);
-
- try {
- pc.add(sp);
- fail("Should not add non-UnresolvedPermission");
- }
- catch (IllegalArgumentException ok) {}
-
- pc.add(up1);
- pc.add(up1);
- pc.add(up2);
-
- pc.setReadOnly();
- try {
- pc.add(up1);
- fail("read-only flag is ignored");
- }
- catch (SecurityException ok) {}
- }
-
- /** This collection never implies any permission. */
- public void testImplies()
- {
- Permission ap = new AllPermission();
- Permission up = new UnresolvedPermission("131234", null, null, null);
- PermissionCollection pc = up.newPermissionCollection();
-
- assertFalse(pc.implies(ap));
- assertFalse(pc.implies(up));
-
- //pc.add(up);
- //assertFalse(pc.implies(up));
- }
-
- /**
- * Should return non-null empty enumeration for empty collection.
- * For non-empty collection, should always return enumeration over unique elements.
- */
- public void testElements()
- {
- PermissionCollection pc = new UnresolvedPermissionCollection();
- Permission up1 = new UnresolvedPermission("131234", null, null, null);
- Permission up2 = new UnresolvedPermission("131234", "ui23rjh", null, null);
- Permission up3 = new UnresolvedPermission("KUJKHVKJgyuygjhb", "xcv456", "26r ytf",
- new java.security.cert.Certificate[0]);
-
- Enumeration en = pc.elements();
- assertNotNull(en);
- assertFalse(en.hasMoreElements());
-
- pc.add(up1);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(up1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());
-
- //no check for duplicate elements - this is too implementation specific.
- /*pc.add(up1);
- en = pc.elements();
- assertTrue(en.hasMoreElements());
- assertTrue(up1.equals(en.nextElement()));
- assertFalse(en.hasMoreElements());*/
-
- pc.add(up2);
- pc.add(up3);
- en = pc.elements();
- Collection els = new ArrayList();
- while (en.hasMoreElements())
- {
- els.add(en.nextElement());
- }
- assertEquals(3, els.size());
- assertTrue(els.contains(up1) && els.contains(up2) && els.contains(up3));
- }
-
- /**
- * For null collection passed, should behave correctly:
- * <ul>
- * <li>If nothing resolved, returns null and does not remove elements
- * <li>If some permission resolved, returns proper collection and removes resolved elements
- * </ul>
- */
- public void testResolveCollection()
- {
- UnresolvedPermissionCollection upc = new UnresolvedPermissionCollection();
- Permission up = new UnresolvedPermission("java.security.AllPermission", "xcv456", "26r ytf",
- new java.security.cert.Certificate[0]);
- Permission ap = new AllPermission();
- Permission bp = new BasicPermission("sfwertsdg"){};
-
- PermissionCollection resolved = upc.resolveCollection(ap, null);
- assertNull(resolved);
-
- upc.add(up);
- resolved = upc.resolveCollection(bp, null);
- assertNull(resolved);
- assertTrue(up.equals(upc.elements().nextElement()));
-
- resolved = upc.resolveCollection(ap, null);
- assertNotNull(resolved);
- assertTrue(ap.equals(resolved.elements().nextElement()));
- assertFalse("resolved permission should be removed from unresolved collection", upc.elements().hasMoreElements());
- }
-
- /**
- * For real collection passed, should behave correctly:
- * <ul>
- * <li>If nothing resolved, returns the collection and does not remove elements
- * <li>If some permission resolved, returns the collection and removes resolved elements
- * </ul>
- */
- public void testResolveCollectionReturnedCollection()
- {
- UnresolvedPermissionCollection upc = new UnresolvedPermissionCollection();
- Permission up3 = new UnresolvedPermission("java.security.AllPermission", "xcv456", null, null);
- Permission ap = new AllPermission();
- PermissionCollection apc = new AllPermissionCollection();
-
- PermissionCollection resolved = upc.resolveCollection(ap, apc);
- assertSame("should return the passed collection if it is not null", apc, resolved);
- // retest the same for case of actually resolved permission
- upc.add(up3);
- resolved = upc.resolveCollection(ap, apc);
- assertSame("should return the passed collection if it is not null", apc, resolved);
- }
-
- /**
- * Test for case when some permissions of the expected type were not resolved for some reason,
- * while others were resolved. Returned collection should contain resolved permissions only,
- * and the unresolved collection should retain unresolved ones only.
- */
- public void testResolveCollectionPartial()
- {
- UnresolvedPermissionCollection upc = new UnresolvedPermissionCollection();
- String name = "ui23rjh";
- Permission up1 = new UnresolvedPermission("java.security.SecurityPermission", null, null, null);
- Permission up2 = new UnresolvedPermission("java.security.SecurityPermission", name, null, null);
- Permission sp = new SecurityPermission(name);
-
- upc.add(up1);
- upc.add(up2);
- PermissionCollection resolved = upc.resolveCollection(new SecurityPermission("34po5ijh"), null);
- assertNotNull(resolved);
- Enumeration els = resolved.elements();
- assertTrue(sp.equals(els.nextElement()));
- assertFalse(els.hasMoreElements());
- els = upc.elements();
- assertTrue("resolved permission should be removed from unresolved collection",
- up1.equals(els.nextElement()));
- assertFalse(els.hasMoreElements());
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java b/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java
deleted file mode 100644
index 705d471..0000000
--- a/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java
+++ /dev/null
@@ -1,40 +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 java.security;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>UnresolvedPermission</code> class fields and methods
- *
- */
-
-public class UnresolvedPermissionTest extends TestCase {
-
- /**
- * newPermissionCollection() should return new BasicPermissionCollection on every invocation
- */
- public void testCollection()
- {
- UnresolvedPermission up = new UnresolvedPermission("a.b.c", null, null, null);
- PermissionCollection pc1 = up.newPermissionCollection();
- PermissionCollection pc2 = up.newPermissionCollection();
- assertTrue((pc1 instanceof UnresolvedPermissionCollection) && (pc2 instanceof UnresolvedPermissionCollection));
- assertNotSame(pc1, pc2);
- }
-}
diff --git a/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java b/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
deleted file mode 100644
index 9fdae07..0000000
--- a/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java
+++ /dev/null
@@ -1,238 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package java.security;
-
-import java.security.cert.Certificate;
-
-import junit.framework.TestCase;
-
-import org.apache.harmony.security.tests.support.cert.MyCertificate;
-
-/**
- * Tests for <code>UnresolvedPermission</code> class fields and methods
- *
- */
-
-public class UnresolvedPermission_ImplTest extends TestCase {
-
- /**
- * This test is valid since 1.5 release only. Checks that UnresolvedPermission returns the proper
- * data for target permission. For non-empty certificates array,
- * returns a new array each time this method is called.
- */
- public void testTargetData()
- {
- String type = "laskjhlsdk 2345346";
- String name = "^%#UHVKU^%V 887y";
- String action = "JHB ^%(*&T klj3h4";
- UnresolvedPermission up = new UnresolvedPermission(type, name, action, null);
- assertEquals(type, up.getUnresolvedType());
- assertEquals(name, up.getUnresolvedName());
- assertEquals(action, up.getUnresolvedActions());
- assertNull(up.getUnresolvedCerts());
- }
-
- public void testEquals()
- {
- String type = "KJHGUiy 24y";
- String name = "kjhsdkfj ";
- String action = "T klj3h4";
- UnresolvedPermission up = new UnresolvedPermission(type, name, action, null);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action, null);
- assertFalse(up.equals(null));
- assertFalse(up.equals(new Object()));
- assertFalse(up.equals(new BasicPermission("df"){}));
- assertTrue(up.equals(up));
- assertTrue(up.equals(up2));
- assertTrue(up.hashCode() == up2.hashCode());
- up2 = new UnresolvedPermission(type, name, action, new java.security.cert.Certificate[0]);
- assertTrue(up.hashCode() == up2.hashCode());
- up2 = new UnresolvedPermission(type, name, action, new java.security.cert.Certificate[2]);
- //case of trivial collections {null}
- up = new UnresolvedPermission(type, name, action, new java.security.cert.Certificate[10]);
- assertTrue(up.hashCode() == up2.hashCode());
- }
-
- /**
- * resolve the unresolved permission to the permission of specified class.
- */
- public void testResolve()
- {
- String name = "abc";
- UnresolvedPermission up = new UnresolvedPermission("java.security.SecurityPermission", name, null, null);
- Permission expected = new SecurityPermission(name);
- //test valid input
- assertEquals(expected, up.resolve(SecurityPermission.class));
-
- //test invalid class
- assertNull(up.resolve(Object.class));
-
- //test invalid signers
- //up = new UnresolvedPermission("java.security.SecurityPermission", name, null, new java.security.cert.Certificate[1]);
- //assertNull(up.resolve(SecurityPermission.class));
-
- //another valid case
- up = new UnresolvedPermission("java.security.AllPermission", null, null, new java.security.cert.Certificate[0]);
- assertEquals(new AllPermission(name, ""), up.resolve(AllPermission.class));
- }
-
- public static final String type = "java.util.PropertyPermission";
-
- public static final String name = "os.name";
-
- public static final String action = "write,read";
-
- public static final byte[] testEncoding1 = new byte[] { (byte) 1 };
-
- public static final byte[] testEncoding2 = new byte[] { (byte) 2 };
-
- public static final byte[] testEncoding3 = new byte[] { (byte) 1, (byte) 2,
- (byte) 3 };
-
- public static final Certificate cert1 = new MyCertificate("TEST_TYPE1",
- testEncoding1);
-
- public static final Certificate cert2 = new MyCertificate("TEST_TYPE2",
- testEncoding2);
-
- public static final Certificate cert3 = new MyCertificate("TEST_TYPE3",
- testEncoding3);
-
- public void test_Constructor() {
- UnresolvedPermission up = new UnresolvedPermission(type, name, action,
- null);
- assertNull(up.getUnresolvedCerts());
-
- up = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[0]);
- assertEquals(0, up.getUnresolvedCerts().length);
-
- up = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[2]);
- assertEquals(2, up.getUnresolvedCerts().length);
- }
-
- public void test_Equals_Scenario0() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- null);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- null);
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario1() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- null);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[0]);
- assertFalse(up1.equals(up2));
- }
-
- public void test_Equals_Scenario2() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- null);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[2]);
- assertFalse(up1.equals(up2));
- }
-
- public void test_Equals_Scenario3() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[0]);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[0]);
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario4() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[0]);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[2]);
- assertFalse(up1.equals(up2));
- }
-
- public void test_Equals_Scenario5() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[2]);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[5]);
- assertFalse(up1.equals(up2));
- }
-
- public void test_Equals_Scenario6() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1 });
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1 });
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario7() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, cert2 });
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, cert2 });
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario8() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, cert2 });
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert2, cert1 });
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario9() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, cert2, cert3 });
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert2, cert1, cert3 });
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario10() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[2]);
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[2]);
- // Non-bug difference, RI throw NPE here.
- assertEquals(up1, up2);
- }
-
- public void test_Equals_Scenario11() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, cert2 });
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, null, cert2 });
- assertFalse(up1.equals(up2));
- }
-
- public void test_Equals_Scenario12() {
- UnresolvedPermission up1 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, null, null });
- UnresolvedPermission up2 = new UnresolvedPermission(type, name, action,
- new java.security.cert.Certificate[] { cert1, null, cert1 });
- assertEquals(up1, up2);
- }
-}
diff --git a/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java b/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java
deleted file mode 100644
index f11fd84..0000000
--- a/security/src/test/impl/java.injected/org/apache/harmony/security/DefaultPolicyScannerTest.java
+++ /dev/null
@@ -1,585 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.harmony.security.DefaultPolicyScanner;
-import junit.framework.TestCase;
-
-
-/**
- * TODO Put your class description here
- *
- */
-
-public class DefaultPolicyScannerTest extends TestCase {
-
- private static String IO_ERROR = "Failed intentionally";
-
- private DefaultPolicyScanner scanner;
-
- private static StreamTokenizer getST(String sample) {
- return new StreamTokenizer(new StringReader(sample));
- }
-
- private static StreamTokenizer getFailingST(String sample) {
- return new StreamTokenizer(new StringReader(sample)) {
-
- public int nextToken() throws IOException {
- throw new IOException(IO_ERROR);
- }
- };
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- scanner = new DefaultPolicyScanner();
- }
-
- /**
- * Tests tokenization of valid policy sample with all possible elements.
- */
- public void testScanStream_Complex() throws Exception {
- List grants = new ArrayList();
- List keys = new ArrayList();
- Reader r = new StringReader(
- "keystore \"url1\";grant{}KeyStore \"url2\", \"type2\""
- + "keystore \"url3\"\nGRANT signedby \"duke,Li\", "
- + "codebase\"\", principal a.b.c \"alias\"{permission XXX \"YYY\", SignedBy \"ZZZ\" \n \t };;;");
- scanner.scanStream(r, grants, keys);
-
- assertEquals("3 keystores expected", 3, keys.size());
- String[] urls = new String[] {
- "url1", "url2", "url3" };
- String[] types = new String[] {
- null, "type2", null };
- for (int i = 0; i < 3; i++) {
- DefaultPolicyScanner.KeystoreEntry key = (DefaultPolicyScanner.KeystoreEntry)keys
- .get(i);
- assertEquals(urls[i], key.url);
- assertEquals(types[i], key.type);
- }
- assertEquals("2 grants expected", 2, grants.size());
- DefaultPolicyScanner.GrantEntry ge = (DefaultPolicyScanner.GrantEntry)grants
- .get(0);
- assertTrue(ge.codebase == null && ge.signers == null
- && ge.principals == null && ge.permissions.size() == 0);
-
- ge = (DefaultPolicyScanner.GrantEntry)grants.get(1);
- assertTrue(ge.codebase.equals("") && ge.signers.equals("duke,Li")
- && ge.principals.size() == 1 && ge.permissions.size() == 1);
-
- DefaultPolicyScanner.PrincipalEntry pn = (DefaultPolicyScanner.PrincipalEntry)ge.principals
- .iterator().next();
- assertTrue(pn.klass.equals("a.b.c") && pn.name.equals("alias"));
-
- DefaultPolicyScanner.PermissionEntry pe = (DefaultPolicyScanner.PermissionEntry)ge.permissions
- .iterator().next();
- assertTrue(pe.klass.equals("XXX") && pe.name.equals("YYY")
- && pe.actions == null && pe.signers.equals("ZZZ"));
- }
-
- public void testScanStream_Empty() throws Exception {
- scanner.scanStream(new StringReader(""), new ArrayList(),
- new ArrayList());
- }
-
- /**
- * Tests that scanStream() throws InvalidFormatException on invalid
- * keywords.
- */
- public void testScanStream_Invalid() throws Exception {
- List grants = new ArrayList();
- List keys = new ArrayList();
- try {
- scanner.scanStream(new StringReader(
- "keystore \"url1\"; granted{} grant{}"), grants, keys);
- fail("InvalidFormatException is not thrown");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
- assertTrue(keys.size() == 1 && grants.size() == 0);
-
- }
-
- try {
- scanner.scanStream(new StringReader(
- "grant{} grant{} keyshop \"url1\"; keystore \"url1\";"),
- grants, keys);
- fail("InvalidFormatException is not thrown 2");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
- assertTrue(keys.size() == 1 && grants.size() == 2);
-
- }
- }
-
- /**
- * Tests that scanStream() throws IOException if stream fails.
- */
- public void testScanStream_IOException() throws Exception {
- try {
- scanner.scanStream(new Reader() {
-
- public void close() throws IOException {
- }
-
- public int read(char[] cbuf, int off, int count)
- throws IOException {
- throw new IOException(IO_ERROR);
- }
- }, new ArrayList(), new ArrayList());
- fail("IOException is intercepted");
- } catch (IOException ok) {
- assertEquals(IO_ERROR, ok.getMessage());
- }
- }
-
- /**
- * Tests that both handleUnexpectedToken() methods throw proper
- * InvalidFormatException exception.
- */
- public void testHandleUnexpectedToken() {
- try {
- scanner.handleUnexpectedToken(getST(""));
- fail("InvalidFormatException is not thrown");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
-
- String message = "bla-bli-blu";
- try {
- scanner.handleUnexpectedToken(getST(""), message);
- fail("InvalidFormatException is not thrown 2");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
- assertNotNull(ok.getMessage());
- assertTrue(ok.getMessage().indexOf(message) >= 0);
- }
- }
-
- /**
- * Tests readKeystoreEntry() for tokenizing all valid syntax variants.
- */
- public void testReadKeystoreEntry() throws Exception {
- DefaultPolicyScanner.KeystoreEntry ke = scanner
- .readKeystoreEntry(getST("\"URL1\""));
- assertEquals("URL1", ke.url);
- assertNull(ke.type);
-
- ke = scanner.readKeystoreEntry(getST("\"URL2\",\"TYPE2\""));
- assertEquals("URL2", ke.url);
- assertEquals("TYPE2", ke.type);
-
- ke = scanner.readKeystoreEntry(getST("\"URL3\" \"TYPE3\""));
- assertEquals("URL3", ke.url);
- assertEquals("TYPE3", ke.type);
- }
-
- /**
- * Tests that readKeystoreEntry() throws IOException if stream fails.
- */
- public void testReadKeystoreEntry_IOException() throws Exception {
- try {
- scanner.readKeystoreEntry(getFailingST(""));
- fail("IOException is intercepted");
- } catch (IOException ok) {
- assertEquals(IO_ERROR, ok.getMessage());
- }
- }
-
- /**
- * Tests that readKeystoreEntry() throws InvalidFormatException on invalid
- * input
- */
- public void testReadKeystoreEntry_Invalid() throws Exception {
- try {
- scanner.readKeystoreEntry(getST(""));
- fail("InvalidFormatException is not thrown 1");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readKeystoreEntry(getST(" ;"));
- fail("InvalidFormatException is not thrown 2");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readKeystoreEntry(getST("URL"));
- fail("InvalidFormatException is not thrown 3");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- }
-
- /**
- * Tests readPrincipalEntry() for tokenizing all valid syntax variants.
- */
- public void testReadPrincipalEntry() throws Exception {
- DefaultPolicyScanner.PrincipalEntry pe = scanner
- .readPrincipalEntry(getST("\"name1\""));
- assertEquals("name1", pe.name);
- assertNull(pe.klass);
-
- pe = scanner.readPrincipalEntry(getST("a.b.c.d\"name 2\""));
- assertEquals("name 2", pe.name);
- assertEquals("a.b.c.d", pe.klass);
-
- pe = scanner.readPrincipalEntry(getST("* *"));
- assertEquals(DefaultPolicyScanner.PrincipalEntry.WILDCARD, pe.name);
- assertEquals(DefaultPolicyScanner.PrincipalEntry.WILDCARD, pe.klass);
-
- pe = scanner.readPrincipalEntry(getST("* \"name3\""));
- assertEquals("name3", pe.name);
- assertEquals(DefaultPolicyScanner.PrincipalEntry.WILDCARD, pe.klass);
-
- pe = scanner.readPrincipalEntry(getST("clazz *"));
- assertEquals(DefaultPolicyScanner.PrincipalEntry.WILDCARD, pe.name);
- assertEquals("clazz", pe.klass);
-
- pe = scanner.readPrincipalEntry(getST("\"a, b, c, d\""));
- assertEquals("a,b,c,d", pe.name);
- assertNull(pe.klass);
- }
-
- /**
- * Tests that readPrincipalEntry() throws InvalidFormatException on invalid
- * input
- */
- public void testReadPrincipalEntry_Invalid() throws Exception {
- try {
- scanner.readPrincipalEntry(getST(""));
- fail("InvalidFormatException is not thrown 1");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPrincipalEntry(getST(" ;"));
- fail("InvalidFormatException is not thrown 2");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPrincipalEntry(getST("class"));
- fail("InvalidFormatException is not thrown 3");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPrincipalEntry(getST("class name"));
- fail("InvalidFormatException is not thrown 4");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPrincipalEntry(getST("class, \"name\""));
- fail("InvalidFormatException is not thrown 5");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPrincipalEntry(getST("* name"));
- fail("InvalidFormatException is not thrown 6");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- }
-
- /**
- * Tests that readPrincipalEntry() throws IOException if stream fails.
- */
- public void testReadPrincipalEntry_IOException() throws Exception {
- try {
- scanner.readPrincipalEntry(getFailingST(""));
- fail("IOException is intercepted");
- } catch (IOException ok) {
- assertEquals(IO_ERROR, ok.getMessage());
- }
- }
-
- /**
- * Tests readPermissionEntries() for tokenizing empty list of permissions.
- */
- public void testReadPermissionEntries_Empty() throws Exception {
- Collection perms = scanner.readPermissionEntries(getST("}"));
- assertNotNull(perms);
- assertEquals(0, perms.size());
- }
-
- /**
- * Tests readPermissionEntries() for tokenizing all valid syntax variants,
- * for just one permission.
- */
- public void testReadPermissionEntries_Single() throws Exception {
- Collection perms = scanner
- .readPermissionEntries(getST("permission a.b.c; }"));
- assertEquals(1, perms.size());
- DefaultPolicyScanner.PermissionEntry pe = (DefaultPolicyScanner.PermissionEntry)perms
- .iterator().next();
- assertEquals("a.b.c", pe.klass);
- assertNull(pe.name);
- assertNull(pe.actions);
- assertNull(pe.signers);
-
- perms = scanner
- .readPermissionEntries(getST("permission a.b.c \"name1\" }"));
- assertEquals(1, perms.size());
- pe = (DefaultPolicyScanner.PermissionEntry)perms.iterator().next();
- assertEquals("a.b.c", pe.klass);
- assertEquals("name1", pe.name);
- assertNull(pe.actions);
- assertNull(pe.signers);
-
- perms = scanner
- .readPermissionEntries(getST("permission a.b.c \"name2\", \"action2\"}"));
- assertEquals(1, perms.size());
- pe = (DefaultPolicyScanner.PermissionEntry)perms.iterator().next();
- assertEquals("a.b.c", pe.klass);
- assertEquals("name2", pe.name);
- assertEquals("action2", pe.actions);
- assertNull(pe.signers);
-
- perms = scanner
- .readPermissionEntries(getST("permission a.b.c \"name3\" signedby \"\"}"));
- assertEquals(1, perms.size());
- pe = (DefaultPolicyScanner.PermissionEntry)perms.iterator().next();
- assertEquals("a.b.c", pe.klass);
- assertEquals("name3", pe.name);
- assertNull(pe.actions);
- assertEquals("", pe.signers);
-
- perms = scanner
- .readPermissionEntries(getST("permission a.b.c4 ,\"actions4\" SignedBy \"sig4\"}"));
- assertEquals(1, perms.size());
- pe = (DefaultPolicyScanner.PermissionEntry)perms.iterator().next();
- assertEquals("a.b.c4", pe.klass);
- assertNull(pe.name);
- assertEquals("actions4", pe.actions);
- assertEquals("sig4", pe.signers);
-
- perms = scanner
- .readPermissionEntries(getST("permission a.b.c5 \"name5\",\"actions5\",signedby \"sig5\";}"));
- assertEquals(1, perms.size());
- pe = (DefaultPolicyScanner.PermissionEntry)perms.iterator().next();
- assertEquals("a.b.c5", pe.klass);
- assertEquals("name5", pe.name);
- assertEquals("actions5", pe.actions);
- assertEquals("sig5", pe.signers);
- }
-
- /**
- * Tests readPermissionEntries() for tokenizing valid syntax for a list of
- * permissions.
- */
- public void testReadPermissionEntries_List() throws Exception {
- Collection perms = scanner
- .readPermissionEntries(getST("permission a.b.c"
- + " permission qwerty ,\"aaa\";"
- + "permission zzz signedby \"xxx\"}"));
- assertEquals(3, perms.size());
-
- for (Iterator it = perms.iterator(); it.hasNext();) {
- DefaultPolicyScanner.PermissionEntry pe = (DefaultPolicyScanner.PermissionEntry)it
- .next();
- if ("a.b.c".equals(pe.klass)) {
- assertNull(pe.name);
- assertNull(pe.actions);
- assertNull(pe.signers);
- } else if ("qwerty".equals(pe.klass)) {
- assertNull(pe.name);
- assertEquals("aaa", pe.actions);
- assertNull(pe.signers);
- } else if ("zzz".equals(pe.klass)) {
- assertNull(pe.name);
- assertNull(pe.actions);
- assertEquals("xxx", pe.signers);
- } else {
- fail("Unknown permission reported: " + pe.klass);
- }
- }
- }
-
- /**
- * Tests that readPermissionEntries() throws InvalidFormatException on
- * invalid input
- */
- public void testReadPermissionEntries_Invalid() throws Exception {
- try {
- scanner.readPermissionEntries(getST("permission a.b.c"));
- fail("InvalidFormatException is not thrown 1");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPermissionEntries(getST("permission;}"));
- fail("InvalidFormatException is not thrown 2");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPermissionEntries(getST("permission class name}"));
- fail("InvalidFormatException is not thrown 3");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readPermissionEntries(getST("permission class ,,}"));
- fail("InvalidFormatException is not thrown 4");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner
- .readPermissionEntries(getST("permission class \"name\", signedby signers}"));
- fail("InvalidFormatException is not thrown 5");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- }
-
- /**
- * Tests that readPermissionEntries() throws IOException if stream fails.
- */
- public void testReadPermissionEntries_IOException() throws Exception {
- try {
- scanner.readPermissionEntries(getFailingST(""));
- fail("IOException is intercepted");
- } catch (IOException ok) {
- assertEquals(IO_ERROR, ok.getMessage());
- }
- }
-
- /**
- * Tests readGrantEntry() for tokenizing all valid syntax variants.
- */
- public void testReadGrantEntry_Empty() throws Exception {
- DefaultPolicyScanner.GrantEntry ge = scanner.readGrantEntry(getST(""));
- assertNull(ge.codebase);
- assertNull(ge.codebase);
- assertNull(ge.principals);
- assertTrue(ge.permissions == null || ge.permissions.isEmpty());
-
- ge = scanner.readGrantEntry(getST("{}"));
- assertNull(ge.codebase);
- assertNull(ge.codebase);
- assertNull(ge.principals);
- assertTrue(ge.permissions == null || ge.permissions.isEmpty());
- }
-
- /**
- * Tests readGrantEntry() for tokenizing all valid syntax variants.
- */
- public void testReadGrantEntry() throws Exception {
- DefaultPolicyScanner.GrantEntry ge = scanner
- .readGrantEntry(getST("codebase \"u1\" signedby \"s1\";"));
- assertEquals("u1", ge.codebase);
- assertEquals("s1", ge.signers);
- assertNull(ge.principals);
-
- ge = scanner.readGrantEntry(getST("signedby \"s2\" codebase \"u2\";"));
- assertEquals("u2", ge.codebase);
- assertEquals("s2", ge.signers);
- assertNull(ge.principals);
-
- ge = scanner.readGrantEntry(getST("signedby \"s2\",signedby \"s3\" "
- + " codebase \"u2\",codebase \"u3\";"));
- assertEquals("u3", ge.codebase);
- assertEquals("s3", ge.signers);
- assertNull(ge.principals);
-
- ge = scanner.readGrantEntry(getST("principal \"a1\" signedby \"s4\" "
- + "principal \"a2\", codebase \"u4\";"));
- assertEquals("u4", ge.codebase);
- assertEquals("s4", ge.signers);
- assertNotNull(ge.principals);
- assertEquals(2, ge.principals.size());
-
- ge = scanner.readGrantEntry(getST("principal * *, principal bbb \"b2\""
- + ", principal ccc \"c2\" codebase \"u5\";"));
- assertEquals("u5", ge.codebase);
- assertNull(ge.signers);
- assertNotNull(ge.principals);
- assertEquals(3, ge.principals.size());
-
- ge = scanner.readGrantEntry(getST("principal * *"
- + ", signedby \"s6\";"));
- assertNull(ge.codebase);
- assertEquals("s6", ge.signers);
- assertNotNull(ge.principals);
- assertEquals(1, ge.principals.size());
- }
-
- /**
- * Tests that readGrantEntry() throws InvalidFormatException on invalid
- * input
- */
- public void testReadGrantEntry_Invalid() throws Exception {
- try {
- scanner.readGrantEntry(getST("codebase"));
- fail("InvalidFormatException is not thrown 1");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readGrantEntry(getST("signedby"));
- fail("InvalidFormatException is not thrown 2");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readGrantEntry(getST("signedby *"));
- fail("InvalidFormatException is not thrown 3");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readGrantEntry(getST("codebase file://URL"));
- fail("InvalidFormatException is not thrown 4");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- try {
- scanner.readGrantEntry(getST("codebase \"a2\", signedby \"a2\", "
- + "principal a \"a2\", b \"b2\" "));
- fail("InvalidFormatException is not thrown 5");
- } catch (DefaultPolicyScanner.InvalidFormatException ok) {
-
- }
- }
-
- /**
- * Tests that readGrantEntry() throws IOException if stream fails.
- */
- public void testReadGrantEntry_IOException() throws Exception {
- try {
- scanner.readGrantEntry(getFailingST(""));
- fail("IOException is intercepted");
- } catch (IOException ok) {
- assertEquals(IO_ERROR, ok.getMessage());
- }
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/PolicyEntryTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/PolicyEntryTest.java
deleted file mode 100644
index 2ece08f..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/PolicyEntryTest.java
+++ /dev/null
@@ -1,315 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests;
-
-import java.net.URL;
-import java.security.cert.Certificate;
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.Principal;
-import java.security.SecurityPermission;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-
-import org.apache.harmony.security.PolicyEntry;
-import org.apache.harmony.security.UnresolvedPrincipal;
-import junit.framework.TestCase;
-
-
-/**
- * TODO Put your class description here
- *
- */
-
-public class PolicyEntryTest extends TestCase {
-
- /**
- * Tests constructor and accessors of PolicyEntry
- */
- public void testCtor() {
- PolicyEntry pe = new PolicyEntry(null, null, null);
- assertTrue(pe.isVoid());
- assertNull(pe.getPermissions());
-
- pe = new PolicyEntry(new CodeSource(null, (Certificate[])null),
- new ArrayList(), new ArrayList());
- assertTrue(pe.isVoid());
- assertNull(pe.getPermissions());
-
- Collection perms = Arrays.asList(new Permission[] {
- new SecurityPermission("dsfg"), new AllPermission() });
- pe = new PolicyEntry(null, null, perms);
- assertFalse(pe.isVoid());
- assertEquals(perms, new ArrayList(pe.getPermissions()));
- }
-
- /**
- * Null CodeSource of PolicyEntry implies any CodeSource; non-null
- * CodeSource should delegate to its own imply() functionality
- */
- public void testImpliesCodeSource() throws Exception {
- CodeSource cs0 = new CodeSource(null, (Certificate[]) null);
-
- CodeSource cs10 = new CodeSource(new URL("file:"), (Certificate[]) null);
- CodeSource cs11 = new CodeSource(new URL("file:/"), (Certificate[]) null);
- CodeSource cs12 = new CodeSource(new URL("file://"), (Certificate[]) null);
- CodeSource cs13 = new CodeSource(new URL("file:///"), (Certificate[]) null);
-
- CodeSource cs20 = new CodeSource(new URL("file:*"), (Certificate[]) null);
- CodeSource cs21 = new CodeSource(new URL("file:/*"), (Certificate[]) null);
- CodeSource cs22 = new CodeSource(new URL("file://*"), (Certificate[]) null);
- CodeSource cs23 = new CodeSource(new URL("file:///*"), (Certificate[]) null);
-
- CodeSource cs30 = new CodeSource(new URL("file:-"), (Certificate[]) null);
- CodeSource cs31 = new CodeSource(new URL("file:/-"), (Certificate[]) null);
- CodeSource cs32 = new CodeSource(new URL("file://-"), (Certificate[]) null);
- CodeSource cs33 = new CodeSource(new URL("file:///-"), (Certificate[]) null);
-
- PolicyEntry pe0 = new PolicyEntry(null, null, null);
-
- PolicyEntry pe10 = new PolicyEntry(cs10, null, null);
- PolicyEntry pe11 = new PolicyEntry(cs11, null, null);
- PolicyEntry pe12 = new PolicyEntry(cs12, null, null);
- PolicyEntry pe13 = new PolicyEntry(cs13, null, null);
-
- PolicyEntry pe20 = new PolicyEntry(cs20, null, null);
- PolicyEntry pe21 = new PolicyEntry(cs21, null, null);
- PolicyEntry pe22 = new PolicyEntry(cs22, null, null);
- PolicyEntry pe23 = new PolicyEntry(cs23, null, null);
-
- PolicyEntry pe30 = new PolicyEntry(cs30, null, null);
- PolicyEntry pe31 = new PolicyEntry(cs31, null, null);
- PolicyEntry pe32 = new PolicyEntry(cs32, null, null);
- PolicyEntry pe33 = new PolicyEntry(cs33, null, null);
-
- assertTrue (pe0.impliesCodeSource(null));
- assertTrue (pe0.impliesCodeSource(cs10));
- assertTrue (pe0.impliesCodeSource(cs11));
- assertTrue (pe0.impliesCodeSource(cs12));
- assertTrue (pe0.impliesCodeSource(cs13));
- assertTrue (pe0.impliesCodeSource(cs20));
- assertTrue (pe0.impliesCodeSource(cs21));
- assertTrue (pe0.impliesCodeSource(cs22));
- assertTrue (pe0.impliesCodeSource(cs23));
- assertTrue (pe0.impliesCodeSource(cs30));
- assertTrue (pe0.impliesCodeSource(cs31));
- assertTrue (pe0.impliesCodeSource(cs32));
- assertTrue (pe0.impliesCodeSource(cs33));
-
- assertFalse(pe10.impliesCodeSource(null));
- assertTrue (pe10.impliesCodeSource(cs10));
- assertFalse(pe10.impliesCodeSource(cs11));
- assertTrue (pe10.impliesCodeSource(cs12));
- assertFalse(pe10.impliesCodeSource(cs13));
- assertTrue (pe10.impliesCodeSource(cs20));
- assertFalse(pe10.impliesCodeSource(cs21));
- assertFalse(pe10.impliesCodeSource(cs22));
- assertFalse(pe10.impliesCodeSource(cs23));
- assertTrue (pe10.impliesCodeSource(cs30));
- assertFalse(pe10.impliesCodeSource(cs31));
- assertFalse(pe10.impliesCodeSource(cs32));
- assertFalse(pe10.impliesCodeSource(cs33));
-
- assertFalse(pe11.impliesCodeSource(null));
- assertFalse(pe11.impliesCodeSource(cs10));
- assertTrue (pe11.impliesCodeSource(cs11));
- assertFalse(pe11.impliesCodeSource(cs12));
- assertTrue (pe11.impliesCodeSource(cs13));
- assertFalse(pe11.impliesCodeSource(cs20));
- assertFalse(pe11.impliesCodeSource(cs21));
- assertFalse(pe11.impliesCodeSource(cs22));
- assertFalse(pe11.impliesCodeSource(cs23));
- assertFalse(pe11.impliesCodeSource(cs30));
- assertFalse(pe11.impliesCodeSource(cs31));
- assertFalse(pe11.impliesCodeSource(cs32));
- assertFalse(pe11.impliesCodeSource(cs33));
-
- assertFalse(pe12.impliesCodeSource(null));
- assertTrue (pe12.impliesCodeSource(cs10));
- assertFalse(pe12.impliesCodeSource(cs11));
- assertTrue (pe12.impliesCodeSource(cs12));
- assertFalse(pe12.impliesCodeSource(cs13));
- assertTrue (pe12.impliesCodeSource(cs20));
- assertFalse(pe12.impliesCodeSource(cs21));
- assertFalse(pe12.impliesCodeSource(cs22));
- assertFalse(pe12.impliesCodeSource(cs23));
- assertTrue (pe12.impliesCodeSource(cs30));
- assertFalse(pe12.impliesCodeSource(cs31));
- assertFalse(pe12.impliesCodeSource(cs32));
- assertFalse(pe12.impliesCodeSource(cs33));
-
- assertFalse(pe13.impliesCodeSource(null));
- assertFalse(pe13.impliesCodeSource(cs10));
- assertTrue (pe13.impliesCodeSource(cs11));
- assertFalse(pe13.impliesCodeSource(cs12));
- assertTrue (pe13.impliesCodeSource(cs13));
- assertFalse(pe13.impliesCodeSource(cs20));
- assertFalse(pe13.impliesCodeSource(cs21));
- assertFalse(pe13.impliesCodeSource(cs22));
- assertFalse(pe13.impliesCodeSource(cs23));
- assertFalse(pe13.impliesCodeSource(cs30));
- assertFalse(pe13.impliesCodeSource(cs31));
- assertFalse(pe13.impliesCodeSource(cs32));
- assertFalse(pe13.impliesCodeSource(cs33));
-
- assertFalse(pe20.impliesCodeSource(null));
- assertTrue (pe20.impliesCodeSource(cs10));
- assertFalse(pe20.impliesCodeSource(cs11));
- assertTrue (pe20.impliesCodeSource(cs12));
- assertFalse(pe20.impliesCodeSource(cs13));
- assertTrue (pe20.impliesCodeSource(cs20));
- assertFalse(pe20.impliesCodeSource(cs21));
- assertFalse(pe20.impliesCodeSource(cs22));
- assertFalse(pe20.impliesCodeSource(cs23));
- assertTrue (pe20.impliesCodeSource(cs30));
- assertFalse(pe20.impliesCodeSource(cs31));
- assertFalse(pe20.impliesCodeSource(cs32));
- assertFalse(pe20.impliesCodeSource(cs33));
-
- assertFalse(pe21.impliesCodeSource(null));
- assertFalse(pe21.impliesCodeSource(cs10));
- assertTrue (pe21.impliesCodeSource(cs11));
- assertFalse(pe21.impliesCodeSource(cs12));
- assertTrue (pe21.impliesCodeSource(cs13));
- assertFalse(pe21.impliesCodeSource(cs20));
- assertTrue (pe21.impliesCodeSource(cs21));
- assertFalse(pe21.impliesCodeSource(cs22));
- assertTrue (pe21.impliesCodeSource(cs23));
- assertFalse(pe21.impliesCodeSource(cs30));
- assertTrue (pe21.impliesCodeSource(cs31));
- assertFalse(pe21.impliesCodeSource(cs32));
- assertTrue (pe21.impliesCodeSource(cs33));
-
- assertFalse(pe22.impliesCodeSource(null));
- assertFalse(pe22.impliesCodeSource(cs10));
- // assertFalse(pe22.impliesCodeSource(cs11));
- assertFalse(pe22.impliesCodeSource(cs12));
- // assertFalse(pe22.impliesCodeSource(cs13));
- assertFalse(pe22.impliesCodeSource(cs20));
- assertFalse(pe22.impliesCodeSource(cs21));
- assertTrue (pe22.impliesCodeSource(cs22));
- assertFalse(pe22.impliesCodeSource(cs23));
- assertFalse(pe22.impliesCodeSource(cs30));
- assertFalse(pe22.impliesCodeSource(cs31));
- assertTrue (pe22.impliesCodeSource(cs32));
- assertFalse(pe22.impliesCodeSource(cs33));
-
- assertFalse(pe23.impliesCodeSource(null));
- assertFalse(pe23.impliesCodeSource(cs10));
- assertTrue (pe23.impliesCodeSource(cs11));
- assertFalse(pe23.impliesCodeSource(cs12));
- assertTrue (pe23.impliesCodeSource(cs13));
- assertFalse(pe23.impliesCodeSource(cs20));
- assertTrue (pe23.impliesCodeSource(cs21));
- assertFalse(pe23.impliesCodeSource(cs22));
- assertTrue (pe23.impliesCodeSource(cs23));
- assertFalse(pe23.impliesCodeSource(cs30));
- assertTrue (pe23.impliesCodeSource(cs31));
- assertFalse(pe23.impliesCodeSource(cs32));
- assertTrue (pe23.impliesCodeSource(cs33));
-
- assertFalse(pe30.impliesCodeSource(null));
- assertTrue (pe30.impliesCodeSource(cs10));
- assertFalse(pe30.impliesCodeSource(cs11));
- assertTrue (pe30.impliesCodeSource(cs12));
- assertFalse(pe30.impliesCodeSource(cs13));
- assertTrue (pe30.impliesCodeSource(cs20));
- assertFalse(pe30.impliesCodeSource(cs21));
- assertFalse(pe30.impliesCodeSource(cs22));
- assertFalse(pe30.impliesCodeSource(cs23));
- assertTrue (pe30.impliesCodeSource(cs30));
- assertFalse(pe30.impliesCodeSource(cs31));
- assertFalse(pe30.impliesCodeSource(cs32));
- assertFalse(pe30.impliesCodeSource(cs33));
-
- assertFalse(pe31.impliesCodeSource(null));
- assertTrue (pe31.impliesCodeSource(cs10));
- assertTrue (pe31.impliesCodeSource(cs11));
- assertTrue (pe31.impliesCodeSource(cs12));
- assertTrue (pe31.impliesCodeSource(cs13));
- assertTrue (pe31.impliesCodeSource(cs20));
- assertTrue (pe31.impliesCodeSource(cs21));
- assertFalse(pe31.impliesCodeSource(cs22));
- assertTrue (pe31.impliesCodeSource(cs23));
- assertTrue (pe31.impliesCodeSource(cs30));
- assertTrue (pe31.impliesCodeSource(cs31));
- assertFalse(pe31.impliesCodeSource(cs32));
- assertTrue (pe31.impliesCodeSource(cs33));
-
- assertFalse(pe32.impliesCodeSource(null));
- assertFalse(pe32.impliesCodeSource(cs10));
- assertFalse(pe32.impliesCodeSource(cs11));
- assertFalse(pe32.impliesCodeSource(cs12));
- assertFalse(pe32.impliesCodeSource(cs13));
- assertFalse(pe32.impliesCodeSource(cs20));
- assertFalse(pe32.impliesCodeSource(cs21));
- assertFalse(pe32.impliesCodeSource(cs22));
- assertFalse(pe32.impliesCodeSource(cs23));
- assertFalse(pe32.impliesCodeSource(cs30));
- assertFalse(pe32.impliesCodeSource(cs31));
- assertTrue (pe32.impliesCodeSource(cs32));
- assertFalse(pe32.impliesCodeSource(cs33));
-
- assertFalse(pe33.impliesCodeSource(null));
- assertTrue (pe33.impliesCodeSource(cs10));
- assertTrue (pe33.impliesCodeSource(cs11));
- assertTrue (pe33.impliesCodeSource(cs12));
- assertTrue (pe33.impliesCodeSource(cs13));
- assertTrue (pe33.impliesCodeSource(cs20));
- assertTrue (pe33.impliesCodeSource(cs21));
- assertFalse(pe33.impliesCodeSource(cs22));
- assertTrue (pe33.impliesCodeSource(cs23));
- assertTrue (pe33.impliesCodeSource(cs30));
- assertTrue (pe33.impliesCodeSource(cs31));
- assertFalse(pe33.impliesCodeSource(cs32));
- assertTrue (pe33.impliesCodeSource(cs33));
- }
-
- /**
- * Null or empty set of Principals of PolicyEntry implies any Principals;
- * otherwise tested set must contain all Principals of PolicyEntry.
- */
- public void testImpliesPrincipals() {
- PolicyEntry pe = new PolicyEntry(null, null, null);
- Principal[] pp1 = new Principal[] {};
- Principal[] pp2 = new Principal[] { new UnresolvedPrincipal("a.b.c",
- "XXX") };
- Principal[] pp3 = new Principal[] {
- new UnresolvedPrincipal("a.b.c", "YYY"),
- new UnresolvedPrincipal("a.b.c", "XXX"),
- new UnresolvedPrincipal("e.f.g", "ZZZ") };
-
- assertTrue(pe.impliesPrincipals(null));
- assertTrue(pe.impliesPrincipals(pp1));
-
- pe = new PolicyEntry(null, new HashSet(), null);
- assertTrue(pe.impliesPrincipals(pp3));
-
- pe = new PolicyEntry(null, Arrays.asList(pp2), null);
- assertFalse(pe.impliesPrincipals(null));
- assertFalse(pe.impliesPrincipals(pp1));
- assertTrue(pe.impliesPrincipals(pp3));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java
deleted file mode 100644
index a6e5e01..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyParserTest.java
+++ /dev/null
@@ -1,104 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.fortress;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.Principal;
-import java.security.SecurityPermission;
-import java.security.cert.Certificate;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.harmony.security.PolicyEntry;
-import org.apache.harmony.security.fortress.DefaultPolicyParser;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for DefaultPolicyParser
- *
- */
-
-public class DefaultPolicyParserTest extends TestCase {
-
- /**
- * Tests parsing of a sample policy from temporary file, validates returned
- * PolicyEntries.
- */
- public void testParse() throws Exception {
- File tmp = File.createTempFile("policy", null);
- try {
- FileWriter out = new FileWriter(tmp);
- out.write("grant{}KeyStore \"url2\", \"type2\" "
- + "GRANT signedby \"duke,Li\", codebase\"\", principal a.b.c \"guest\" "
- + "{permission XXX \"YYY\", SignedBy \"ZZZ\" \n \t };;;"
- + "GRANT codebase\"http://a.b.c/-\", principal * * "
- + "{permission java.security.SecurityPermission \"YYY\";}"
- + "GRANT {permission java.security.SecurityPermission \"ZZZ\";}"
- + "GRANT {permission java.security.UnresolvedPermission \"NONE\";}");
- out.flush();
- out.close();
-
- DefaultPolicyParser parser = new DefaultPolicyParser();
- Collection entries = parser.parse(tmp.toURI().toURL(), null);
- assertEquals(2, entries.size());
- for (Iterator iter = entries.iterator(); iter.hasNext();) {
- PolicyEntry element = (PolicyEntry)iter.next();
- if (element.getPermissions()
- .contains(new SecurityPermission("ZZZ"))) {
- assertTrue(element.impliesCodeSource(new CodeSource(null,
- (Certificate[])null)));
- assertTrue(element.impliesPrincipals(null));
- } else if (element.getPermissions()
- .contains(new SecurityPermission("YYY"))) {
- assertFalse(element.impliesCodeSource(null));
- assertFalse(element.impliesPrincipals(null));
- assertTrue(element.impliesCodeSource(new CodeSource(new URL(
- "http://a.b.c/-"), (Certificate[])null)));
- assertTrue(element
- .impliesPrincipals(new Principal[] { new FakePrincipal(
- "qqq") }));
- } else {
- fail("Extra entry parsed");
- }
- }
- } finally {
- tmp.delete();
- }
- }
-}
-
-class FakePrincipal implements Principal {
-
- private String name;
-
- public FakePrincipal(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java
deleted file mode 100644
index 6d230f3..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/DefaultPolicyTest.java
+++ /dev/null
@@ -1,174 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.fortress;
-
-import java.net.URL;
-import java.security.cert.Certificate;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Principal;
-import java.security.ProtectionDomain;
-import java.security.SecurityPermission;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Properties;
-
-import org.apache.harmony.security.PolicyEntry;
-import org.apache.harmony.security.UnresolvedPrincipal;
-import org.apache.harmony.security.fortress.DefaultPolicy;
-import org.apache.harmony.security.fortress.DefaultPolicyParser;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for DefaultPolicy
- *
- */
-public class DefaultPolicyTest extends TestCase {
-
- static class TestParser extends DefaultPolicyParser {
-
- PolicyEntry[] content;
-
- public TestParser(PolicyEntry[] content) {
- this.content = content;
- }
-
- public Collection parse(URL location, Properties system)
- throws Exception {
- if (content != null) {
- return Arrays.asList(content);
- }
- throw new RuntimeException();
- }
- }
-
- /**
- * Tests that policy is really resetted on refresh().
- */
- public void testRefresh() {
- Permission sp = new SecurityPermission("sdf");
- PolicyEntry[] pe = new PolicyEntry[] { new PolicyEntry(null, null,
- Arrays.asList(new Permission[] { sp })) };
- TestParser tp = new TestParser(pe);
- DefaultPolicy policy = new DefaultPolicy(tp);
- CodeSource cs = new CodeSource(null, (Certificate[])null);
- assertTrue(policy.getPermissions(cs).implies(sp));
-
- tp.content = new PolicyEntry[0];
- policy.refresh();
- assertFalse(policy.getPermissions(cs).implies(sp));
-
- tp.content = null;
- policy.refresh();
- assertFalse(policy.getPermissions(cs).implies(sp));
- }
-
- /**
- * Tests that refresh() does not fail on failing parser.
- */
- public void testRefresh_Failure() {
- CodeSource cs = new CodeSource(null, (Certificate[])null);
- DefaultPolicy policy = new DefaultPolicy(new TestParser(null));
- policy.refresh();
- assertFalse(policy.getPermissions(cs).elements().hasMoreElements());
- }
-
- /**
- * Tests proper policy evaluation for CodeSource parameters.
- */
- public void testGetPermissions_CodeSource() throws Exception {
- CodeSource cs = new CodeSource(null, (Certificate[])null);
- CodeSource cs2 = new CodeSource(new URL("http://a.b.c"),
- (Certificate[])null);
- Permission sp1 = new SecurityPermission("aaa");
- Permission sp2 = new SecurityPermission("bbb");
- Permission sp3 = new SecurityPermission("ccc");
- PolicyEntry pe1 = new PolicyEntry(cs, null, Arrays
- .asList(new Permission[] { sp1 }));
- PolicyEntry pe2 = new PolicyEntry(cs2, new HashSet(), Arrays
- .asList(new Permission[] { sp2 }));
- PolicyEntry pe3 = new PolicyEntry(cs, Arrays
- .asList(new Principal[] { new FakePrincipal("qqq") }), Arrays
- .asList(new Permission[] { sp3 }));
- PolicyEntry[] peArray = new PolicyEntry[] {
- pe1, pe2, pe3 };
- DefaultPolicy policy = new DefaultPolicy(new TestParser(peArray));
-
- assertTrue(policy.getPermissions(cs).implies(sp1));
- assertFalse(policy.getPermissions(cs).implies(sp2));
- assertFalse(policy.getPermissions(cs).implies(sp3));
-
- assertTrue(policy.getPermissions(cs2).implies(sp1));
- assertTrue(policy.getPermissions(cs2).implies(sp2));
- assertFalse(policy.getPermissions(cs2).implies(sp3));
- }
-
- /**
- * Tests proper policy evaluation for ProtectionDomain parameters.
- */
- public void testGetPermissions_ProtectionDomain() throws Exception {
- Permission sp1 = new SecurityPermission("aaa");
- Permission sp2 = new SecurityPermission("bbb");
- Permission sp3 = new SecurityPermission("ccc");
- Permission sp4 = new SecurityPermission("ddd");
- Permission spZ = new SecurityPermission("zzz");
- PermissionCollection pcZ = spZ.newPermissionCollection();
- pcZ.add(spZ);
- CodeSource cs = new CodeSource(null, (Certificate[])null);
- CodeSource cs2 = new CodeSource(new URL("http://a.b.c"),
- (Certificate[])null);
- ProtectionDomain pd1 = new ProtectionDomain(cs, null);
- ProtectionDomain pd2 = new ProtectionDomain(cs2, pcZ, null,
- new Principal[] { new FakePrincipal("qqq") });
-
- PolicyEntry pe1 = new PolicyEntry(cs, null, Arrays
- .asList(new Permission[] { sp1 }));
- PolicyEntry pe2 = new PolicyEntry(cs2, Arrays
- .asList(new Principal[] { new UnresolvedPrincipal(
- UnresolvedPrincipal.WILDCARD, UnresolvedPrincipal.WILDCARD) }),
- Arrays.asList(new Permission[] { sp2 }));
- PolicyEntry pe3 = new PolicyEntry(cs, Arrays
- .asList(new Principal[] { new UnresolvedPrincipal(
- FakePrincipal.class.getName(), "qqq") }), Arrays
- .asList(new Permission[] { sp3 }));
- PolicyEntry pe4 = new PolicyEntry(cs2, Arrays
- .asList(new Principal[] { new UnresolvedPrincipal(
- FakePrincipal.class.getName(), "ttt") }), Arrays
- .asList(new Permission[] { sp4 }));
- PolicyEntry[] peArray = new PolicyEntry[] {
- pe1, pe2, pe3, pe4 };
- DefaultPolicy policy = new DefaultPolicy(new TestParser(peArray));
-
- assertTrue(policy.getPermissions(pd1).implies(sp1));
- assertFalse(policy.getPermissions(pd1).implies(sp2));
- assertFalse(policy.getPermissions(pd1).implies(sp3));
- assertFalse(policy.getPermissions(pd1).implies(sp4));
-
- assertTrue(policy.getPermissions(pd2).implies(sp1));
- assertTrue(policy.getPermissions(pd2).implies(sp2));
- assertTrue(policy.getPermissions(pd2).implies(sp3));
- assertFalse(policy.getPermissions(pd2).implies(sp4));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/PolicyUtilsTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/PolicyUtilsTest.java
deleted file mode 100644
index 8208f59..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/fortress/PolicyUtilsTest.java
+++ /dev/null
@@ -1,330 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.fortress;
-
-import java.io.File;
-import java.net.URL;
-import java.security.AllPermission;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Security;
-import java.security.SecurityPermission;
-import java.security.UnresolvedPermission;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Properties;
-
-import org.apache.harmony.security.fortress.PolicyUtils;
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>PolicyUtils</code> class fields and methods.
- *
- */
-
-public class PolicyUtilsTest extends TestCase {
-
- /** Tests valid expansion of ${key} entries. */
- public void testExpand() throws Exception {
- String[] input = new String[] { "${key.1}", "abcd${key.1}",
- "a ${key.1} b ${$key$}${key.2}", "$key.1", "${}" };
- String[] output = new String[] { "value1", "abcdvalue1",
- "a value1 b ${${${${${${value.2", "$key.1", "" };
- Properties props = new Properties();
- props.put("key.1", "value1");
- props.put("key.2", "value.2");
- props.put("$key$", "${${${${${${");
- props.put("", "");
- for (int i = 0; i < output.length; i++) {
- assertEquals(output[i], PolicyUtils.expand(input[i], props));
- }
- }
-
- /** Tests ExpansionFailedException for missing keys of ${key} entries. */
- public void testExpandFailed() throws Exception {
- try {
- PolicyUtils.expand("${key.123}", new Properties());
- fail("Should throw ExpansionFailedException");
- }
- catch (PolicyUtils.ExpansionFailedException ok) {}
- }
-
- /** Tests valid URL-specific expansion. */
- public void testExpandURL() throws Exception {
- String input = "file:/${my.home}" + File.separator + "lib/extensions/";
- Properties props = new Properties();
- String q = File.separator + "drl" + File.separator + "tools1.2";
- props.put("my.home", q);
- assertEquals("file://drl/tools1.2/lib/extensions/", PolicyUtils.expandURL(input,
- props));
- }
-
- /** Tests valid expansion of ${{protocol:data}} entries. */
- public void testExpandGeneral() throws Exception {
- String[] input = new String[] { "${{a:b}}", "a ${{self}}${{a: made}}",
- "${{}}" };
- String[] output = new String[] { "b", "a this made", "" };
- PolicyUtils.GeneralExpansionHandler handler = new PolicyUtils.GeneralExpansionHandler() {
-
- public String resolve(String protocol, String data) {
- if ("a".equals(protocol)) {
- return data;
- }
- if ("self".equals(protocol)) {
- return "this";
- }
- if ("".equals(protocol)) {
- return protocol;
- }
- return null;
- }
- };
- for (int i = 0; i < output.length; i++) {
- assertEquals(output[i], PolicyUtils
- .expandGeneral(input[i], handler));
- }
- }
-
- /**
- * Tests ExpansionFailedException for undefined protocol
- * of ${{protocol:data}} entries.
- */
- public void testExpandGeneralFailed() throws Exception {
- try {
- PolicyUtils.expandGeneral("${{c}}",
- new PolicyUtils.GeneralExpansionHandler() {
-
- public String resolve(String protocol, String data)
- throws PolicyUtils.ExpansionFailedException {
- throw new PolicyUtils.ExpansionFailedException("");
- }
- });
- fail("Should throw ExpansionFailedException");
- }
- catch (PolicyUtils.ExpansionFailedException ok) {}
- }
-
- /**
- * Tests positive/negative/invalid/missing values of
- * &quot;policy.expandProperties&quot; security property.
- */
- public void testCanExpandProperties() {
- final String key = "policy.expandProperties";
- String OLD = Security.getProperty(key);
- try {
- Security.setProperty(key, "true");
- assertTrue(PolicyUtils.canExpandProperties());
- Security.setProperty(key, "false");
- assertFalse(PolicyUtils.canExpandProperties());
- Security.setProperty(key, "");
- assertTrue(PolicyUtils.canExpandProperties());
- Security.setProperty(key, "laejhg");
- assertTrue(PolicyUtils.canExpandProperties());
- }
- finally {
- Security.setProperty(key, OLD);
- }
- }
-
- /**
- * Tests cases of enabled/disabled system URL.
- */
- public void testGetPolicyURLs01() throws Throwable {
- final String KEY_DYNAMIC = "policy.allowSystemProperty";
- String OLD_DYNAMIC = Security.getProperty(KEY_DYNAMIC);
-
- final String KEY = "dsfvdf";
- Properties arg = new Properties();
- arg.put(KEY, "http://foo.bar.com");
- try {
- Security.setProperty(KEY_DYNAMIC, "true");
- URL[] result = PolicyUtils.getPolicyURLs(arg, KEY, "");
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(new URL("http://foo.bar.com"), result[0]);
-
- Security.setProperty(KEY_DYNAMIC, "false");
- result = PolicyUtils.getPolicyURLs(arg, KEY, "");
- assertNotNull(result);
- assertEquals(0, result.length);
-
- Security.setProperty(KEY_DYNAMIC, "");
- result = PolicyUtils.getPolicyURLs(arg, KEY, "");
- assertNotNull(result);
- assertEquals(1, result.length);
- assertEquals(new URL("http://foo.bar.com"), result[0]);
- }
- finally {
- Security.setProperty(KEY_DYNAMIC, OLD_DYNAMIC);
- }
- }
-
- /** Tests finding algorithm for numbered locations in security properties. */
- public void testGetPolicyURLs02() throws Throwable {
- final String PREFIX = "testGetPolicyURLs02.";
- String[] OLD = new String[5];
- for (int i = 0; i < OLD.length; i++) {
- OLD[i] = Security.getProperty(PREFIX + i);
- }
-
- try {
- Security.setProperty(PREFIX + 0, "http://foo0.bar.com");
- Security.setProperty(PREFIX + 1, "http://foo1.bar.com");
- Security.setProperty(PREFIX + 2, "http://foo2.bar.com");
- Security.setProperty(PREFIX + 4, "http://foo4.bar.com");
- URL[] result = PolicyUtils.getPolicyURLs(new Properties(), "",
- PREFIX);
- assertNotNull(result);
- assertEquals(2, result.length);
- assertEquals(new URL("http://foo1.bar.com"), result[0]);
- assertEquals(new URL("http://foo2.bar.com"), result[1]);
-
- Security.setProperty(PREFIX + 1, "slkjdfhk/svfv*&^");
- Security.setProperty(PREFIX + 3, "dlkfjvb3lk5jt");
- result = PolicyUtils.getPolicyURLs(new Properties(), "", PREFIX);
- assertNotNull(result);
- assertEquals(2, result.length);
- assertEquals(new URL("http://foo2.bar.com"), result[0]);
- assertEquals(new URL("http://foo4.bar.com"), result[1]);
- }
- finally {
- for (int i = 0; i < OLD.length; i++) {
- Security
- .setProperty(PREFIX + i, (OLD[i] == null) ? "" : OLD[i]);
- }
- }
- }
-
- /**
- * Tests expansion in system and security URLs.
- */
- public void testGetPolicyURLs03() throws Throwable {
- final String KEY_DYNAMIC = "policy.allowSystemProperty";
- final String OLD_DYNAMIC = Security.getProperty(KEY_DYNAMIC);
- final String KEY_EXP = "policy.expandProperties";
- final String OLD_EXP = Security.getProperty(KEY_EXP);
- final String PREFIX = "testGetPolicyURLs03.";
- String[] OLD = new String[5];
- for (int i = 0; i < OLD.length; i++) {
- OLD[i] = Security.getProperty(PREFIX + i);
- }
-
- final String KEY = "dsfvdf";
- Properties arg = new Properties();
- arg.put(KEY, "file://${foo.path}/${foo.name}");
- arg.put("foo.path", "path");
- arg.put("foo.name", "name");
- arg.put("foo", "acme");
- Security.setProperty(KEY_DYNAMIC, "true");
- Security.setProperty(KEY_EXP, "true");
- Security.setProperty(PREFIX + 1, "http://foo0.${foo}.org");
- Security.setProperty(PREFIX + 2, "http://${bar}.com");
- Security.setProperty(PREFIX + 3,
- "http://foo2.bar.com/${foo.path}/${foo.name}");
- try {
-
- URL[] result = PolicyUtils.getPolicyURLs(arg, KEY, PREFIX);
- assertNotNull(result);
- assertEquals(3, result.length);
- assertEquals(new URL("http://foo0.acme.org"), result[0]);
- assertEquals(new URL("http://foo2.bar.com/path/name"), result[1]);
- assertEquals(new URL("file://path/name"), result[2]);
-
- //expansion here cannot be switched off
- Security.setProperty(KEY_EXP, "false");
- result = PolicyUtils.getPolicyURLs(arg, KEY, PREFIX);
- assertNotNull(result);
- assertEquals(3, result.length);
- assertEquals(new URL("http://foo0.acme.org"), result[0]);
- assertEquals(new URL("http://foo2.bar.com/path/name"), result[1]);
- assertEquals(new URL("file://path/name"), result[2]);
- }
- finally {
- Security.setProperty(KEY_DYNAMIC, OLD_DYNAMIC);
- Security.setProperty(KEY_EXP, OLD_EXP);
- for (int i = 0; i < OLD.length; i++) {
- Security
- .setProperty(PREFIX + i, (OLD[i] == null) ? "" : OLD[i]);
- }
- }
- }
-
- /** Tests conversion of null, empty and non-empty heterogeneous collections. */
- public void testToPermissionCollection() {
- Permission p1 = new SecurityPermission("abc");
- Permission p2 = new AllPermission();
- Collection c1 = Arrays.asList(new Permission[] { p1, p2, });
-
- PermissionCollection pc = PolicyUtils.toPermissionCollection(null);
- assertNotNull(pc);
- assertFalse(pc.elements().hasMoreElements());
-
- pc = PolicyUtils.toPermissionCollection(new HashSet());
- assertNotNull(pc);
- assertFalse(pc.elements().hasMoreElements());
-
- pc = PolicyUtils.toPermissionCollection(c1);
- assertNotNull(pc);
- Enumeration en = pc.elements();
- Collection c2 = new HashSet();
- c2.add(en.nextElement());
- c2.add(en.nextElement());
- assertFalse(en.hasMoreElements());
- assertTrue(c2.contains(p1));
- assertTrue(c2.contains(p2));
- }
-
- public void testInstantiatePermission() throws Throwable {
- String name = "abc";
- Permission expected = new SecurityPermission(name);
- //test valid input
- assertEquals(expected, PolicyUtils.instantiatePermission(SecurityPermission.class, name, null));
- assertEquals(expected, PolicyUtils.instantiatePermission(SecurityPermission.class, name, "4t46"));
-
- //test invalid class
- try {
- PolicyUtils.instantiatePermission(UnresolvedPermission.class, null, null);
- fail("IllegalArgumentException expected on invalid class argument");
- } catch (IllegalArgumentException ok) {}
- }
-
- /**
- * Tests various combinations of arrays:
- * null/empty/containing null/containing real objects.
- */
- public void testMatchSubset() {
- assertTrue(PolicyUtils.matchSubset(null, null));
- assertTrue(PolicyUtils.matchSubset(new Object[] {}, null));
- assertTrue(PolicyUtils.matchSubset(new Object[] { null }, null));
- assertTrue(PolicyUtils.matchSubset(new Object[] {},
- new Object[] { null }));
- assertTrue(PolicyUtils.matchSubset(new Object[] { "1", "2" },
- new Object[] { "3", "2", "1" }));
- assertTrue(PolicyUtils.matchSubset(new Object[] { "1", null },
- new Object[] { "3", "2", "1" }));
- assertFalse(PolicyUtils.matchSubset(new Object[] { "1", null },
- new Object[] { "3", "2", }));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java
deleted file mode 100644
index bef756b..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/CodeSource_ImplTest.java
+++ /dev/null
@@ -1,222 +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.
- */
-
-/**
-* @author Alexander V. Astapchuk
-*/
-
-package org.apache.harmony.security.tests.java.security;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.security.CodeSigner;
-import java.security.CodeSource;
-import java.security.Provider;
-import java.security.Security;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.tests.support.TestCertUtils;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for CodeSource.
- *
- */
-
-public class CodeSource_ImplTest extends TestCase {
-
- /* Below are various URLs used during the testing */
- private static URL urlSite;
-
- static {
- try {
- String siteName = "www.intel.com";
- urlSite = new URL("http://"+siteName+"");
- } catch (MalformedURLException ex) {
- throw new Error(ex);
- }
- }
-
- /**
- * Test for equals(Object)<br>
- * The signer certificate may contain nulls, and equals() must not fail with NPE
- */
- public void testEqualsObject_03() {
- Certificate cert0 = new TestCertUtils.TestCertificate();
- Certificate[] certs0 = new Certificate[] { cert0, null };
- Certificate[] certs1 = new Certificate[] { null, cert0 };
- CodeSource thiz = new CodeSource(urlSite, certs0);
- CodeSource that = new CodeSource(urlSite, certs1);
- assertTrue(thiz.equals(that));
- }
-
- /**
- * Test for equals(Object)<br>
- * Checks that both 'null' and not-null certs are taken into account - properly.
- */
- public void testEqualsObject_05() {
- Certificate cert0 = new TestCertUtils.TestCertificate("cert0");
- Certificate cert1 = new TestCertUtils.TestCertificate("cert1");
- Certificate cert2 = new TestCertUtils.TestCertificate("cert2");
-
- Certificate[] smallSet = new Certificate[] { cert0, cert1 };
- Certificate[] bigSet = new Certificate[] { cert0, cert1, cert2 };
-
- CodeSource thiz = new CodeSource(urlSite, smallSet);
- CodeSource that = new CodeSource(urlSite, (Certificate[]) null);
- assertFalse(thiz.equals(that));
-
- that = new CodeSource(urlSite, bigSet);
- assertFalse(thiz.equals(that));
-
- thiz = new CodeSource(urlSite, bigSet);
- that = new CodeSource(urlSite, smallSet);
- assertFalse(thiz.equals(that));
-
- thiz = new CodeSource(urlSite, (Certificate[]) null);
- that = new CodeSource(urlSite, /*any set*/smallSet);
- assertFalse(thiz.equals(that));
- assertFalse(that.equals(thiz));
- }
-
- /**
- * getCodeSigners() must not take into account non-X509 certificates.
- */
- public void testGetCodeSigners_01() {
- Certificate[] certs = { new TestCertUtils.TestCertificate("00") };
- CodeSource cs = new CodeSource(null, certs);
- assertNull(cs.getCodeSigners());
- }
-
- /**
- * getCodeSigners() must return null if no X509 factory available
- */
- public void testGetCodeSigners_02() {
- ArrayList al = new ArrayList();
- boolean noMoreFactories = false;
- try {
- // remove all providers for x509
- // 'for' loop here for the sake of avoiding endless loop - well, just
- // in case if something is wrong with add/remove machinery.
- // '100' seems reasonable big to remove all necessary providers
- // ...
- for (int i = 0; i < 100; i++) {
- try {
- CertificateFactory f = CertificateFactory
- .getInstance("X.509");
- al.add(f.getProvider());
- Security.removeProvider(f.getProvider().getName());
- } catch (CertificateException ex) {
- noMoreFactories = true;
- break;
- }
- }
- if (!noMoreFactories) {
- throw new Error(
- "Unable to setup test: too many providers provide X.509");
- }
- Certificate[] certs = new Certificate[] { TestCertUtils.rootCA };
- CodeSource cs = new CodeSource(null, certs);
- assertNull(cs.getCodeSigners());
- } finally {
- // .. and restore providers back - to avoid affecting following tests
- for (int i = 0; i < al.size(); i++) {
- Security.addProvider((Provider) al.get(i));
- }
- }
-
- }
-
- /**
- * getCodeSigners() must return an array of CodeSigners. Just make sure
- * the array looks healthy.
- */
- public void testGetCodeSigners_03() {
- TestCertUtils.install_test_x509_factory();
- try {
- X500Principal[] ps = TestCertUtils.UniGen.genX500s(3);
-
- // 2-certs chain
- X509Certificate rootCA = TestCertUtils.rootCA;
- X509Certificate c0 = new TestCertUtils.TestX509Certificate(ps[0],
- rootCA.getIssuerX500Principal());
- //
- X509Certificate c1 = new TestCertUtils.TestX509Certificate(ps[1],
- ps[1]);
- X509Certificate c2 = new TestCertUtils.TestX509Certificate(ps[2],
- ps[2]);
-
- java.security.cert.Certificate [] certs = new java.security.cert.Certificate[] {
- c0, rootCA, c1, c2 };
- CodeSource cs = new CodeSource(null, certs);
- CodeSigner[] signers = cs.getCodeSigners();
-
- // must get exactly 3 CodeSigner-s: one for the chain, and one
- // for each of single certs
- assertEquals(3, signers.length);
- } finally {
- TestCertUtils.uninstall_test_x509_factory();
- }
- }
-
- /**
- * getCodeSigners(). Make sure, that CertException is handled properly
- */
- public void testGetCodeSigners_04() {
- try {
- TestCertUtils.install_test_x509_factory();
- X500Principal[] ps = TestCertUtils.UniGen.genX500s(1);
-
- // 2-certs chain
- X509Certificate rootCA = TestCertUtils.rootCA;
- X509Certificate c0 = new TestCertUtils.TestInvalidX509Certificate(
- ps[0], rootCA.getIssuerX500Principal());
- java.security.cert.Certificate [] certs = new java.security.cert.Certificate[] {
- c0, rootCA };
-
- CodeSource cs = new CodeSource(null, certs);
- CodeSigner[] signers = cs.getCodeSigners();
-
- assertNull(signers);
-
- // Must force a check for 'factory==null'
- cs.getCodeSigners();
- } finally {
- TestCertUtils.uninstall_test_x509_factory();
- }
- }
-
-
- /**
- * @tests java.security.CodeSource#toString()
- */
- public void test_toString() throws Exception {
- // Test for method java.lang.String java.security.CodeSource.toString()
- CodeSource cs = new CodeSource(new java.net.URL("file:///test"),
- (Certificate[]) null);
- assertEquals("toString did not return expected value.",
- "CodeSource, url=file:/test, <no certificates>", cs.toString());
- }
-
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java
deleted file mode 100644
index 819bb25..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/PermissionCollection_ImplTest.java
+++ /dev/null
@@ -1,75 +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.java.security;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>PermissionCollection</code>
- */
-public class PermissionCollection_ImplTest extends TestCase {
- // Bare extension to instantiate abstract PermissionCollection class
- private static final class RealPermissionCollection extends
- PermissionCollection {
- final private Collection col;
-
- public RealPermissionCollection(Collection<Permission> col) {
- this.col = col;
- }
-
- public void add(Permission permission) {
- }
-
- public Enumeration<Permission> elements() {
- return col == null ? null : Collections.enumeration(col);
- }
-
- public boolean implies(Permission permission) {
- return false;
- }
- }
-
- /** Test toString() transformation with different elements. */
- public void testToString() {
- // no elements
- PermissionCollection pc = new RealPermissionCollection(null);
- try {
- assertNotNull("No elements", pc.toString());
- } catch (NullPointerException e) {
- // Allowed
- }
-
- // several elements
- List<Permission> bpList = new ArrayList<Permission>();
- bpList.add(new RuntimePermission("aaa"));
- bpList.add(new RuntimePermission("bbb"));
- bpList.add(new RuntimePermission("ccc"));
- String pcString = new RealPermissionCollection(bpList).toString();
- assertTrue("Failed to find aaa", pcString.contains("aaa"));
- assertTrue("Failed to find bbb", pcString.contains("bbb"));
- assertTrue("Failed to find ccc", pcString.contains("ccc"));
- }
-}
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Permissions_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Permissions_ImplTest.java
deleted file mode 100644
index ebab944..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Permissions_ImplTest.java
+++ /dev/null
@@ -1,98 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.AllPermission;
-import java.security.BasicPermission;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.SecurityPermission;
-import java.security.UnresolvedPermission;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Permissions</code>
- *
- */
-
-public class Permissions_ImplTest extends TestCase {
-
- /**
- * A permission is implied by this collection, if either of the following is
- * true:
- * <ul>
- * <li>This collection contains AllPermission;
- * <li>This collection has elements of the same type as the permission
- * being checked, and they imply it;
- * <li>This collection has UnresolvedPermissions which can be resolved to
- * the checked type, and after resolving they imply the checked one.
- * </ul>
- * The only exception is UnresolvedPermission itself, which is effectively
- * implied only by AllPermission
- */
- public void testImplies() {
- Permissions ps = new Permissions();
- Permission ap = new AllPermission();
- Permission bp1 = new BasicPermission("jhb23jhg5") {
- };
- Permission bp2 = new BasicPermission("&%#&^$HJVH") {
-
- public PermissionCollection newPermissionCollection() {
- return null;
- }
- };
- Permission sp1 = new SecurityPermission("a.b.c");
- Permission sp2 = new SecurityPermission("a.b.*");
- Permission sp3 = new SecurityPermission("a.*");
- Permission up = new UnresolvedPermission(
- "java.security.SecurityPermission", "*", null, null);
-
- Permission[] arr = new Permission[] {
- ap, bp1, bp2, sp1, sp2, up };
- for (int i = 0; i < arr.length; i++) {
- assertFalse(ps.implies(arr[i]));
- }
-
- ps.add(bp1);
- assertTrue(ps.implies(bp1));
- assertFalse(ps.implies(bp2));
- assertFalse(ps.implies(ap));
- assertFalse(ps.implies(sp1));
-
- ps.add(sp2);
- assertTrue(ps.implies(sp1));
- assertTrue(ps.implies(sp2));
- assertFalse(ps.implies(sp3));
-
- ps.add(up);
- assertFalse(ps.implies(up));
- assertTrue(ps.implies(sp1));
- assertTrue(ps.implies(sp2));
- assertTrue(ps.implies(sp3));
-
- ps.add(ap);
- for (int i = 0; i < arr.length; i++) {
- assertTrue(ps.implies(arr[i]));
- }
- }
- }
diff --git a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Policy_ImplTest.java b/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Policy_ImplTest.java
deleted file mode 100644
index 9152658..0000000
--- a/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/Policy_ImplTest.java
+++ /dev/null
@@ -1,108 +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.
- */
-
-/**
-* @author Alexey V. Varlamov
-*/
-
-package org.apache.harmony.security.tests.java.security;
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.PermissionCollection;
-import java.security.Policy;
-import java.security.ProtectionDomain;
-import java.security.Security;
-import java.security.SecurityPermission;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>Policy</code>
- *
- */
-
-public class Policy_ImplTest extends TestCase {
-
- public static class TestProvider extends Policy {
-
- PermissionCollection pc;
-
- public PermissionCollection getPermissions(CodeSource cs) {
- return pc;
- }
-
- public void refresh() {
- }
- }
-
- /**
- * Tests loading of a default provider, both valid and invalid class
- * references.
- */
- public void testGetPolicy_LoadDefaultProvider() {
- Policy oldPolicy = Policy.getPolicy();
- String POLICY_PROVIDER = "policy.provider";
- String oldProvider = Security.getProperty(POLICY_PROVIDER);
- try {
- Security.setProperty(POLICY_PROVIDER, TestProvider.class.getName());
- Policy.setPolicy(null);
- Policy p = Policy.getPolicy();
- assertNotNull(p);
- assertEquals(TestProvider.class.getName(), p.getClass().getName());
-
- Security.setProperty(POLICY_PROVIDER, "a.b.c.D");
- Policy.setPolicy(null);
- p = Policy.getPolicy();
- assertNotNull(p);
- //exact type of default provider does not matter
- //assertEquals(DefaultPolicy.class.getName(), p.getClass().getName());
- } finally {
- Security.setProperty(POLICY_PROVIDER, (oldProvider == null) ? ""
- : oldProvider);
- Policy.setPolicy(oldPolicy);
- }
- }
-
- /**
- * Tests that implies() does proper permission evaluation.
- */
- public void testImplies() {
- TestProvider policy = new TestProvider();
- SecurityPermission sp = new SecurityPermission("abc");
- policy.pc = sp.newPermissionCollection();
-
- policy.pc.add(sp);
- assertTrue(policy.implies(new ProtectionDomain(null, null), sp));
- assertFalse(policy.implies(null, sp));
- assertFalse(policy.implies(new ProtectionDomain(null, null), null));
-
- //RI throws NullPointerException.
- try {
- policy.implies(null, null);
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected.
- }
-
-
- ProtectionDomain pd = new ProtectionDomain(null, policy.pc);
- policy.pc = null;
- assertTrue(policy.implies(pd, sp));
- assertFalse(policy.implies(pd, new AllPermission()));
- }
-
-}
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser
deleted file mode 100644
index 931ee3f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/UnresolvedPermissionTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.0.ser
deleted file mode 100644
index 007acc5..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.1.ser
deleted file mode 100644
index a0b8ae6..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionCollectionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.golden.0.ser
deleted file mode 100644
index d90f72b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/AllPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.0.ser
deleted file mode 100644
index 5f21eaa..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.1.ser
deleted file mode 100644
index aed9511..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.2.ser
deleted file mode 100644
index 3fcf4fb..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionCollectionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.golden.0.ser
deleted file mode 100644
index e88e219..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/BasicPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.0.ser
deleted file mode 100644
index b2c234e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.1.ser
deleted file mode 100644
index b2c234e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.2.ser
deleted file mode 100644
index 57aee66..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.3.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.3.ser
deleted file mode 100644
index 835c40b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/CodeSourceTest.golden.3.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.0.ser
deleted file mode 100644
index 99fcd97..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.1.ser
deleted file mode 100644
index ab3f9e1..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionCollectionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.0.ser
deleted file mode 100644
index c474702..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.1.ser
deleted file mode 100644
index 9e6af9e..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.0.ser
deleted file mode 100644
index d4ef01b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.1.ser
deleted file mode 100644
index 3c5eebb..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/PermissionsTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.0.ser
deleted file mode 100644
index 670944f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.1.ser
deleted file mode 100644
index 69242a9..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/SecurityPermissionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.0.ser
deleted file mode 100644
index 2a47e5b..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.1.ser
deleted file mode 100644
index 7accff2..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.2.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.2.ser
deleted file mode 100644
index cb09f46..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionCollectionTest.golden.2.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.0.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.0.ser
deleted file mode 100644
index 9ea31ee..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.0.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.1.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.1.ser
deleted file mode 100644
index 2be5b71..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.1.ser
+++ /dev/null
Binary files differ
diff --git a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser b/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser
deleted file mode 100644
index 2937f2f..0000000
--- a/security/src/test/resources/serialization/org/apache/harmony/security/tests/java/security/serialization/UnresolvedPermissionTest.golden.ser
+++ /dev/null
Binary files differ
diff --git a/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java b/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java
deleted file mode 100644
index ed5edbc..0000000
--- a/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLPermissionTest.java
+++ /dev/null
@@ -1,73 +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.sql.tests.java.sql;
-
-import java.sql.SQLPermission;
-
-import junit.framework.TestCase;
-
-/**
- * JUnit Testcase for the java.sql.SQLPermission class
- *
- * Note that the SQLPermission class only defines 2 constructors and all other
- * methods are inherited. This testcase explicitly tets the constructors but
- * also implicitly tests some of the inherited query methods.
- *
- */
-
-public class SQLPermissionTest extends TestCase {
-
- /*
- * Constructor test
- */
- public void testSQLPermissionStringString() {
- String validName = "setLog";
- String validActions = "theActions";
-
- SQLPermission thePermission = new SQLPermission(validName, validActions);
-
- assertNotNull(thePermission);
- assertEquals(validName, thePermission.getName());
- // System.out.println("The actions: " + thePermission.getActions() + "."
- // );
- assertEquals("", thePermission.getActions());
- } // end method testSQLPermissionStringString
-
- /*
- * Constructor test
- */
- public void testSQLPermissionString() {
- String validName = "setLog";
-
- SQLPermission thePermission = new SQLPermission(validName);
-
- assertNotNull(thePermission);
- assertEquals(validName, thePermission.getName());
-
- // Set an invalid name ...
- String invalidName = "foo";
-
- thePermission = new SQLPermission(invalidName);
-
- assertNotNull(thePermission);
- assertEquals(invalidName, thePermission.getName());
- assertEquals("", thePermission.getActions());
- } // end method testSQLPermissionString
-
-} // end class SQLPermissionTest
-
diff --git a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPermissionTest.java b/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPermissionTest.java
deleted file mode 100644
index a42785b..0000000
--- a/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLPermissionTest.java
+++ /dev/null
@@ -1,43 +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.xnet.tests.javax.net.ssl;
-
-import javax.net.ssl.SSLPermission;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for <code>SSLPermission</code> class constructors.
- *
- */
-public class SSLPermissionTest extends TestCase {
-
- /*
- * Class under test for void SSLPermission(String)
- */
- public void testSSLPermissionString() {
- new SSLPermission("name");
- }
-
- /*
- * Class under test for void SSLPermission(String, String)
- */
- public void testSSLPermissionStringString() {
- new SSLPermission("name", "action");
- }
-}