summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2010-10-29 18:29:04 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-29 18:29:04 -0700
commit9103cc15655ac1b6ec1a9f3af12f57df47ca0073 (patch)
tree3622a42f5a70c0138a397f18800408d271bb47f5
parent93e0cbb1c2d34f5ba3af704f4f62dd3fe1a73b1d (diff)
parent47d9451154a9eed03ae5d51b384547a292cc6759 (diff)
downloadlibcore-9103cc15655ac1b6ec1a9f3af12f57df47ca0073.zip
libcore-9103cc15655ac1b6ec1a9f3af12f57df47ca0073.tar.gz
libcore-9103cc15655ac1b6ec1a9f3af12f57df47ca0073.tar.bz2
am 47d94511: am 95d52b3b: Remove a pointless test, which just tested a test support class.
* commit '47d9451154a9eed03ae5d51b384547a292cc6759': Remove a pointless test, which just tested a test support class.
-rw-r--r--luni/src/test/java/tests/security/cert/AllTests.java1
-rw-r--r--luni/src/test/java/tests/security/cert/PolicyNodeTest.java292
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/cert/PolicyNodeImpl.java256
3 files changed, 0 insertions, 549 deletions
diff --git a/luni/src/test/java/tests/security/cert/AllTests.java b/luni/src/test/java/tests/security/cert/AllTests.java
index 56acc26..5c0af64 100644
--- a/luni/src/test/java/tests/security/cert/AllTests.java
+++ b/luni/src/test/java/tests/security/cert/AllTests.java
@@ -74,7 +74,6 @@ public class AllTests {
// Crashes on RI.
// suite.addTestSuite(X509CertSelectorTest.class);
suite.addTestSuite(X509Certificate2Test.class);
- suite.addTestSuite(PolicyNodeTest.class);
// $JUnit-END$
return suite;
diff --git a/luni/src/test/java/tests/security/cert/PolicyNodeTest.java b/luni/src/test/java/tests/security/cert/PolicyNodeTest.java
deleted file mode 100644
index 9756c18..0000000
--- a/luni/src/test/java/tests/security/cert/PolicyNodeTest.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tests.security.cert;
-
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargetClass;
-
-import junit.framework.TestCase;
-
-import java.security.cert.PolicyNode;
-import java.security.cert.PolicyQualifierInfo;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.Iterator;
-
-import org.apache.harmony.security.tests.support.cert.PolicyNodeImpl;
-
-/**
- * Tests for <code>java.security.cert.PolicyNode</code> fields and methods
- *
- */
-@TestTargetClass(PolicyNode.class)
-public class PolicyNodeTest extends TestCase {
-
- private String validPolicy = "ValidPolicy";
- private String anyPolicy = "2.5.29.32.0";
- private boolean criticalityIndicator = true;
- private HashSet hs = null;
-
- /**
- * Returns valid DER encoding for the following ASN.1 definition
- * (as specified in RFC 3280 -
- * Internet X.509 Public Key Infrastructure.
- * Certificate and Certificate Revocation List (CRL) Profile.
- * http://www.ietf.org/rfc/rfc3280.txt):
- *
- * PolicyQualifierInfo ::= SEQUENCE {
- * policyQualifierId PolicyQualifierId,
- * qualifier ANY DEFINED BY policyQualifierId
- * }
- *
- * where policyQualifierId (OID) is
- * 1.3.6.1.5.5.7.2.1
- * and qualifier (IA5String) is
- * "http://www.qq.com/stmt.txt"
- *
- * (data generated by own encoder during test development)
- */
- private static final byte[] getDerEncoding() {
- // DO NOT MODIFY!
- return new byte[] {
- (byte)0x30, (byte)0x26, // tag Seq, length
- (byte)0x06, (byte)0x08, // tag OID, length
- (byte)0x2b, (byte)0x06, (byte)0x01, (byte)0x05, // oid value
- (byte)0x05, (byte)0x07, (byte)0x02, (byte)0x01, // oid value
- (byte)0x16, (byte)0x1a, // tag IA5String, length
- (byte)0x68, (byte)0x74, (byte)0x74, (byte)0x70, // IA5String value
- (byte)0x3a, (byte)0x2f, (byte)0x2f, (byte)0x77, // IA5String value
- (byte)0x77, (byte)0x77, (byte)0x2e, (byte)0x71, // IA5String value
- (byte)0x71, (byte)0x2e, (byte)0x63, (byte)0x6f, // IA5String value
- (byte)0x6d, (byte)0x2f, (byte)0x73, (byte)0x74, // IA5String value
- (byte)0x6d, (byte)0x74, (byte)0x2e, (byte)0x74, // IA5String value
- (byte)0x78, (byte)0x74 // IA5String value
- };
- }
-
- protected void setUp() {
- hs = new HashSet();
- hs.add(new String("StringParameter1"));
- hs.add(new String("StringParameter2"));
- hs.add(new String("StringParameter3"));
- }
-
- protected void setUp1() {
- hs = new HashSet();
- try {
- hs.add(new PolicyQualifierInfo(getDerEncoding()));
- } catch (Exception e) {
- fail("Ezxception " + e + " for setUp1()");
- }
- }
-
-
- class MyPolicyNode extends PolicyNodeImpl {
- MyPolicyNode(PolicyNodeImpl policynode, String s, Set set,
- boolean flag, Set set1, boolean flag1) {
- super(policynode, s, set, flag, set1, flag1);
- }
- }
-
- //
- // Tests
- //
-
- /**
- * @tests java.security.cert.PolicyNode#getDepth()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getDepth",
- args = {}
- )
- public final void test_getDepth() {
- MyPolicyNode pn = new MyPolicyNode(null, validPolicy, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn.getDepth(), 0);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- MyPolicyNode pn1 = new MyPolicyNode(pn, validPolicy, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn1.getDepth(), 1);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-
- /**
- * @tests java.security.cert.PolicyNode#getValidPolicy()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getValidPolicy",
- args = {}
- )
- public final void test_getValidPolicy() {
- MyPolicyNode pn = new MyPolicyNode(null, null, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn.getValidPolicy(), "");
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- pn = new MyPolicyNode(pn, validPolicy, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn.getValidPolicy(), "ValidPolicy");
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- pn = new MyPolicyNode(pn, anyPolicy, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn.getValidPolicy(), "2.5.29.32.0");
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-
- /**
- * @tests java.security.cert.PolicyNode#isCritical()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "isCritical",
- args = {}
- )
- public final void test_isCritical() {
- MyPolicyNode pn = new MyPolicyNode(null, anyPolicy, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn.isCritical(), true);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- criticalityIndicator = false;
- pn = new MyPolicyNode(null, validPolicy, null, criticalityIndicator, null, true);
- try {
- assertEquals(pn.isCritical(), false);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-
- /**
- * @tests java.security.cert.PolicyNode#getParent()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getParent",
- args = {}
- )
- public final void test_getParent() {
- MyPolicyNode pn = new MyPolicyNode(null, anyPolicy, null, criticalityIndicator, null, true);
- try {
- assertNull(pn.getParent());
- assertEquals(pn.getDepth(), 0);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- MyPolicyNode pn1 = new MyPolicyNode(pn, anyPolicy, null, criticalityIndicator, null, true);
- try {
- PolicyNode newPN = pn1.getParent();
- assertEquals(newPN.getDepth(), 0);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- MyPolicyNode pn2 = new MyPolicyNode(pn1, anyPolicy, null, criticalityIndicator, null, true);
- try {
- PolicyNode newPN = pn2.getParent();
- assertEquals(newPN.getDepth(), 1);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-
- /**
- * @tests java.security.cert.PolicyNode#getExpectedPolicies()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getExpectedPolicies",
- args = {}
- )
- public final void test_getExpectedPolicies() {
- setUp();
- MyPolicyNode pn = new MyPolicyNode(null, anyPolicy, null, criticalityIndicator, hs, true);
- try {
- Set res = pn.getExpectedPolicies();
- assertEquals(res.size(), hs.size());
- assertEquals(res, hs);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-
- /**
- * @tests java.security.cert.PolicyNode#getPolicyQualifiers()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getPolicyQualifiers",
- args = {}
- )
- public final void test_getPolicyQualifiers() {
- setUp1();
- MyPolicyNode pn = new MyPolicyNode(null, anyPolicy, hs, criticalityIndicator, null, true);
- try {
- Set res = pn.getPolicyQualifiers();
- assertEquals(res.size(), hs.size());
- assertEquals(res, hs);
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-
- /**
- * @tests java.security.cert.PolicyNode#getChildren()
- */
- @TestTargetNew(
- level = TestLevel.COMPLETE,
- notes = "",
- method = "getChildren",
- args = {}
- )
- public final void test_getChildren() {
- MyPolicyNode pn = new MyPolicyNode(null, anyPolicy, null, criticalityIndicator, null, true);
- Iterator it = pn.getChildren();
- try {
- it.remove();
- fail("UnsupportedOperationException was not thrown");
- } catch (UnsupportedOperationException uoe) {
- //expected
- }
- MyPolicyNode pn1 = new MyPolicyNode(pn, anyPolicy, null, criticalityIndicator, null, true);
- try {
- it = pn1.getChildren();
- assertFalse(it.hasNext());
- } catch (Exception e) {
- fail("Unexpected exception: " + e);
- }
- }
-} \ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/cert/PolicyNodeImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/cert/PolicyNodeImpl.java
deleted file mode 100644
index cfe2a43..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/cert/PolicyNodeImpl.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.harmony.security.tests.support.cert;
-
-import java.security.cert.PolicyNode;
-import java.util.*;
-
-public class PolicyNodeImpl implements PolicyNode {
-
- private static final String ANY_POLICY = "2.5.29.32.0";
- private PolicyNodeImpl mParent;
- private HashSet mChildren;
- private String mValidPolicy;
- private HashSet mQualifierSet;
- private boolean mCriticalityIndicator;
- private HashSet mExpectedPolicySet;
- private boolean mOriginalExpectedPolicySet;
- private int mDepth;
- private boolean isImmutable;
-
- public PolicyNodeImpl(PolicyNodeImpl policynodeimpl, String s, Set set,
- boolean flag, Set set1, boolean flag1) {
- isImmutable = false;
- mParent = policynodeimpl;
- mChildren = new HashSet();
- if(s != null) {
- mValidPolicy = s;
- } else {
- mValidPolicy = "";
- }
- if(set != null) {
- mQualifierSet = new HashSet(set);
- } else {
- mQualifierSet = new HashSet();
- }
- mCriticalityIndicator = flag;
- if(set1 != null) {
- mExpectedPolicySet = new HashSet(set1);
- } else {
- mExpectedPolicySet = new HashSet();
- }
- mOriginalExpectedPolicySet = !flag1;
- if(mParent != null) {
- mDepth = mParent.getDepth() + 1;
- mParent.addChild(this);
- } else {
- mDepth = 0;
- }
- }
-
- PolicyNodeImpl(PolicyNodeImpl policynodeimpl,
- PolicyNodeImpl policynodeimpl1) {
- this(policynodeimpl, policynodeimpl1.mValidPolicy, ((Set) (policynodeimpl1.mQualifierSet)), policynodeimpl1.mCriticalityIndicator, ((Set) (policynodeimpl1.mExpectedPolicySet)), false);
- }
-
- public PolicyNode getParent() {
- return mParent;
- }
-
- public Iterator getChildren() {
- return Collections.unmodifiableSet(mChildren).iterator();
- }
-
- public int getDepth() {
- return mDepth;
- }
-
- public String getValidPolicy() {
- return mValidPolicy;
- }
-
- public Set getPolicyQualifiers() {
- return Collections.unmodifiableSet(mQualifierSet);
- }
-
- public Set getExpectedPolicies() {
- return Collections.unmodifiableSet(mExpectedPolicySet);
- }
-
- public boolean isCritical() {
- return mCriticalityIndicator;
- }
-
- public String toString() {
- StringBuffer stringbuffer = new StringBuffer(asString());
- for(Iterator iterator = getChildren(); iterator.hasNext(); stringbuffer.append((PolicyNodeImpl)iterator.next()));
- return stringbuffer.toString();
- }
-
- boolean isImmutable() {
- return isImmutable;
- }
-
- void setImmutable() {
- if(isImmutable) return;
- PolicyNodeImpl policynodeimpl;
- for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.setImmutable())
- policynodeimpl = (PolicyNodeImpl)iterator.next();
-
- isImmutable = true;
- }
-
- private void addChild(PolicyNodeImpl policynodeimpl) {
- if(isImmutable) {
- throw new IllegalStateException("PolicyNode is immutable");
- } else {
- mChildren.add(policynodeimpl);
- return;
- }
- }
-
- void addExpectedPolicy(String s) {
- if(isImmutable)
- throw new IllegalStateException("PolicyNode is immutable");
- if(mOriginalExpectedPolicySet) {
- mExpectedPolicySet.clear();
- mOriginalExpectedPolicySet = false;
- }
- mExpectedPolicySet.add(s);
- }
-
- void prune(int i) {
- if(isImmutable)
- throw new IllegalStateException("PolicyNode is immutable");
- if(mChildren.size() == 0)
- return;
- Iterator iterator = mChildren.iterator();
- do {
- if(!iterator.hasNext()) break;
- PolicyNodeImpl policynodeimpl = (PolicyNodeImpl)iterator.next();
- policynodeimpl.prune(i);
- if(policynodeimpl.mChildren.size() == 0 && i > mDepth + 1)
- iterator.remove();
- } while(true);
- }
-
- void deleteChild(PolicyNode policynode) {
- if(isImmutable) {
- throw new IllegalStateException("PolicyNode is immutable");
- } else {
- mChildren.remove(policynode);
- return;
- }
- }
-
- PolicyNodeImpl copyTree() {
- return copyTree(null);
- }
-
- private PolicyNodeImpl copyTree(PolicyNodeImpl policynodeimpl) {
- PolicyNodeImpl policynodeimpl1 = new PolicyNodeImpl(policynodeimpl, this);
- PolicyNodeImpl policynodeimpl2;
- for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl2.copyTree(policynodeimpl1))
- policynodeimpl2 = (PolicyNodeImpl)iterator.next();
-
- return policynodeimpl1;
- }
-
- Set getPolicyNodes(int i) {
- HashSet hashset = new HashSet();
- getPolicyNodes(i, ((Set) (hashset)));
- return hashset;
- }
-
- private void getPolicyNodes(int i, Set set) {
- if(mDepth == i) {
- set.add(this);
- } else {
- PolicyNodeImpl policynodeimpl;
- for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); policynodeimpl.getPolicyNodes(i, set))
- policynodeimpl = (PolicyNodeImpl)iterator.next();
- }
- }
-
- Set getPolicyNodesExpected(int i, String s, boolean flag) {
- if(s.equals("2.5.29.32.0"))
- return getPolicyNodes(i);
- else
- return getPolicyNodesExpectedHelper(i, s, flag);
- }
-
- private Set getPolicyNodesExpectedHelper(int i, String s, boolean flag) {
- HashSet hashset = new HashSet();
- if(mDepth < i) {
- PolicyNodeImpl policynodeimpl;
- for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesExpectedHelper(i, s, flag)))
- policynodeimpl = (PolicyNodeImpl)iterator.next();
-
- } else if(flag) {
- if(mExpectedPolicySet.contains("2.5.29.32.0"))
- hashset.add(this);
- } else if(mExpectedPolicySet.contains(s)) {
- hashset.add(this);
- }
- return hashset;
- }
-
- Set getPolicyNodesValid(int i, String s) {
- HashSet hashset = new HashSet();
- if(mDepth < i) {
- PolicyNodeImpl policynodeimpl;
- for(Iterator iterator = mChildren.iterator(); iterator.hasNext(); hashset.addAll(policynodeimpl.getPolicyNodesValid(i, s)))
- policynodeimpl = (PolicyNodeImpl)iterator.next();
-
- } else if(mValidPolicy.equals(s)) {
- hashset.add(this);
- }
- return hashset;
- }
-
- private static String policyToString(String s) {
- if(s.equals("2.5.29.32.0")) {
- return "anyPolicy";
- } else {
- return s;
- }
- }
-
- String asString() {
- if(mParent == null)
- return "anyPolicy ROOT\n";
- StringBuffer stringbuffer = new StringBuffer();
- int i = 0;
- for(int j = getDepth(); i < j; i++)
- stringbuffer.append(" ");
-
- stringbuffer.append(policyToString(getValidPolicy()));
- stringbuffer.append(" CRIT: ");
- stringbuffer.append(isCritical());
- stringbuffer.append(" EP: ");
- for(Iterator iterator = getExpectedPolicies().iterator(); iterator.hasNext(); stringbuffer.append(" ")) {
- String s = (String)iterator.next();
- stringbuffer.append(policyToString(s));
- }
-
- stringbuffer.append(" (");
- stringbuffer.append(getDepth());
- stringbuffer.append(")\n");
- return stringbuffer.toString();
- }
-}