harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r636288 - /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
Date Wed, 12 Mar 2008 12:01:07 GMT
Author: smishura
Date: Wed Mar 12 05:01:06 2008
New Revision: 636288

URL: http://svn.apache.org/viewvc?rev=636288&view=rev
Log:
Fix JUnit style

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

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java?rev=636288&r1=636287&r2=636288&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/ProviderServiceTest.java
Wed Mar 12 05:01:06 2008
@@ -67,21 +67,12 @@
 		Provider.Service s = new Provider.Service(p,
                 "type", "algorithm", "className", null, null);
 		
-		if (!s.getType().equals("type")) {
-			fail("getType() failed");
-		}
-		if (!s.getAlgorithm().equals("algorithm")) {
-			fail("getAlgorithm() failed");
-		}
-		if (s.getProvider()!= p) {
-			fail("getProvider() failed");
-		}
-		if (!s.getClassName().equals("className")) {
-			fail("getClassName() failed");
-		}
-		if (!s.supportsParameter(new Object())) {
-			fail("supportsParameter() failed");
-		}
+        assertEquals("getType() failed", "type", s.getType());
+        assertEquals("getAlgorithm() failed", "algorithm", s.getAlgorithm());
+        assertSame("getProvider() failed", p, s.getProvider());
+        assertEquals("getClassName() failed", "className", s.getClassName());
+        assertTrue("supportsParameter() failed", s
+                .supportsParameter(new Object()));
 	}
 
 	public void testGetAttribute() {
@@ -94,9 +85,7 @@
 		} catch (NullPointerException e) {	
 		}
 	
-		if (s.getAttribute("aaa") != null) {
-			fail("getAttribute(aaa) failed");			
-		}
+        assertNull("getAttribute(aaa) failed", s.getAttribute("aaa"));
 		
 		HashMap hm = new HashMap();
 		hm.put("attribute", "value");
@@ -105,33 +94,22 @@
 		
 		s = new Provider.Service(p, "type", "algorithm", "className", 
 		 		null, hm);
-		if (s.getAttribute("bbb") != null) {
-			fail("getAttribute(bbb) failed");			
-		}
-		if (!s.getAttribute("attribute").equals("value")) {
-			fail("getAttribute(attribute) failed");			
-		}
-		if (!s.getAttribute("KeySize").equals("1024")) {
-			fail("getAttribute(KeySize) failed");			
-		}	
+        assertNull("getAttribute(bbb) failed", s.getAttribute("bbb"));
+        assertEquals("getAttribute(attribute) failed", "value", s
+                .getAttribute("attribute"));
+        assertEquals("getAttribute(KeySize) failed", "1024", s
+                .getAttribute("KeySize"));
 	}
     
-    public void testNewInstance() {
+    public void testNewInstance() throws NoSuchAlgorithmException {
         Provider p = new MyProvider();
         Provider.Service s = new Provider.Service(p, "SecureRandom",
                 "algorithm",
                 "org.apache.harmony.security.tests.support.RandomImpl",
                 null, null);
-        Object o = null;
-        try {
-            o = s.newInstance(null);
-        } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
-            fail("newInstance() failed");
-        }
-        if (!(o instanceof RandomImpl)) {
-            fail("incorrect instance");
-        }
+
+        Object o = s.newInstance(null);
+        assertTrue("incorrect instance", o instanceof RandomImpl);
         
         try {
             o = s.newInstance(new Object());



Mime
View raw message