harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r488558 - /harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/AlgorithmParametersTest.java
Date Tue, 19 Dec 2006 07:02:03 GMT
Author: smishura
Date: Mon Dec 18 23:02:02 2006
New Revision: 488558

URL: http://svn.apache.org/viewvc?view=rev&rev=488558
Log:
Evaluation for HARMONY-2724:
[classlib][security]AlgorithmParameters.init(byte[] params, String spec) throws NullPointerException
while spec is Null on Harmony while not on RI.

Added a separate test case for AlgorithmParameters.void init(byte[] params, String format)
Removed duplicated testing

Modified:
    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/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=488558&r1=488557&r2=488558
==============================================================================
--- 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
Mon Dec 18 23:02:02 2006
@@ -282,7 +282,6 @@
         checkUnititialized(ap);
 
         ap.init(new byte[6], "aaa");
-        assertTrue("init() failed", MyAlgorithmParameters.runEngineInit3);
 
         try {
             ap.init(new MyAlgorithmParameterSpec());
@@ -377,6 +376,82 @@
         assertTrue(paramSpi.runEngineInitB$);
     }
 
+    /**
+     * @tests java.security.AlgorithmParameters#init(byte[],String)
+     */
+    public void test_init$BLjava_lang_String() throws Exception {
+
+        //
+        // test: corresponding spi method is invoked
+        //
+        final byte[] enc = new byte[] { 0x02, 0x01, 0x03 };
+        final String strFormatParam = "format";
+
+        MyAlgorithmParameters paramSpi = new MyAlgorithmParameters() {
+            protected void engineInit(byte[] params, String format)
+                    throws IOException {
+
+                runEngineInitB$String = true;
+                assertSame(enc, params);
+                assertSame(strFormatParam, format);
+            }
+        };
+
+        AlgorithmParameters params = new DummyAlgorithmParameters(paramSpi, p,
+                "algorithm");
+
+        params.init(enc, strFormatParam);
+        assertTrue(paramSpi.runEngineInitB$String);
+
+        //
+        // test: IOException if already initialized
+        //
+        try {
+            params.init(enc, strFormatParam);
+            fail("No expected IOException");
+        } catch (IOException e) {
+            // expected
+        }
+
+        params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
+        params.init(new MyAlgorithmParameterSpec());
+        try {
+            params.init(enc, strFormatParam);
+            fail("No expected IOException");
+        } catch (IOException e) {
+            // expected
+        }
+
+        params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
+        params.init(enc);
+        try {
+            params.init(enc, strFormatParam);
+            fail("No expected IOException");
+        } catch (IOException e) {
+            // expected
+        }
+
+        //
+        // test: if params and format are null
+        //
+        paramSpi = new MyAlgorithmParameters() {
+
+            protected void engineInit(byte[] params, String format)
+                    throws IOException {
+
+                runEngineInitB$String = true;
+
+                // null is passed to spi-provider
+                assertNull(params);
+                assertNull(format);
+            }
+        };
+
+        params = new DummyAlgorithmParameters(paramSpi, p, "algorithm");
+        params.init(null, null);
+        assertTrue(paramSpi.runEngineInitB$String);
+    }
+
 	private void checkUnititialized(AlgorithmParameters ap) {
         assertNull("Unititialized: toString() failed", ap.toString());
 	}
@@ -417,7 +492,7 @@
 
         public boolean runEngineInitB$ = false;
 
-        public static boolean runEngineInit3 = false;
+        public boolean runEngineInitB$String = false;
 
         public static boolean runEngineToString = false;
 
@@ -431,7 +506,6 @@
 
         protected void engineInit(byte[] params, String format)
                 throws IOException {
-            runEngineInit3 = true;
         }
 
         protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec)



Mime
View raw message