harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r392891 [1/5] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/auth/make/common/ modules/auth/src/test/java/common/tests/ modules/auth/src/test/java/common/tests/api/ modules/auth/src/test/java/common/tests/api/javax/ modules/...
Date Mon, 10 Apr 2006 05:38:38 GMT
Author: mloenko
Date: Sun Apr  9 22:38:31 2006
New Revision: 392891

URL: http://svn.apache.org/viewcvs?rev=392891&view=rev
Log:
Intergation of auth, crypto, and security parts of HARMONY-88 
(Contribution of code and unit tests for jndi, logging, prefs and sql plus unit tests only for beans, crypto, math, regex and security)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/x500/
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/x500/X500PrincipalTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlContextTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControllerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AllPermissionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/BasicPermissionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/CodeSourceTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/DigestExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/DigestInputStreamTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/DigestOutputStreamTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/DomainCombinerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/GeneralSecurityExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/IdentityScopeTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/IdentityTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/InvalidAlgorithmParameterExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/InvalidKeyExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/InvalidParameterExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/KeyExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/KeyFactoryTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/KeyManagementExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/KeyPairGeneratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/KeyStoreExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/KeyStoreTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/MessageDigestTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/NoSuchAlgorithmExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/NoSuchProviderExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PermissionCollectionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PermissionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PermissionsTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PolicyTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrincipalTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrivilegedActionExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureClassLoaderTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureRandomTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignerTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/AclNotFoundExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/LastOwnerExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/NotOwnerExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateEncodingExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateFactoryTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLEntryTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CRLTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/X509CertificateTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/spec/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/spec/EncodedKeySpecTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/PermissionCollection/
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/PermissionCollection/keystore.bks   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/PermissionCollection/mypermissionBKS.jar   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/PermissionCollection/signedBKS.jar   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/hyts_badpem.cer
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/hyts_certificate_PEM.txt
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/resources/hyts_ks.bks   (with props)
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetLocal.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetResource.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderJCE.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderRSA.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderTrust.java
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestProvider.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/make/build-test.xml
    incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml

Modified: incubator/harmony/enhanced/classlib/trunk/make/build-test.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/make/build-test.xml?rev=392891&r1=392890&r2=392891&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/make/build-test.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/make/build-test.xml Sun Apr  9 22:38:31 2006
@@ -33,7 +33,7 @@
 
 	<!-- this list of components to test will grow to eventually be all modules -->
 	<target name="test-all"
-		depends="clean, test-luni, test-archive, test-text, test-nio, test-xnet, test-nio_char, test-logging, test-jndi, test-sql, test-prefs, test-beans, test-math, test-crypto, test-auth, gen-report">
+		depends="clean, test-security, test-luni, test-archive, test-text, test-nio, test-xnet, test-nio_char, test-logging, test-jndi, test-sql, test-prefs, test-beans, test-math, test-crypto, test-auth, gen-report">
 	</target>
 
 	<target name="clean">
@@ -153,13 +153,13 @@
             <ant antfile="make/build.xml" dir="modules/math" target="test" />
 	</target>
 
-	<target name="test-security">
+	<target name="test-security" depends="compile-support">
 	
-        <echo message="=================================="/>
-        <echo message="Running tests for module security"/>
-        <echo message="=================================="/>
+            <echo message="=================================="/>
+            <echo message="Running tests for module security"/>
+            <echo message="=================================="/>
 
-        <ant antfile="make/build.xml" dir="modules/security" target="test"/>
+            <ant antfile="make/build.xml" dir="modules/security" target="test"/>
 	</target>
 
 	<target name="gen-report">

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml?rev=392891&r1=392890&r2=392891&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/make/common/build.xml Sun Apr  9 22:38:31 2006
@@ -132,6 +132,7 @@
 					<exclude name="javax/security/auth/login/serialization/SerAccountExpiredExceptionTest.java"/>
 					<exclude name="javax/security/auth/login/serialization/SerCredentialExpiredExceptionTest.java"/>
 					<exclude name="javax/security/auth/x500/X500PrincipalTest.java" />
+					<exclude name="tests/api/javax/security/auth/x500/X500PrincipalTest.java" />
 
 				</fileset>
 			</batchtest>

Added: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/x500/X500PrincipalTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/x500/X500PrincipalTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/x500/X500PrincipalTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/tests/api/javax/security/auth/x500/X500PrincipalTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,50 @@
+/* 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.
+ */
+
+package tests.api.javax.security.auth.x500;
+
+import javax.security.auth.x500.X500Principal;
+
+public class X500PrincipalTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests javax.security.auth.x500.X500Principal#X500Principal(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		X500Principal principal = new X500Principal(
+				"CN=Hermione Granger, O=Apache Software Foundation, OU=Harmony, L=Hogwarts, ST=Hants, C=GB");
+		String name = principal.getName();
+		String expectedOuput = "CN=Hermione Granger,O=Apache Software Foundation,OU=Harmony,L=Hogwarts,ST=Hants,C=GB";
+		assertEquals("Output order precedence problem", expectedOuput, name);
+	}
+
+	/**
+	 * @tests javax.security.auth.x500.X500Principal#getName(java.lang.String)
+	 */
+	public void test_getNameLjava_lang_String() {
+		X500Principal principal = new X500Principal(
+				"CN=Dumbledore, OU=Administration, O=Hogwarts School, C=GB");
+		String canonical = principal.getName(X500Principal.CANONICAL);
+		String expected = "cn=dumbledore,ou=administration,o=hogwarts school,c=gb";
+		assertEquals("CANONICAL output differs from expected result", expected,
+				canonical);
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+}
\ No newline at end of file

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/make/common/build.xml?rev=392891&r1=392890&r2=392891&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/make/common/build.xml Sun Apr  9 22:38:31 2006
@@ -61,8 +61,9 @@
                         <pathelement location="${hy.crypto}/../security/src/test/java/common"/>
                     </src>
 
+                    <include name="tests/api/javax/crypto/**/*.java" />
                     <include name="javax/crypto/**/*.java" />
