You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/04/10 07:38:38 UTC
svn commit: r392891 [4/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/...
Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PolicyTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PolicyTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PolicyTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PolicyTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,99 @@
+/* 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.CodeSource;
+import java.security.PermissionCollection;
+import java.security.Policy;
+
+public class PolicyTest extends junit.framework.TestCase {
+
+ static class TestPolicy extends Policy {
+ public PermissionCollection getPermissions(CodeSource cs) {
+ return null;
+ }
+
+ public void refresh() {
+ }
+ }
+
+ /**
+ * @tests java.security.Policy#Policy()
+ */
+ public void test_Constructor() {
+ try {
+ new TestPolicy();
+ } catch (Exception e) {
+ fail("Caught exception: " + e + " during construction");
+ }
+ }
+
+ /**
+ * @tests java.security.Policy#getPolicy()
+ */
+ public void test_getPolicy() {
+ try {
+ assertNotNull("Got a null system security policy", Policy
+ .getPolicy());
+ } catch (Exception e) {
+ fail("Caught a " + e.toString() + " exception!");
+ }
+
+ try {
+ // set a security manager and then try getting the policy
+ System.setSecurityManager(new SecurityManager());
+
+ assertNotNull("Got a null system security policy", Policy
+ .getPolicy());
+ fail("We shouldn't have been able to get the policy "
+ + "with a SecurityManager in place!");
+ } catch (Exception e) {
+ assertTrue("Policy.getPolicy() should have thrown "
+ + "a: java.security.AccessControlException but "
+ + "instead threw a: " + e.toString(),
+ e instanceof java.security.AccessControlException);
+ } finally {
+ System.setSecurityManager(null);
+ }
+ }
+
+ /**
+ * @tests java.security.Policy#setPolicy(java.security.Policy)
+ */
+ public void test_setPolicyLjava_security_Policy() {
+ // get the policy
+ Policy sysPolicy = Policy.getPolicy();
+ try {
+ Policy newPolicy = new TestPolicy();
+ // set the policy
+ Policy.setPolicy(newPolicy);
+ // make sure it was set
+ assertEquals("Policy could not be set!", newPolicy, Policy
+ .getPolicy());
+ } catch (Exception e) {
+ fail("Unexpected exception : " + e);
+ } finally {
+ // restore the policy
+ Policy.setPolicy(sysPolicy);
+ }
+ }
+
+ protected void setUp() {
+ }
+
+ 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/PrincipalTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrincipalTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrincipalTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrincipalTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,42 @@
+/* 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.Principal;
+
+import javax.security.auth.x500.X500Principal;
+
+public class PrincipalTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.Principal#equals(java.lang.Object)
+ */
+ public void test_equalsLjava_lang_Object() {
+ Principal xp1 = new X500Principal(
+ "C=US, ST=California, L=San Diego, O=Apache, OU=Project Harmony, CN=Test cert");
+ assertNotNull(xp1);
+ assertEquals(
+ "Unexpected name",
+ "C=US,ST=California,L=San Diego,O=Apache,OU=Project Harmony,CN=Test cert",
+ xp1.getName());
+ }
+
+ protected void setUp() {
+ }
+
+ 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/PrivilegedActionExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrivilegedActionExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrivilegedActionExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/PrivilegedActionExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,53 @@
+/* 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.security.PrivilegedActionException;
+
+public class PrivilegedActionExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.PrivilegedActionException#PrivilegedActionException(java.lang.Exception)
+ */
+ public void test_ConstructorLjava_lang_Exception() {
+ Exception e = new Exception("test exception");
+ PrivilegedActionException pe = new PrivilegedActionException(e);
+ assertEquals("Did not encapsulate test exception!", e, pe
+ .getException());
+
+ // try it with a null exception
+ pe = new PrivilegedActionException(null);
+ assertNull("Did not encapsulate null test exception properly!", pe
+ .getException());
+ }
+
+ /**
+ * @tests java.security.PrivilegedActionException#getException()
+ */
+ public void test_getException() {
+ Exception e = new IOException("test IOexception");
+ PrivilegedActionException pe = new PrivilegedActionException(e);
+ assertEquals("Did not encapsulate test IOexception!", e, pe
+ .getException());
+ }
+
+ protected void setUp() {
+ }
+
+ 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/ProviderExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,56 @@
+/* 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.ProviderException;
+
+public class ProviderExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.ProviderException#ProviderException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.ProviderException()
+ ProviderException e = new ProviderException();
+ assertEquals("Failed toString test for constructed instance",
+ "java.security.ProviderException", e.toString());
+ }
+
+ /**
+ * @tests java.security.ProviderException#ProviderException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method java.security.ProviderException(java.lang.String)
+ ProviderException e = new ProviderException("test message");
+ assertTrue("Failed toString test for constructed instance", e
+ .toString().equals(
+ "java.security.ProviderException: test message"));
+ }
+
+ /**
+ * 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/ProviderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/ProviderTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,106 @@
+/* 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.Provider;
+
+public class ProviderTest extends junit.framework.TestCase {
+
+ class TestProvider extends Provider {
+ TestProvider(String name, double version, String info) {
+ super(name, version, info);
+ }
+ }
+
+ TestProvider provTest = new TestProvider("provTest", 1.2,
+ "contains nothings, purely for testing the class");
+
+ /**
+ * @tests java.security.Provider#entrySet()
+ */
+ public void test_entrySet() {
+ // test method of java.security.provider.entrySet
+ provTest.put("test.prop", "this is a test property");
+ try {
+ provTest.entrySet().add("another property value");
+ fail("was able to modify the entrySet");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests java.security.Provider#getInfo()
+ */
+ public void test_getInfo() {
+ // test method of java.security.provider.getInfo
+ assertEquals("the information of the provider is not stored properly",
+ "contains nothings, purely for testing the class", provTest
+ .getInfo());
+ }
+
+ /**
+ * @tests java.security.Provider#getName()
+ */
+ public void test_getName() {
+ // test method of java.security.provider.getName
+ assertEquals("the name of the provider is not stored properly",
+ "provTest", provTest.getName());
+ }
+
+ /**
+ * @tests java.security.Provider#getVersion()
+ */
+ public void test_getVersion() {
+ // test method of java.security.provider.getVersion
+ assertEquals("the version of the provider is not stored properly",
+ 1.2, provTest.getVersion(), 0);
+ }
+
+ /**
+ * @tests java.security.Provider#keySet()
+ */
+ public void test_keySet() {
+ // test method of java.security.provider.keySet
+ provTest.put("test.prop", "this is a test property");
+ try {
+ provTest.keySet().add("another property key");
+ fail("was able to modify the keySet");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests java.security.Provider#values()
+ */
+ public void test_values() {
+ // test method of java.security.provider.values
+ provTest.put("test.prop", "this is a test property");
+ try {
+ provTest.values().add("another property value");
+ fail("was able to modify the values collection");
+ } catch (UnsupportedOperationException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() {
+ }
+
+ 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/SecureClassLoaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureClassLoaderTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureClassLoaderTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureClassLoaderTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,76 @@
+/* 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.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.CodeSource;
+import java.security.PermissionCollection;
+import java.security.ProtectionDomain;
+import java.security.SecureClassLoader;
+import java.security.cert.Certificate;
+import java.util.Enumeration;
+import java.util.jar.JarFile;
+
+import tests.support.Support_GetLocal;
+
+public class SecureClassLoaderTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.SecureClassLoader#getPermissions(java.security.CodeSource)
+ */
+ public void test_getPermissionsLjava_security_CodeSource() {
+ class MyClassLoader extends SecureClassLoader {
+ public PermissionCollection getPerms() {
+ return super.getPermissions(new CodeSource(null,
+ (Certificate[]) null));
+ }
+
+ public Class define(String name, byte[] bytes) {
+ return defineClass(name, bytes, 0, bytes.length,
+ (ProtectionDomain) null);
+ }
+ };
+
+ MyClassLoader myloader = new MyClassLoader();
+ PermissionCollection pc = myloader.getPerms();
+ Enumeration e1 = pc.elements();
+ int count = 0;
+ while (e1.hasMoreElements()) {
+ e1.nextElement();
+ count++;
+ }
+ assertEquals("expected no permissions", 0, count);
+
+ byte[] bytes = null;
+ try {
+ File file = Support_GetLocal.getLocalFile("hyts_security.jar");
+ JarFile jar = new JarFile(file);
+ InputStream in = jar.getInputStream(jar
+ .getEntry("packA/SecurityTest.class"));
+ bytes = new byte[in.available()];
+ in.read(bytes);
+ in.close();
+ } catch (IOException e) {
+ fail("unexpected IOException : " + e);
+ }
+ Class c = myloader.define("packA.SecurityTest", bytes);
+ ProtectionDomain pd = c.getProtectionDomain();
+ assertNotNull("Expected dynamic policy", pd.getClassLoader());
+ assertNull("Expected null permissions", pd.getPermissions());
+ }
+}
\ No newline at end of file
Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureRandomTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureRandomTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureRandomTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecureRandomTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,174 @@
+/* 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.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+
+public class SecureRandomTest extends junit.framework.TestCase {
+
+ private static final byte[] SEED_BYTES = { (byte) 33, (byte) 15, (byte) -3,
+ (byte) 22, (byte) 77, (byte) -16, (byte) -33, (byte) 56 };
+
+ private static final int SEED_SIZE = 539;
+
+ private static final long SEED_VALUE = 5335486759L;
+
+ /**
+ * @tests java.security.SecureRandom#SecureRandom()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.SecureRandom()
+ try {
+ new SecureRandom();
+ } catch (Exception e) {
+ fail("Constructor threw exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#SecureRandom(byte[])
+ */
+ public void test_Constructor$B() {
+ // Test for method java.security.SecureRandom(byte [])
+ try {
+ new SecureRandom(SEED_BYTES);
+ } catch (Exception e) {
+ fail("Constructor threw exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#generateSeed(int)
+ */
+ public void test_generateSeedI() {
+ // Test for method byte [] java.security.SecureRandom.generateSeed(int)
+ byte[] seed = new SecureRandom().generateSeed(SEED_SIZE);
+ assertEquals("seed has incorrect size", SEED_SIZE, seed.length);
+ }
+
+ /**
+ * @tests java.security.SecureRandom#getInstance(java.lang.String)
+ */
+ public void test_getInstanceLjava_lang_String() {
+ // Test for method java.security.SecureRandom
+ // java.security.SecureRandom.getInstance(java.lang.String)
+ try {
+ SecureRandom.getInstance("SHA1PRNG");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find a SHA1PRNG algorithm");
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#getInstance(java.lang.String,
+ * java.lang.String)
+ */
+ public void test_getInstanceLjava_lang_StringLjava_lang_String() {
+ // Test for method java.security.SecureRandom
+ // java.security.SecureRandom.getInstance(java.lang.String,
+ // java.lang.String)
+ try {
+ Provider[] providers = Security
+ .getProviders("SecureRandom.SHA1PRNG");
+ if (providers != null) {
+ for (int i = 0; i < providers.length; i++) {
+ SecureRandom
+ .getInstance("SHA1PRNG", providers[i].getName());
+ }// end for
+ } else {
+ fail("No providers support SHA1PRNG");
+ }
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find a SHA1PRNG algorithm");
+ } catch (NoSuchProviderException e) {
+ fail("getInstance did not find the provider for SHA1PRNG");
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#getProvider()
+ */
+ public void test_getProvider() {
+ // Test for method java.security.Provider
+ // java.security.SecureRandom.getProvider()
+ Provider p = new SecureRandom().getProvider();
+ assertNotNull("SecureRandom provider is null", p);
+ }
+
+ /**
+ * @tests java.security.SecureRandom#getSeed(int)
+ */
+ public void test_getSeedI() {
+ // Test for method byte [] java.security.SecureRandom.getSeed(int)
+ byte[] seed = SecureRandom.getSeed(SEED_SIZE);
+ assertEquals("seed has incorrect size", SEED_SIZE, seed.length);
+ }
+
+ /**
+ * @tests java.security.SecureRandom#nextBytes(byte[])
+ */
+ public void test_nextBytes$B() {
+ // Test for method void java.security.SecureRandom.nextBytes(byte [])
+ byte[] bytes = new byte[313];
+ try {
+ new SecureRandom().nextBytes(bytes);
+ } catch (Exception e) {
+ fail("next bytes not ok : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#setSeed(byte[])
+ */
+ public void test_setSeed$B() {
+ // Test for method void java.security.SecureRandom.setSeed(byte [])
+ try {
+ new SecureRandom().setSeed(SEED_BYTES);
+ } catch (Exception e) {
+ fail("seed generation with bytes failed : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#setSeed(long)
+ */
+ public void test_setSeedJ() {
+ // Test for method void java.security.SecureRandom.setSeed(long)
+ try {
+ new SecureRandom().setSeed(SEED_VALUE);
+ } catch (Exception e) {
+ fail("seed generation with long failed : " + e);
+ }
+ }
+
+ /**
+ * 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/SecurityPermissionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityPermissionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,60 @@
+/* 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.SecurityPermission;
+
+public class SecurityPermissionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.SecurityPermission#SecurityPermission(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method java.security.SecurityPermission(java.lang.String)
+ assertTrue("create securityPermission constructor(string) failed",
+ new SecurityPermission("SecurityPermission(string)").getName()
+ .equals("SecurityPermission(string)"));
+
+ }
+
+ /**
+ * @tests java.security.SecurityPermission#SecurityPermission(java.lang.String,
+ * java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+ // Test for method java.security.SecurityPermission(java.lang.String,
+ // java.lang.String)
+ SecurityPermission sp = new SecurityPermission("security.file", "write");
+ assertTrue(
+ "creat securityPermission constructor(string,string) failed",
+ sp.getName().equals("security.file"));
+
+ }
+
+ /**
+ * 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/SecurityTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SecurityTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,552 @@
+/* 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.InvalidParameterException;
+import java.security.Provider;
+import java.security.Security;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import tests.support.Support_ProviderJCE;
+import tests.support.Support_ProviderRSA;
+import tests.support.Support_ProviderTrust;
+import tests.support.Support_TestProvider;
+
+public class SecurityTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.Security#getProperty(java.lang.String)
+ */
+ public void test_getPropertyLjava_lang_String() {
+ // Test for method java.lang.String
+ // java.security.Security.getProperty(java.lang.String)
+ Security.setProperty("keyTestAlternate", "testing a property set");
+ assertTrue(
+ "the property value returned for keyTestAlternate was incorrect",
+ Security.getProperty("keyTestAlternate").equals(
+ "testing a property set"));
+ }
+
+ /**
+ * @tests java.security.Security#setProperty(java.lang.String,
+ * java.lang.String)
+ */
+ public void test_setPropertyLjava_lang_StringLjava_lang_String() {
+ // Test for method void
+ // java.security.Security.setProperty(java.lang.String,
+ // java.lang.String)
+
+ Security.setProperty("keyTest", "permission to set property");
+ assertTrue("the property value returned for keyTest was not correct",
+ Security.getProperty("keyTest").equals(
+ "permission to set property"));
+
+ }
+
+ /**
+ * @tests java.security.Security#addProvider(java.security.Provider)
+ */
+ public void test_addProviderLjava_security_Provider() {
+ // Test for method int
+ // java.security.Security.addProvider(java.security.Provider)
+
+ // adding the dummy RSA provider
+ Provider rsa = new Support_ProviderRSA();
+ String rsaName = rsa.getName();
+ try {
+ int prefPos = Security.addProvider(rsa);
+ Provider provTest[] = Security.getProviders();
+ Provider result = Security.getProvider(rsaName);
+ assertTrue("ERROR:the RSA provider was not added properly", result
+ .getName().equals(rsaName)
+ && result.getInfo().equals(rsa.getInfo())
+ && result.getVersion() == rsa.getVersion());
+ // Provider should have been added at the end of the sequence of
+ // providers.
+ assertTrue("provider is not found at the expected position",
+ provTest[prefPos - 1].getName().equals(rsaName));
+ } catch (Exception e) {
+ fail("Unexpected exception : " + e);
+ } finally {
+ // Now remove it - does nothing if provider not actually installed
+ Security.removeProvider(rsaName);
+ }
+
+ // adding TestProvider provider
+ Provider test = new Support_TestProvider();
+ try {
+ int prefPosTest = Security.addProvider(test);
+ Provider provTest2[] = Security.getProviders();
+ Provider result2 = provTest2[prefPosTest - 1];
+ assertTrue(
+ "ERROR: the TestProvider provider was not added properly",
+ result2.getName().equals(test.getName())
+ && result2.getInfo().equals(test.getInfo())
+ && result2.getVersion() == test.getVersion());
+ } catch (Exception e) {
+ fail("Unexpected exception : " + e);
+ } finally {
+ // Now remove it - does nothing if provider not actually installed
+ Security.removeProvider(test.getName());
+ }
+
+ // adding the dummy entrust provider
+ Provider entrust = new Support_ProviderTrust();
+ try {
+ int prefPosEnt = Security.addProvider(entrust);
+ Provider provTest3[] = Security.getProviders();
+ assertTrue(
+ "ERROR: the entrust provider was not added properly",
+ provTest3[prefPosEnt - 1].getName().equals(
+ entrust.getName())
+ && provTest3[prefPosEnt - 1].getInfo().equals(
+ entrust.getInfo())
+ && provTest3[prefPosEnt - 1].getVersion() == entrust
+ .getVersion());
+ assertTrue("provider should be added at the end of the array",
+ prefPosEnt == provTest3.length);
+
+ // trying to add the entrust provider again
+ int prefPosEntAdded = Security.addProvider(entrust);
+ Security.getProviders();
+ assertEquals("addProvider method did not return a -1 for "
+ + "a provider already added", -1, prefPosEntAdded);
+ } catch (Exception e) {
+ fail("Unexpected exception : " + e);
+ } finally {
+ // Now remove it - does nothing if provider not actually installed
+ Security.removeProvider(entrust.getName());
+ }
+ }
+
+ /**
+ * @tests java.security.Security#getProvider(java.lang.String)
+ */
+ public void test_getProviderLjava_lang_String() {
+ // Test for method java.security.Provider
+ // java.security.Security.getProvider(java.lang.String)
+ Provider[] providers = Security.getProviders();
+ assertNotNull("getProviders returned null", providers);
+ assertTrue("getProviders returned zero length array",
+ providers.length > 0);
+ for (int i = 0; i < providers.length; i++) {
+ Provider provider = providers[i];
+ String providerName = provider.getName();
+ assertTrue("Getting provider " + providerName + " was not "
+ + "successful even though it is already added", Security
+ .getProvider(providerName).getName().equals(providerName));
+ }// end for
+
+ // exception case
+ assertNull(Security.getProvider("IDontExist"));
+ }
+
+ /**
+ * This test has been written with the default Harmony security
+ * configuration in mind. Recode or else exclude from run if using a
+ * different providers configuration. i.e.
+ * security.provider.1=org.apache.harmony.security.provider.cert.DRLCertFactory
+ * security.provider.2=org.bouncycastle.jce.provider.BouncyCastleProvider
+ *
+ * @tests java.security.Security#getProviders()
+ */
+ public void test_getProviders() {
+ // Test for method java.security.Provider []
+ // java.security.Security.getProviders()
+ Provider provTest[] = Security.getProviders();
+ assertEquals("the number of providers is not 2 it was: "
+ + provTest.length, 2, provTest.length);
+ assertTrue("the first provider should be DRLCertFactory", provTest[0]
+ .getName().equals("DRLCertFactory"));
+ assertTrue("the second provider should be BC", provTest[1].getName()
+ .equals("BC"));
+ }
+
+ /**
+ * @tests java.security.Security#getProviders(java.lang.String)
+ */
+ public void test_getProvidersLjava_lang_String() {
+ // Test for method void
+ // java.security.Security.getProviders(java.lang.String)
+
+ Hashtable allSupported = new Hashtable();
+ Provider[] allProviders = Security.getProviders();
+
+ // Add all non-alias entries to allSupported
+ for (int i = 0; i < allProviders.length; i++) {
+ Provider provider = allProviders[i];
+ Iterator it = provider.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry) it.next();
+ String key = (String) entry.getKey();
+ // No aliases and no provider data
+ if (!isAlias(key) && !isProviderData(key)) {
+ addOrIncrementTable(allSupported, key);
+ }
+ }// end while more entries
+ }// end for all providers
+
+ // Now walk through aliases. If an alias has actually been added
+ // to the allSupported table then increment the count of the
+ // entry that is being aliased.
+ for (int i = 0; i < allProviders.length; i++) {
+ Provider provider = allProviders[i];
+ Iterator it = provider.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry entry = (Map.Entry) it.next();
+ String key = (String) entry.getKey();
+ if (isAlias(key)) {
+ String aliasVal = key.substring("ALG.ALIAS.".length());
+ String aliasKey = aliasVal.substring(0, aliasVal
+ .indexOf(".") + 1)
+ + entry.getValue();
+ // Skip over nonsense alias declarations where alias and
+ // aliased are identical. Such entries can occur.
+ if (!aliasVal.equals(aliasKey)) {
+ // Has a real entry been added for aliasValue ?
+ if (allSupported.containsKey(aliasVal)) {
+ // Add 1 to the provider count of the thing being
+ // aliased
+ addOrIncrementTable(allSupported, aliasKey);
+ }
+ }
+ }
+ }// end while more entries
+ }// end for all providers
+
+ Provider provTest[] = null;
+ Iterator it = allSupported.keySet().iterator();
+ while (it.hasNext()) {
+ String filterString = (String) it.next();
+ try {
+ provTest = Security.getProviders(filterString);
+ int expected = ((Integer) allSupported.get(filterString))
+ .intValue();
+ assertEquals(
+ "Unexpected number of providers returned for filter "
+ + filterString, expected, provTest.length);
+ } catch (InvalidParameterException e) {
+ // NO OP
+ }
+ }// end while
+
+ // exception
+ try {
+ provTest = Security.getProviders("Signature.SHA1withDSA :512");
+ fail("InvalidParameterException should be thrown <Signature.SHA1withDSA :512>");
+ } catch (InvalidParameterException e) {
+ // Expected
+ } catch (Exception e) {
+ fail("<Signature.SHA1withDSA :512> - Expected InvalidParameterException but got a "
+ + e);
+ }
+ }
+
+ /**
+ * @param key
+ * @return
+ */
+ private boolean isProviderData(String key) {
+ return key.toUpperCase().startsWith("PROVIDER.");
+ }
+
+ /**
+ * @param key
+ * @return
+ */
+ private boolean isAlias(String key) {
+ return key.toUpperCase().startsWith("ALG.ALIAS.");
+ }
+
+ /**
+ * @param table
+ * @param key
+ */
+ private void addOrIncrementTable(Hashtable table, String key) {
+ if (table.containsKey(key)) {
+ Integer before = (Integer) table.get(key);
+ table.put(key, new Integer(before.intValue() + 1));
+ } else {
+ table.put(key, new Integer(1));
+ }
+ }
+
+ /**
+ * @param filterMap
+ * @return
+ */
+ private int getProvidersCount(Map filterMap) {
+ int result = 0;
+ Provider[] allProviders = Security.getProviders();
+
+ // for each provider
+ for (int i = 0; i < allProviders.length; i++) {
+ Provider provider = allProviders[i];
+ Set allProviderKeys = provider.keySet();
+ boolean noMatchFoundForFilterEntry = false;
+
+ // for each filter item
+ Set allFilterKeys = filterMap.keySet();
+ Iterator fkIter = allFilterKeys.iterator();
+ while (fkIter.hasNext()) {
+ String filterString = ((String) fkIter.next()).trim();
+
+ // Remove any "=" characters that may be on the end of the
+ // map keys (no, I don't know why they might be there either
+ // but I have seen them)
+ if (filterString.endsWith("=")) {
+ filterString = filterString.substring(0, filterString
+ .length() - 1);
+ }
+
+ if (filterString != null) {
+ if (filterString.indexOf(" ") == -1) {
+ // Is this filter string in the keys of the
+ // current provider ?
+ if (!allProviderKeys.contains(filterString)) {
+ // Check that the key is not contained as an
+ // alias.
+ if (!allProviderKeys.contains("Alg.Alias."
+ + filterString)) {
+ noMatchFoundForFilterEntry = true;
+ break; // out of while loop
+ }
+ }
+ } else {
+ // handle filter strings with attribute names
+ if (allProviderKeys.contains(filterString)) {
+ // Does the corresponding values match ?
+ String filterVal = (String) filterMap
+ .get(filterString);
+ String providerVal = (String) provider
+ .get(filterString);
+ if (providerVal == null
+ || !providerVal.equals(filterVal)) {
+ noMatchFoundForFilterEntry = true;
+ break; // out of while loop
+ }
+ }// end if filter string with named attribute is
+ // found
+ }// end else
+ }// end if non-null key
+ }// end while there are more filter strings for current map
+
+ if (!noMatchFoundForFilterEntry) {
+ // Current provider is a match for the filterMap
+ result++;
+ }
+ }// end for each provider
+
+ return result;
+ }
+
+ /**
+ * @tests java.security.Security#getProviders(java.util.Map)
+ */
+ public void test_getProvidersLjava_util_Map() {
+ // Test for method void
+ // java.security.Security.getProviders(java.util.Map)
+
+ Map filter = new Hashtable();
+ filter.put("KeyStore.BKS", "");
+ filter.put("Signature.SHA1withDSA", "");
+ Provider provTest[] = Security.getProviders(filter);
+ if (provTest == null) {
+ assertTrue("Filter : <KeyStore.BKS>,<Signature.SHA1withDSA>",
+ getProvidersCount(filter) == 0);
+ } else {
+ assertEquals("Filter : <KeyStore.BKS>,<Signature.SHA1withDSA>",
+ getProvidersCount(filter), provTest.length);
+ }
+
+ filter = new Hashtable();
+ filter.put("MessageDigest.MD2", "");
+ filter.put("CertificateFactory.X.509", "");
+ filter.put("KeyFactory.RSA", "");
+ provTest = Security.getProviders(filter);
+ if (provTest == null) {
+ assertTrue(
+ "Filter : <MessageDigest.MD2>,<CertificateFactory.X.509>,<KeyFactory.RSA>",
+ getProvidersCount(filter) == 0);
+ } else {
+ assertEquals(
+ "Filter : <MessageDigest.MD2>,<CertificateFactory.X.509>,<KeyFactory.RSA>",
+ getProvidersCount(filter), provTest.length);
+ }
+
+ filter = new Hashtable();
+ filter.put("MessageDigest.SHA", "");
+ filter.put("CertificateFactory.X.509", "");
+ provTest = Security.getProviders(filter);
+ if (provTest == null) {
+ assertTrue(
+ "Filter : <MessageDigest.SHA><CertificateFactory.X.509>",
+ getProvidersCount(filter) == 0);
+ } else {
+ assertEquals(
+ "Filter : <MessageDigest.SHA><CertificateFactory.X.509>",
+ getProvidersCount(filter), provTest.length);
+ }
+
+ filter = new Hashtable();
+ filter.put("CertificateFactory.X509", "");
+ provTest = Security.getProviders(filter);
+ if (provTest == null) {
+ assertTrue("Filter : <CertificateFactory.X509>",
+ getProvidersCount(filter) == 0);
+ } else {
+ assertEquals("Filter : <CertificateFactory.X509>",
+ getProvidersCount(filter), provTest.length);
+ }
+
+ filter = new Hashtable();
+ filter.put("Provider.id name", "DRLCertFactory");
+ provTest = Security.getProviders(filter);
+ if (provTest == null) {
+ assertTrue("Filter : <Provider.id name, DRLCertFactory >",
+ getProvidersCount(filter) == 0);
+ } else {
+ assertEquals("Filter : <Provider.id name, DRLCertFactory>",
+ getProvidersCount(filter), provTest.length);
+ }
+
+ // exception - no attribute name after the service.algorithm yet we
+ // still supply an expected value. This is not valid.
+ try {
+ filter = new Hashtable();
+ filter.put("Signature.SHA1withDSA", "512");
+ provTest = Security.getProviders(filter);
+ fail("InvalidParameterException should be thrown <Signature.SHA1withDSA><512>");
+ } catch (InvalidParameterException e) {
+ // Expected
+ } catch (Exception e) {
+ fail("InvalidParameterException was expected for"
+ + " <Signature.SHA1withDSA><512> " + " but we got a " + e);
+ }
+
+ // exception - space character in the service.algorithm pair. Not valid.
+ try {
+ filter = new Hashtable();
+ filter.put("Signature. KeySize", "512");
+ provTest = Security.getProviders(filter);
+ fail("InvalidParameterException should be thrown <Signature. KeySize><512>");
+ } catch (InvalidParameterException e) {
+ // Expected
+ } catch (Exception e) {
+ fail("InvalidParameterException was expected for"
+ + " <Signature. KeySize><512> " + " but we got a " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Security#insertProviderAt(java.security.Provider,
+ * int)
+ */
+ public void test_insertProviderAtLjava_security_ProviderI() {
+ // Test for method int
+ // java.security.Security.insertProviderAt(java.security.Provider, int)
+
+ String initialSecondProviderName = (Security.getProviders()[1])
+ .getName();
+ Provider jceProvider = new Support_ProviderJCE();
+
+ try {
+ Security.insertProviderAt(jceProvider, 2);
+ Provider provTest[] = Security.getProviders();
+ assertTrue("the second provider should be jceProvider", provTest[1]
+ .getName().equals(jceProvider.getName())
+ && provTest[1].getVersion() == jceProvider.getVersion()
+ && provTest[1].getInfo().equals(jceProvider.getInfo()));
+ assertTrue("the third provider should be the previous second "
+ + "provider shifted down", provTest[2].getName().equals(
+ initialSecondProviderName));
+
+ // trying to insert a provider that already exists
+ int referAdded = Security.insertProviderAt(jceProvider, 3);
+ assertEquals("the method insertProviderAt did not "
+ + "return a -1 for providers already added", -1, referAdded);
+ } catch (Exception e) {
+ fail("Unexpected exception : " + e);
+ } finally {
+ // Tidy up before we leave
+ Security.removeProvider(jceProvider.getName());
+ }
+ }
+
+ /**
+ * @tests java.security.Security#removeProvider(java.lang.String)
+ */
+ public void test_removeProviderLjava_lang_String() {
+ // Test for method void
+ // java.security.Security.removeProvider(java.lang.String)
+ Provider test = new Support_TestProvider();
+ Provider entrust = new Support_ProviderTrust();
+ try {
+ // Make sure provider not already loaded. Should do nothing
+ // if not already loaded.
+ Security.removeProvider(test.getName());
+
+ // Now add it
+ int addResult = Security.addProvider(test);
+ assertTrue("Failed to add provider", addResult != -1);
+
+ Security.removeProvider(test.getName());
+ assertTrue(
+ "the provider TestProvider is found after it was removed",
+ Security.getProvider(test.getName()) == null);
+
+ // Make sure entrust provider not already loaded. Should do nothing
+ // if not already loaded.
+ Security.removeProvider(entrust.getName());
+
+ // Now add entrust
+ addResult = Security.addProvider(entrust);
+ assertTrue("Failed to add provider", addResult != -1);
+
+ Security.removeProvider(entrust.getName());
+ Provider provTest[] = Security.getProviders();
+ for (int i = 0; i < provTest.length; i++) {
+ assertTrue(
+ "the provider entrust is found after it was removed",
+ provTest[i].getName() != entrust.getName());
+ }
+ } catch (Exception e) {
+ fail("Unexpected exception : " + e);
+ } finally {
+ // Tidy up - the following calls do nothing if the providers were
+ // already removed above.
+ Security.removeProvider(test.getName());
+ Security.removeProvider(entrust.getName());
+ }
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection. This method
+ * is called before a test is executed.
+ */
+ protected void setUp() {
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection. This
+ * method is called after a test is executed.
+ */
+ protected void tearDown() {
+ }
+}
\ No newline at end of file
Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,56 @@
+/* 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.SignatureException;
+
+public class SignatureExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.SignatureException#SignatureException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.SignatureException()
+ SignatureException e = new SignatureException();
+ assertTrue("Failed toString test for constructed instance", e
+ .toString().equals("java.security.SignatureException"));
+ }
+
+ /**
+ * @tests java.security.SignatureException#SignatureException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method java.security.SignatureException(java.lang.String)
+ SignatureException e = new SignatureException("test message");
+ assertTrue("Failed toString test for constructed instance", e
+ .toString().equals(
+ "java.security.SignatureException: test message"));
+ }
+
+ /**
+ * 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/SignatureTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignatureTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,465 @@
+/* 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.InvalidKeyException;
+import java.security.InvalidParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.spec.DSAParameterSpec;
+
+public class SignatureTest extends junit.framework.TestCase {
+
+ private static final String MESSAGE = "abc";
+
+ /**
+ * @tests java.security.Signature#clone()
+ */
+ public void test_clone() {
+ try {
+ Signature s = Signature.getInstance("DSA");
+ try {
+ s.clone();
+ fail("A Signature may not be cloneable");
+ } catch (CloneNotSupportedException e) {
+ // Expected - a Signature may not be cloneable
+ }
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm");
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#getAlgorithm()
+ */
+ public void test_getAlgorithm() {
+ try {
+ String alg = Signature.getInstance("DSA").getAlgorithm();
+ assertTrue("getAlgorithm did not get DSA (" + alg + ")", alg
+ .indexOf("DSA") != -1);
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm");
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#getInstance(java.lang.String)
+ */
+ public void test_getInstanceLjava_lang_String() {
+ try {
+ Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm");
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#getInstance(java.lang.String,
+ * java.lang.String)
+ */
+ public void test_getInstanceLjava_lang_StringLjava_lang_String() {
+ try {
+ Provider[] providers = Security.getProviders("Signature.DSA");
+ assertNotNull("No providers support Signature.DSA", providers);
+ for (int i = 0; i < providers.length; i++) {
+ Signature.getInstance("DSA", providers[i].getName());
+ }// end for
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ } catch (NoSuchProviderException e) {
+ fail("getInstance did not find named provider : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#getParameter(java.lang.String)
+ */
+ public void test_getParameterLjava_lang_String() {
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ boolean passed = false;
+ try {
+ sig.getParameter("r");
+ sig.getParameter("s");
+ passed = true;
+ } catch (UnsupportedOperationException e) {
+ passed = true;
+ } catch (Exception e) {
+ passed = false;
+ }
+ assertTrue("getParameter did not pass or threw incorrect exception",
+ passed);
+ }
+
+ /**
+ * @tests java.security.Signature#getProvider()
+ */
+ public void test_getProvider() {
+ try {
+ Provider p = Signature.getInstance("DSA").getProvider();
+ assertNotNull("provider is null", p);
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#initSign(java.security.PrivateKey)
+ */
+ public void test_initSignLjava_security_PrivateKey() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initSign(keys.getPrivate());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#initVerify(java.security.PublicKey)
+ */
+ public void test_initVerifyLjava_security_PublicKey() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initVerify(keys.getPublic());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#setParameter(java.lang.String,
+ * java.lang.Object)
+ */
+ public void test_setParameterLjava_lang_StringLjava_lang_Object() {
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ try {
+ sig.setParameter("r", BigInteger.ONE);
+ sig.setParameter("s", BigInteger.ONE);
+ } catch (InvalidParameterException e) {
+ // Could be that it's an invalid param for the found algorithm
+ } catch (UnsupportedOperationException e) {
+ // Could be that the operation is not supported
+ } catch (Exception e) {
+ fail("test_setParameterLjava_lang_StringLjava_lang_Object "
+ + "threw incorrect exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#setParameter(java.security.spec.AlgorithmParameterSpec)
+ */
+ public void test_setParameterLjava_security_spec_AlgorithmParameterSpec() {
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ try {
+ DSAParameterSpec spec = new DSAParameterSpec(BigInteger.ONE,
+ BigInteger.ONE, BigInteger.ONE);
+ sig.setParameter(spec);
+ } catch (InvalidParameterException e) {
+ // Could be that it's an invalid param for the found algorithm
+ } catch (UnsupportedOperationException e) {
+ // Could be that the operation is not supported
+ } catch (Exception e) {
+ fail("test_setParameterLjava_security_spec_AlgorithmParameterSpec "
+ + "threw incorrect exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#sign()
+ */
+ public void test_sign() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initSign(keys.getPrivate());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ try {
+ sig.update(MESSAGE.getBytes());
+ } catch (SignatureException e) {
+ fail("Problem updating Signature bytes : " + e);
+ }
+ try {
+ sig.sign();
+ } catch (SignatureException e) {
+ fail("Signature problem signing bytes : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#toString()
+ */
+ public void test_toString() {
+ try {
+ String str = Signature.getInstance("DSA").toString();
+ assertNotNull("toString is null", str);
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#update(byte[])
+ */
+ public void test_update$B() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initSign(keys.getPrivate());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ try {
+ byte[] bytes = MESSAGE.getBytes();
+ sig.update(bytes);
+ } catch (SignatureException e) {
+ fail("Problem updating Signature bytes : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#update(byte[], int, int)
+ */
+ public void test_update$BII() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initSign(keys.getPrivate());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ try {
+ byte[] bytes = MESSAGE.getBytes();
+ sig.update(bytes, 0, bytes.length);
+ } catch (SignatureException e) {
+ fail("Signature problem updating bytes : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#update(byte)
+ */
+ public void test_updateB() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initSign(keys.getPrivate());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ try {
+ sig.update(MESSAGE.getBytes()[0]);
+ } catch (SignatureException e) {
+ fail("Problem updating Signature bytes : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signature#verify(byte[])
+ */
+ public void test_verify$B() {
+
+ fail("Test hangs - dependent on full math implementation ??");
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+
+ KeyPairGenerator keyGen = null;
+ try {
+ keyGen = KeyPairGenerator.getInstance("DSA");
+ } catch (NoSuchAlgorithmException e) {
+ fail("getInstance did not find algorithm : " + e);
+ }
+ SecureRandom random = new SecureRandom();
+ keyGen.initialize(1024, random);
+ KeyPair keys = keyGen.generateKeyPair();
+ try {
+ sig.initSign(keys.getPrivate());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ try {
+ sig.update(MESSAGE.getBytes());
+ } catch (SignatureException e) {
+ fail("Problem updating Signature bytes : " + e);
+ }
+ byte[] signature = null;
+ try {
+ signature = sig.sign();
+ } catch (SignatureException e) {
+ fail("Signature problem signing bytes : " + e);
+ }
+
+ try {
+ sig.initVerify(keys.getPublic());
+ } catch (InvalidKeyException e) {
+ fail("Invalid key : " + e);
+ }
+ try {
+ sig.update(MESSAGE.getBytes());
+ } catch (SignatureException e) {
+ fail("Problem updating Signature bytes : " + e);
+ }
+ boolean ok = false;
+ try {
+ ok = sig.verify(signature);
+ } catch (SignatureException e) {
+ fail("Signature problem verifying bytes : " + e);
+ }
+
+ assertTrue("Sign/Verify does not pass", ok);
+ }
+
+ protected void setUp() {
+ }
+
+ 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/SignerTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignerTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignerTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/SignerTest.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.IdentityScope;
+import java.security.KeyManagementException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.Signer;
+
+import tests.api.java.security.IdentityScopeTest.IdentityScopeSubclass;
+
+public class SignerTest extends junit.framework.TestCase {
+
+ public class SignerImpl extends Signer {
+ public SignerImpl() {
+ super();
+ }
+
+ public SignerImpl(String name) {
+ super(name);
+ }
+
+ public SignerImpl(String name, IdentityScope scope)
+ throws KeyManagementException {
+ super(name, scope);
+ }
+ }
+
+ /**
+ * @tests java.security.Signer#Signer()
+ */
+ public void test_Constructor() {
+ try {
+ new SignerImpl();
+ } catch (Exception e) {
+ fail("Caught exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signer#Signer(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ try {
+ new SignerImpl("test");
+ } catch (Exception e) {
+ fail("Caught exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signer#Signer(java.lang.String,
+ * java.security.IdentityScope)
+ */
+ public void test_ConstructorLjava_lang_StringLjava_security_IdentityScope() {
+ try {
+ new SignerImpl("test", new IdentityScopeSubclass());
+ } catch (Exception e) {
+ fail("Caught exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signer#getPrivateKey()
+ */
+ public void test_getPrivateKey() {
+
+ fail("Test hangs - could be dependent on reall math implementation ??");
+
+ try {
+ SignerImpl signer = new SignerImpl("test");
+ KeyPairGenerator gen = KeyPairGenerator.getInstance("DSA");
+ KeyPair pair = gen.genKeyPair();
+ signer.setKeyPair(pair);
+ signer.getPrivateKey();
+ } catch (Exception e) {
+ fail("Caught exception : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Signer#toString()
+ */
+ public void test_toString() {
+ try {
+ SignerImpl signer = new SignerImpl("test");
+ assertEquals("Unexpected return from toString method",
+ "[Signer]test", signer.toString());
+ } catch (Exception e) {
+ fail("Caught exception : " + e);
+ }
+ }
+
+ protected void setUp() {
+ }
+
+ 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/UnrecoverableKeyExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/UnrecoverableKeyExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,58 @@
+/* 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.UnrecoverableKeyException;
+
+public class UnrecoverableKeyExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.UnrecoverableKeyException#UnrecoverableKeyException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.UnrecoverableKeyException()
+ UnrecoverableKeyException e = new UnrecoverableKeyException();
+ assertTrue("Failed toString test for constructed instance", e
+ .toString().equals("java.security.UnrecoverableKeyException"));
+ }
+
+ /**
+ * @tests java.security.UnrecoverableKeyException#UnrecoverableKeyException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method
+ // java.security.UnrecoverableKeyException(java.lang.String)
+ UnrecoverableKeyException e = new UnrecoverableKeyException(
+ "test message");
+ assertEquals("Failed toString test for constructed instance",
+ "java.security.UnrecoverableKeyException: test message", e
+ .toString());
+ }
+
+ /**
+ * 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/acl/AclNotFoundExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/AclNotFoundExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/AclNotFoundExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/AclNotFoundExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,54 @@
+/* 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.acl;
+
+import java.security.acl.AclNotFoundException;
+
+public class AclNotFoundExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.acl.AclNotFoundException#AclNotFoundException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.acl.AclNotFoundException()
+ try {
+ if (true) {
+ throw new AclNotFoundException();
+ }
+ fail("Should have thrown AclNotFoundException");
+ } catch (AclNotFoundException e) {
+ assertEquals("AclNotFoundException.toString() should have been "
+ + "'java.security.acl.AclNotFoundException' but was "
+ + e.toString(),
+ "java.security.acl.AclNotFoundException",
+ e.toString());
+ }
+ }
+
+ /**
+ * 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/acl/LastOwnerExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/LastOwnerExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/LastOwnerExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/LastOwnerExceptionTest.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.java.security.acl;
+
+import java.security.acl.LastOwnerException;
+
+public class LastOwnerExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.acl.LastOwnerException#LastOwnerException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.acl.LastOwnerException()
+ try {
+ throw new LastOwnerException();
+ } catch (LastOwnerException e) {
+ assertEquals("LastOwnerException.toString() should have been "
+ + "'java.security.acl.LastOwnerException' but was "
+ + e.toString(), "java.security.acl.LastOwnerException", e
+ .toString());
+ }
+ }
+
+ /**
+ * 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/acl/NotOwnerExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/NotOwnerExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/NotOwnerExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/acl/NotOwnerExceptionTest.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.java.security.acl;
+
+import java.security.acl.NotOwnerException;
+
+public class NotOwnerExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.acl.NotOwnerException#NotOwnerException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.acl.NotOwnerException()
+ try {
+ throw new NotOwnerException();
+ } catch (NotOwnerException e) {
+ assertEquals("NotOwnerException.toString() should have been "
+ + "'java.security.acl.NotOwnerException' but was "
+ + e.toString(), "java.security.acl.NotOwnerException", e
+ .toString());
+ }
+ }
+
+ /**
+ * 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/cert/CertificateEncodingExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateEncodingExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateEncodingExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateEncodingExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,54 @@
+/* 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.cert;
+
+import java.security.cert.CertificateEncodingException;
+
+public class CertificateEncodingExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.cert.CertificateEncodingException#CertificateEncodingException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.cert.CertificateEncodingException()
+ try {
+ if (true) {
+ throw new CertificateEncodingException();
+ }
+ fail("Should have thrown CertificateEncodingException");
+ } catch (CertificateEncodingException e) {
+ assertEquals("Initializer failed : " + e.toString(),
+ "java.security.cert.CertificateEncodingException",
+ e.toString());
+ } catch (Exception e) {
+ fail("Unexpected exception during test : " + e);
+ }
+ }
+
+ /**
+ * 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/cert/CertificateExceptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateExceptionTest.java?rev=392891&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateExceptionTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/tests/api/java/security/cert/CertificateExceptionTest.java Sun Apr 9 22:38:31 2006
@@ -0,0 +1,72 @@
+/* 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.cert;
+
+import java.security.cert.CertificateException;
+
+public class CertificateExceptionTest extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.cert.CertificateException#CertificateException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.cert.CertificateException()
+ try {
+ if (true) {
+ throw new CertificateException();
+ }
+ fail("Should have thrown CertificateException");
+ } catch (CertificateException e) {
+ assertEquals("Initializer failed : " + e.toString(),
+ "java.security.cert.CertificateException", e.toString());
+ } catch (Exception e) {
+ fail("Unexpected exception during test : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.cert.CertificateException#CertificateException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method
+ // java.security.cert.CertificateException(java.lang.String)
+ try {
+ if (true) {
+ throw new CertificateException("Some error message");
+ }
+ fail("Should have thrown CertificateException");
+ } catch (CertificateException e) {
+ assertEquals("Initializer failed",
+ "Some error message", e.getMessage());
+ } catch (Exception e) {
+ fail("Unexpected exception during test : " + e);
+ }
+ }
+
+ /**
+ * 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