You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/09/15 03:18:16 UTC
svn commit: r443539 [12/29] - in
/incubator/harmony/enhanced/classlib/trunk/modules/security: ./ .settings/
META-INF/ make/ src/main/java/common/java/security/
src/main/java/common/java/security/acl/
src/main/java/common/java/security/cert/ src/main/ja...
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java Thu Sep 14 18:17:39 2006
@@ -1,50 +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 org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchAlgorithmException;
-
-public class NoSuchAlgorithmException2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException()
- */
- public void test_Constructor() {
- try {
- throw new NoSuchAlgorithmException();
- } catch (NoSuchAlgorithmException e) {
- assertNull("Message should be null", e.getMessage());
- assertEquals("Unexpected toString value",
- "java.security.NoSuchAlgorithmException", e.toString());
- }
- }
-
- /**
- * @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method
- // java.security.NoSuchAlgorithmException(java.lang.String)
- try {
- throw new NoSuchAlgorithmException("Test string");
- } catch (NoSuchAlgorithmException e) {
- assertEquals("Wrong message", "Test string", e.getMessage());
- assertEquals("Unexpected toString value",
- "java.security.NoSuchAlgorithmException: Test string", e
- .toString());
- }
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.NoSuchAlgorithmException;
+
+public class NoSuchAlgorithmException2Test extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException()
+ */
+ public void test_Constructor() {
+ try {
+ throw new NoSuchAlgorithmException();
+ } catch (NoSuchAlgorithmException e) {
+ assertNull("Message should be null", e.getMessage());
+ assertEquals("Unexpected toString value",
+ "java.security.NoSuchAlgorithmException", e.toString());
+ }
+ }
+
+ /**
+ * @tests java.security.NoSuchAlgorithmException#NoSuchAlgorithmException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method
+ // java.security.NoSuchAlgorithmException(java.lang.String)
+ try {
+ throw new NoSuchAlgorithmException("Test string");
+ } catch (NoSuchAlgorithmException e) {
+ assertEquals("Wrong message", "Test string", e.getMessage());
+ assertEquals("Unexpected toString value",
+ "java.security.NoSuchAlgorithmException: Test string", e
+ .toString());
+ }
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmException2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchAlgorithmExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java Thu Sep 14 18:17:39 2006
@@ -1,51 +1,51 @@
-/* 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 org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchProviderException;
-
-public class NoSuchProviderException2Test extends junit.framework.TestCase {
-
- /**
- * @tests java.security.NoSuchProviderException#NoSuchProviderException()
- */
- public void test_Constructor() {
- // Test for method java.security.NoSuchProviderException()
- try {
- throw new NoSuchProviderException();
- } catch (NoSuchProviderException e) {
- assertNull("Message should be null", e.getMessage());
- assertEquals("Unexpected toString value",
- "java.security.NoSuchProviderException", e.toString());
- }
- }
-
- /**
- * @tests java.security.NoSuchProviderException#NoSuchProviderException(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // Test for method
- // java.security.NoSuchProviderException(java.lang.String)
- try {
- throw new NoSuchProviderException("Test string");
- } catch (NoSuchProviderException e) {
- assertEquals("Wrong message", "Test string", e.getMessage());
- assertEquals("Unexpected toString value",
- "java.security.NoSuchProviderException: Test string", e
- .toString());
- }
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.NoSuchProviderException;
+
+public class NoSuchProviderException2Test extends junit.framework.TestCase {
+
+ /**
+ * @tests java.security.NoSuchProviderException#NoSuchProviderException()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.NoSuchProviderException()
+ try {
+ throw new NoSuchProviderException();
+ } catch (NoSuchProviderException e) {
+ assertNull("Message should be null", e.getMessage());
+ assertEquals("Unexpected toString value",
+ "java.security.NoSuchProviderException", e.toString());
+ }
+ }
+
+ /**
+ * @tests java.security.NoSuchProviderException#NoSuchProviderException(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // Test for method
+ // java.security.NoSuchProviderException(java.lang.String)
+ try {
+ throw new NoSuchProviderException("Test string");
+ } catch (NoSuchProviderException e) {
+ assertEquals("Wrong message", "Test string", e.getMessage());
+ assertEquals("Unexpected toString value",
+ "java.security.NoSuchProviderException: Test string", e
+ .toString());
+ }
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderException2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/NoSuchProviderExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java Thu Sep 14 18:17:39 2006
@@ -1,110 +1,110 @@
-/* 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 org.apache.harmony.security.tests.java.security;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.SecurityPermission;
-
-public class Permission2Test extends junit.framework.TestCase {
- static class ConcretePermission extends Permission {
- public ConcretePermission() {
- super("noname");
- }
-
- public boolean equals(Object obj) {
- return true;
- }
-
- public String getActions() {
- return "none";
- }
-
- public int hashCode() {
- return 1;
- }
-
- public boolean implies(Permission p) {
- return true;
- }
- }
-
- /**
- * @tests java.security.Permission#Permission(java.lang.String)
- */
- public void test_ConstructorLjava_lang_String() {
- // test method java.security.permission.Permission(string)
- SecurityPermission permi = new SecurityPermission(
- "Testing the permission abstract class");
- String name = permi.getName();
- assertEquals("Permission Constructor failed",
- "Testing the permission abstract class", name);
- }
-
- /**
- * @tests java.security.Permission#checkGuard(java.lang.Object)
- */
- public void test_checkGuardLjava_lang_Object() {
- // test method java.security.permission.checkGuard(object)
- SecurityPermission permi = new SecurityPermission(
- "Testing the permission abstract class");
- String name = permi.getName();
- try {
- permi.checkGuard(name);
- } catch (SecurityException e) {
- fail("security not granted when it is suppose to be : " + e);
- }
- }
-
- /**
- * @tests java.security.Permission#getName()
- */
- public void test_getName() {
- // test method java.security.permission.getName()
- SecurityPermission permi = new SecurityPermission("testing getName()");
- String name = permi.getName();
- assertEquals("getName failed to obtain the correct name",
- "testing getName()", name);
-
- SecurityPermission permi2 = new SecurityPermission("93048Helloworld");
- assertEquals("getName failed to obtain correct name",
- "93048Helloworld", permi2.getName());
- }
-
- /**
- * @tests java.security.Permission#newPermissionCollection()
- */
- public void test_newPermissionCollection() {
- // test method java.security.permission.newPermissionCollection
- Permission permi = new ConcretePermission();
- PermissionCollection permiCollect = permi.newPermissionCollection();
- assertNull("newPermissionCollector of the abstract class "
- + "permission did not return a null instance "
- + "of permissionCollection", permiCollect);
- }
-
- /**
- * @tests java.security.Permission#toString()
- */
- public void test_toString() {
- // test method java.security.permission.toString
- // test for permission with no action
- SecurityPermission permi = new SecurityPermission("testing toString");
- String toString = permi.toString();
- assertNotNull("toString should have returned a string of elements",
- toString);
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.SecurityPermission;
+
+public class Permission2Test extends junit.framework.TestCase {
+ static class ConcretePermission extends Permission {
+ public ConcretePermission() {
+ super("noname");
+ }
+
+ public boolean equals(Object obj) {
+ return true;
+ }
+
+ public String getActions() {
+ return "none";
+ }
+
+ public int hashCode() {
+ return 1;
+ }
+
+ public boolean implies(Permission p) {
+ return true;
+ }
+ }
+
+ /**
+ * @tests java.security.Permission#Permission(java.lang.String)
+ */
+ public void test_ConstructorLjava_lang_String() {
+ // test method java.security.permission.Permission(string)
+ SecurityPermission permi = new SecurityPermission(
+ "Testing the permission abstract class");
+ String name = permi.getName();
+ assertEquals("Permission Constructor failed",
+ "Testing the permission abstract class", name);
+ }
+
+ /**
+ * @tests java.security.Permission#checkGuard(java.lang.Object)
+ */
+ public void test_checkGuardLjava_lang_Object() {
+ // test method java.security.permission.checkGuard(object)
+ SecurityPermission permi = new SecurityPermission(
+ "Testing the permission abstract class");
+ String name = permi.getName();
+ try {
+ permi.checkGuard(name);
+ } catch (SecurityException e) {
+ fail("security not granted when it is suppose to be : " + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Permission#getName()
+ */
+ public void test_getName() {
+ // test method java.security.permission.getName()
+ SecurityPermission permi = new SecurityPermission("testing getName()");
+ String name = permi.getName();
+ assertEquals("getName failed to obtain the correct name",
+ "testing getName()", name);
+
+ SecurityPermission permi2 = new SecurityPermission("93048Helloworld");
+ assertEquals("getName failed to obtain correct name",
+ "93048Helloworld", permi2.getName());
+ }
+
+ /**
+ * @tests java.security.Permission#newPermissionCollection()
+ */
+ public void test_newPermissionCollection() {
+ // test method java.security.permission.newPermissionCollection
+ Permission permi = new ConcretePermission();
+ PermissionCollection permiCollect = permi.newPermissionCollection();
+ assertNull("newPermissionCollector of the abstract class "
+ + "permission did not return a null instance "
+ + "of permissionCollection", permiCollect);
+ }
+
+ /**
+ * @tests java.security.Permission#toString()
+ */
+ public void test_toString() {
+ // test method java.security.permission.toString
+ // test for permission with no action
+ SecurityPermission permi = new SecurityPermission("testing toString");
+ String toString = permi.toString();
+ assertNotNull("toString should have returned a string of elements",
+ toString);
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permission2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionCollectionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java Thu Sep 14 18:17:39 2006
@@ -1,155 +1,155 @@
-/* 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 org.apache.harmony.security.tests.java.security;
-
-import java.io.File;
-import java.io.FilePermission;
-import java.security.Permissions;
-import java.util.Enumeration;
-
-public class Permissions2Test extends junit.framework.TestCase {
- FilePermission readAllFiles = new FilePermission("<<ALL FILES>>", "read");
-
- FilePermission alsoReadAllFiles = new FilePermission("<<ALL FILES>>",
- "read");
-
- FilePermission allInCurrent = new FilePermission("*",
- "read, write, execute,delete");
-
- FilePermission readInCurrent = new FilePermission("*", "read");
-
- FilePermission readInFile = new FilePermission("aFile.file", "read");
-
- /**
- * @tests java.security.Permissions#Permissions()
- */
- public void test_Constructor() {
- // Test for method java.security.Permissions()
- try {
- new Permissions();
- } catch (Exception e) {
- fail("creating an instance of permissions constructor failed : "
- + e);
- }
- }
-
- /**
- * @tests java.security.Permissions#add(java.security.Permission)
- */
- public void test_addLjava_security_Permission() {
- // Test for method void
- // java.security.Permissions.add(java.security.Permission)
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[7];
- perm[0] = readAllFiles;
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
- perm[4] = alsoReadAllFiles;
- perm[5] = readInFile;
- perm[6] = new FilePermission("hello.file", "write");
- Permissions perms = new Permissions();
- try {
- for (int i = 0; i < perm.length; i++) {
- perms.add(perm[i]);
- }
- } catch (IllegalStateException e) {
- fail("add method failed with unexpected IllegalStateException : "
- + e);
- }
-
- Enumeration e = perms.elements();
- FilePermission perm2[] = new FilePermission[10];
- int i = 0;
- while (e.hasMoreElements()) {
- perm2[i] = (FilePermission) e.nextElement();
- i++;
- }
- assertEquals("Permissions.elements did not return the correct number "
- + "of permission - called in add() test ", i, perm.length);
- }
-
- /**
- * @tests java.security.Permissions#elements()
- */
- public void test_elements() {
- // Test for method java.util.Enumeration
- // java.security.Permissions.elements()
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[7];
- perm[0] = readAllFiles;
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
- perm[4] = alsoReadAllFiles;
- perm[5] = readInFile;
- perm[6] = new FilePermission("hello.file", "write");
- Permissions perms = new Permissions();
- for (int i = 0; i < perm.length; i++) {
- perms.add(perm[i]);
- }
- Enumeration e = perms.elements();
- FilePermission perm2[] = new FilePermission[10];
- int i = 0;
- while (e.hasMoreElements()) {
- perm2[i] = (FilePermission) e.nextElement();
- i++;
- }
- assertEquals("Permissions.elements did not return the correct "
- + "number of permission - called in element() test", i,
- perm.length);
- }
-
- /**
- * @tests java.security.Permissions#implies(java.security.Permission)
- */
- public void test_impliesLjava_security_Permission() {
- // Test for method boolean
- // java.security.Permissions.implies(java.security.Permission)
- char s = File.separatorChar;
- FilePermission perm[] = new FilePermission[7];
- perm[0] = new FilePermission("test1.file", "write");
- perm[1] = allInCurrent;
- perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
- "read,write");
- perm[3] = new FilePermission(s + "tmp" + s + "test" + s
- + "collection.file", "read");
- perm[4] = new FilePermission(s + "windows" + "*", "delete");
- perm[5] = readInFile;
- perm[6] = new FilePermission("hello.file", "write");
- Permissions perms = new Permissions();
- for (int i = 0; i < perm.length; i++) {
- perms.add(perm[i]);
- }
- assertTrue("Returned true for non-subset of files", !perms
- .implies(new FilePermission("<<ALL FILES>>", "execute")));
- assertTrue("Returned true for non-subset of action", !perms
- .implies(new FilePermission(s + "tmp" + s + "test" + s + "*",
- "execute")));
- assertTrue("Returned false for subset of actions", perms
- .implies(new FilePermission("*", "write")));
- assertTrue("Returned false for subset of files", perms
- .implies(new FilePermission(s + "tmp" + s + "test" + s
- + "test.file", "read")));
- assertTrue("Returned false for subset of files and actions", perms
- .implies(new FilePermission(s + "tmp" + s + "test" + s
- + "test2.file", "write")));
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.security.Permissions;
+import java.util.Enumeration;
+
+public class Permissions2Test extends junit.framework.TestCase {
+ FilePermission readAllFiles = new FilePermission("<<ALL FILES>>", "read");
+
+ FilePermission alsoReadAllFiles = new FilePermission("<<ALL FILES>>",
+ "read");
+
+ FilePermission allInCurrent = new FilePermission("*",
+ "read, write, execute,delete");
+
+ FilePermission readInCurrent = new FilePermission("*", "read");
+
+ FilePermission readInFile = new FilePermission("aFile.file", "read");
+
+ /**
+ * @tests java.security.Permissions#Permissions()
+ */
+ public void test_Constructor() {
+ // Test for method java.security.Permissions()
+ try {
+ new Permissions();
+ } catch (Exception e) {
+ fail("creating an instance of permissions constructor failed : "
+ + e);
+ }
+ }
+
+ /**
+ * @tests java.security.Permissions#add(java.security.Permission)
+ */
+ public void test_addLjava_security_Permission() {
+ // Test for method void
+ // java.security.Permissions.add(java.security.Permission)
+ char s = File.separatorChar;
+ FilePermission perm[] = new FilePermission[7];
+ perm[0] = readAllFiles;
+ perm[1] = allInCurrent;
+ perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
+ "read,write");
+ perm[3] = new FilePermission(s + "tmp" + s + "test" + s
+ + "collection.file", "read");
+ perm[4] = alsoReadAllFiles;
+ perm[5] = readInFile;
+ perm[6] = new FilePermission("hello.file", "write");
+ Permissions perms = new Permissions();
+ try {
+ for (int i = 0; i < perm.length; i++) {
+ perms.add(perm[i]);
+ }
+ } catch (IllegalStateException e) {
+ fail("add method failed with unexpected IllegalStateException : "
+ + e);
+ }
+
+ Enumeration e = perms.elements();
+ FilePermission perm2[] = new FilePermission[10];
+ int i = 0;
+ while (e.hasMoreElements()) {
+ perm2[i] = (FilePermission) e.nextElement();
+ i++;
+ }
+ assertEquals("Permissions.elements did not return the correct number "
+ + "of permission - called in add() test ", i, perm.length);
+ }
+
+ /**
+ * @tests java.security.Permissions#elements()
+ */
+ public void test_elements() {
+ // Test for method java.util.Enumeration
+ // java.security.Permissions.elements()
+ char s = File.separatorChar;
+ FilePermission perm[] = new FilePermission[7];
+ perm[0] = readAllFiles;
+ perm[1] = allInCurrent;
+ perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
+ "read,write");
+ perm[3] = new FilePermission(s + "tmp" + s + "test" + s
+ + "collection.file", "read");
+ perm[4] = alsoReadAllFiles;
+ perm[5] = readInFile;
+ perm[6] = new FilePermission("hello.file", "write");
+ Permissions perms = new Permissions();
+ for (int i = 0; i < perm.length; i++) {
+ perms.add(perm[i]);
+ }
+ Enumeration e = perms.elements();
+ FilePermission perm2[] = new FilePermission[10];
+ int i = 0;
+ while (e.hasMoreElements()) {
+ perm2[i] = (FilePermission) e.nextElement();
+ i++;
+ }
+ assertEquals("Permissions.elements did not return the correct "
+ + "number of permission - called in element() test", i,
+ perm.length);
+ }
+
+ /**
+ * @tests java.security.Permissions#implies(java.security.Permission)
+ */
+ public void test_impliesLjava_security_Permission() {
+ // Test for method boolean
+ // java.security.Permissions.implies(java.security.Permission)
+ char s = File.separatorChar;
+ FilePermission perm[] = new FilePermission[7];
+ perm[0] = new FilePermission("test1.file", "write");
+ perm[1] = allInCurrent;
+ perm[2] = new FilePermission(s + "tmp" + s + "test" + s + "*",
+ "read,write");
+ perm[3] = new FilePermission(s + "tmp" + s + "test" + s
+ + "collection.file", "read");
+ perm[4] = new FilePermission(s + "windows" + "*", "delete");
+ perm[5] = readInFile;
+ perm[6] = new FilePermission("hello.file", "write");
+ Permissions perms = new Permissions();
+ for (int i = 0; i < perm.length; i++) {
+ perms.add(perm[i]);
+ }
+ assertTrue("Returned true for non-subset of files", !perms
+ .implies(new FilePermission("<<ALL FILES>>", "execute")));
+ assertTrue("Returned true for non-subset of action", !perms
+ .implies(new FilePermission(s + "tmp" + s + "test" + s + "*",
+ "execute")));
+ assertTrue("Returned false for subset of actions", perms
+ .implies(new FilePermission("*", "write")));
+ assertTrue("Returned false for subset of files", perms
+ .implies(new FilePermission(s + "tmp" + s + "test" + s
+ + "test.file", "read")));
+ assertTrue("Returned false for subset of files and actions", perms
+ .implies(new FilePermission(s + "tmp" + s + "test" + s
+ + "test2.file", "write")));
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Permissions2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PermissionsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java Thu Sep 14 18:17:39 2006
@@ -1,87 +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 org.apache.harmony.security.tests.java.security;
-
-import java.security.AccessControlException;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Policy;
-
-public class Policy2Test 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() {
- new TestPolicy();
- }
-
- /**
- * @tests java.security.Policy#getPolicy()
- */
- public void test_getPolicy() {
- assertNotNull("Got a null system security policy", Policy.getPolicy());
-
- SecurityManager sm = new SecurityManager() {
- public void checkPermission(Permission p) {
- if( p == null || !"setSecurityManager".equals(p.getName()) ) {
- super.checkPermission(p);
- }
- }
- };
-
- // set a security manager and then try getting the policy
- System.setSecurityManager(sm);
-
- try {
- Policy.getPolicy();
- fail("We shouldn't have been able to get the policy "
- + "with a SecurityManager in place!");
- } catch (AccessControlException e) {
- } 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());
- } finally {
- // restore the policy
- Policy.setPolicy(sysPolicy);
- }
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.AccessControlException;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Policy;
+
+public class Policy2Test 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() {
+ new TestPolicy();
+ }
+
+ /**
+ * @tests java.security.Policy#getPolicy()
+ */
+ public void test_getPolicy() {
+ assertNotNull("Got a null system security policy", Policy.getPolicy());
+
+ SecurityManager sm = new SecurityManager() {
+ public void checkPermission(Permission p) {
+ if( p == null || !"setSecurityManager".equals(p.getName()) ) {
+ super.checkPermission(p);
+ }
+ }
+ };
+
+ // set a security manager and then try getting the policy
+ System.setSecurityManager(sm);
+
+ try {
+ Policy.getPolicy();
+ fail("We shouldn't have been able to get the policy "
+ + "with a SecurityManager in place!");
+ } catch (AccessControlException e) {
+ } 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());
+ } finally {
+ // restore the policy
+ Policy.setPolicy(sysPolicy);
+ }
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Policy2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivateKeyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java Thu Sep 14 18:17:39 2006
@@ -1,47 +1,47 @@
-/* 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 org.apache.harmony.security.tests.java.security;
-
-import java.io.IOException;
-import java.security.PrivilegedActionException;
-
-public class PrivilegedActionException2Test 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());
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.io.IOException;
+import java.security.PrivilegedActionException;
+
+public class PrivilegedActionException2Test 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());
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionException2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PrivilegedActionExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProtectionDomainTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java Thu Sep 14 18:17:39 2006
@@ -1,116 +1,116 @@
-/* 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 org.apache.harmony.security.tests.java.security;
-
-import java.security.Provider;
-
-public class Provider2Test extends junit.framework.TestCase {
-
- class TestProvider extends Provider {
- TestProvider(String name, double version, String info) {
- super(name, version, info);
- }
- }
-
- class MyEntry implements java.util.Map.Entry {
- public Object getKey() {
- return null;
- }
-
- public Object getValue() {
- return null;
- }
-
- public Object setValue(Object value) {
- return null;
- }
- }
-
- 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 {
- //make it compilable on 1.5
- provTest.entrySet().add(new MyEntry());
- 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
- }
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.Provider;
+
+public class Provider2Test extends junit.framework.TestCase {
+
+ class TestProvider extends Provider {
+ TestProvider(String name, double version, String info) {
+ super(name, version, info);
+ }
+ }
+
+ class MyEntry implements java.util.Map.Entry {
+ public Object getKey() {
+ return null;
+ }
+
+ public Object getValue() {
+ return null;
+ }
+
+ public Object setValue(Object value) {
+ return null;
+ }
+ }
+
+ 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 {
+ //make it compilable on 1.5
+ provTest.entrySet().add(new MyEntry());
+ 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
+ }
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Provider2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java Thu Sep 14 18:17:39 2006
@@ -1,42 +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 org.apache.harmony.security.tests.java.security;
-
-import java.security.ProviderException;
-
-public class ProviderException2Test 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");
- assertEquals("Failed toString test for constructed instance",
- "java.security.ProviderException: test message", e
- .toString());
- }
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.ProviderException;
+
+public class ProviderException2Test 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");
+ assertEquals("Failed toString test for constructed instance",
+ "java.security.ProviderException: test message", e
+ .toString());
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderException2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderExceptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PublicKeyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java Thu Sep 14 18:17:39 2006
@@ -1,76 +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 org.apache.harmony.security.tests.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 SecureClassLoader2Test 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());
- }
+/* 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 org.apache.harmony.security.tests.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 SecureClassLoader2Test 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());
+ }
}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java?view=diff&rev=443539&r1=443538&r2=443539
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java Thu Sep 14 18:17:39 2006
@@ -1,173 +1,173 @@
-/* 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 org.apache.harmony.security.tests.java.security;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.SecureRandomSpi;
-import java.security.Security;
-
-public class SecureRandom2Test 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#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);
- }
- }
-
- /**
- * @tests java.security.SecureRandom#getAlgorithm()
- */
- public void test_getAlgorithm() {
- // Regression for HARMONY-750
-
- SecureRandomSpi spi = new SecureRandomSpi() {
-
- protected void engineSetSeed(byte[] arg) {}
-
- protected void engineNextBytes(byte[] arg) {}
-
- protected byte[] engineGenerateSeed(int arg) {
- return null;
- }
- };
-
- SecureRandom sr = new SecureRandom(spi, null) {};
-
- assertEquals("unknown", sr.getAlgorithm());
- }
-}
+/* 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 org.apache.harmony.security.tests.java.security;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.SecureRandomSpi;
+import java.security.Security;
+
+public class SecureRandom2Test 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#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);
+ }
+ }
+
+ /**
+ * @tests java.security.SecureRandom#getAlgorithm()
+ */
+ public void test_getAlgorithm() {
+ // Regression for HARMONY-750
+
+ SecureRandomSpi spi = new SecureRandomSpi() {
+
+ protected void engineSetSeed(byte[] arg) {}
+
+ protected void engineNextBytes(byte[] arg) {}
+
+ protected byte[] engineGenerateSeed(int arg) {
+ return null;
+ }
+ };
+
+ SecureRandom sr = new SecureRandom(spi, null) {};
+
+ assertEquals("unknown", sr.getAlgorithm());
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureRandom2Test.java
------------------------------------------------------------------------------
svn:eol-style = native