-                    <include name="org/apache/harmony/crypto/internal/*Test.java" />
+                    <include name="org/apache/harmony/crypto/**/*Test.java" />
                     <include name="org/apache/harmony/security/test/**/*" />
                     <exclude name="**/SecurityTest.java"/>
 
@@ -71,6 +72,7 @@
                             <include name="**/*.jar" />
                         </fileset>
                     </bootclasspath>
+                    <classpath location="../../../../build/tests" />
 		</javac>
 	</target>
 
@@ -100,18 +102,22 @@
 			<!-- to pick up junit.jar               -->
 			<!-- FIXME: package access tests and    -->
 			<!-- public API tests must be separated -->
-			<jvmarg value="-Xbootclasspath/a:${hy.crypto.bin.test}${path.separator}../../../../${junit.jar}"/>
+			<jvmarg value="-Xbootclasspath/a:${hy.crypto.bin.test}${path.separator}../../../../${junit.jar}${path.separator}../../../../build/tests"/>
 
 			<formatter type="xml" />
 
 			<batchtest todir="${hy.tests.reports}" haltonfailure="no">
 				<fileset dir="${hy.crypto.src.test.java}">
 					<include name="**/*Test.java"/>
+
+					<!-- Harmony exclude list -->
+					<exclude name="tests/api/javax/crypto/CipherTest.java"/>
 				</fileset>
 			</batchtest>
 		</junit>
 	</target>
 	
