harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r597572 - in /harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security: KeyPairGenerator5Test.java PolicySpiTest.java
Date Fri, 23 Nov 2007 06:37:00 GMT
Author: pyang
Date: Thu Nov 22 22:36:52 2007
New Revision: 597572

URL: http://svn.apache.org/viewvc?rev=597572&view=rev
Log:
Add test for java6 new class PolicySpi

Added:
    harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
  (with props)
    harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
  (with props)

Added: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java?rev=597572&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
Thu Nov 22 22:36:52 2007
@@ -0,0 +1,46 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.security.tests.java.security;
+
+import java.math.BigInteger;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.spec.DSAParameterSpec;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.DSAParams;
+
+public class KeyPairGenerator5Test extends junit.framework.TestCase {
+
+   private class MockKeyPairGenerator extends KeyPairGenerator
+   {
+
+    protected MockKeyPairGenerator(String algorithm) {
+        super(algorithm);        
+    }       
+   }
+   
+   
+   public void test_generateKeyPair()
+   {
+       MockKeyPairGenerator mockKeyPairGenerator = new MockKeyPairGenerator("MOCKKEYPAIRGENERATOR");
+       assertNull(mockKeyPairGenerator.generateKeyPair());
+   }
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/KeyPairGenerator5Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java?rev=597572&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
Thu Nov 22 22:36:52 2007
@@ -0,0 +1,94 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.harmony.security.tests.java.security;
+
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.PolicySpi;
+import java.security.ProtectionDomain;
+
+import junit.framework.TestCase;
+
+public class PolicySpiTest extends TestCase {
+
+	class MockPolicySpi extends PolicySpi {
+		
+		@Override
+		protected boolean engineImplies(ProtectionDomain domain,
+				Permission permission) {
+			return false;
+		}
+		
+		public PermissionCollection testEngineGetPermissionsCodeSource() {
+			return super.engineGetPermissions((CodeSource) null);
+		}
+		
+		public PermissionCollection testEngineGetPermissionsProtectionDomain() {
+			return super.engineGetPermissions((ProtectionDomain) null);
+		}
+        
+        public void engineRefresh() {
+            //do nothing.
+            return;
+        }
+
+		
+	}
+	
+	/**
+	 * @tests java.security.PolicySpi#engineGetPermissions(CodeSource)
+	 * @since 1.6
+	 */
+	public void test_engineGetPermissions_LCodeSource() {
+		MockPolicySpi spi = new MockPolicySpi();
+		assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
+				.testEngineGetPermissionsCodeSource());
+	}
+
+	/**
+	 * @tests java.security.PolicySpi#engineGetPermissions(ProtectionDomain)
+	 * @since 1.6
+	 */
+	public void test_engineGetPermissions_LProtectionDomain() {
+		MockPolicySpi spi = new MockPolicySpi();
+        assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
+                .testEngineGetPermissionsProtectionDomain());
+	}
+    
+    /**
+     * @tests java.security.PolicySpi#engineRefresh()
+     * @since 1.6
+     */
+    public void test_engineRefresh()
+    {
+        MockPolicySpi spi = new MockPolicySpi();
+        assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
+                .testEngineGetPermissionsCodeSource());
+        assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
+                .testEngineGetPermissionsCodeSource());
+
+        // Nothing should be done according to java doc.
+        spi.engineRefresh();
+        assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
+                .testEngineGetPermissionsCodeSource());
+        assertSame(Policy.UNSUPPORTED_EMPTY_COLLECTION, spi
+                .testEngineGetPermissionsCodeSource());        
+    }
+
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/PolicySpiTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message