Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 64658 invoked from network); 19 Dec 2006 07:02:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Dec 2006 07:02:52 -0000 Received: (qmail 31199 invoked by uid 500); 19 Dec 2006 07:02:59 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 31179 invoked by uid 500); 19 Dec 2006 07:02:59 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 31170 invoked by uid 99); 19 Dec 2006 07:02:59 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Dec 2006 23:02:59 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Dec 2006 23:02:51 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 211151A981A; Mon, 18 Dec 2006 23:02:03 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@harmony.apache.org From: smishura@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061219070203.211151A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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)