harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r505181 - 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 04:58:47 GMT
Author: smishura
Date: Thu Feb  8 20:58:47 2007
New Revision: 505181

URL: http://svn.apache.org/viewvc?view=rev&rev=505181
Log:
Merge and refactor tests for Security.insertProviderAt()

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=505181&r1=505180&r2=505181
==============================================================================
--- 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 20:58:47 2007
@@ -363,39 +363,6 @@
 	}
 
 	/**
-	 * @tests java.security.Security#insertProviderAt(java.security.Provider,
-	 *        int)
-	 */
-	public void test_insertProviderAtLjava_security_ProviderI() {
-		// Test for method int
-		// java.security.Security.insertProviderAt(java.security.Provider, int)
-
-		String initialSecondProviderName = (Security.getProviders()[1])
-				.getName();
-		Provider jceProvider = new Support_ProviderJCE();
-
-		try {
-			Security.insertProviderAt(jceProvider, 2);
-			Provider provTest[] = Security.getProviders();
-			assertTrue("the second provider should be jceProvider", provTest[1]
-					.getName().equals(jceProvider.getName())
-					&& provTest[1].getVersion() == jceProvider.getVersion()
-					&& provTest[1].getInfo().equals(jceProvider.getInfo()));
-			assertTrue("the third provider should be the previous second "
-					+ "provider shifted down", provTest[2].getName().equals(
-					initialSecondProviderName));
-
-			// trying to insert a provider that already exists
-			int referAdded = Security.insertProviderAt(jceProvider, 3);
-			assertEquals("the method insertProviderAt did not "
-					+ "return a -1 for providers already added", -1, referAdded);
-		} finally {
-			// Tidy up before we leave
-			Security.removeProvider(jceProvider.getName());
-		}
-	}
-
-	/**
 	 * @tests java.security.Security#removeProvider(java.lang.String)
 	 */
 	public void test_removeProviderLjava_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=505181&r1=505180&r2=505181
==============================================================================
--- 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 20:58:47 2007
@@ -55,55 +55,44 @@
 
     }
   
-    public final void testInsertProviderAt() {
+    /**
+     * @tests java.security.Security#insertProviderAt(Provider, int)
+     */
+    public final void test_insertProviderAtLjava_security_ProviderLI() {
+
+        try {
+            Security.insertProviderAt(null, 1);
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
+        }
+
         Provider p = new MyProvider();
-        int position;
-        int newposition;
-        Provider providers[] = Security.getProviders();
-        int providersNumber = providers.length;
-        
+        int initNum = Security.getProviders().length; // initial number of providers
+        Provider initialSecondProviderName = Security.getProviders()[1];
+
         try {
 
-            // Insert at position -1
-            position = -1;
-            newposition = Security.insertProviderAt(p, position);
-            assertEquals(providersNumber + 1, newposition);
-
-            providers = Security.getProviders();
-            assertSame("Provider not inserted at position " + newposition, p,
-                    providers[newposition - 1]);
-        
+            // Insert at position -1, the provider is inserted at the end 
+            assertEquals(initNum + 1, Security.insertProviderAt(p, -1));
+            assertSame(p, Security.getProviders()[initNum]);
+
             // A provider cannot be added if it is already installed
-            newposition = Security.insertProviderAt(p, 1);
-            assertEquals(-1, newposition);
-        
+            assertEquals(-1, Security.insertProviderAt(p, 1));
+
             Security.removeProvider(p.getName());
-        
+
             // insert at the end
-            position = providersNumber + 100;
-            newposition = Security.insertProviderAt(p, position);
-            assertEquals(providersNumber + 1, newposition);
-
-            providers = Security.getProviders();
-            assertSame("Provider not inserted at position " + newposition, p,
-                    providers[newposition - 1]);
-            
+            assertEquals(initNum + 1, Security.insertProviderAt(p,
+                    initNum + 100));
+            assertSame(p, Security.getProviders()[initNum]);
+
             Security.removeProvider(p.getName());
-            
+
             // insert at the first position
-            position = 1;
-            newposition = Security.insertProviderAt(p, position);
-            assertEquals(position, newposition);
-
-            providers = Security.getProviders();
-            assertSame("Provider not inserted at position " + newposition, p,
-                    providers[newposition - 1]);
-        
-            try {
-                Security.insertProviderAt(null, position);
-                fail("No expected NullPointerException.");
-            } catch (NullPointerException e) {
-            }
+            assertEquals(1, Security.insertProviderAt(p, 1));
+            assertSame(p, Security.getProviders()[0]);
+            assertSame(initialSecondProviderName, // provider shifted down 
+                    Security.getProviders()[2]);
         } finally { //clean up
             Security.removeProvider(p.getName());
         }



Mime
View raw message