harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r487460 - in /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security: AlgorithmParameters2Test.java AlgorithmParametersTest.java
Date Fri, 15 Dec 2006 06:08:54 GMT
Author: smishura
Date: Thu Dec 14 22:08:53 2006
New Revision: 487460

URL: http://svn.apache.org/viewvc?view=rev&rev=487460
Log:
Merging and refactoring tests for:
- AlgorithmParameters.getAlgorithm()
- AlgorithmParameters.getProvider()

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java?view=diff&rev=487460&r1=487459&r2=487460
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParameters2Test.java
Thu Dec 14 22:08:53 2006
@@ -30,16 +30,6 @@
 public class AlgorithmParameters2Test extends junit.framework.TestCase {
 
 	/**
-	 * @tests java.security.AlgorithmParameters#getAlgorithm()
-	 */
-	public void test_getAlgorithm() throws Exception {
-		// Test for method java.lang.String
-		// java.security.AlgorithmParameters.getAlgorithm()
-		String alg = AlgorithmParameters.getInstance("DSA").getAlgorithm();
-		assertEquals("algorithm name should be DSA", alg, "DSA");
-	}
-
-	/**
 	 * @tests java.security.AlgorithmParameters#getEncoded()
 	 */
 	public void test_getEncoded() throws Exception {
@@ -130,17 +120,6 @@
        		assertTrue("p is wrong ", spec.getP().equals(BigInteger.ONE));
        		assertTrue("q is wrong ", spec.getQ().equals(BigInteger.ONE));
        		assertTrue("g is wrong ", spec.getG().equals(BigInteger.ONE));
-	}
-
-	/**
-	 * @tests java.security.AlgorithmParameters#getProvider()
-	 */
-	public void test_getProvider() throws Exception {
-		// Test for method java.security.Provider
-		// java.security.AlgorithmParameters.getProvider()
-        Provider p = AlgorithmParameters.getInstance("DSA").getProvider();
-        assertNotNull("provider is null", p);
-
 	}
 
 	/**

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java?view=diff&rev=487460&r1=487459&r2=487460
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
Thu Dec 14 22:08:53 2006
@@ -22,10 +22,16 @@
 
 package org.apache.harmony.security.tests.java.security;
 
-import java.security.*;
-import junit.framework.TestCase;
+import java.security.AlgorithmParameters;
+import java.security.AlgorithmParametersSpi;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.Security;
 import java.security.spec.AlgorithmParameterSpec;
 
+import junit.framework.TestCase;
+
 import org.apache.harmony.security.tests.support.MyAlgorithmParameters;
 
 /**
@@ -56,14 +62,20 @@
 		super.tearDown();
 		Security.removeProvider(p.getName());
 	}
-	
-	public void testAlgorithmParameters() {
-		Provider p = new MyProvider();
-		AlgorithmParameters ap = new DummyAlgorithmParameters(null, p, "AAA");
-		if (p != ap.getProvider() || !"AAA".equals(ap.getAlgorithm())) {
-			fail("Constructor failed");
-		}
-	}
+
+    /**
+     * @tests java.security.AlgorithmParameters#getAlgorithm()
+     */
+    public void test_getAlgorithm() throws Exception {
+
+        // test: null value
+        AlgorithmParameters ap = new DummyAlgorithmParameters(null, p, null);
+        assertNull(ap.getAlgorithm());
+
+        // test: not null value
+        ap = new DummyAlgorithmParameters(null, p, "AAA");
+        assertEquals("AAA", ap.getAlgorithm());
+    }
 
 	/*
 	 * Class under test for AlgorithmParameters getInstance(String)
@@ -168,6 +180,19 @@
 		}
 		checkAP(ap, p);
 	}
+
+    /**
+     * @tests java.security.AlgorithmParameters#getProvider()
+     */
+    public void test_getProvider() throws Exception {
+        // test: null value
+        AlgorithmParameters ap = new DummyAlgorithmParameters(null, null, "AAA");
+        assertNull(ap.getProvider());
+
+        // test: not null value
+        ap = new DummyAlgorithmParameters(null, p, "AAA");
+        assertSame(p, ap.getProvider());
+    }
 
 	private void checkUnititialized(AlgorithmParameters ap) {
 		try {



Mime
View raw message