harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r413841 [4/9] - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/ test/api/java.injected/java/security/ test/api/java/org/apache/harmony/security/tests/java/security/ test/impl/java.injected...
Date Tue, 13 Jun 2006 08:58:17 GMT
Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java?rev=413841&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Provider_ImplTest.java Tue Jun 13 01:58:11 2006
@@ -0,0 +1,100 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.util.HashMap;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>Provider</code> constructor and methods
+ * 
+ */
+public class Provider_ImplTest extends TestCase {
+
+    Provider p;
+    
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        p = new MyProvider();
+    }
+
+    /*
+     * Class under test for String toString()
+     */
+    public final void testToString() {
+        assertEquals("Incorrect provider.toString()",
+                "MyProvider provider, Ver. 1.0 Provider for testing", p
+                        .toString());
+    }
+ 
+    public final void testImplementsAlg() {
+        HashMap hm = new HashMap();
+        hm.put("KeySize", "1024");
+        hm.put("AAA", "BBB");
+        Provider.Service s = new Provider.Service(p, "Type", "Algorithm",
+                "className", null, hm);
+        p.putService(s);
+        if (!p.implementsAlg("Type", "Algorithm", null, null) ||
+                !p.implementsAlg("MessageDigest", "SHA-1", null, null)) {
+            fail("Case 1. implementsAlg failed");
+        }
+        if (!p.implementsAlg("Type", "Algorithm", "KeySize", "512")) {
+            fail("Case 2. implementsAlg failed");
+        }
+        if (p.implementsAlg("Type", "Algorithm", "KeySize", "1025")) {
+            fail("Case 3. implementsAlg failed");
+        }
+        if (!p.implementsAlg("Type", "Algorithm", "AAA", "BBB")) {
+            fail("Case 3. implementsAlg failed");
+        }    
+    }
+
+    public final void testSetProviderNumber() {
+        p.setProviderNumber(100);
+        assertEquals("Incorrect ProviderNumber", 100, p.getProviderNumber());
+    }
+
+    public final void testGetProviderNumber() {
+        assertEquals("Incorrect ProviderNumber", -1, p.getProviderNumber());
+        
+        int i = Security.addProvider(p);
+        assertEquals("Incorrect ProviderNumber", i, p.getProviderNumber());
+        Security.removeProvider(p.getName());    // clean up
+    }
+
+    class MyProvider extends Provider {
+        MyProvider() {
+            super("MyProvider", 1.0, "Provider for testing");
+            put("MessageDigest.SHA-1", "SomeClassName");
+            put("MessageDigest.abc", "SomeClassName");
+            put("Alg.Alias.MessageDigest.SHA1", "SHA-1");
+        }
+        
+        MyProvider(String name, double version, String info) {
+            super(name, version, info);
+        }
+    }
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Security_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Security_ImplTest.java?rev=413841&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Security_ImplTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Security_ImplTest.java Tue Jun 13 01:58:11 2006
@@ -0,0 +1,225 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests for <code>Security</code> constructor and methods
+ * 
+ */
+public class Security_ImplTest extends TestCase {
+
+    public final void testGetAlgorithmProperty() {
+        assertNull("Incorrect result on null parameter", Security
+                .getAlgorithmProperty(null, "MyService"));
+        assertNull("Incorrect result on null parameter", Security
+                .getAlgorithmProperty("MyAlgorithm", null));
+        assertNull("Incorrect result (provider not added)", Security
+                .getAlgorithmProperty("MyAlgorithm", "MyService"));
+
+        Provider p = new MyProvider();
+        Security.addProvider(p);
+        try {
+            assertEquals("Incorrect result (provider added)",
+                    "SomeClassName", Security.getAlgorithmProperty("MyAlGoriThm", "MySerVicE"));    
+        } finally { //clean up
+            Security.removeProvider(p.getName());
+        }
+    }
+
+    /*
+     * Class under test for Provider[] getProviders()
+     */
+    public final void testGetProviders() {
+        Provider[] providers;
+
+        providers = Security.getProviders();
+        for (int i = 0; i < providers.length; i++) {
+            // position is 1-based
+            assertEquals("Incorrect provider number", i + 1, providers[i]
+                    .getProviderNumber());
+        }
+    }
+
+    /*
+     * Class under test for Provider[] getProviders(String)
+     */
+    public final void testGetProvidersString() {
+        Provider[] providers;
+        try {
+            Security.getProviders("");
+            fail("No expected InvalidParameterException");
+        } catch (InvalidParameterException e) {
+        }
+
+        try {
+            Security.getProviders((String) null);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
+        }
+
+        try {
+            Security.getProviders("AAA.BBB CCC");
+            fail("AAA.BBB CCC: No expected InvalidParameterException");
+        } catch (InvalidParameterException e) {
+        }
+
+        Provider p = new MyProvider();
+
+        try {
+            Security.addProvider(p);
+            providers = Security.getProviders("MyService.MyAlgorithm");
+            assertTrue("failed for MyService.MyAlgorithm", providers != null);
+            assertEquals("failed for MyService.MyAlgorithm", 1,
+                    providers.length);
+            assertEquals("failed for MyService.MyAlgorithm", p, providers[0]);
+            if (providers == null || providers.length != 1 || providers[0] != p) {
+                fail("fail for MyService.MyAlgorithm");
+            }
+
+            providers = Security
+                    .getProviders("MyService.MyAlgorithm KeySize:512");
+            assertTrue("failed for MyService.MyAlgorithm KeySize:512",
+                    providers != null);
+            assertEquals("failed for MyService.MyAlgorithm KeySize:512", 1,
+                    providers.length);
+            assertEquals("failed for MyService.MyAlgorithm KeySize:512", p,
+                    providers[0]);
+
+            providers = Security
+                    .getProviders("MyService.MyAlgorithm KeySize:1025");
+            assertNull("failed for MyService.MyAlgorithm KeySize:1025",
+                    providers);
+
+        } finally { //clean up
+            Security.removeProvider(p.getName());
+        }
+    }
+
+    /*
+     * Class under test for Provider[] getProviders(Map)
+     */
+    public final void testGetProvidersMap() {
+        Provider[] providers;
+        Map m = new Properties();
+        Security.getProviders(m);
+        assertNull("Not null result on empty map", Security.getProviders(m));
+
+        try {
+            Security.getProviders((Map)null);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {    
+        }
+
+        m.clear();
+        m.put("AAA.BBB CCC", "");
+        m.put("AAA.BBB", "");
+        try {
+            Security.getProviders(m);
+            fail("attribute value is empty string: No expected InvalidParameterException");
+        } catch (InvalidParameterException  e) {    
+        }
+
+        m.clear();
+        m.put("AAA.BBB.CCC", "aaaa");
+        m.put("AAA.BBB", "");
+        try {
+            Security.getProviders(m);
+            fail("value associated with the key is not an empty string: No expected InvalidParameterException");
+        } catch (InvalidParameterException  e) {    
+        }
+
+        Provider p = new MyProvider();
+        try {
+            Security.addProvider(p);
+            m.clear();
+            m.put("MyService.MyAlgorithm", "");
+            m.put("MessageDigest.SHA-1", "");
+            providers = Security.getProviders(m);
+            assertNotNull("failed for MyService.MyAlgorithm", providers);
+            assertEquals("failed for MyService.MyAlgorithm", 1,
+                    providers.length);
+            assertEquals("failed for MyService.MyAlgorithm", p, providers[0]);
+            
+            m.clear();
+            m.put("MyService.MyAlgorithm KeySize", "512");
+            m.put("MessageDigest.SHA-1", "");
+            providers = Security.getProviders(m);
+            assertNotNull("failed for MyService.MyAlgorithm KeySize:512",
+                    providers);
+            assertEquals("failed for MyService.MyAlgorithm KeySize:512", 1,
+                    providers.length);
+            assertEquals("failed for MyService.MyAlgorithm KeySize:512", p,
+                    providers[0]);
+            
+            m.clear();
+            m.put("MyService.MyAlgorithm KeySize", "1025");
+            m.put("MessageDigest.SHA-1", "");
+            providers = Security.getProviders(m);
+            assertNull("failed for MyService.MyAlgorithm KeySize:1025",
+                    providers);
+        } finally { //clean up
+            Security.removeProvider(p.getName());
+        }
+    }
+
+    public final void testGetAlgorithms() {
+        Set alg1;
+        Set alg2;
+
+        alg1 = Security.getAlgorithms("AAAAAAAAAAAAAAA");
+        assertTrue("failed for non-existent service", alg1 != null);
+        assertEquals("failed for non-existent service", 0, alg1.size());
+
+        alg1 = Security.getAlgorithms("SecureRandom");
+        alg2 = Security.getAlgorithms("seCuReranDom");
+        assertEquals("different size", alg1.size(), alg2.size());
+        assertTrue("different content", alg2.containsAll(alg1));
+
+        Provider p = new MyProvider();
+
+        try {
+            Security.addProvider(p);
+            alg1 = Security.getAlgorithms("MyService");
+            assertEquals("failed for MyService", 1, alg1.size());
+            assertTrue("failed for MyService", alg1.contains("MyAlgorithm"));
+        } finally { //clean up
+            Security.removeProvider(p.getName());
+        }
+    }
+
+    class MyProvider extends Provider {
+        MyProvider() {
+            super("MyProvider", 1.0, "Provider for testing");
+            put("MessageDigest.SHA-1", "SomeClassName");
+            put("MyService.MyAlgorithm", "SomeClassName");
+            put("MyService.MyAlgorithm KeySize", "1024");
+        }
+    }
+
+}

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java?rev=413841&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl1Test.java Tue Jun 13 01:58:11 2006
@@ -0,0 +1,102 @@
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Boris V. Kuznetsov
+* @version $Revision$
+*/
+
+package java.security;
+
+import org.apache.harmony.security.tests.support.MySignature1;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>Signature</code> constructor and methods
+ * 
+ */
+public class Signature_Impl1Test extends TestCase {
+
+	/*
+	 * Class under test for int sign(byte[], int, int)
+	 */
+	public void testSignbyteArrayintint() {
+		MySignature1 s = new MySignature1("ABC");
+		byte[] b = new byte[8];
+		try {
+			s.sign(b, 0, 5);
+			fail("No expected SignatureException 1");
+		} catch (SignatureException e) {		
+		}
+		
+		try {
+			s.initVerify(new MyPublicKey());
+		} catch (InvalidKeyException e) {
+			fail(e.toString());
+		}
+		
+		try {
+			s.sign(b, 0, 5);
+			fail("No expected SignatureException 1");
+		} catch (SignatureException e) {		
+		}
+		
+		try {
+			s.initSign(new MyPrivateKey());
+		} catch (InvalidKeyException e) {
+			fail(e.toString());
+		}
+		
+		try {
+			s.sign(b, 0, 5);
+		} catch (SignatureException e) {
+			fail(e.toString());
+		}
+		if (s.getState() != Signature.SIGN) {
+			fail("Incorrect state");
+		}
+		if (!s.runEngineSign) {
+			fail("sign() failed");
+		}
+	}
+
+	/*
+	 * Class under test for String toString()
+	 */
+	public void testToString() {
+        MySignature1 s = new MySignature1("ABC");
+        assertEquals("toString() failed", "SIGNATURE ABC state: UNINITIALIZED",
+                s.toString());
+    }
+
+    private class MyKey implements Key {
+        public String getFormat() {
+            return "123";
+        }
+        public byte[] getEncoded() {
+            return null;
+        }
+        public String getAlgorithm() {
+            return "aaa";
+        }       
+    }
+    
+    private class MyPublicKey extends MyKey implements PublicKey {}
+
+    private class MyPrivateKey extends MyKey implements PrivateKey {}
+
+}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java (from r412639, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/Signature2Test.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/Signature2Test.java&r1=412639&r2=413841&rev=413841&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/Signature2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/Signature_Impl2Test.java Tue Jun 13 01:58:11 2006
@@ -30,7 +30,7 @@
  * Tests for <code>Signature</code> constructor and methods
  * 
  */
-public class Signature2Test extends TestCase {
+public class Signature_Impl2Test extends TestCase {
 
 	/**
 	 * Provider
@@ -57,294 +57,145 @@
 	/*
 	 * Class under test for Signature getInstance(String)
 	 */
-	public void testGetInstanceString1() {
-		Signature sig = null;
-		
-		try {
-			sig = Signature.getInstance("ABC");		
-		} catch (NoSuchAlgorithmException e) {
-			fail(e.toString());
-		}
+	public void testGetInstanceString1() throws Exception {
+		Signature sig = Signature.getInstance("ABC");		
 		checkSig1(sig, p);
 	}
 	
 	/*
 	 * Class under test for Signature getInstance(String)
 	 */
-	public void testGetInstanceString2() {
-		Signature sig = null;
-		
-		try {
-			sig = Signature.getInstance("CBA");
-		} catch (NoSuchAlgorithmException e) {
-			fail(e.toString());
-		}
+	public void testGetInstanceString2() throws Exception {
+		Signature sig = Signature.getInstance("CBA");
 		checkSig2(sig, p);
 	}
 
 	/*
 	 * Class under test for Signature getInstance(String, String)
 	 */
-	public void testGetInstanceStringString1() {
-		Signature sig = null;
-		
-		try {
-			sig = Signature.getInstance("ABC", "MyProvider");		
-		} catch (NoSuchAlgorithmException e) {
-			fail(e.toString());
-		} catch (NoSuchProviderException e) {
-			fail(e.toString());
-		}
+	public void testGetInstanceStringString1() throws Exception {
+		Signature sig = Signature.getInstance("ABC", "MyProvider");		
 		checkSig1(sig, p);
 	}
 	
 	/*
 	 * Class under test for Signature getInstance(String, String)
 	 */
-	public void testGetInstanceStringString2() {
-		Signature sig = null;
-		
-		try {
-			sig = Signature.getInstance("CBA", "MyProvider");
-		} catch (NoSuchAlgorithmException e) {
-			fail(e.toString());
-		} catch (NoSuchProviderException e) {
-			fail(e.toString());
-		}
+	public void testGetInstanceStringString2() throws Exception {
+		Signature sig = Signature.getInstance("CBA", "MyProvider");
 		checkSig2(sig, p);
-		
 	}
 
 
 	/*
 	 * Class under test for Signature getInstance(String, Provider)
 	 */
-	public void testGetInstanceStringProvider1() {
+	public void testGetInstanceStringProvider1() throws Exception {
 		Provider p1 = new MyProvider();
-		Signature sig = null;
-		
-		try {
-			sig = Signature.getInstance("ABC", p1);		
-		} catch (NoSuchAlgorithmException e) {
-			fail(e.toString());
-		}
+		Signature sig = Signature.getInstance("ABC", p1);		
 		checkSig1(sig, p1);
 	}
 	
 	/*
 	 * Class under test for Signature getInstance(String, Provider)
 	 */
-	public void testGetInstanceStringProvider2() {
+	public void testGetInstanceStringProvider2() throws Exception {
 		Provider p2 = new MyProvider();
-		Signature sig = null;
-		
-		try {
-			sig = Signature.getInstance("CBA", p2);
-		} catch (NoSuchAlgorithmException e) {
-			fail(e.toString());
-		}
+		Signature sig = Signature.getInstance("CBA", p2);
 		checkSig2(sig, p2);
 	}
 
-	private void checkSig1(Signature s, Provider p) {
-		byte[] b = {1, 2, 3, 4};
-		if (!(s instanceof MySignature1)) {
-			fail("getInstance() failed");
-		}
-		if (s.getProvider() != p) {
-			System.out.println(p);
-			System.out.println(s.getProvider());
-			fail("getProvider() failed");
-		}
-
-		if (!"ABC".equals(s.getAlgorithm())) {
-			fail("getAlgorithm() failed");			
-		}
-		try {
-			s.sign();
-			fail("No expected SignatureException");
-		} catch (SignatureException e) {		
-		}
-
-		try {
-			s.initVerify(new MyPublicKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.sign();
-			fail("No expected SignatureException");
-		} catch (SignatureException e) {		
-		}
-		
-		try {
-			s.initSign(new MyPrivateKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		try {
-			s.sign();
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-		if (((MySignature1)s).getState() != Signature.SIGN) {
-			fail("Incorrect state");
-		}
-		if (!((MySignature1)s).runEngineSign) {
-			fail("sign() failed");
-		}
-		
-		try {
-			s.initVerify(new MyPublicKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.update((byte)1);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.initSign(new MyPrivateKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		try {
-			s.update((byte)1);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-		if (((MySignature1)s).getState() != Signature.SIGN) {
-			fail("Incorrect state");
-		}
-		if (!((MySignature1)s).runEngineUpdate1) {
-			fail("update() failed");
-		}
-		
-		try {
-			s.initSign(new MyPrivateKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.verify(b);
-			fail("No expected SignatureException");
-		} catch (SignatureException e) {		
-		}
-		
-		try {
-			s.initVerify(new MyPublicKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.verify(b);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-		
-		if (((MySignature1)s).getState() != Signature.VERIFY) {
-			fail("Incorrect state");
-		}
-		if (!((MySignature1)s).runEngineVerify) {
-			fail("verify() failed");
-		}
-	}
+	private void checkSig1(Signature s, Provider p) throws Exception {
+        byte[] b = { 1, 2, 3, 4 };
+        assertTrue("getInstance() failed", s instanceof MySignature1);
+        assertEquals("getProvider() failed", p, s.getProvider());
+        assertEquals("getAlgorithm() failed", "ABC", s.getAlgorithm());
+
+        try {
+            s.sign();
+            fail("No expected SignatureException");
+        } catch (SignatureException e) {
+        }
+
+        s.initVerify(new MyPublicKey());
+
+        try {
+            s.sign();
+            fail("No expected SignatureException");
+        } catch (SignatureException e) {
+        }
+
+        s.initSign(new MyPrivateKey());
+        s.sign();
+        assertEquals("Incorrect state", Signature.SIGN, ((MySignature1) s)
+                .getState());
+        assertTrue("sign() failed", ((MySignature1) s).runEngineSign);
+
+        s.initVerify(new MyPublicKey());
+        s.update((byte) 1);
+
+        s.initSign(new MyPrivateKey());
+        s.update((byte) 1);
+
+        assertEquals("Incorrect state", Signature.SIGN, ((MySignature1) s)
+                .getState());
+        assertTrue("sign() failed", ((MySignature1) s).runEngineUpdate1);
+
+        s.initSign(new MyPrivateKey());
+
+        try {
+            s.verify(b);
+            fail("No expected SignatureException");
+        } catch (SignatureException e) {
+        }
+        s.initVerify(new MyPublicKey());
+        s.verify(b);
+        assertEquals("Incorrect state", Signature.VERIFY, ((MySignature1) s)
+                .getState());
+        assertTrue("verify() failed", ((MySignature1) s).runEngineVerify);
+    }
 	
-	private void checkSig2(Signature s, Provider p) {
-		byte[] b = {1, 2, 3, 4};
-		if (s.getProvider() != p) {
-			fail("getProvider() failed");
-		}
-		if (!"CBA".equals(s.getAlgorithm())) {
-			fail("getAlgorithm() failed");			
-		}
-		try {
-			s.initVerify(new MyCertificate());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		try {
-			s.sign(b, 0, 5);
-			fail("No expected SignatureException 1");
-		} catch (SignatureException e) {		
-		}
-		
-		try {
-			s.initSign(new MyPrivateKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.sign(b, 0, 3);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-
-		if (!MySignature2.runEngineSign) {
-			fail("sign() failed");
-		}
-		try {
-			s.update(b);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.initSign(new MyPrivateKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		try {
-			s.update(b);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-
-		if (!MySignature2.runEngineUpdate2) {
-			fail("update() failed");
-		}
-		
-		try {
-			s.initSign(new MyPrivateKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		try {
-			s.verify(b, 0, 3);
-			fail("No expected SignatureException");
-		} catch (SignatureException e) {		
-		}
-		
-		try {
-			s.initVerify(new MyPublicKey());
-		} catch (InvalidKeyException e) {
-			fail(e.toString());
-		}
-		
-		try {
-			s.verify(b, 0, 5);
-			fail("No expected IllegalArgumentException");
-		} catch (IllegalArgumentException e) { 
-		} catch (SignatureException e) {		
-		}
-		
-		try {
-			s.verify(b, 0, 3);
-		} catch (SignatureException e) {
-			fail(e.toString());
-		}
-		
-		if (!MySignature2.runEngineVerify) {
-			fail("verify() failed");
-		}
-	}
+	private void checkSig2(Signature s, Provider p) throws Exception {
+        byte[] b = { 1, 2, 3, 4 };
+
+        assertEquals("getProvider() failed", p, s.getProvider());
+        assertEquals("getAlgorithm() failed", "CBA", s.getAlgorithm());
+
+        s.initVerify(new MyCertificate());
+
+        try {
+            s.sign(b, 0, 5);
+            fail("No expected SignatureException 1");
+        } catch (SignatureException e) {
+        }
+
+        s.initSign(new MyPrivateKey());
+        s.sign(b, 0, 3);
+
+        assertTrue("sign() failed", MySignature2.runEngineSign);
+        s.update(b);
+        s.initSign(new MyPrivateKey());
+        s.update(b);
+        assertTrue("update() failed", MySignature2.runEngineUpdate2);
+
+        s.initSign(new MyPrivateKey());
+        try {
+            s.verify(b, 0, 3);
+            fail("No expected SignatureException");
+        } catch (SignatureException e) {
+        }
+        s.initVerify(new MyPublicKey());
+
+        try {
+            s.verify(b, 0, 5);
+            fail("No expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+        } catch (SignatureException e) {
+        }
+
+        s.verify(b, 0, 3);
+        assertTrue("verify() failed", MySignature2.runEngineVerify);
+    }
 	
 	private class MyProvider extends Provider {
 		MyProvider() {

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java (from r412639, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollectionTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollectionTest.java&r1=412639&r2=413841&rev=413841&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollectionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionCollection_ImplTest.java Tue Jun 13 01:58:11 2006
@@ -31,11 +31,7 @@
  * 
  */
 
-public class UnresolvedPermissionCollectionTest extends TestCase {
-
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(UnresolvedPermissionCollectionTest.class);
-    }
+public class UnresolvedPermissionCollection_ImplTest extends TestCase {
 
     /** 
      * Can add any number of UnresolvedPermission instances, but no any other permissions.

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java (from r412639, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java&r1=412639&r2=413841&rev=413841&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermissionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/UnresolvedPermission_ImplTest.java Tue Jun 13 01:58:11 2006
@@ -28,55 +28,7 @@
  * 
  */
 
-public class UnresolvedPermissionTest extends TestCase {
-
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(UnresolvedPermissionTest.class);
-    }
-
-    /**
-     * Constructor for UnresolvedPermissionTest.
-     * @param arg0
-     */
-    public UnresolvedPermissionTest(String arg0) {
-        super(arg0);
-    }
-    
-    /**
-     * Creates an Object with given name, type, action, certificaties. 
-     * 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("exception is not thrown on null type");
-        }
-        catch (Exception ok) {}
-        /*try {
-            new UnresolvedPermission("", name, action, null);
-            fail("exception is not thrown on empty type");
-        }
-        catch (Exception ok) {}*/
-    }
+public class UnresolvedPermission_ImplTest extends TestCase {  
     
     /**
      * This test is valid since 1.5 release only. Checks that UnresolvedPermission returns the proper 
@@ -125,29 +77,6 @@
         up = new UnresolvedPermission(type, name, action, new java.security.cert.Certificate[10]);
         assertTrue(up.equals(up2));
         assertTrue(up.hashCode() == up2.hashCode());
-    }
-    
-    /** 
-     * 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")));
-    }
-    
-    /**
-     * newPermissionCollection() should return new BasicPermissionCollection on every invokation
-     */
-    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);
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java?rev=413841&r1=413840&r2=413841&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java.injected/java/security/cert/X509CRLSelectorTest.java Tue Jun 13 01:58:11 2006
@@ -1,590 +1,590 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed 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 Y. Kleymenov
-* @version $Revision$
-*/
-
-package java.security.cert;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.SignatureException;
-import java.security.cert.CRLException;
-import java.security.cert.X509CRLEntry;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Set;
-import javax.security.auth.x500.X500Principal;
-
-import org.apache.harmony.security.asn1.ASN1Integer;
-import org.apache.harmony.security.asn1.ASN1OctetString;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- */
-
-public class X509CRLSelectorTest extends TestCase {
-
-    /**
-     * The abstract class stub implementation.
-     */
-    private class TestCRL extends X509CRL {
-
-        private X500Principal principal = null;
-        private BigInteger crlNumber = null;
-        private Date thisUpdate = null;
-        private Date nextUpdate = null;
-
-        public TestCRL(X500Principal principal) {
-            this.principal = principal;
-        }
-
-        public TestCRL(Date thisUpdate, Date nextUpdate) {
-            setUpdateDates(thisUpdate, nextUpdate);
-        }
-
-        public TestCRL(BigInteger crlNumber) {
-            setCrlNumber(crlNumber);
-        }
-
-        public void setUpdateDates(Date thisUpdate, Date nextUpdate) {
-            this.thisUpdate = thisUpdate;
-            this.nextUpdate = nextUpdate;
-        }
-        
-        public void setCrlNumber(BigInteger crlNumber) {
-            this.crlNumber = crlNumber;
-        }
-
-        public X500Principal getIssuerX500Principal() {
-            return principal;
-        }
-
-        public String toString() {
-            return null;
-        }
-
-        public boolean isRevoked(Certificate cert) {
-            return true;
-        }
-
-        public Set getNonCriticalExtensionOIDs() {
-            return null;
-        }
-
-        public Set getCriticalExtensionOIDs() {
-            return null;
-        }
-
-        public byte[] getExtensionValue(String oid) {
-            if ("2.5.29.20".equals(oid) && (crlNumber != null)) {
-                return ASN1OctetString.getInstance().encode(
-                        ASN1Integer.getInstance().encode(
-                                crlNumber.toByteArray()));
-            }
-            return null;
-        }
-
-        public boolean hasUnsupportedCriticalExtension() {
-            return false;
-        }
-
-        public byte[] getEncoded() {
-            return null;
-        }
-
-        public void verify(PublicKey key)
-                 throws CRLException, NoSuchAlgorithmException,
-                        InvalidKeyException, NoSuchProviderException,
-                        SignatureException
-        {
-        }
-
-        public void verify(PublicKey key, String sigProvider)
-                 throws CRLException, NoSuchAlgorithmException,
-                        InvalidKeyException, NoSuchProviderException,
-                        SignatureException
-        {
-        }
-
-        public int getVersion() {
-            return 2;
-        }
-
-        public Principal getIssuerDN() {
-            return null;
-        }
-
-        public Date getThisUpdate() {
-            return thisUpdate;
-        }
-
-        public Date getNextUpdate() {
-            return nextUpdate;
-        }
-
-        public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
-            return null;
-        }
-
-        public Set getRevokedCertificates() {
-            return null;
-        }
-
-        public byte[] getTBSCertList() {
-            return null;
-        }
-
-        public byte[] getSignature() {
-            return null;
-        }
-
-        public String getSigAlgName() {
-            return null;
-        }
-
-        public String getSigAlgOID() {
-            return null;
-        }
-
-        public byte[] getSigAlgParams() {
-            return null;
-        }
-    }
-
-    /**
-     * setIssuers(Collection <X500Principal> issuers) method testing.
-     * Tests if CRLs with any issuers match the selector in the case of
-     * null issuerNames criteria, if specified issuers match the selector,
-     * and if not specified issuer does not match the selector.
-     */
-    public void testSetIssuers() {
-        X509CRLSelector selector = new X509CRLSelector();
-        X500Principal iss1 = new X500Principal("O=First Org.");
-        X500Principal iss2 = new X500Principal("O=Second Org.");
-        X500Principal iss3 = new X500Principal("O=Third Org.");
-        TestCRL crl1 = new TestCRL(iss1);
-        TestCRL crl2 = new TestCRL(iss2);
-        TestCRL crl3 = new TestCRL(iss3);
-
-        selector.setIssuers(null);
-        assertTrue("Any CRL issuers should match in the case of null issuers.",
-                    selector.match(crl1) && selector.match(crl2));
-
-        ArrayList issuers = new ArrayList(2);
-        issuers.add(iss1);
-        issuers.add(iss2);
-        selector.setIssuers(issuers);
-        assertTrue("The CRL should match the selection criteria.",
-                    selector.match(crl1) && selector.match(crl2));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl3));
-        issuers.add(iss3);
-        assertFalse("The internal issuer collection is not protected "
-                    + "against the modifications.", selector.match(crl3));
-    }
-
-    /**
-     * setIssuerNames(Collection <?> names) method testing.
-     * Tests if CRLs with any issuers match the selector in the case of
-     * null issuerNames criteria, if specified issuers match the selector,
-     * if not specified issuer does not match the selector, and if the
-     * internal collection of issuer names is copied during initialization.
-     */
-    public void testSetIssuerNames() {
-        X509CRLSelector selector = new X509CRLSelector();
-        String iss1 = "O=First Org.";
-        byte[] iss2 = new byte[]
-            //manually obtained DER encoding of "O=Second Org." issuer name;
-            {48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
-            83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46};
-        String iss3 = "O=Third Org.";
-        TestCRL crl1 = new TestCRL(new X500Principal(iss1));
-        TestCRL crl2 = new TestCRL(new X500Principal(iss2));
-        TestCRL crl3 = new TestCRL(new X500Principal(iss3));
-
-        try {
-            selector.setIssuerNames(null);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        assertTrue("Any CRL issuers should match in the case of null issuers.",
-                    selector.match(crl1) && selector.match(crl2));
-
-        ArrayList issuers = new ArrayList(2);
-        issuers.add(iss1);
-        issuers.add(iss2);
-        try {
-            selector.setIssuerNames(issuers);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        assertTrue("The CRL should match the selection criteria.",
-                    selector.match(crl1) && selector.match(crl2));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl3));
-        issuers.add(iss3);
-        assertFalse("The internal issuer collection is not protected "
-                    + "against the modifications.", selector.match(crl3));
-    }
-
-    /**
-     * addIssuer(X500Principal issuer) method testing.
-     * Tests if CRLs with specified issuers match the selector,
-     * and if not specified issuer does not match the selector.
-     */
-    public void testAddIssuer() {
-        X509CRLSelector selector = new X509CRLSelector();
-        X500Principal iss1 = new X500Principal("O=First Org.");
-        X500Principal iss2 = new X500Principal("O=Second Org.");
-        TestCRL crl1 = new TestCRL(iss1);
-        TestCRL crl2 = new TestCRL(iss2);
-
-        selector.addIssuer(iss1);
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl1));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl2));
-        selector.addIssuer(iss2);
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl2));
-    }
-
-    /**
-     * addIssuerName(String name) method testing.
-     * Tests if CRLs with specified issuers match the selector,
-     * and if not specified issuer does not match the selector.
-     */
-    public void testAddIssuerName1() {
-        X509CRLSelector selector = new X509CRLSelector();
-        String iss1 = "O=First Org.";
-        String iss2 = "O=Second Org.";
-        TestCRL crl1 = new TestCRL(new X500Principal(iss1));
-        TestCRL crl2 = new TestCRL(new X500Principal(iss2));
-
-        try {
-            selector.addIssuerName(iss1);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl1));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl2));
-        try {
-            selector.addIssuerName(iss2);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl2));
-    }
-
-    /**
-     * addIssuerName(byte[] name) method testing.
-     * Tests if CRLs with specified issuers match the selector,
-     * and if not specified issuer does not match the selector.
-     */
-    public void testAddIssuerName2() {
-        X509CRLSelector selector = new X509CRLSelector();
-        byte[] iss1 = new byte[]
-            //manually obtained DER encoding of "O=First Org." issuer name;
-            {48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
-                70, 105, 114, 115, 116, 32, 79, 114, 103, 46};
-        byte[] iss2 = new byte[]
-            //manually obtained DER encoding of "O=Second Org." issuer name;
-            {48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
-            83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46};
-        TestCRL crl1 = new TestCRL(new X500Principal(iss1));
-        TestCRL crl2 = new TestCRL(new X500Principal(iss2));
-
-        try {
-            selector.addIssuerName(iss1);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl1));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl2));
-        try {
-            selector.addIssuerName(iss2);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl2));
-    }
-
-    /**
-     * setMinCRLNumber(BigInteger minCRL) method testing.
-     * Tests if CRLs with any crl number value match the selector in the case of
-     * null crlNumber criteria, if specified minCRL value matches the selector,
-     * and if CRL with inappropriate crlNumber value does not match the selector. 
-     */
-    public void testSetMinCRLNumber() {
-        X509CRLSelector selector = new X509CRLSelector();
-        BigInteger minCRL = new BigInteger("10000");
-        TestCRL crl = new TestCRL(minCRL);
-
-        selector.setMinCRLNumber(null);
-        assertTrue("Any CRL should match in the case of null minCRLNumber.",
-                                            selector.match(crl));
-        selector.setMinCRLNumber(minCRL);
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl));
-        selector.setMinCRLNumber(new BigInteger("10001"));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl));
-    }
-
-    /**
-     * setMaxCRLNumber(BigInteger maxCRL) method testing.
-     * Tests if CRLs with any crl number value match the selector in the case of
-     * null crlNumber criteria, if specified maxCRL value matches the selector,
-     * and if CRL with inappropriate crlNumber value does not match the selector. 
-     */
-    public void testSetMaxCRLNumber() {
-        X509CRLSelector selector = new X509CRLSelector();
-        BigInteger maxCRL = new BigInteger("10000");
-        TestCRL crl = new TestCRL(maxCRL);
-
-        selector.setMaxCRLNumber(null);
-        assertTrue("Any CRL should match in the case of null minCRLNumber.",
-                                            selector.match(crl));
-        selector.setMaxCRLNumber(maxCRL);
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl));
-        selector.setMaxCRLNumber(new BigInteger("9999"));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl));
-    }
-
-    /**
-     * setDateAndTime(Date dateAndTime) method testing.
-     * Tests if CRLs with any update dates match the selector in the case of
-     * null dateAndTime criteria, if correct dates match and incorrect 
-     * do not match the selector.
-     */
-    public void testSetDateAndTime() {
-        X509CRLSelector selector = new X509CRLSelector();
-        TestCRL crl = new TestCRL(new Date(200), new Date(300));
-        selector.setDateAndTime(null);
-        assertTrue("Any CRL should match in the case of null dateAndTime.",
-                                            selector.match(crl));
-        selector.setDateAndTime(new Date(200));
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl));
-        selector.setDateAndTime(new Date(250));
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl));
-        selector.setDateAndTime(new Date(300));
-        assertTrue("The CRL should match the selection criteria.",
-                                            selector.match(crl));
-        selector.setDateAndTime(new Date(150));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl));
-        selector.setDateAndTime(new Date(350));
-        assertFalse("The CRL should not match the selection criteria.",
-                                            selector.match(crl));
-    }
-
-    /**
-     * getIssuers() method testing.
-     * Tests if the method return null in the case of not specified issuers,
-     * if the returned collection corresponds to the specified issuers and
-     * this collection is unmodifiable.
-     */
-    public void testGetIssuers() {
-        X509CRLSelector selector = new X509CRLSelector();
-        X500Principal iss1 = new X500Principal("O=First Org.");
-        X500Principal iss2 = new X500Principal("O=Second Org.");
-        X500Principal iss3 = new X500Principal("O=Third Org.");
-        assertNull("The collection should be null.",
-                                        selector.getIssuers());
-        selector.addIssuer(iss1);
-        selector.addIssuer(iss2);
-        Collection result = selector.getIssuers();
-        try {
-            result.add(iss3);
-            fail("The returned collection should be unmodifiable.");
-        } catch (UnsupportedOperationException e) {
-        }
-        assertTrue("The collection should contain the specified DN.",
-                                            result.contains(iss2));
-    }
-
-    /**
-     * getIssuerNames() method testing.
-     * Tests if the method return null in the case of not specified issuers,
-     * if the returned collection corresponds to the specified issuers.
-     */
-    public void testGetIssuerNames() {
-        X509CRLSelector selector = new X509CRLSelector();
-        byte[] iss1 = new byte[]
-            //manually obtained DER encoding of "O=First Org." issuer name;
-            {48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
-                70, 105, 114, 115, 116, 32, 79, 114, 103, 46};
-        byte[] iss2 = new byte[]
-            //manually obtained DER encoding of "O=Second Org." issuer name;
-            {48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
-            83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46};
-        assertNull("The collection should be null.",
-                                        selector.getIssuerNames());
-        try {
-            selector.addIssuerName(iss1);
-            selector.addIssuerName(iss2);
-        } catch (IOException e) {
-            e.printStackTrace();
-            fail("Unexpected IOException was thrown.");
-        }
-        Collection result = selector.getIssuerNames();
-        assertEquals("The collection should contain all of the specified DNs.",
-                                                2, result.size());
-    }
-
-    /**
-     * getMinCRL() method testing.
-     * Tests if the method return null in the case of not specified minCRL 
-     * criteria, and if the returned value corresponds to the specified one.
-     */
-    public void testGetMinCRL() {
-        X509CRLSelector selector = new X509CRLSelector();
-        assertNull("Initially the minCRL should be null.",
-                                        selector.getMinCRL());
-        BigInteger minCRL = new BigInteger("10000");
-        selector.setMinCRLNumber(minCRL);
-        assertTrue("The result should be equal to specified.",
-                                        minCRL.equals(selector.getMinCRL()));
-    }
-
-    /**
-     * getMaxCRL() method testing.
-     * Tests if the method return null in the case of not specified maxCRL 
-     * criteria, and if the returned value corresponds to the specified one.
-     */
-    public void testGetMaxCRL() {
-        X509CRLSelector selector = new X509CRLSelector();
-        assertNull("Initially the maxCRL should be null.",
-                                        selector.getMaxCRL());
-        BigInteger maxCRL = new BigInteger("10000");
-        selector.setMaxCRLNumber(maxCRL);
-        assertTrue("The result should be equal to specified.",
-                                        maxCRL.equals(selector.getMaxCRL()));
-    }
-
-    /**
-     * getDateAndTime() method testing.
-     * Tests if the method return null in the case of not specified dateAndTime 
-     * criteria, and if the returned value corresponds to the specified one.
-     */
-    public void testGetDateAndTime() {
-        X509CRLSelector selector = new X509CRLSelector();
-        assertNull("Initially the dateAndTime criteria should be null.",
-                                        selector.getDateAndTime());
-        Date date = new Date(200);
-        selector.setDateAndTime(date);
-        assertTrue("The result should be equal to specified.",
-                                        date.equals(selector.getDateAndTime()));
-    }
-
-    /**
-     * match(CRL crl) method testing.
-     * Tests if the null object matches to the selector or not.
-     */
-    public void testMatch() {
-        X509CRLSelector selector = new X509CRLSelector();
-        assertFalse("The null object should not match", 
-                                        selector.match((X509CRL) null));
-    }
-
-    /**
-     * clone() method testing.
-     * Tests if the selector is cloned correctly: the crl which matche to
-     * the initial selector should match to the clone and the change of clone
-     * should not cause the change of initial selector.
-     */
-    public void testClone() {
-        X509CRLSelector selector = new X509CRLSelector();
-        X500Principal iss1 = new X500Principal("O=First Org.");
-        X500Principal iss2 = new X500Principal("O=Second Org.");
-        X500Principal iss3 = new X500Principal("O=Third Org.");
-        BigInteger minCRL = new BigInteger("10000");
-        BigInteger maxCRL = new BigInteger("10000");
-        Date date = new Date(200);
-
-        selector.addIssuer(iss1);
-        selector.addIssuer(iss2);
-        selector.setMinCRLNumber(minCRL);
-        selector.setMaxCRLNumber(maxCRL);
-        selector.setDateAndTime(date);
-
-        X509CRLSelector clone = (X509CRLSelector) selector.clone();
-        TestCRL crl = new TestCRL(iss1);
-        crl.setCrlNumber(minCRL);
-        crl.setUpdateDates(new Date(200), new Date(200));
-        assertTrue("The specified CRL should match the clone selector.",
-                    selector.match(crl));
-
-        clone.addIssuer(iss3);
-        assertFalse("The changes of the clone selector should not cause "
-                    + "the changes of initial object", 
-                                    selector.getIssuerNames().size() == 3);
-    }
-
-    public void testToString() {
-        X509CRLSelector selector = new X509CRLSelector();
-        X500Principal iss1 = new X500Principal("O=First Org.");
-        X500Principal iss2 = new X500Principal("O=Second Org.");
-        BigInteger minCRL = new BigInteger("10000");
-        BigInteger maxCRL = new BigInteger("10000");
-        Date date = new Date(200);
-
-        selector.addIssuer(iss1);
-        selector.addIssuer(iss2);
-        selector.setMinCRLNumber(minCRL);
-        selector.setMaxCRLNumber(maxCRL);
-        selector.setDateAndTime(date);
-
-        assertNotNull("The result should not be null.", selector.toString());
-    }
-
-    public static Test suite() {
-        return new TestSuite(X509CRLSelectorTest.class);
-    }
-
-    public static void main(String[] args) {
-        junit.textui.TestRunner.run(suite());
-    }
-}
-
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 Y. Kleymenov
+* @version $Revision$
+*/
+
+package java.security.cert;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Principal;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.CRLException;
+import java.security.cert.X509CRLEntry;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Set;
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.harmony.security.asn1.ASN1Integer;
+import org.apache.harmony.security.asn1.ASN1OctetString;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ */
+
+public class X509CRLSelectorTest extends TestCase {
+
+    /**
+     * The abstract class stub implementation.
+     */
+    private class TestCRL extends X509CRL {
+
+        private X500Principal principal = null;
+        private BigInteger crlNumber = null;
+        private Date thisUpdate = null;
+        private Date nextUpdate = null;
+
+        public TestCRL(X500Principal principal) {
+            this.principal = principal;
+        }
+
+        public TestCRL(Date thisUpdate, Date nextUpdate) {
+            setUpdateDates(thisUpdate, nextUpdate);
+        }
+
+        public TestCRL(BigInteger crlNumber) {
+            setCrlNumber(crlNumber);
+        }
+
+        public void setUpdateDates(Date thisUpdate, Date nextUpdate) {
+            this.thisUpdate = thisUpdate;
+            this.nextUpdate = nextUpdate;
+        }
+        
+        public void setCrlNumber(BigInteger crlNumber) {
+            this.crlNumber = crlNumber;
+        }
+
+        public X500Principal getIssuerX500Principal() {
+            return principal;
+        }
+
+        public String toString() {
+            return null;
+        }
+
+        public boolean isRevoked(Certificate cert) {
+            return true;
+        }
+
+        public Set getNonCriticalExtensionOIDs() {
+            return null;
+        }
+
+        public Set getCriticalExtensionOIDs() {
+            return null;
+        }
+
+        public byte[] getExtensionValue(String oid) {
+            if ("2.5.29.20".equals(oid) && (crlNumber != null)) {
+                return ASN1OctetString.getInstance().encode(
+                        ASN1Integer.getInstance().encode(
+                                crlNumber.toByteArray()));
+            }
+            return null;
+        }
+
+        public boolean hasUnsupportedCriticalExtension() {
+            return false;
+        }
+
+        public byte[] getEncoded() {
+            return null;
+        }
+
+        public void verify(PublicKey key)
+                 throws CRLException, NoSuchAlgorithmException,
+                        InvalidKeyException, NoSuchProviderException,
+                        SignatureException
+        {
+        }
+
+        public void verify(PublicKey key, String sigProvider)
+                 throws CRLException, NoSuchAlgorithmException,
+                        InvalidKeyException, NoSuchProviderException,
+                        SignatureException
+        {
+        }
+
+        public int getVersion() {
+            return 2;
+        }
+
+        public Principal getIssuerDN() {
+            return null;
+        }
+
+        public Date getThisUpdate() {
+            return thisUpdate;
+        }
+
+        public Date getNextUpdate() {
+            return nextUpdate;
+        }
+
+        public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
+            return null;
+        }
+
+        public Set getRevokedCertificates() {
+            return null;
+        }
+
+        public byte[] getTBSCertList() {
+            return null;
+        }
+
+        public byte[] getSignature() {
+            return null;
+        }
+
+        public String getSigAlgName() {
+            return null;
+        }
+
+        public String getSigAlgOID() {
+            return null;
+        }
+
+        public byte[] getSigAlgParams() {
+            return null;
+        }
+    }
+
+    /**
+     * setIssuers(Collection <X500Principal> issuers) method testing.
+     * Tests if CRLs with any issuers match the selector in the case of
+     * null issuerNames criteria, if specified issuers match the selector,
+     * and if not specified issuer does not match the selector.
+     */
+    public void testSetIssuers() {
+        X509CRLSelector selector = new X509CRLSelector();
+        X500Principal iss1 = new X500Principal("O=First Org.");
+        X500Principal iss2 = new X500Principal("O=Second Org.");
+        X500Principal iss3 = new X500Principal("O=Third Org.");
+        TestCRL crl1 = new TestCRL(iss1);
+        TestCRL crl2 = new TestCRL(iss2);
+        TestCRL crl3 = new TestCRL(iss3);
+
+        selector.setIssuers(null);
+        assertTrue("Any CRL issuers should match in the case of null issuers.",
+                    selector.match(crl1) && selector.match(crl2));
+
+        ArrayList issuers = new ArrayList(2);
+        issuers.add(iss1);
+        issuers.add(iss2);
+        selector.setIssuers(issuers);
+        assertTrue("The CRL should match the selection criteria.",
+                    selector.match(crl1) && selector.match(crl2));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl3));
+        issuers.add(iss3);
+        assertFalse("The internal issuer collection is not protected "
+                    + "against the modifications.", selector.match(crl3));
+    }
+
+    /**
+     * setIssuerNames(Collection <?> names) method testing.
+     * Tests if CRLs with any issuers match the selector in the case of
+     * null issuerNames criteria, if specified issuers match the selector,
+     * if not specified issuer does not match the selector, and if the
+     * internal collection of issuer names is copied during initialization.
+     */
+    public void testSetIssuerNames() {
+        X509CRLSelector selector = new X509CRLSelector();
+        String iss1 = "O=First Org.";
+        byte[] iss2 = new byte[]
+            //manually obtained DER encoding of "O=Second Org." issuer name;
+            {48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
+            83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46};
+        String iss3 = "O=Third Org.";
+        TestCRL crl1 = new TestCRL(new X500Principal(iss1));
+        TestCRL crl2 = new TestCRL(new X500Principal(iss2));
+        TestCRL crl3 = new TestCRL(new X500Principal(iss3));
+
+        try {
+            selector.setIssuerNames(null);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        assertTrue("Any CRL issuers should match in the case of null issuers.",
+                    selector.match(crl1) && selector.match(crl2));
+
+        ArrayList issuers = new ArrayList(2);
+        issuers.add(iss1);
+        issuers.add(iss2);
+        try {
+            selector.setIssuerNames(issuers);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        assertTrue("The CRL should match the selection criteria.",
+                    selector.match(crl1) && selector.match(crl2));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl3));
+        issuers.add(iss3);
+        assertFalse("The internal issuer collection is not protected "
+                    + "against the modifications.", selector.match(crl3));
+    }
+
+    /**
+     * addIssuer(X500Principal issuer) method testing.
+     * Tests if CRLs with specified issuers match the selector,
+     * and if not specified issuer does not match the selector.
+     */
+    public void testAddIssuer() {
+        X509CRLSelector selector = new X509CRLSelector();
+        X500Principal iss1 = new X500Principal("O=First Org.");
+        X500Principal iss2 = new X500Principal("O=Second Org.");
+        TestCRL crl1 = new TestCRL(iss1);
+        TestCRL crl2 = new TestCRL(iss2);
+
+        selector.addIssuer(iss1);
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl1));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl2));
+        selector.addIssuer(iss2);
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl2));
+    }
+
+    /**
+     * addIssuerName(String name) method testing.
+     * Tests if CRLs with specified issuers match the selector,
+     * and if not specified issuer does not match the selector.
+     */
+    public void testAddIssuerName1() {
+        X509CRLSelector selector = new X509CRLSelector();
+        String iss1 = "O=First Org.";
+        String iss2 = "O=Second Org.";
+        TestCRL crl1 = new TestCRL(new X500Principal(iss1));
+        TestCRL crl2 = new TestCRL(new X500Principal(iss2));
+
+        try {
+            selector.addIssuerName(iss1);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl1));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl2));
+        try {
+            selector.addIssuerName(iss2);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl2));
+    }
+
+    /**
+     * addIssuerName(byte[] name) method testing.
+     * Tests if CRLs with specified issuers match the selector,
+     * and if not specified issuer does not match the selector.
+     */
+    public void testAddIssuerName2() {
+        X509CRLSelector selector = new X509CRLSelector();
+        byte[] iss1 = new byte[]
+            //manually obtained DER encoding of "O=First Org." issuer name;
+            {48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
+                70, 105, 114, 115, 116, 32, 79, 114, 103, 46};
+        byte[] iss2 = new byte[]
+            //manually obtained DER encoding of "O=Second Org." issuer name;
+            {48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
+            83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46};
+        TestCRL crl1 = new TestCRL(new X500Principal(iss1));
+        TestCRL crl2 = new TestCRL(new X500Principal(iss2));
+
+        try {
+            selector.addIssuerName(iss1);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl1));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl2));
+        try {
+            selector.addIssuerName(iss2);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl2));
+    }
+
+    /**
+     * setMinCRLNumber(BigInteger minCRL) method testing.
+     * Tests if CRLs with any crl number value match the selector in the case of
+     * null crlNumber criteria, if specified minCRL value matches the selector,
+     * and if CRL with inappropriate crlNumber value does not match the selector. 
+     */
+    public void testSetMinCRLNumber() {
+        X509CRLSelector selector = new X509CRLSelector();
+        BigInteger minCRL = new BigInteger("10000");
+        TestCRL crl = new TestCRL(minCRL);
+
+        selector.setMinCRLNumber(null);
+        assertTrue("Any CRL should match in the case of null minCRLNumber.",
+                                            selector.match(crl));
+        selector.setMinCRLNumber(minCRL);
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl));
+        selector.setMinCRLNumber(new BigInteger("10001"));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl));
+    }
+
+    /**
+     * setMaxCRLNumber(BigInteger maxCRL) method testing.
+     * Tests if CRLs with any crl number value match the selector in the case of
+     * null crlNumber criteria, if specified maxCRL value matches the selector,
+     * and if CRL with inappropriate crlNumber value does not match the selector. 
+     */
+    public void testSetMaxCRLNumber() {
+        X509CRLSelector selector = new X509CRLSelector();
+        BigInteger maxCRL = new BigInteger("10000");
+        TestCRL crl = new TestCRL(maxCRL);
+
+        selector.setMaxCRLNumber(null);
+        assertTrue("Any CRL should match in the case of null minCRLNumber.",
+                                            selector.match(crl));
+        selector.setMaxCRLNumber(maxCRL);
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl));
+        selector.setMaxCRLNumber(new BigInteger("9999"));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl));
+    }
+
+    /**
+     * setDateAndTime(Date dateAndTime) method testing.
+     * Tests if CRLs with any update dates match the selector in the case of
+     * null dateAndTime criteria, if correct dates match and incorrect 
+     * do not match the selector.
+     */
+    public void testSetDateAndTime() {
+        X509CRLSelector selector = new X509CRLSelector();
+        TestCRL crl = new TestCRL(new Date(200), new Date(300));
+        selector.setDateAndTime(null);
+        assertTrue("Any CRL should match in the case of null dateAndTime.",
+                                            selector.match(crl));
+        selector.setDateAndTime(new Date(200));
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl));
+        selector.setDateAndTime(new Date(250));
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl));
+        selector.setDateAndTime(new Date(300));
+        assertTrue("The CRL should match the selection criteria.",
+                                            selector.match(crl));
+        selector.setDateAndTime(new Date(150));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl));
+        selector.setDateAndTime(new Date(350));
+        assertFalse("The CRL should not match the selection criteria.",
+                                            selector.match(crl));
+    }
+
+    /**
+     * getIssuers() method testing.
+     * Tests if the method return null in the case of not specified issuers,
+     * if the returned collection corresponds to the specified issuers and
+     * this collection is unmodifiable.
+     */
+    public void testGetIssuers() {
+        X509CRLSelector selector = new X509CRLSelector();
+        X500Principal iss1 = new X500Principal("O=First Org.");
+        X500Principal iss2 = new X500Principal("O=Second Org.");
+        X500Principal iss3 = new X500Principal("O=Third Org.");
+        assertNull("The collection should be null.",
+                                        selector.getIssuers());
+        selector.addIssuer(iss1);
+        selector.addIssuer(iss2);
+        Collection result = selector.getIssuers();
+        try {
+            result.add(iss3);
+            fail("The returned collection should be unmodifiable.");
+        } catch (UnsupportedOperationException e) {
+        }
+        assertTrue("The collection should contain the specified DN.",
+                                            result.contains(iss2));
+    }
+
+    /**
+     * getIssuerNames() method testing.
+     * Tests if the method return null in the case of not specified issuers,
+     * if the returned collection corresponds to the specified issuers.
+     */
+    public void testGetIssuerNames() {
+        X509CRLSelector selector = new X509CRLSelector();
+        byte[] iss1 = new byte[]
+            //manually obtained DER encoding of "O=First Org." issuer name;
+            {48, 21, 49, 19, 48, 17, 6, 3, 85, 4, 10, 19, 10,
+                70, 105, 114, 115, 116, 32, 79, 114, 103, 46};
+        byte[] iss2 = new byte[]
+            //manually obtained DER encoding of "O=Second Org." issuer name;
+            {48, 22, 49, 20, 48, 18, 6, 3, 85, 4, 10, 19, 11,
+            83, 101, 99, 111, 110, 100, 32, 79, 114, 103, 46};
+        assertNull("The collection should be null.",
+                                        selector.getIssuerNames());
+        try {
+            selector.addIssuerName(iss1);
+            selector.addIssuerName(iss2);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail("Unexpected IOException was thrown.");
+        }
+        Collection result = selector.getIssuerNames();
+        assertEquals("The collection should contain all of the specified DNs.",
+                                                2, result.size());
+    }
+
+    /**
+     * getMinCRL() method testing.
+     * Tests if the method return null in the case of not specified minCRL 
+     * criteria, and if the returned value corresponds to the specified one.
+     */
+    public void testGetMinCRL() {
+        X509CRLSelector selector = new X509CRLSelector();
+        assertNull("Initially the minCRL should be null.",
+                                        selector.getMinCRL());
+        BigInteger minCRL = new BigInteger("10000");
+        selector.setMinCRLNumber(minCRL);
+        assertTrue("The result should be equal to specified.",
+                                        minCRL.equals(selector.getMinCRL()));
+    }
+
+    /**
+     * getMaxCRL() method testing.
+     * Tests if the method return null in the case of not specified maxCRL 
+     * criteria, and if the returned value corresponds to the specified one.
+     */
+    public void testGetMaxCRL() {
+        X509CRLSelector selector = new X509CRLSelector();
+        assertNull("Initially the maxCRL should be null.",
+                                        selector.getMaxCRL());
+        BigInteger maxCRL = new BigInteger("10000");
+        selector.setMaxCRLNumber(maxCRL);
+        assertTrue("The result should be equal to specified.",
+                                        maxCRL.equals(selector.getMaxCRL()));
+    }
+
+    /**
+     * getDateAndTime() method testing.
+     * Tests if the method return null in the case of not specified dateAndTime 
+     * criteria, and if the returned value corresponds to the specified one.
+     */
+    public void testGetDateAndTime() {
+        X509CRLSelector selector = new X509CRLSelector();
+        assertNull("Initially the dateAndTime criteria should be null.",
+                                        selector.getDateAndTime());
+        Date date = new Date(200);
+        selector.setDateAndTime(date);
+        assertTrue("The result should be equal to specified.",
+                                        date.equals(selector.getDateAndTime()));
+    }
+
+    /**
+     * match(CRL crl) method testing.
+     * Tests if the null object matches to the selector or not.
+     */
+    public void testMatch() {
+        X509CRLSelector selector = new X509CRLSelector();
+        assertFalse("The null object should not match", 
+                                        selector.match((X509CRL) null));
+    }
+
+    /**
+     * clone() method testing.
+     * Tests if the selector is cloned correctly: the crl which matche to
+     * the initial selector should match to the clone and the change of clone
+     * should not cause the change of initial selector.
+     */
+    public void testClone() {
+        X509CRLSelector selector = new X509CRLSelector();
+        X500Principal iss1 = new X500Principal("O=First Org.");
+        X500Principal iss2 = new X500Principal("O=Second Org.");
+        X500Principal iss3 = new X500Principal("O=Third Org.");
+        BigInteger minCRL = new BigInteger("10000");
+        BigInteger maxCRL = new BigInteger("10000");
+        Date date = new Date(200);
+
+        selector.addIssuer(iss1);
+        selector.addIssuer(iss2);
+        selector.setMinCRLNumber(minCRL);
+        selector.setMaxCRLNumber(maxCRL);
+        selector.setDateAndTime(date);
+
+        X509CRLSelector clone = (X509CRLSelector) selector.clone();
+        TestCRL crl = new TestCRL(iss1);
+        crl.setCrlNumber(minCRL);
+        crl.setUpdateDates(new Date(200), new Date(200));
+        assertTrue("The specified CRL should match the clone selector.",
+                    selector.match(crl));
+
+        clone.addIssuer(iss3);
+        assertFalse("The changes of the clone selector should not cause "
+                    + "the changes of initial object", 
+                                    selector.getIssuerNames().size() == 3);
+    }
+
+    public void testToString() {
+        X509CRLSelector selector = new X509CRLSelector();
+        X500Principal iss1 = new X500Principal("O=First Org.");
+        X500Principal iss2 = new X500Principal("O=Second Org.");
+        BigInteger minCRL = new BigInteger("10000");
+        BigInteger maxCRL = new BigInteger("10000");
+        Date date = new Date(200);
+
+        selector.addIssuer(iss1);
+        selector.addIssuer(iss2);
+        selector.setMinCRLNumber(minCRL);
+        selector.setMaxCRLNumber(maxCRL);
+        selector.setDateAndTime(date);
+
+        assertNotNull("The result should not be null.", selector.toString());
+    }
+
+    public static Test suite() {
+        return new TestSuite(X509CRLSelectorTest.class);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+}
+



Mime
View raw message