harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r505200 - in /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security: Security2Test.java SecurityTest.java
Date Fri, 09 Feb 2007 06:42:58 GMT
Author: smishura
Date: Thu Feb  8 22:42:57 2007
New Revision: 505200

URL: http://svn.apache.org/viewvc?view=rev&rev=505200
Log:
Refactor tests and delete duplicated testing for Security.addProvider()

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

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java?view=diff&rev=505200&r1=505199&r2=505200
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/Security2Test.java
Thu Feb  8 22:42:57 2007
@@ -25,82 +25,10 @@
 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 Security2Test extends junit.framework.TestCase {
-
-	/**
-	 * @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));
-		} 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());
-		} 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);
-		} finally {
-			// Now remove it - does nothing if provider not actually installed
-			Security.removeProvider(entrust.getName());
-		}
-	}
 
 	/**
 	 * @tests java.security.Security#getProviders(java.lang.String)

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java?view=diff&rev=505200&r1=505199&r2=505200
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecurityTest.java
Thu Feb  8 22:42:57 2007
@@ -98,35 +98,30 @@
         }
     }
 
-    public final void testAddProvider() {
+    /**
+     * @tests java.security.Security#addProvider(Provider)
+     */
+    public final void test_addProviderLjava_security_Provider() {
+
+        try {
+            Security.addProvider(null);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
+        }
 
         Provider p = new MyProvider();
-        int newposition;
-        Provider providers[] = Security.getProviders();
-        int providersNumber = providers.length;
-        
+        int initNum = Security.getProviders().length; // initial number of providers
+
         try {
             // add
-            newposition = Security.addProvider(p);
-            assertEquals(providersNumber + 1, newposition);
+            assertEquals(initNum + 1, Security.addProvider(p));
+            assertSame(p, Security.getProviders()[initNum]);
 
-            providers = Security.getProviders();
-            assertSame("Provider not inserted at position " + newposition, p,
-                    providers[newposition - 1]);
-        
             // A provider cannot be added if it is already installed
-            newposition = Security.addProvider(p);
-            assertEquals(-1, newposition);
-        
-            try {
-                Security.addProvider(null);
-                fail("No expected NullPointerException.");
-            } catch (NullPointerException e) {
-            }
+            assertEquals(-1, Security.addProvider(p));
         } finally { //clean up
             Security.removeProvider(p.getName());
         }
-        
     }
 
     public final void testRemoveProvider() {



Mime
View raw message