+
 	
 	<target name="copy.resources">
 		<!-- Nothing for CRYPTO -->

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/java/tests/api/javax/crypto/CipherTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,635 @@
+/* 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.
+ */
+
+package tests.api.javax.crypto;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.AlgorithmParameters;
+import java.security.Key;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.spec.AlgorithmParameterSpec;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESedeKeySpec;
+import javax.crypto.spec.IvParameterSpec;
+
+import tests.support.resource.Support_Resources;
+
+public class CipherTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests javax.crypto.Cipher#getInstance(java.lang.String)
+	 */
+	public void test_getInstanceLjava_lang_String() {
+		try {
+			Cipher cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding");
+			assertNotNull("Received a null Cipher instance", cipher);
+		} catch (Exception e) {
+			fail("Could not find cipher");
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getInstance(java.lang.String,
+	 *        java.lang.String)
+	 */
+	public void test_getInstanceLjava_lang_StringLjava_lang_String() {
+		try {
+			Provider[] providers = Security.getProviders("Cipher.DES");
+			if (providers != null) {
+				for (int i = 0; i < providers.length; i++) {
+					Cipher cipher = Cipher.getInstance("DES", providers[i]
+							.getName());
+					assertNotNull("Cipher.getInstance() returned a null value",
+							cipher);
+
+					// Exception case
+					try {
+						cipher = Cipher.getInstance("DoBeDoBeDo", providers[i]);
+						fail("Should have thrown an NoSuchAlgorithmException");
+					} catch (NoSuchAlgorithmException e) {
+						// Expected
+					} catch (Exception e) {
+						fail("Expected an NoSuchAlgorithmException but got a "
+								+ e);
+					}
+				}// end for
+			} else {
+				fail("No installed providers support Cipher.DES");
+			}
+		} catch (Exception e) {
+			fail("Unexpected exception finding cipher : " + e);
+		}
+
+		// Exception case
+		try {
+			Cipher cipher = Cipher.getInstance("DES", (String) null);
+			fail("Should have thrown an IllegalArgumentException");
+		} catch (IllegalArgumentException e) {
+			// Expected
+		} catch (Exception e) {
+			fail("Expected an IllegalArgumentException but got a " + e);
+		}
+
+		// Exception case
+		try {
+			Cipher cipher = Cipher.getInstance("DES", "IHaveNotBeenConfigured");
+			fail("Should have thrown an NoSuchProviderException");
+		} catch (NoSuchProviderException e) {
+			// Expected
+		} catch (Exception e) {
+			fail("Expected an NoSuchProviderException but got a " + e);
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getInstance(java.lang.String,
+	 *        java.security.Provider)
+	 */
+	public void test_getInstanceLjava_lang_StringLjava_security_Provider() {
+		try {
+			Provider[] providers = Security.getProviders("Cipher.DES");
+			if (providers != null) {
+				for (int i = 0; i < providers.length; i++) {
+					Cipher cipher = Cipher.getInstance("DES", providers[i]);
+					assertNotNull("Cipher.getInstance() returned a null value",
+							cipher);
+				}// end for
+			} else {
+				fail("No installed providers support Cipher.DES");
+			}
+		} catch (Exception e) {
+			fail("Unexpected exception finding cipher : " + e);
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getProvider()
+	 */
+	public void test_getProvider() {
+		try {
+			Provider[] providers = Security.getProviders("Cipher.AES");
+			if (providers != null) {
+				for (int i = 0; i < providers.length; i++) {
+					Provider provider = providers[i];
+					Cipher cipher = Cipher.getInstance("AES", provider
+							.getName());
+					Provider cipherProvider = cipher.getProvider();
+					assertTrue("Cipher provider is not the same as that "
+							+ "provided as parameter to getInstance()",
+							cipherProvider.equals(provider));
+				}// end for
+			} else {
+				fail("No providers support Cipher.AES");
+			}
+		} catch (Exception e) {
+			fail("Unexpected exception " + e);
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getAlgorithm()
+	 */
+	public void test_getAlgorithm() {
+		final String algorithm = "DESede/CBC/PKCS5Padding";
+		try {
+			Cipher cipher = Cipher.getInstance(algorithm);
+			assertTrue("Cipher algorithm does not match", cipher.getAlgorithm()
+					.equals(algorithm));
+		} catch (Exception e) {
+			fail("Unexpected Exception");
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getBlockSize()
+	 */
+	public void test_getBlockSize() {
+		final String algorithm = "DESede/CBC/PKCS5Padding";
+		try {
+			Cipher cipher = Cipher.getInstance(algorithm);
+			assertTrue("Block size does not match", cipher.getBlockSize() == 8);
+		} catch (Exception e) {
+			fail("Unexpected Exception");
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getOutputSize(int)
+	 */
+	public void test_getOutputSizeI() {
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Caught a NoSuchAlgorithmException : " + e);
+			}
+			cipherKey = kg.generateKey();
+
+			cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding");
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr);
+		} catch (Exception e) {
+			fail("Setup failed");
+		}
+
+		// A 25-byte input could result in at least 4 8-byte blocks
+		int result = cipher.getOutputSize(25);
+		assertTrue("Output size too small", result > 31);
+
+		// A 8-byte input should result in 2 8-byte blocks
+		result = cipher.getOutputSize(8);
+		assertTrue("Output size too small", result > 15);
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getIV()
+	 * @tests javax.crypto.Cipher#init(int, java.security.Key,
+	 *        java.security.AlgorithmParameters)
+	 */
+	public void test_getIV() {
+		/*
+		 * If this test is changed, implement the following:
+		 * test_initILjava_security_KeyLjava_security_AlgorithmParameters()
+		 */
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		byte[] iv = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Unexpected NoSuchAlgorithmException : " + e);
+			}
+
+			cipherKey = kg.generateKey();
+
+			iv = new byte[8];
+			sr.nextBytes(iv);
+			AlgorithmParameters ap = AlgorithmParameters.getInstance(algorithm);
+			ap.init(iv, "RAW");
+
+			cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap);
+
+		} catch (Exception e) {
+			fail("Setup error");
+		}
+
+		byte[] cipherIV = cipher.getIV();
+
+		assertTrue("IVs differ", bytesArraysAreEqual(cipherIV, iv));
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#getParameters()
+	 * @tests javax.crypto.Cipher#init(int, java.security.Key,
+	 *        java.security.AlgorithmParameters, java.security.SecureRandom)
+	 */
+	public void test_getParameters() {
+
+		/*
+		 * If this test is changed, implement the following:
+		 * test_initILjava_security_KeyLjava_security_AlgorithmParametersLjava_security_SecureRandom()
+		 */
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		byte[] apEncoding = null;
+
+		byte[] iv = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Caught a NoSuchAlgorithmException : " + e);
+			}
+			cipherKey = kg.generateKey();
+
+			iv = new byte[8];
+			sr.nextBytes(iv);
+
+			AlgorithmParameters ap = AlgorithmParameters.getInstance("DESede");
+			ap.init(iv, "RAW");
+			apEncoding = ap.getEncoded("ASN.1");
+
+			cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ap, sr);
+
+		} catch (Exception e) {
+			fail("Setup error");
+		}
+
+		try {
+			byte[] cipherParmsEnc = cipher.getParameters().getEncoded("ASN.1");
+			assertTrue("Parameters differ", bytesArraysAreEqual(apEncoding,
+					cipherParmsEnc));
+		} catch (IOException e) {
+			fail("Parameter encoding problem");
+		}
+
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#init(int, java.security.Key)
+	 */
+	public void test_initILjava_security_Key() {
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		byte[] apEncoding = null;
+
+		byte[] iv = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Caught a NoSuchAlgorithmException : " + e);
+			}
+			cipherKey = kg.generateKey();
+
+			cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding");
+
+		} catch (Exception e) {
+			fail("Setup error");
+		}
+
+		try {
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey);
+		} catch (Exception e) {
+			fail("Unexpected exception");
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#init(int, java.security.Key,
+	 *        java.security.SecureRandom)
+	 */
+	public void test_initILjava_security_KeyLjava_security_SecureRandom() {
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		byte[] apEncoding = null;
+
+		byte[] iv = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Caught a NoSuchAlgorithmException : " + e);
+			}
+			cipherKey = kg.generateKey();
+
+			cipher = Cipher.getInstance(algorithm + "/ECB/PKCS5Padding");
+
+		} catch (Exception e) {
+			fail("Setup error");
+		}
+
+		try {
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey, sr);
+		} catch (Exception e) {
+			fail("Unexpected exception : " + e);
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#init(int, java.security.Key,
+	 *        java.security.spec.AlgorithmParameterSpec)
+	 */
+	public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpec() {
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		byte[] iv = null;
+		AlgorithmParameterSpec ivAVP = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Caught a NoSuchAlgorithmException : " + e);
+			}
+			cipherKey = kg.generateKey();
+
+			iv = new byte[8];
+			sr.nextBytes(iv);
+			ivAVP = new IvParameterSpec(iv);
+
+			cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
+		} catch (Exception e) {
+			fail("Setup error");
+		}
+
+		try {
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ivAVP);
+		} catch (Exception e) {
+			fail("Unexpected exception : " + e);
+		}
+
+		byte[] cipherIV = cipher.getIV();
+
+		assertTrue("IVs differ", bytesArraysAreEqual(cipherIV, iv));
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#init(int, java.security.Key,
+	 *        java.security.spec.AlgorithmParameterSpec,
+	 *        java.security.SecureRandom)
+	 */
+	public void test_initILjava_security_KeyLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() {
+		final String algorithm = "DESede";
+		final int keyLen = 168;
+
+		Key cipherKey = null;
+		SecureRandom sr = new SecureRandom();
+		Cipher cipher = null;
+
+		byte[] iv = null;
+		AlgorithmParameterSpec ivAVP = null;
+
+		try {
+			KeyGenerator kg = null;
+			try {
+				kg = KeyGenerator.getInstance(algorithm);
+				kg.init(keyLen, new SecureRandom());
+			} catch (NoSuchAlgorithmException e) {
+				fail("Caught a NoSuchAlgorithmException : " + e);
+			}
+			cipherKey = kg.generateKey();
+
+			iv = new byte[8];
+			sr.nextBytes(iv);
+			ivAVP = new IvParameterSpec(iv);
+
+			cipher = Cipher.getInstance(algorithm + "/CBC/PKCS5Padding");
+		} catch (Exception e) {
+			fail("Setup error");
+		}
+
+		try {
+			cipher.init(Cipher.ENCRYPT_MODE, cipherKey, ivAVP, sr);
+		} catch (Exception e) {
+			fail("Unexpected exception : " + e);
+		}
+
+		byte[] cipherIV = cipher.getIV();
+
+		assertTrue("IVs differ", bytesArraysAreEqual(cipherIV, iv));
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#update(byte[], int, int)
+	 */
+	public void test_update$BII() {
+		try {
+			for (int index = 1; index < 4; index++) {
+				Cipher c = null;
+				try {
+					c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding");
+				} catch (Exception e) {
+					fail("Caught unexpected exception : " + e);
+				}
+
+				byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test"
+						+ index + ".key");
+				DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial);
+				SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE");
+				Key k = skf.generateSecret(keySpec);
+
+				byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test"
+						+ index + ".iv");
+				IvParameterSpec iv = new IvParameterSpec(ivMaterial);
+
+				c.init(Cipher.DECRYPT_MODE, k, iv);
+
+				ByteArrayOutputStream baos = new ByteArrayOutputStream();
+				byte[] input = new byte[256];
+				String resPath = "hyts_" + "des-ede3-cbc.test" + index
+						+ ".ciphertext";
+				InputStream is = Support_Resources.getStream(resPath);
+
+				int bytesRead = is.read(input, 0, 256);
+				while (bytesRead > 0) {
+					byte[] output = c.update(input, 0, bytesRead);
+					if (output != null) {
+						baos.write(output);
+					}
+					bytesRead = is.read(input, 0, 256);
+				}
+
+				byte[] output = c.doFinal();
+				if (output != null) {
+					baos.write(output);
+				}
+
+				byte[] decipheredCipherText = baos.toByteArray();
+				is.close();
+
+				byte[] plaintextBytes = loadBytes("hyts_" + "des-ede3-cbc.test"
+						+ index + ".plaintext");
+				if (bytesArraysAreEqual(plaintextBytes, decipheredCipherText) == false) {
+					fail("Operation produced incorrect results");
+				}
+			}// end for
+		} catch (Exception e) {
+			fail("Unexpected exception : " + e);
+		}
+	}
+
+	/**
+	 * @tests javax.crypto.Cipher#doFinal()
+	 */
+	public void test_doFinal() {
+		try {
+			for (int index = 1; index < 4; index++) {
+				Cipher c = null;
+				try {
+					c = Cipher.getInstance("DESEDE/CBC/PKCS5Padding");
+				} catch (Exception e) {
+					fail("Caught unexpected exception : " + e);
+				}
+
+				byte[] keyMaterial = loadBytes("hyts_" + "des-ede3-cbc.test"
+						+ index + ".key");
+				DESedeKeySpec keySpec = new DESedeKeySpec(keyMaterial);
+				SecretKeyFactory skf = SecretKeyFactory.getInstance("DESEDE");
+				Key k = skf.generateSecret(keySpec);
+
+				byte[] ivMaterial = loadBytes("hyts_" + "des-ede3-cbc.test"
+						+ index + ".iv");
+				IvParameterSpec iv = new IvParameterSpec(ivMaterial);
+
+				c.init(Cipher.ENCRYPT_MODE, k, iv);
+
+				ByteArrayOutputStream baos = new ByteArrayOutputStream();
+				byte[] input = new byte[256];
+				String resPath = "hyts_" + "des-ede3-cbc.test" + index
+						+ ".plaintext";
+				InputStream is = Support_Resources.getStream(resPath);
+
+				int bytesRead = is.read(input, 0, 256);
+				while (bytesRead > 0) {
+					byte[] output = c.update(input, 0, bytesRead);
+					if (output != null) {
+						baos.write(output);
+					}
+					bytesRead = is.read(input, 0, 256);
+				}
+				byte[] output = c.doFinal();
+				if (output != null) {
+					baos.write(output);
+				}
+				byte[] encryptedPlaintext = baos.toByteArray();
+				is.close();
+
+				byte[] cipherText = loadBytes("hyts_" + "des-ede3-cbc.test"
+						+ index + ".cipherText");
+				if (!bytesArraysAreEqual(encryptedPlaintext, cipherText)) {
+					fail("Operation produced incorrect results");
+				}
+			}// end for
+		} catch (Exception e) {
+			fail("Unexpected exception : " + e);
+		}
+	}
+
+	private byte[] loadBytes(String resPath) {
+		try {
+			InputStream is = Support_Resources.getStream(resPath);
+
+			ByteArrayOutputStream out = new ByteArrayOutputStream();
+			byte[] buff = new byte[1024];
+			int readlen;
+			while ((readlen = is.read(buff)) > 0) {
+				out.write(buff, 0, readlen);
+			}
+			is.close();
+			return out.toByteArray();
+		} catch (IOException e) {
+			return null;
+		}
+	}
+
+	private boolean bytesArraysAreEqual(byte[] arr1, byte[] arr2) {
+		if (arr1.length != arr2.length) {
+			return false;
+		}
+
+		for (int i = 0; i < arr1.length; i++) {
+			if (arr1[i] != arr2[i]) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.ciphertext Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+!#oN{¦@
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.iv Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+žôQ2#P\
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.key Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+igêŽkXŒÜ´têyA#˜{ †ôö$
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test1.plaintext Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+߆
ÓC
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext?rev=392891&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.ciphertext
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.iv Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+@ö"З<
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.key Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+q’<»Å(GåâÁΡԑ€Iž:Æá¹'
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext?rev=392891&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test2.plaintext
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext?rev=392891&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.ciphertext
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.iv Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+÷–~ÞSr[	
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.key Sun Apr  9 22:38:31 2006
@@ -0,0 +1 @@
+ïÝ/]o³¨DÐεžPeɵ®à¸0?6
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext?rev=392891&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/resources/hyts_des-ede3-cbc.test3.plaintext
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml?rev=392891&r1=392890&r2=392891&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/make/common/build.xml Sun Apr  9 22:38:31 2006
@@ -61,6 +61,7 @@
 					<include name="**/*.jar" />
 				</fileset>
 			</bootclasspath>
+			<classpath location="../../../../build/tests" />
 		</javac>
 	</target>
 
@@ -105,6 +106,29 @@
 
 					<!-- Harmony exclude list -->
 					<exclude name="java/security/serialization/KeyPairTest.java"/>
+					<exclude name="tests/api/java/security/AccessControllerTest.java"/>
+					<exclude name="tests/api/java/security/AlgorithmParameterGeneratorTest.java"/>
+					<exclude name="tests/api/java/security/AlgorithmParametersTest.java"/>
+					<exclude name="tests/api/java/security/CodeSourceTest.java"/>
+					<exclude name="tests/api/java/security/DigestInputStreamTest.java"/>
+					<exclude name="tests/api/java/security/DigestOutputStreamTest.java"/>
+					<exclude name="tests/api/java/security/IdentityScopeTest.java"/>
+					<exclude name="tests/api/java/security/IdentityTest.java"/>
+					<exclude name="tests/api/java/security/KeyPairGeneratorTest.java"/>
+					<exclude name="tests/api/java/security/KeyStoreTest.java"/>
+					<exclude name="tests/api/java/security/PermissionCollectionTest.java"/>
+					<exclude name="tests/api/java/security/SecureClassLoaderTest.java"/>
+					<exclude name="tests/api/java/security/SecureRandomTest.java"/>
+					<exclude name="tests/api/java/security/SecurityTest.java"/>
+					<exclude name="tests/api/java/security/SignerTest.java"/>
+					<exclude name="tests/api/java/security/SignatureTest.java"/>
+					<exclude name="tests/api/java/security/cert/CertificateFactoryTest.java"/>
+					<exclude name="tests/api/java/security/cert/X509CertificateTest.java"/>
+					<exclude name="tests/api/java/security/cert/X509CRLEntryTest.java"/>
+					<exclude name="tests/api/java/security/cert/X509CRLTest.java"/>
+					<exclude name="tests/api/java/security/spec/EncodedKeySpecTest.java"/>
+					<exclude name="java/security/serialization/AccessControlExceptionTest.java"/>
+					<exclude name="java/security/serialization/InvalidParameterExceptionTest.java"/>
 
 				</fileset>
 			</batchtest>

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlContextTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlContextTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlContextTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlContextTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,95 @@
+/* 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.
+ */
+
+package tests.api.java.security;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.ProtectionDomain;
+import java.util.PropertyPermission;
+
+public class AccessControlContextTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.security.AccessControlContext#AccessControlContext(java.security.ProtectionDomain[])
+	 */
+	public void test_Constructor$Ljava_security_ProtectionDomain() {
+		// Test for method
+		// java.security.AccessControlContext(java.security.ProtectionDomain [])
+
+		// Create a permission which is not normally granted
+		final Permission perm = new PropertyPermission("java.class.path",
+				"read");
+		PermissionCollection col = perm.newPermissionCollection();
+		col.add(perm);
+		final ProtectionDomain pd = new ProtectionDomain(null, col);
+		AccessControlContext acc = new AccessControlContext(
+				new ProtectionDomain[] { pd });
+		try {
+			acc.checkPermission(perm);
+		} catch (SecurityException e) {
+			fail("Should have permission");
+		}
+
+		final boolean[] result = new boolean[] { false };
+		Thread th = new Thread(new Runnable() {
+			public void run() {
+				AccessControlContext acc = new AccessControlContext(
+						new ProtectionDomain[] { pd });
+				try {
+					acc.checkPermission(perm);
+					result[0] = true;
+				} catch (SecurityException e) {
+				}
+			}
+		});
+		th.start();
+		try {
+			th.join();
+		} catch (InterruptedException e) {
+			// ignore
+		}
+		assertTrue("Thread should have permission", result[0]);
+	}
+
+	/**
+	 * @tests java.security.AccessControlContext#AccessControlContext(java.security.AccessControlContext,
+	 *        java.security.DomainCombiner)
+	 */
+	public void test_ConstructorLjava_security_AccessControlContextLjava_security_DomainCombiner() {
+		AccessControlContext context = AccessController.getContext();
+		try {
+			new AccessControlContext(context, null);
+		} catch (NullPointerException e) {
+			fail("should not throw NullPointerException");
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControlExceptionTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,87 @@
+/* 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.
+ */
+
+package tests.api.java.security;
+
+import java.io.FilePermission;
+import java.security.AccessControlException;
+
+public class AccessControlExceptionTest extends junit.framework.TestCase {
+	FilePermission filePermission;
+
+	AccessControlException acException;
+
+	AccessControlException acException1;
+
+	/**
+	 * @tests java.security.AccessControlException#AccessControlException(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		// Test for method
+		// java.security.AccessControlException(java.lang.String)
+		assertTrue("AccessControlException's toString() should have returned "
+				+ "'java.security.AccessControlException: test message' but "
+				+ "returned: " + acException.toString(), acException.toString()
+				.equals("java.security.AccessControlException: test message"));
+	}
+
+	/**
+	 * @tests java.security.AccessControlException#AccessControlException(java.lang.String,
+	 *        java.security.Permission)
+	 */
+	public void test_ConstructorLjava_lang_StringLjava_security_Permission() {
+		// Test for method
+		// java.security.AccessControlException(java.lang.String,
+		// java.security.Permission)
+		assertTrue("AccessControlException's toString() should have returned "
+				+ "'java.security.AccessControlException: test message "
+				+ "(java.io.FilePermission /* read)' but returned: "
+				+ acException1.toString(), acException1.toString().equals(
+				"java.security.AccessControlException: test message"));
+	}
+
+	/**
+	 * @tests java.security.AccessControlException#getPermission()
+	 */
+	public void test_getPermission() {
+		// Test for method java.security.Permission
+		// java.security.AccessControlException.getPermission()
+		// make sure getPermission returns null when it's not set
+		assertTrue(
+				"getPermission should have returned null if no permission was set",
+				acException.getPermission() == null);
+		assertTrue(
+				"getPermission should have returned the permission we assigned to it",
+				acException1.getPermission() == filePermission);
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+		filePermission = new FilePermission("/*", "read");
+		acException = new AccessControlException("test message");
+		acException1 = new AccessControlException("test message",
+				filePermission);
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControllerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControllerTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControllerTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AccessControllerTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,65 @@
+/* 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.
+ */
+
+package tests.api.java.security;
+
+import java.security.AccessController;
+import java.security.AllPermission;
+import java.security.PrivilegedAction;
+
+public class AccessControllerTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.security.AccessController#doPrivileged(java.security.PrivilegedAction)
+	 */
+	public void test_doPrivilegedLjava_security_PrivilegedAction() {
+		// Test for method java.lang.Object
+		// java.security.AccessController.doPrivileged(java.security.PrivilegedAction)
+
+		// Pass fail flag...
+		Boolean pass;
+
+		// First test 1 argument version (TBD).
+
+		// Then test 2 argument version. 
+		pass = (Boolean) AccessController.doPrivileged(new PrivilegedAction() {
+			public Object run() {
+				try {
+					AccessController.checkPermission(new AllPermission());
+					return new Boolean(false);
+				} catch (SecurityException ex) {
+					return new Boolean(true);
+				}
+			}
+		}, null);
+		assertTrue("Got AllPermission by passing in a null PD", pass
+				.booleanValue());
+
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParameterGeneratorTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,246 @@
+/* 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.
+ */
+
+package tests.api.java.security;
+
+import java.math.BigInteger;
+import java.security.AlgorithmParameterGenerator;
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.spec.DSAParameterSpec;
+
+public class AlgorithmParameterGeneratorTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#generateParameters()
+	 */
+	public void test_generateParameters() {
+
+		fail("Takes ages. Problem with SecureRandom and stub math ?");
+		
+		// Test for method java.security.AlgorithmParameters
+		// java.security.AlgorithmParameterGenerator.generateParameters()
+		try {
+			AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
+					.getInstance("DSA");
+			gen.init(1024);
+			// WARNING - The next line can take MINUTES to run
+			AlgorithmParameters params = gen.generateParameters();
+			assertTrue("params is null", params != null);
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#getAlgorithm()
+	 */
+	public void test_getAlgorithm() {
+		// Test for method java.lang.String
+		// java.security.AlgorithmParameterGenerator.getAlgorithm()
+		try {
+			String alg = AlgorithmParameterGenerator.getInstance("DSA")
+					.getAlgorithm();
+			assertTrue("getAlgorithm ok", alg.equals("DSA"));
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#getInstance(java.lang.String)
+	 */
+	public void test_getInstanceLjava_lang_String() {
+		// Test for method java.security.AlgorithmParameterGenerator
+		// java.security.AlgorithmParameterGenerator.getInstance(java.lang.String)
+		try {
+			AlgorithmParameterGenerator.getInstance("DSA");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#getInstance(java.lang.String,
+	 *        java.lang.String)
+	 */
+	public void test_getInstanceLjava_lang_StringLjava_lang_String() {
+		// Test for method java.security.AlgorithmParameterGenerator
+		// java.security.AlgorithmParameterGenerator.getInstance(java.lang.String,
+		// java.lang.String)
+
+		// Opting for DSA here as it is pretty widely supported
+		try {
+			Provider[] provs = Security
+					.getProviders("AlgorithmParameterGenerator.DSA");
+
+			if (provs != null) {
+				for (int i = 0; i < provs.length; i++) {
+					Provider provider = provs[i];
+					AlgorithmParameterGenerator.getInstance("DSA", provider
+							.getName());
+				}// end for
+			} else {
+				fail("No providers support AlgorithmParameterGenerator.DSA");
+			}
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		} catch (NoSuchProviderException e) {
+			fail("getInstance did not find the provider");
+		}
+
+		// exception case - should throw IllegalArgumentException for null
+		// provider
+		try {
+			AlgorithmParameterGenerator.getInstance("DSA", (String) null);
+			fail("Should have thrown IllegalArgumentException");
+		} catch (IllegalArgumentException e) {
+			// Expected
+		} catch (Exception e) {
+			fail("Expected IllegalArgumentException for null provider "
+					+ "string, got " + e);
+		}
+
+		// exception case - should throw IllegalArgumentException for empty
+		// provider
+		try {
+			AlgorithmParameterGenerator.getInstance("DSA", "");
+			fail("Should have thrown IllegalArgumentException");
+		} catch (IllegalArgumentException e) {
+			// Expected
+		} catch (Exception e) {
+			fail("Expected IllegalArgumentException for empty provider "
+					+ "string, got " + e);
+		}
+
+		// exception case - should throw NoSuchProviderException
+		try {
+			AlgorithmParameterGenerator.getInstance("DSA", "IDontExist");
+			fail("Should have thrown NoSuchProviderException");
+		} catch (NoSuchProviderException e) {
+			// Expected
+		} catch (Exception e) {
+			fail("Expected NoSuchProviderException for non-existent "
+					+ "provider, got " + e);
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#getProvider()
+	 */
+	public void test_getProvider() {
+		// Test for method java.security.Provider
+		// java.security.AlgorithmParameterGenerator.getProvider()
+		try {
+			Provider p = AlgorithmParameterGenerator.getInstance("DSA")
+					.getProvider();
+			assertTrue("provider is null", p != null);
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#init(int)
+	 */
+	public void test_initI() {
+		// Test for method void
+		// java.security.AlgorithmParameterGenerator.init(int)
+		try {
+			AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
+					.getInstance("DSA");
+			gen.init(1024);
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#init(int,
+	 *        java.security.SecureRandom)
+	 */
+	public void test_initILjava_security_SecureRandom() {
+		// Test for method void
+		// java.security.AlgorithmParameterGenerator.init(int,
+		// java.security.SecureRandom)
+		try {
+			AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
+					.getInstance("DSA");
+			gen.init(1024, new SecureRandom());
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec)
+	 */
+	public void test_initLjava_security_spec_AlgorithmParameterSpec() {
+		// Test for method void
+		// java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec)
+		try {
+			DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
+					BigInteger.ONE, BigInteger.ONE);
+			AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
+					.getInstance("DSA");
+			gen.init(spec);
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm DSA");
+		} catch (InvalidAlgorithmParameterException e) {
+			fail("InvalidAlgorithmParameterException getting spec");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameterGenerator#init(java.security.spec.AlgorithmParameterSpec,
+	 *        java.security.SecureRandom)
+	 */
+	public void test_initLjava_security_spec_AlgorithmParameterSpecLjava_security_SecureRandom() {
+		// Test for method void
+		// java.security.AlgorithmParameterGenerator.init(java.security.spec.AlgorithmParameterSpec,
+		// java.security.SecureRandom)
+		try {
+			DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
+					BigInteger.ONE, BigInteger.ONE);
+			AlgorithmParameterGenerator gen = AlgorithmParameterGenerator
+					.getInstance("DSA");
+			gen.init(spec, new SecureRandom());
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm DSA");
+		} catch (InvalidAlgorithmParameterException e) {
+			fail("InvalidAlgorithmParameterException getting spec");
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AlgorithmParametersTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,320 @@
+/* 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.
+ */
+
+package tests.api.java.security;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.AlgorithmParameters;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
+import java.security.spec.DSAParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.util.Arrays;
+
+public class AlgorithmParametersTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getAlgorithm()
+	 */
+	public void test_getAlgorithm() {
+		// Test for method java.lang.String
+		// java.security.AlgorithmParameters.getAlgorithm()
+		try {
+			String alg = AlgorithmParameters.getInstance("DSA").getAlgorithm();
+			assertTrue("provider is null", alg.equals("DSA"));
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getEncoded()
+	 */
+	public void test_getEncoded() {
+		// Test for method byte []
+		// java.security.AlgorithmParameters.getEncoded()
+		AlgorithmParameters params = null;
+		try {
+			params = AlgorithmParameters.getInstance("DSA");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+
+		byte[] enc = null;
+		try {
+			enc = params.getEncoded();
+			fail("should not get encoded from un-initialized instance");
+		} catch (IOException e) {
+			// expected
+		}
+
+		try {
+			params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
+					BigInteger.ONE));
+			enc = params.getEncoded();
+			assertTrue("encoded is null", enc != null);
+		} catch (InvalidParameterSpecException e) {
+			fail("can't pass DSAParameterSpec");
+		} catch (IOException e) {
+			fail("IOException when passing DSAParameterSpec");
+		} catch (Exception e) {
+			fail("Caught unexpected exception : " + e);
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getEncoded(java.lang.String)
+	 */
+	public void test_getEncodedLjava_lang_String() {
+		// Test for method byte []
+		// java.security.AlgorithmParameters.getEncoded(java.lang.String)
+		AlgorithmParameters params = null;
+		try {
+			params = AlgorithmParameters.getInstance("DSA");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+
+		byte[] enc = null;
+		try {
+			params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
+					BigInteger.ONE));
+			enc = params.getEncoded("JUNK");
+			fail("bogus format should have resulted in IOException");
+		} catch (InvalidParameterSpecException e) {
+			fail("cant pass DSAParameterSpec");
+		} catch (IOException e) {
+			// expected
+		}
+
+		try {
+			enc = params.getEncoded("ASN.1");
+			assertTrue("ANS.1 should be supported", enc != null);
+		} catch (IOException e) {
+			fail("IOException with ASN.1");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getInstance(java.lang.String)
+	 */
+	public void test_getInstanceLjava_lang_String() {
+		// Test for method java.security.AlgorithmParameters
+		// java.security.AlgorithmParameters.getInstance(java.lang.String)
+		try {
+			AlgorithmParameters.getInstance("DSA");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getInstance(java.lang.String,
+	 *        java.lang.String)
+	 */
+	public void test_getInstanceLjava_lang_StringLjava_lang_String() {
+		// Test for method java.security.AlgorithmParameters
+		// java.security.AlgorithmParameters.getInstance(java.lang.String,
+		// java.lang.String)
+
+		// Opting for DSA here as it is pretty widely supported
+		try {
+			Provider[] provs = Security.getProviders("AlgorithmParameters.DSA");
+
+			if (provs != null) {
+				for (int i = 0; i < provs.length; i++) {
+					Provider provider = provs[i];
+					AlgorithmParameters.getInstance("DSA", provider.getName());
+				}// end for
+			} else {
+				fail("No providers support AlgorithmParameters.DSA");
+			}
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		} catch (NoSuchProviderException e) {
+			fail("getInstance did not find the provider");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getParameterSpec(java.lang.Class)
+	 */
+	public void test_getParameterSpecLjava_lang_Class() {
+		// Test for method java.security.spec.AlgorithmParameterSpec
+		// java.security.AlgorithmParameters.getParameterSpec(java.lang.Class)
+		AlgorithmParameters params = null;
+		try {
+			params = AlgorithmParameters.getInstance("DSA");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+
+		DSAParameterSpec dsaps = new DSAParameterSpec(BigInteger.ONE,
+				BigInteger.ONE, BigInteger.ONE);
+		try {
+			params.init(dsaps);
+		} catch (InvalidParameterSpecException e) {
+			fail("cant pass DSAParameterSpec");
+		}
+
+		try {
+			DSAParameterSpec spec = (DSAParameterSpec) params
+					.getParameterSpec(dsaps.getClass());
+			assertTrue("param spec is null", spec != null);
+			assertTrue("p is wrong ", spec.getP().equals(BigInteger.ONE));
+			assertTrue("q is wrong ", spec.getQ().equals(BigInteger.ONE));
+			assertTrue("g is wrong ", spec.getG().equals(BigInteger.ONE));
+		} catch (InvalidParameterSpecException e) {
+			fail("InvalidParameterSpecException getting spec");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#getProvider()
+	 */
+	public void test_getProvider() {
+		// Test for method java.security.Provider
+		// java.security.AlgorithmParameters.getProvider()
+		try {
+			Provider p = AlgorithmParameters.getInstance("DSA").getProvider();
+			assertTrue("provider is null", p != null);
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#init(byte[])
+	 */
+	public void test_init$B() {
+		// Test for method void java.security.AlgorithmParameters.init(byte [])
+		try {
+			AlgorithmParameters params = AlgorithmParameters.getInstance("DSA");
+			params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
+					BigInteger.ONE));
+			byte[] encoded = params.getEncoded();
+			assertTrue("encoded spec is null", encoded != null);
+			AlgorithmParameters params2 = AlgorithmParameters
+					.getInstance("DSA");
+			params2.init(encoded);
+			byte[] encodedAfter = params2.getEncoded();
+			assertTrue("param encoded is different", Arrays.equals(encoded,
+					encodedAfter));
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		} catch (IOException e) {
+			fail("IOException getting encoded");
+		} catch (InvalidParameterSpecException e) {
+			fail("cant pass DSAParameterSpec");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#init(byte[], java.lang.String)
+	 */
+	public void test_init$BLjava_lang_String() {
+		// Test for method void java.security.AlgorithmParameters.init(byte [],
+		// java.lang.String)
+		try {
+			AlgorithmParameters params = AlgorithmParameters.getInstance("DSA");
+			params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
+					BigInteger.ONE));
+			byte[] encoded = params.getEncoded();
+			assertTrue("encoded spec is null", encoded != null);
+			AlgorithmParameters params2 = AlgorithmParameters
+					.getInstance("DSA");
+			params2.init(encoded, "ASN.1");
+			byte[] encodedAfter = params2.getEncoded();
+			assertTrue("param encoded is different", Arrays.equals(encoded,
+					encodedAfter));
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		} catch (IOException e) {
+			fail("IOException getting encoded");
+		} catch (InvalidParameterSpecException e) {
+			fail("cant pass DSAParameterSpec");
+		}
+
+		try {
+			AlgorithmParameters params = AlgorithmParameters.getInstance("DSA");
+			params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
+					BigInteger.ONE));
+			byte[] encoded = params.getEncoded();
+			assertTrue("encoded spec is null", encoded != null);
+			params.init(encoded, "DOUGLASMAWSON");
+			fail("unsupported format should have raised IOException");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		} catch (IOException e) {
+			// expected
+		} catch (InvalidParameterSpecException e) {
+			fail("cant pass DSAParameterSpec");
+		}
+
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#init(java.security.spec.AlgorithmParameterSpec)
+	 */
+	public void test_initLjava_security_spec_AlgorithmParameterSpec() {
+		// Test for method void
+		// java.security.AlgorithmParameters.init(java.security.spec.AlgorithmParameterSpec)
+		AlgorithmParameters params = null;
+		try {
+			params = AlgorithmParameters.getInstance("DSA");
+		} catch (NoSuchAlgorithmException e) {
+			fail("getInstance did not find algorithm");
+		}
+
+		try {
+			params.init(new DSAParameterSpec(BigInteger.ONE, BigInteger.ONE,
+					BigInteger.ONE));
+		} catch (InvalidParameterSpecException e) {
+			fail("cant pass DSAParameterSpec");
+		}
+	}
+
+	/**
+	 * @tests java.security.AlgorithmParameters#toString()
+	 */
+	public void test_toString() {
+		// Test for method java.lang.String
+		// java.security.AlgorithmParameters.toString()
+		try {
+			String str = AlgorithmParameters.getInstance("DSA").toString();
+			assertNull("toString should be null", str);
+		} catch (NoSuchAlgorithmException e) {
+			e.printStackTrace();
+			assertTrue("getInstance did not find algorithm", false);
+		}
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+}
\ No newline at end of file

Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AllPermissionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AllPermissionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AllPermissionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/AllPermissionTest.java Sun Apr  9 22:38:31 2006
@@ -0,0 +1,113 @@
+/* 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.
+ */
+
+package tests.api.java.security;
+
+import java.security.AllPermission;
+import java.security.SecurityPermission;
+
+public class AllPermissionTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.security.AllPermission#AllPermission()
+	 */
+	public void test_Constructor() {
+		// Test for method java.security.AllPermission()
+		AllPermission ap = new AllPermission();
+		assertEquals("Bogus name for AllPermission \"" + ap.getName() + "\".",
+				"<all permissions>", ap.getName());
+	}
+
+	/**
+	 * @tests java.security.AllPermission#AllPermission(java.lang.String,
+	 *        java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+		// Test for method java.security.AllPermission(java.lang.String,
+		// java.lang.String)
+		AllPermission ap = new AllPermission("Don't remember this stupid name",
+				"or this action");
+		assertEquals("Bogus name for AllPermission \"" + ap.getName() + "\".",
+				"<all permissions>", ap.getName());
+		assertEquals(
+				"AllPermission constructed with actions didn't ignore them.",
+				"<all actions>", ap.getActions());
+	}
+
+	/**
+	 * @tests java.security.AllPermission#equals(java.lang.Object)
+	 */
+	public void test_equalsLjava_lang_Object() {
+		// Test for method boolean
+		// java.security.AllPermission.equals(java.lang.Object)
+		assertTrue("Two AllPermissions not equal to each other.",
+				new AllPermission().equals(new AllPermission()));
+		assertTrue("AllPermission equals a SecurityPermission.",
+				!(new AllPermission().equals(new SecurityPermission("ugh!"))));
+	}
+
+	/**
+	 * @tests java.security.AllPermission#getActions()
+	 */
+	public void test_getActions() {
+		AllPermission ap = new AllPermission();
+		// Test for method java.lang.String
+		// java.security.AllPermission.getActions()
+		assertTrue("AllPermission has non-empty actions. (" + ap.getActions()
+				+ ")", ap.getActions().equals("<all actions>"));
+	}
+
+	/**
+	 * @tests java.security.AllPermission#hashCode()
+	 */
+	public void test_hashCode() {
+		final int ALLPERMISSION_HASH = 1;
+		// Test for method int java.security.AllPermission.hashCode()
+		AllPermission TestAllPermission = new AllPermission();
+		assertTrue("AllPermission hashCode is wrong. Should have been "
+				+ ALLPERMISSION_HASH + " but was "
+				+ TestAllPermission.hashCode(),
+				TestAllPermission.hashCode() == ALLPERMISSION_HASH);
+	}
+
+	/**
+	 * @tests java.security.AllPermission#implies(java.security.Permission)
+	 */
+	public void test_impliesLjava_security_Permission() {
+		// Test for method boolean
+		// java.security.AllPermission.implies(java.security.Permission)
+		assertTrue("AllPermission does not imply a AllPermission.",
+				new AllPermission().implies(new AllPermission()));
+		assertTrue("AllPermission does not imply a SecurityPermission.",
+				new AllPermission().implies(new SecurityPermission("ugh!")));
+		assertTrue("SecurityPermission implies AllPermission.",
+				!(new SecurityPermission("ugh!").implies(new AllPermission())));
+	}
+
+	/**
+	 * Sets up the fixture, for example, open a network connection. This method
+	 * is called before a test is executed.
+	 */
+	protected void setUp() {
+	}
+
+	/**
+	 * Tears down the fixture, for example, close a network connection. This
+	 * method is called after a test is executed.
+	 */
+	protected void tearDown() {
+	}
+
+}
\ No newline at end of file



Mime
View raw message