harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r415555 [12/17] - in /incubator/harmony/enhanced/classlib/trunk/modules/security: make/common/ src/test/api/java.injected/java/security/acl/ src/test/api/java.injected/java/security/cert/ src/test/api/java.injected/java/security/interfaces/...
Date Tue, 20 Jun 2006 08:11:19 GMT
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/EllipticCurveTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/EllipticCurveTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/EllipticCurveTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurveTest.java Tue Jun 20 01:11:04 2006
@@ -1,762 +1,690 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
-* @author Vladimir N. Molotkov
-* @version $Revision$
-*/
-
-package java.security.spec;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>EllipticCurve</code> class fields and methods.
- * 
- */
-public class EllipticCurveTest extends TestCase {
-
-    /**
-     * Constructor for EllipticCurveTest.
-     * @param name
-     */
-    public EllipticCurveTest(String name) {
-        super(name);
-    }
-
-    //
-    // Tests
-    //
-
-    /**
-     * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
-     * constructor<br>
-     * Assertion: creates instance of EllipticCurve<br>
-     * Test preconditions: valid parameters passed<br>
-     * Expected: must pass without any exceptions
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray01() {
-        // test case 1 parameters set
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-        // perform test case 1
-        new EllipticCurve(f, a, b, seed);
-
-        // test case 2 parameters set
-        ECFieldF2m f1 = new ECFieldF2m(5);
-        a = BigInteger.ZERO;
-        b = BigInteger.valueOf(23L);
-        // perform test case 2
-        new EllipticCurve(f1, a, b, seed);
-
-        // test case 3 parameters set,
-        // the seed parameter may be null 
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.ONE;
-        b = BigInteger.valueOf(19L);
-        seed = null;
-        // perform test case 3
-        new EllipticCurve(f, a, b, seed);
-    }
-
-    /**
-     * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
-     * constructor<br>
-     * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
-     * <code>a</code> or <code>b</code> is <code>null</code><br>
-     * Test preconditions: pass <code>null</code> as mentioned parameters<br>
-     * Expected: must throw <code>NullPointerException</code>
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray02() {
-        // test case 1 parameters set
-        ECFieldFp f = null;
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-
-        // perform test case 1
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#1: Expected NPE not thrown");
-        } catch (NullPointerException ok) {
-        }
-
-
-        // test case 2 parameters set,
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = null;
-        b = BigInteger.valueOf(19L);
-        seed = new byte[24];
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#2: Expected NPE not thrown");
-        } catch (NullPointerException ok) {
-        }
-
-
-        // test case 3 parameters set,
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.ONE;
-        b = null;
-        seed = new byte[24];
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#3: Expected NPE not thrown");
-        } catch (NullPointerException ok) {
-        }
-    }
-
-    /**
-     * Test #3 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
-     * constructor<br>
-     * Assertion: throws <code>IllegalArgumentException</code> if
-     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
-     * the <code>field</code><br>
-     * Test preconditions: pass <code>a</code>, <code>b</code> which are
-     * not in the <code>field</code> of type <code>ECFieldFp</code><br>
-     * Expected: must throw <code>IllegalArgumentException</code>
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray03() {
-        // test case 1 parameters set,
-        // a is not in field
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.valueOf(24L);
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-
-        // perform test case 1
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#1: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 1.1 parameters set,
-        // b is not in field
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.valueOf(1L);
-        b = BigInteger.valueOf(23L);
-        seed = new byte[24];
-        // perform test case 1.1
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#1.1: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-        // test case 2 parameters set,
-        // b is not in field
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.valueOf(19L);
-        b = BigInteger.valueOf(24L);
-        seed = new byte[24];
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#2: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 3 parameters set,
-        // both a and b are not in field
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.valueOf(25L);
-        b = BigInteger.valueOf(240L);
-        seed = new byte[24];
-        // perform test case 3
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#3: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-    }
-
-    /**
-     * Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
-     * constructor<br>
-     * Assertion: throws <code>IllegalArgumentException</code> if
-     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
-     * the <code>field</code><br>
-     * Test preconditions: pass <code>a</code>, <code>b</code> which are
-     * not in the <code>field</code> of type <code>ECFieldF2m</code><br>
-     * Expected: must throw <code>IllegalArgumentException</code>
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray04() {
-        // test case 1 parameters set,
-        // a is not in field
-        ECFieldF2m f = new ECFieldF2m(5);
-        BigInteger a = BigInteger.valueOf(32L);
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-
-
-        // perform test case 1
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#1: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 2 parameters set,
-        // b is not in field
-        f = new ECFieldF2m(5);
-        a = BigInteger.valueOf(19L);
-        b = BigInteger.valueOf(32L);
-        seed = new byte[24];
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#2: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 3 parameters set,
-        // both a and b are not in field
-        f = new ECFieldF2m(5);
-        a = BigInteger.valueOf(32L);
-        b = BigInteger.valueOf(43L);
-        seed = new byte[24];
-        // perform test case 3
-        try {
-            new EllipticCurve(f, a, b, seed);
-            fail("#3: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-    }
-
-    /**
-     * Test #5 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
-     * constructor<br>
-     * Assertion: array <code>seed</code> is copied to prevent subsequent modification<br>
-     * Test preconditions: pass <code>seed</code> to the ctor then modify it<br>
-     * Expected: getSeed() must return unmodified array
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray05() {
-        ECFieldF2m f = new ECFieldF2m(5);
-        BigInteger a = BigInteger.valueOf(0L);
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-        byte[] seedCopy = seed.clone();
-        EllipticCurve c = new EllipticCurve(f, a, b, seedCopy);
-        // modify array passed
-        seedCopy[0] = (byte)1;
-        // check that above modification did not changed
-        // internal state of test object
-        assertTrue(Arrays.equals(seed, c.getSeed()));
-    }
-
-    /**
-     * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
-     * constructor<br>
-     * Assertion: creates instance of EllipticCurve<br>
-     * Test preconditions: valid parameters passed, field type is ECFieldFp<br>
-     * Expected: must pass without any exceptions
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigInteger01() {
-        // test case 1 parameters set
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-        // perform test case 1
-        new EllipticCurve(f, a, b);
-
-        // test case 2 parameters set
-        ECFieldF2m f1 = new ECFieldF2m(5);
-        a = BigInteger.ZERO;
-        b = BigInteger.valueOf(23L);
-        // perform test case 2
-        new EllipticCurve(f1, a, b);
-
-        // test case 3 parameters set,
-        // the seed parameter may be null 
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.ONE;
-        b = BigInteger.valueOf(19L);
-        // perform test case 3
-        new EllipticCurve(f, a, b);
-    }
-
-    /**
-     * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
-     * constructor<br>
-     * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
-     * <code>a</code> or <code>b</code> is <code>null</code><br>
-     * Test preconditions: pass <code>null</code> as mentioned parameters<br>
-     * Expected: must throw <code>NullPointerException</code>
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigInteger02() {
-        // test case 1 parameters set
-        ECFieldFp f = null;
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-
-        // perform test case 1
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#1: Expected NPE not thrown");
-        } catch (NullPointerException ok) {
-        }
-
-
-        // test case 2 parameters set,
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = null;
-        b = BigInteger.valueOf(19L);
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#2: Expected NPE not thrown");
-        } catch (NullPointerException ok) {
-        }
-
-
-        // test case 3 parameters set,
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.ONE;
-        b = null;
-        // perform test case 3
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#3: Expected NPE not thrown");
-        } catch (NullPointerException ok) {
-        }
-    }
-
-    /**
-     * Test #3 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
-     * constructor<br>
-     * Assertion: throws <code>IllegalArgumentException</code> if
-     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
-     * the <code>field</code><br>
-     * Test preconditions: pass <code>a</code>, <code>b</code> which are
-     * not in the <code>field</code> of type <code>ECFieldFp</code><br>
-     * Expected: must throw <code>IllegalArgumentException</code>
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigInteger03() {
-        // test case 1 parameters set,
-        // a is not in field
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.valueOf(24L);
-        BigInteger b = BigInteger.valueOf(19L);
-
-        // perform test case 1
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#1: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 1.1 parameters set,
-        // a is not in field
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.valueOf(23L);
-        b = BigInteger.valueOf(19L);
-        // perform test case 1.1
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#1.1: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 2 parameters set,
-        // b is not in field
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.valueOf(19L);
-        b = BigInteger.valueOf(24L);
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#2: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 3 parameters set,
-        // both a and b are not in field
-        f = new ECFieldFp(BigInteger.valueOf(23L));
-        a = BigInteger.valueOf(25L);
-        b = BigInteger.valueOf(240L);
-        // perform test case 3
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#3: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-    }
-
-    /**
-     * Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
-     * constructor<br>
-     * Assertion: throws <code>IllegalArgumentException</code> if
-     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
-     * the <code>field</code><br>
-     * Test preconditions: pass <code>a</code>, <code>b</code> which are
-     * not in the <code>field</code> of type <code>ECFieldF2m</code><br>
-     * Expected: must throw <code>IllegalArgumentException</code>
-     */
-    public final void testEllipticCurveECFieldBigIntegerBigInteger04() {
-        // test case 1 parameters set,
-        // a is not in field
-        ECFieldF2m f = new ECFieldF2m(5);
-        BigInteger a = BigInteger.valueOf(32L);
-        BigInteger b = BigInteger.valueOf(19L);
-        // perform test case 1
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#1: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 2 parameters set,
-        // b is not in field
-        f = new ECFieldF2m(5);
-        a = BigInteger.valueOf(19L);
-        b = BigInteger.valueOf(32L);
-        // perform test case 2
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#2: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-
-
-        // test case 3 parameters set,
-        // both a and b are not in field
-        f = new ECFieldF2m(5);
-        a = BigInteger.valueOf(32L);
-        b = BigInteger.valueOf(43L);
-        // perform test case 3
-        try {
-            new EllipticCurve(f, a, b);
-            fail("#3: Expected IAE not thrown");
-        } catch (IllegalArgumentException ok) {
-        }
-    }
-
-    /**
-     * Test for <code>getA()</code> method<br>
-     * Assertion: returns coefficient <code>a</code><br>
-     * Test preconditions: <code>ECFieldF2m</code> instance
-     * created using valid parameters<br>
-     * Expected: must return coefficient <code>a</code> which is equal
-     * to the one passed to the constructor; (both must refer
-     * the same object)
-     */
-    public final void testGetA() {
-        ECFieldF2m f = new ECFieldF2m(5);
-        BigInteger a = BigInteger.valueOf(5L);
-        BigInteger b = BigInteger.valueOf(19L);
-        EllipticCurve c = new EllipticCurve(f, a, b);
-        assertEquals(a, c.getA());
-        assertSame(a, c.getA());
-    }
-
-    /**
-     * Test for <code>getB()</code> method<br>
-     * Assertion: returns coefficient <code>b</code><br>
-     * Test preconditions: <code>ECFieldF2m</code> instance
-     * created using valid parameters<br>
-     * Expected: must return coefficient <code>b</code> which is equal
-     * to the one passed to the constructor; (both must refer
-     * the same object)
-     */
-    public final void testGetB() {
-        ECFieldF2m f = new ECFieldF2m(5);
-        BigInteger a = BigInteger.valueOf(5L);
-        BigInteger b = BigInteger.valueOf(19L);
-        EllipticCurve c = new EllipticCurve(f, a, b);
-        assertEquals(b, c.getB());
-        assertSame(b, c.getB());
-    }
-
-    /**
-     * Test for <code>getField()</code> method<br>
-     * Assertion: returns <code>field</code><br>
-     * Test preconditions: <code>ECFieldF2m</code> instance
-     * created using valid parameters<br>
-     * Expected: must return <code>field</code> which is equal
-     * to the one passed to the constructor; (both must refer
-     * the same object)
-     */
-    public final void testGetField() {
-        ECFieldF2m f = new ECFieldF2m(5);
-        BigInteger a = BigInteger.valueOf(5L);
-        BigInteger b = BigInteger.valueOf(19L);
-        EllipticCurve c = new EllipticCurve(f, a, b);
-        assertEquals(f, c.getField());
-        assertSame(f, c.getField());
-    }
-
-    /**
-     * Test #1 for <code>getSeed()</code> method<br>
-     * Assertion: returns <code>seed</code><br>
-     * Test preconditions: <code>ECFieldF2m</code> instance
-     * created using valid parameters<br>
-     * Expected: must return <code>seed</code> which is equal
-     * to the one passed to the constructor
-     */
-    public final void testGetSeed01() {
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-        EllipticCurve c = new EllipticCurve(f, a, b, seed);
-        byte[] seedRet = c.getSeed();
-        assertNotNull(seedRet);
-        assertTrue(Arrays.equals(seed, seedRet));
-    }
-
-    /**
-     * Test #2 for <code>getSeed()</code> method<br>
-     * Assertion: returned array is copied to prevent subsequent modification<br>
-     * Test preconditions: <code>ECFieldF2m</code> instance
-     * created using valid parameters; <code>getSeed()</code>
-     * called and then returned array modified<br>
-     * Expected: internal state must not be affected by the modification
-     */
-    public final void testGetSeed02() {
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-        EllipticCurve c = new EllipticCurve(f, a, b, seed.clone());
-        byte[] seedRet = c.getSeed();
-        // modify returned array
-        seedRet[0] = (byte)1;
-        // check that above modification did not changed
-        // internal state of test object
-        assertTrue(Arrays.equals(seed, c.getSeed()));
-    }
-
-    /**
-     * Test #3 for <code>getSeed()</code> method<br>
-     * Assertion: returned array is copied to prevent subsequent modification<br>
-     * Test preconditions: <code>ECFieldF2m</code> instance
-     * created using valid parameters<br>
-     * Expected: repeated method calls must return different refs
-     */
-    public final void testGetSeed03() {
-        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
-        BigInteger a = BigInteger.ONE;
-        BigInteger b = BigInteger.valueOf(19L);
-        byte[] seed = new byte[24];
-        EllipticCurve c = new EllipticCurve(f, a, b, seed);
-        c.getSeed();
-        assertNotSame(c.getSeed(), c.getSeed());
-    }
-
-    /**
-     * Test #1 for <code>equals(Object other)</code> method<br>
-     * Assertion: return true if this and other objects are equal<br>
-     * Test preconditions: see test comments<br>
-     * Expected: all objects in this test must be equal
-     */
-    public final void testEqualsObject01() {
-        // test case 1: must be equal to itself
-        EllipticCurve c2=null, c1 =
-            new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                    BigInteger.ONE,
-                    BigInteger.valueOf(19L));
-        assertTrue(c1.equals(c1));
-
-        // test case 2: equal objects
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L));
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.valueOf(1L),
-                BigInteger.valueOf(19L));
-        assertTrue(c1.equals(c2) && c2.equals(c1));
-
-        // test case 3: equal objects with seed not null
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.valueOf(1L),
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        assertTrue(c1.equals(c2) && c2.equals(c1));
-
-        // test case 4: equal object and subclass object
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        MyEllipticCurve c3 = new MyEllipticCurve(
-                new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        assertTrue(c1.equals(c3) && c3.equals(c1));
-
-        // test case 5: equal objects
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L));
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.valueOf(1L),
-                BigInteger.valueOf(19L),
-                null);
-        assertTrue(c1.equals(c2) && c2.equals(c1));
-    }
-
-    /**
-     * Test #2 for <code>equals(Object other)</code> method<br>
-     * Assertion: return false if this and other objects are not equal<br>
-     * Test preconditions: see test comments<br>
-     * Expected: all objects in this test must be NOT equal
-     */
-    public final void testEqualsObject02() {
-        // test case 1: must not be equal to null
-        EllipticCurve c2=null, c1 =
-            new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                    BigInteger.ONE,
-                    BigInteger.valueOf(19L));
-        assertFalse(c1.equals(c2));
-
-        // test case 2: not equal objects - field
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L));
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(31L)),
-                BigInteger.valueOf(1L),
-                BigInteger.valueOf(19L));
-        assertFalse(c1.equals(c2) || c2.equals(c1));
-
-        // test case 3: not equal objects - a
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L));
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ZERO,
-                BigInteger.valueOf(19L));
-        assertFalse(c1.equals(c2) || c2.equals(c1));
-
-        // test case 4: not equal objects - b
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L));
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(17L));
-        assertFalse(c1.equals(c2) || c2.equals(c1));
-
-        // test case 5: not equal objects - both seed not null
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.valueOf(1L),
-                BigInteger.valueOf(19L),
-                new byte[25]);
-        assertFalse(c1.equals(c2) || c2.equals(c1));
-
-        // test case 6: not equal objects - one seed is null
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                null);
-        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.valueOf(1L),
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        assertFalse(c1.equals(c2) || c2.equals(c1));
-
-        // test case 7: not equal objects - field class
-        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        c2 = new EllipticCurve(new ECFieldF2m(5),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        assertFalse(c1.equals(c2) || c2.equals(c1));
-    }
-
-    /**
-     * Test #1 for <code>hashCode()</code> method.<br>
-     *
-     * Assertion: must return the same value if invoked
-     * repeatedly on the same object. 
-     */
-    public final void testHashCode01() {
-        int hc = 0;
-        EllipticCurve f = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                BigInteger.ONE,
-                BigInteger.valueOf(19L),
-                new byte[24]);
-        hc = f.hashCode();
-        assertTrue(hc == f.hashCode() &&
-                hc == f.hashCode() &&
-                hc == f.hashCode() &&
-                hc == f.hashCode() &&
-                hc == f.hashCode() &&
-                hc == f.hashCode() &&
-                hc == f.hashCode() &&
-                hc == f.hashCode());
-    }
-
-    /**
-     * Test #2 for <code>hashCode()</code> method.<br>
-     *
-     * Assertion: must return the same value if invoked
-     * on equal (according to the <code>equals(Object)</code> method) objects. 
-     */
-    public final void testHashCode02() {
-        assertEquals(
-                new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                        BigInteger.ONE,
-                        BigInteger.valueOf(19L),
-                        new byte[24]).hashCode(),
-                new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
-                        BigInteger.ONE,
-                        BigInteger.valueOf(19L),
-                        new byte[24]).hashCode());
-    }
-
-    //
-    // Private stuff
-    //
-
-    /**
-     * EllipticCurve subclass for testing purposes
-     * 
-     */
-    private static class MyEllipticCurve extends EllipticCurve {
-        MyEllipticCurve(ECField f, BigInteger a, BigInteger b, byte[] seed) {
-            super(f,a,b,seed);
-        }
-    }
-}
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.spec;
+
+import java.math.BigInteger;
+import java.security.spec.ECField;
+import java.security.spec.ECFieldF2m;
+import java.security.spec.ECFieldFp;
+import java.security.spec.EllipticCurve;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>EllipticCurve</code> class fields and methods.
+ * 
+ */
+public class EllipticCurveTest extends TestCase {
+
+    /**
+     * Constructor for EllipticCurveTest.
+     * @param name
+     */
+    public EllipticCurveTest(String name) {
+        super(name);
+    }
+
+    //
+    // Tests
+    //
+
+    /**
+     * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
+     * constructor<br>
+     * Assertion: creates instance of EllipticCurve<br>
+     * Test preconditions: valid parameters passed<br>
+     * Expected: must pass without any exceptions
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray01() {
+        // test case 1 parameters set
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+        // perform test case 1
+        new EllipticCurve(f, a, b, seed);
+
+        // test case 2 parameters set
+        ECFieldF2m f1 = new ECFieldF2m(5);
+        a = BigInteger.ZERO;
+        b = BigInteger.valueOf(23L);
+        // perform test case 2
+        new EllipticCurve(f1, a, b, seed);
+
+        // test case 3 parameters set,
+        // the seed parameter may be null 
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.ONE;
+        b = BigInteger.valueOf(19L);
+        seed = null;
+        // perform test case 3
+        new EllipticCurve(f, a, b, seed);
+    }
+
+    /**
+     * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
+     * constructor<br>
+     * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
+     * <code>a</code> or <code>b</code> is <code>null</code><br>
+     * Test preconditions: pass <code>null</code> as mentioned parameters<br>
+     * Expected: must throw <code>NullPointerException</code>
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray02() {
+        // test case 1 parameters set
+        ECFieldFp f = null;
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+
+        // perform test case 1
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#1: Expected NPE not thrown");
+        } catch (NullPointerException ok) {
+        }
+
+
+        // test case 2 parameters set,
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = null;
+        b = BigInteger.valueOf(19L);
+        seed = new byte[24];
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#2: Expected NPE not thrown");
+        } catch (NullPointerException ok) {
+        }
+
+
+        // test case 3 parameters set,
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.ONE;
+        b = null;
+        seed = new byte[24];
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#3: Expected NPE not thrown");
+        } catch (NullPointerException ok) {
+        }
+    }
+
+    /**
+     * Test #3 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
+     * constructor<br>
+     * Assertion: throws <code>IllegalArgumentException</code> if
+     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
+     * the <code>field</code><br>
+     * Test preconditions: pass <code>a</code>, <code>b</code> which are
+     * not in the <code>field</code> of type <code>ECFieldFp</code><br>
+     * Expected: must throw <code>IllegalArgumentException</code>
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray03() {
+        // test case 1 parameters set,
+        // a is not in field
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.valueOf(24L);
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+
+        // perform test case 1
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#1: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 1.1 parameters set,
+        // b is not in field
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.valueOf(1L);
+        b = BigInteger.valueOf(23L);
+        seed = new byte[24];
+        // perform test case 1.1
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#1.1: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+        // test case 2 parameters set,
+        // b is not in field
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.valueOf(19L);
+        b = BigInteger.valueOf(24L);
+        seed = new byte[24];
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#2: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 3 parameters set,
+        // both a and b are not in field
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.valueOf(25L);
+        b = BigInteger.valueOf(240L);
+        seed = new byte[24];
+        // perform test case 3
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#3: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+    }
+
+    /**
+     * Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
+     * constructor<br>
+     * Assertion: throws <code>IllegalArgumentException</code> if
+     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
+     * the <code>field</code><br>
+     * Test preconditions: pass <code>a</code>, <code>b</code> which are
+     * not in the <code>field</code> of type <code>ECFieldF2m</code><br>
+     * Expected: must throw <code>IllegalArgumentException</code>
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray04() {
+        // test case 1 parameters set,
+        // a is not in field
+        ECFieldF2m f = new ECFieldF2m(5);
+        BigInteger a = BigInteger.valueOf(32L);
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+
+
+        // perform test case 1
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#1: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 2 parameters set,
+        // b is not in field
+        f = new ECFieldF2m(5);
+        a = BigInteger.valueOf(19L);
+        b = BigInteger.valueOf(32L);
+        seed = new byte[24];
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#2: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 3 parameters set,
+        // both a and b are not in field
+        f = new ECFieldF2m(5);
+        a = BigInteger.valueOf(32L);
+        b = BigInteger.valueOf(43L);
+        seed = new byte[24];
+        // perform test case 3
+        try {
+            new EllipticCurve(f, a, b, seed);
+            fail("#3: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+    }
+
+    /**
+     * Test #5 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
+     * constructor<br>
+     * Assertion: array <code>seed</code> is copied to prevent subsequent modification<br>
+     * Test preconditions: pass <code>seed</code> to the ctor then modify it<br>
+     * Expected: getSeed() must return unmodified array
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigIntegerbyteArray05() {
+        ECFieldF2m f = new ECFieldF2m(5);
+        BigInteger a = BigInteger.valueOf(0L);
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+        byte[] seedCopy = seed.clone();
+        EllipticCurve c = new EllipticCurve(f, a, b, seedCopy);
+        // modify array passed
+        seedCopy[0] = (byte)1;
+        // check that above modification did not changed
+        // internal state of test object
+        assertTrue(Arrays.equals(seed, c.getSeed()));
+    }
+
+    /**
+     * Test #1 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
+     * constructor<br>
+     * Assertion: creates instance of EllipticCurve<br>
+     * Test preconditions: valid parameters passed, field type is ECFieldFp<br>
+     * Expected: must pass without any exceptions
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigInteger01() {
+        // test case 1 parameters set
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+        // perform test case 1
+        new EllipticCurve(f, a, b);
+
+        // test case 2 parameters set
+        ECFieldF2m f1 = new ECFieldF2m(5);
+        a = BigInteger.ZERO;
+        b = BigInteger.valueOf(23L);
+        // perform test case 2
+        new EllipticCurve(f1, a, b);
+
+        // test case 3 parameters set,
+        // the seed parameter may be null 
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.ONE;
+        b = BigInteger.valueOf(19L);
+        // perform test case 3
+        new EllipticCurve(f, a, b);
+    }
+
+    /**
+     * Test #2 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
+     * constructor<br>
+     * Assertion: throws <code>NullPointerException</code> if <code>field</code>,
+     * <code>a</code> or <code>b</code> is <code>null</code><br>
+     * Test preconditions: pass <code>null</code> as mentioned parameters<br>
+     * Expected: must throw <code>NullPointerException</code>
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigInteger02() {
+        // test case 1 parameters set
+        ECFieldFp f = null;
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+
+        // perform test case 1
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#1: Expected NPE not thrown");
+        } catch (NullPointerException ok) {
+        }
+
+
+        // test case 2 parameters set,
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = null;
+        b = BigInteger.valueOf(19L);
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#2: Expected NPE not thrown");
+        } catch (NullPointerException ok) {
+        }
+
+
+        // test case 3 parameters set,
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.ONE;
+        b = null;
+        // perform test case 3
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#3: Expected NPE not thrown");
+        } catch (NullPointerException ok) {
+        }
+    }
+
+    /**
+     * Test #3 for <code>EllipticCurve(ECField, BigInteger, BigInteger)</code>
+     * constructor<br>
+     * Assertion: throws <code>IllegalArgumentException</code> if
+     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
+     * the <code>field</code><br>
+     * Test preconditions: pass <code>a</code>, <code>b</code> which are
+     * not in the <code>field</code> of type <code>ECFieldFp</code><br>
+     * Expected: must throw <code>IllegalArgumentException</code>
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigInteger03() {
+        // test case 1 parameters set,
+        // a is not in field
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.valueOf(24L);
+        BigInteger b = BigInteger.valueOf(19L);
+
+        // perform test case 1
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#1: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 1.1 parameters set,
+        // a is not in field
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.valueOf(23L);
+        b = BigInteger.valueOf(19L);
+        // perform test case 1.1
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#1.1: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 2 parameters set,
+        // b is not in field
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.valueOf(19L);
+        b = BigInteger.valueOf(24L);
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#2: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 3 parameters set,
+        // both a and b are not in field
+        f = new ECFieldFp(BigInteger.valueOf(23L));
+        a = BigInteger.valueOf(25L);
+        b = BigInteger.valueOf(240L);
+        // perform test case 3
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#3: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+    }
+
+    /**
+     * Test #4 for <code>EllipticCurve(ECField, BigInteger, BigInteger, byte[])</code>
+     * constructor<br>
+     * Assertion: throws <code>IllegalArgumentException</code> if
+     * <code>a</code> or <code>b</code> is not <code>null</code> and not in
+     * the <code>field</code><br>
+     * Test preconditions: pass <code>a</code>, <code>b</code> which are
+     * not in the <code>field</code> of type <code>ECFieldF2m</code><br>
+     * Expected: must throw <code>IllegalArgumentException</code>
+     */
+    public final void testEllipticCurveECFieldBigIntegerBigInteger04() {
+        // test case 1 parameters set,
+        // a is not in field
+        ECFieldF2m f = new ECFieldF2m(5);
+        BigInteger a = BigInteger.valueOf(32L);
+        BigInteger b = BigInteger.valueOf(19L);
+        // perform test case 1
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#1: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 2 parameters set,
+        // b is not in field
+        f = new ECFieldF2m(5);
+        a = BigInteger.valueOf(19L);
+        b = BigInteger.valueOf(32L);
+        // perform test case 2
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#2: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+
+        // test case 3 parameters set,
+        // both a and b are not in field
+        f = new ECFieldF2m(5);
+        a = BigInteger.valueOf(32L);
+        b = BigInteger.valueOf(43L);
+        // perform test case 3
+        try {
+            new EllipticCurve(f, a, b);
+            fail("#3: Expected IAE not thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+    }
+
+    /**
+     * Test for <code>getA()</code> method<br>
+     * Assertion: returns coefficient <code>a</code><br>
+     * Test preconditions: <code>ECFieldF2m</code> instance
+     * created using valid parameters<br>
+     * Expected: must return coefficient <code>a</code> which is equal
+     * to the one passed to the constructor; (both must refer
+     * the same object)
+     */
+    public final void testGetA() {
+        ECFieldF2m f = new ECFieldF2m(5);
+        BigInteger a = BigInteger.valueOf(5L);
+        BigInteger b = BigInteger.valueOf(19L);
+        EllipticCurve c = new EllipticCurve(f, a, b);
+        assertEquals(a, c.getA());
+        assertSame(a, c.getA());
+    }
+
+    /**
+     * Test for <code>getB()</code> method<br>
+     * Assertion: returns coefficient <code>b</code><br>
+     * Test preconditions: <code>ECFieldF2m</code> instance
+     * created using valid parameters<br>
+     * Expected: must return coefficient <code>b</code> which is equal
+     * to the one passed to the constructor; (both must refer
+     * the same object)
+     */
+    public final void testGetB() {
+        ECFieldF2m f = new ECFieldF2m(5);
+        BigInteger a = BigInteger.valueOf(5L);
+        BigInteger b = BigInteger.valueOf(19L);
+        EllipticCurve c = new EllipticCurve(f, a, b);
+        assertEquals(b, c.getB());
+        assertSame(b, c.getB());
+    }
+
+    /**
+     * Test for <code>getField()</code> method<br>
+     * Assertion: returns <code>field</code><br>
+     * Test preconditions: <code>ECFieldF2m</code> instance
+     * created using valid parameters<br>
+     * Expected: must return <code>field</code> which is equal
+     * to the one passed to the constructor; (both must refer
+     * the same object)
+     */
+    public final void testGetField() {
+        ECFieldF2m f = new ECFieldF2m(5);
+        BigInteger a = BigInteger.valueOf(5L);
+        BigInteger b = BigInteger.valueOf(19L);
+        EllipticCurve c = new EllipticCurve(f, a, b);
+        assertEquals(f, c.getField());
+        assertSame(f, c.getField());
+    }
+
+    /**
+     * Test #1 for <code>getSeed()</code> method<br>
+     * Assertion: returns <code>seed</code><br>
+     * Test preconditions: <code>ECFieldF2m</code> instance
+     * created using valid parameters<br>
+     * Expected: must return <code>seed</code> which is equal
+     * to the one passed to the constructor
+     */
+    public final void testGetSeed01() {
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+        EllipticCurve c = new EllipticCurve(f, a, b, seed);
+        byte[] seedRet = c.getSeed();
+        assertNotNull(seedRet);
+        assertTrue(Arrays.equals(seed, seedRet));
+    }
+
+    /**
+     * Test #2 for <code>getSeed()</code> method<br>
+     * Assertion: returned array is copied to prevent subsequent modification<br>
+     * Test preconditions: <code>ECFieldF2m</code> instance
+     * created using valid parameters; <code>getSeed()</code>
+     * called and then returned array modified<br>
+     * Expected: internal state must not be affected by the modification
+     */
+    public final void testGetSeed02() {
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+        EllipticCurve c = new EllipticCurve(f, a, b, seed.clone());
+        byte[] seedRet = c.getSeed();
+        // modify returned array
+        seedRet[0] = (byte)1;
+        // check that above modification did not changed
+        // internal state of test object
+        assertTrue(Arrays.equals(seed, c.getSeed()));
+    }
+
+    /**
+     * Test #3 for <code>getSeed()</code> method<br>
+     * Assertion: returned array is copied to prevent subsequent modification<br>
+     * Test preconditions: <code>ECFieldF2m</code> instance
+     * created using valid parameters<br>
+     * Expected: repeated method calls must return different refs
+     */
+    public final void testGetSeed03() {
+        ECFieldFp f = new ECFieldFp(BigInteger.valueOf(23L));
+        BigInteger a = BigInteger.ONE;
+        BigInteger b = BigInteger.valueOf(19L);
+        byte[] seed = new byte[24];
+        EllipticCurve c = new EllipticCurve(f, a, b, seed);
+        c.getSeed();
+        assertNotSame(c.getSeed(), c.getSeed());
+    }
+
+    /**
+     * Test #1 for <code>equals(Object other)</code> method<br>
+     * Assertion: return true if this and other objects are equal<br>
+     * Test preconditions: see test comments<br>
+     * Expected: all objects in this test must be equal
+     */
+    public final void testEqualsObject01() {
+        // test case 1: must be equal to itself
+        EllipticCurve c2=null, c1 =
+            new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                    BigInteger.ONE,
+                    BigInteger.valueOf(19L));
+        assertTrue(c1.equals(c1));
+
+        // test case 2: equal objects
+        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.ONE,
+                BigInteger.valueOf(19L));
+        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.valueOf(1L),
+                BigInteger.valueOf(19L));
+        assertTrue(c1.equals(c2) && c2.equals(c1));
+
+        // test case 3: equal objects with seed not null
+        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.ONE,
+                BigInteger.valueOf(19L),
+                new byte[24]);
+        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.valueOf(1L),
+                BigInteger.valueOf(19L),
+                new byte[24]);
+        assertTrue(c1.equals(c2) && c2.equals(c1));
+
+        // test case 4: equal object and subclass object
+        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.ONE,
+                BigInteger.valueOf(19L),
+                new byte[24]);
+        MyEllipticCurve c3 = new MyEllipticCurve(
+                new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.ONE,
+                BigInteger.valueOf(19L),
+                new byte[24]);
+        assertTrue(c1.equals(c3) && c3.equals(c1));
+
+        // test case 5: equal objects
+        c1 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.ONE,
+                BigInteger.valueOf(19L));
+        c2 = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.valueOf(1L),
+                BigInteger.valueOf(19L),
+                null);
+        assertTrue(c1.equals(c2) && c2.equals(c1));
+    }
+
+    /**
+     * Test #1 for <code>hashCode()</code> method.<br>
+     *
+     * Assertion: must return the same value if invoked
+     * repeatedly on the same object. 
+     */
+    public final void testHashCode01() {
+        int hc = 0;
+        EllipticCurve f = new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                BigInteger.ONE,
+                BigInteger.valueOf(19L),
+                new byte[24]);
+        hc = f.hashCode();
+        assertTrue(hc == f.hashCode() &&
+                hc == f.hashCode() &&
+                hc == f.hashCode() &&
+                hc == f.hashCode() &&
+                hc == f.hashCode() &&
+                hc == f.hashCode() &&
+                hc == f.hashCode() &&
+                hc == f.hashCode());
+    }
+
+    /**
+     * Test #2 for <code>hashCode()</code> method.<br>
+     *
+     * Assertion: must return the same value if invoked
+     * on equal (according to the <code>equals(Object)</code> method) objects. 
+     */
+    public final void testHashCode02() {
+        assertEquals(
+                new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                        BigInteger.ONE,
+                        BigInteger.valueOf(19L),
+                        new byte[24]).hashCode(),
+                new EllipticCurve(new ECFieldFp(BigInteger.valueOf(23L)),
+                        BigInteger.ONE,
+                        BigInteger.valueOf(19L),
+                        new byte[24]).hashCode());
+    }
+
+    //
+    // Private stuff
+    //
+
+    /**
+     * EllipticCurve subclass for testing purposes
+     * 
+     */
+    private static class MyEllipticCurve extends EllipticCurve {
+        MyEllipticCurve(ECField f, BigInteger a, BigInteger b, byte[] seed) {
+            super(f,a,b,seed);
+        }
+    }
+}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/spec/EncodedKeySpecTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/spec/EncodedKeySpecTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/tests/api/java/security/spec/EncodedKeySpecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpec2Test.java Tue Jun 20 01:11:04 2006
@@ -13,7 +13,7 @@
  * limitations under the License.
  */
 
-package tests.api.java.security.spec;
+package org.apache.harmony.security.tests.java.security.spec;
 
 import java.security.Key;
 import java.security.KeyFactory;
@@ -26,7 +26,7 @@
 
 import junit.framework.TestCase;
 
-public class EncodedKeySpecTest extends TestCase {
+public class EncodedKeySpec2Test extends TestCase {
 
 	/**
 	 * @tests java.security.spec.EncodedKeySpec#getEncoded()

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/EncodedKeySpecTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/EncodedKeySpecTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/EncodedKeySpecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/EncodedKeySpecTest.java Tue Jun 20 01:11:04 2006
@@ -1,109 +1,110 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
-* @author Vladimir N. Molotkov
-* @version $Revision$
-*/
-
-package java.security.spec;
-
-import org.apache.harmony.security.tests.support.spec.MyEncodedKeySpec;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>EncodedKeySpec</code> class fields and methods.
- * 
- */
-
-public class EncodedKeySpecTest extends TestCase {
-
-    /**
-     * Constructor for EncodedKeySpecTest.
-     * @param name
-     */
-    public EncodedKeySpecTest(String name) {
-        super(name);
-    }
-    
-    /**
-     * Tests that <code>getEncoded()</code> method
-     * returns valid byte array
-     */
-    public final void testGetEncoded() {
-        
-        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
-        EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
-        
-        /* Get encoded key */
-        byte[] ek = meks.getEncoded();
-        
-        /* Check returned array */
-        boolean result = true;
-        for (int i=0; i<encodedKey.length; i++) {
-            if (encodedKey[i] != ek[i]) {
-                /* indicate failure */
-                result = false;
-            }
-        }
-        /* passed */
-        assertTrue(result);
-    }
-    
-    /**
-     * Tests that internal state of the object
-     * can not be modified by modifying initial array value
-     */
-    public final void testIsStatePreserved1() {
-        /* Create initial byte array */
-        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
-        
-        EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
-        
-        /* Modify initial array's value */
-        encodedKey[3] = (byte)5;
-        
-        /* Get encoded key */
-        byte[] ek = meks.getEncoded();
-        
-        /* Check that byte value has not been changed */
-        assertTrue(ek[3] == (byte)4);
-    }
-    
-    /**
-     * Tests that internal state of the object
-     * can not be modified using returned value
-     * of <code>getEncoded()</code> method 
-    */
-    public final void testIsStatePreserved2() {
-        
-        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
-        EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
-        
-        /* Get encoded key */
-        byte[] ek = meks.getEncoded();        
-        /* Modify returned value */
-        ek[3] = (byte)5;
-        /* Get encoded key again */
-        byte[] ek1 = meks.getEncoded();
-        
-        /* Check that byte value has not been changed */
-        assertTrue(ek1[3] == (byte)4);
-    }
- 
-}
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vladimir N. Molotkov
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.spec;
+
+import java.security.spec.EncodedKeySpec;
+
+import org.apache.harmony.security.tests.support.spec.MyEncodedKeySpec;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>EncodedKeySpec</code> class fields and methods.
+ * 
+ */
+
+public class EncodedKeySpecTest extends TestCase {
+
+    /**
+     * Constructor for EncodedKeySpecTest.
+     * @param name
+     */
+    public EncodedKeySpecTest(String name) {
+        super(name);
+    }
+    
+    /**
+     * Tests that <code>getEncoded()</code> method
+     * returns valid byte array
+     */
+    public final void testGetEncoded() {
+        
+        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
+        EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
+        
+        /* Get encoded key */
+        byte[] ek = meks.getEncoded();
+        
+        /* Check returned array */
+        boolean result = true;
+        for (int i=0; i<encodedKey.length; i++) {
+            if (encodedKey[i] != ek[i]) {
+                /* indicate failure */
+                result = false;
+            }
+        }
+        /* passed */
+        assertTrue(result);
+    }
+    
+    /**
+     * Tests that internal state of the object
+     * can not be modified by modifying initial array value
+     */
+    public final void testIsStatePreserved1() {
+        /* Create initial byte array */
+        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
+        
+        EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
+        
+        /* Modify initial array's value */
+        encodedKey[3] = (byte)5;
+        
+        /* Get encoded key */
+        byte[] ek = meks.getEncoded();
+        
+        /* Check that byte value has not been changed */
+        assertTrue(ek[3] == (byte)4);
+    }
+    
+    /**
+     * Tests that internal state of the object
+     * can not be modified using returned value
+     * of <code>getEncoded()</code> method 
+    */
+    public final void testIsStatePreserved2() {
+        
+        byte[] encodedKey = new byte[] {(byte)1,(byte)2,(byte)3,(byte)4};
+        EncodedKeySpec meks = new MyEncodedKeySpec(encodedKey);
+        
+        /* Get encoded key */
+        byte[] ek = meks.getEncoded();        
+        /* Modify returned value */
+        ek[3] = (byte)5;
+        /* Get encoded key again */
+        byte[] ek1 = meks.getEncoded();
+        
+        /* Check that byte value has not been changed */
+        assertTrue(ek1[3] == (byte)4);
+    }
+ 
+}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/InvalidKeySpecExceptionTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/InvalidKeySpecExceptionTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/InvalidKeySpecExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/spec/InvalidKeySpecExceptionTest.java Tue Jun 20 01:11:04 2006
@@ -1,241 +1,240 @@
-/*
- *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- */
-
-/**
-* @author Vera Y. Petrashkova
-* @version $Revision$
-*/
-
-package java.security.spec;
-
-import java.security.spec.InvalidKeySpecException;
-
-import junit.framework.TestCase;
-
-
-/**
- * Tests for <code>InvalidKeySpecException</code> class constructors and
- * methods.
- * 
- */
-public class InvalidKeySpecExceptionTest extends TestCase {
-
-    public static void main(String[] args) {
-    }
-
-    /**
-     * Constructor for InvalidKeySpecExceptionTests.
-     * 
-     * @param arg0
-     */
-    public InvalidKeySpecExceptionTest(String arg0) {
-        super(arg0);
-    }
-
-    private static String[] msgs = {
-            "",
-            "Check new message",
-            "Check new message Check new message Check new message Check new message Check new message" };
-
-    private static Throwable tCause = new Throwable("Throwable for exception");
-
-    static String createErr(Exception tE, Exception eE) {
-        return "InvalidKeySpecException: ".concat(tE.toString()).concat(
-                " is not equal to caught exception: ").concat(eE.toString());
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException()</code> constructor Assertion:
-     * constructs InvalidKeySpecException with no detail message
-     */
-    public void testInvalidKeySpecException01() {
-        InvalidKeySpecException tE = new InvalidKeySpecException();
-        assertNull("getMessage() must return null.", tE.getMessage());
-        assertNull("getCause() must return null", tE.getCause());
-        try {
-            throw tE;
-        } catch (Exception e) {
-            assertTrue(createErr(tE, e), tE.equals(e));
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(String)</code> constructor
-     * Assertion: constructs InvalidKeySpecException with detail message msg.
-     * Parameter <code>msg</code> is not null.
-     */
-    public void testInvalidKeySpecException02() {
-        InvalidKeySpecException tE;
-        for (int i = 0; i < msgs.length; i++) {
-            tE = new InvalidKeySpecException(msgs[i]);
-            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
-                    .getMessage(), msgs[i]);
-            assertNull("getCause() must return null", tE.getCause());
-            try {
-                throw tE;
-            } catch (Exception e) {
-                assertTrue(createErr(tE, e), tE.equals(e));
-            }
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(String)</code> constructor
-     * Assertion: constructs InvalidKeySpecException when <code>msg</code> is
-     * null
-     */
-    public void testInvalidKeySpecException03() {
-        String msg = null;
-        InvalidKeySpecException tE = new InvalidKeySpecException(msg);
-        assertNull("getMessage() must return null.", tE.getMessage());
-        assertNull("getCause() must return null", tE.getCause());
-        try {
-            throw tE;
-        } catch (Exception e) {
-            assertTrue(createErr(tE, e), tE.equals(e));
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(Throwable)</code> constructor
-     * Assertion: constructs InvalidKeySpecException when <code>cause</code>
-     * is null
-     */
-    public void testInvalidKeySpecException04() {
-        Throwable cause = null;
-        InvalidKeySpecException tE = new InvalidKeySpecException(cause);
-        assertNull("getMessage() must return null.", tE.getMessage());
-        assertNull("getCause() must return null", tE.getCause());
-        try {
-            throw tE;
-        } catch (Exception e) {
-            assertTrue(createErr(tE, e), tE.equals(e));
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(Throwable)</code> constructor
-     * Assertion: constructs InvalidKeySpecException when <code>cause</code>
-     * is not null
-     */
-    public void testInvalidKeySpecException05() {
-        InvalidKeySpecException tE = new InvalidKeySpecException(tCause);
-        if (tE.getMessage() != null) {
-            String toS = tCause.toString();
-            String getM = tE.getMessage();
-            assertTrue("getMessage() should contain ".concat(toS), (getM
-                    .indexOf(toS) != -1));
-        }
-        assertNotNull("getCause() must not return null", tE.getCause());
-        assertEquals("getCause() must return ".concat(tCause.toString()), tE
-                .getCause(), tCause);
-        try {
-            throw tE;
-        } catch (Exception e) {
-            assertTrue(createErr(tE, e), tE.equals(e));
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
-     * constructor Assertion: constructs InvalidKeySpecException when
-     * <code>cause</code> is null <code>msg</code> is null
-     */
-    public void testInvalidKeySpecException06() {
-        InvalidKeySpecException tE = new InvalidKeySpecException(null, null);
-        assertNull("getMessage() must return null", tE.getMessage());
-        assertNull("getCause() must return null", tE.getCause());
-        try {
-            throw tE;
-        } catch (Exception e) {
-            assertTrue(createErr(tE, e), tE.equals(e));
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
-     * constructor Assertion: constructs InvalidKeySpecException when
-     * <code>cause</code> is null <code>msg</code> is not null
-     */
-    public void testInvalidKeySpecException07() {
-        InvalidKeySpecException tE;
-        for (int i = 0; i < msgs.length; i++) {
-            tE = new InvalidKeySpecException(msgs[i], null);
-            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
-                    .getMessage(), msgs[i]);
-            assertNull("getCause() must return null", tE.getCause());
-            try {
-                throw tE;
-            } catch (Exception e) {
-                assertTrue(createErr(tE, e), tE.equals(e));
-            }
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
-     * constructor Assertion: constructs InvalidKeySpecException when
-     * <code>cause</code> is not null <code>msg</code> is null
-     */
-    public void testInvalidKeySpecException08() {
-        InvalidKeySpecException tE = new InvalidKeySpecException(null, tCause);
-        if (tE.getMessage() != null) {
-            String toS = tCause.toString();
-            String getM = tE.getMessage();
-            assertTrue("getMessage() must should ".concat(toS), (getM
-                    .indexOf(toS) != -1));
-        }
-        assertNotNull("getCause() must not return null", tE.getCause());
-        assertEquals("getCause() must return ".concat(tCause.toString()), tE
-                .getCause(), tCause);
-        try {
-            throw tE;
-        } catch (Exception e) {
-            assertTrue(createErr(tE, e), tE.equals(e));
-        }
-    }
-
-    /**
-     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
-     * constructor Assertion: constructs InvalidKeySpecException when
-     * <code>cause</code> is not null <code>msg</code> is not null
-     */
-    public void testInvalidKeySpecException09() {
-        InvalidKeySpecException tE;
-        for (int i = 0; i < msgs.length; i++) {
-            tE = new InvalidKeySpecException(msgs[i], tCause);
-            String getM = tE.getMessage();
-            String toS = tCause.toString();
-            if (msgs[i].length() > 0) {
-                assertTrue("getMessage() must contain ".concat(msgs[i]), getM
-                        .indexOf(msgs[i]) != -1);
-                if (!getM.equals(msgs[i])) {
-                    assertTrue("getMessage() should contain ".concat(toS), getM
-                            .indexOf(toS) != -1);
-                }
-            }
-            assertNotNull("getCause() must not return null", tE.getCause());
-            assertEquals("getCause() must return ".concat(tCause.toString()),
-                    tE.getCause(), tCause);
-
-            try {
-                throw tE;
-            } catch (Exception e) {
-                assertTrue(createErr(tE, e), tE.equals(e));
-            }
-        }
-    }
-}
+/*
+ *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+* @author Vera Y. Petrashkova
+* @version $Revision$
+*/
+
+package org.apache.harmony.security.tests.java.security.spec;
+
+import java.security.spec.InvalidKeySpecException;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>InvalidKeySpecException</code> class constructors and
+ * methods.
+ * 
+ */
+public class InvalidKeySpecExceptionTest extends TestCase {
+
+    public static void main(String[] args) {
+    }
+
+    /**
+     * Constructor for InvalidKeySpecExceptionTests.
+     * 
+     * @param arg0
+     */
+    public InvalidKeySpecExceptionTest(String arg0) {
+        super(arg0);
+    }
+
+    private static String[] msgs = {
+            "",
+            "Check new message",
+            "Check new message Check new message Check new message Check new message Check new message" };
+
+    private static Throwable tCause = new Throwable("Throwable for exception");
+
+    static String createErr(Exception tE, Exception eE) {
+        return "InvalidKeySpecException: ".concat(tE.toString()).concat(
+                " is not equal to caught exception: ").concat(eE.toString());
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException()</code> constructor Assertion:
+     * constructs InvalidKeySpecException with no detail message
+     */
+    public void testInvalidKeySpecException01() {
+        InvalidKeySpecException tE = new InvalidKeySpecException();
+        assertNull("getMessage() must return null.", tE.getMessage());
+        assertNull("getCause() must return null", tE.getCause());
+        try {
+            throw tE;
+        } catch (Exception e) {
+            assertTrue(createErr(tE, e), tE.equals(e));
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(String)</code> constructor
+     * Assertion: constructs InvalidKeySpecException with detail message msg.
+     * Parameter <code>msg</code> is not null.
+     */
+    public void testInvalidKeySpecException02() {
+        InvalidKeySpecException tE;
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new InvalidKeySpecException(msgs[i]);
+            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
+                    .getMessage(), msgs[i]);
+            assertNull("getCause() must return null", tE.getCause());
+            try {
+                throw tE;
+            } catch (Exception e) {
+                assertTrue(createErr(tE, e), tE.equals(e));
+            }
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(String)</code> constructor
+     * Assertion: constructs InvalidKeySpecException when <code>msg</code> is
+     * null
+     */
+    public void testInvalidKeySpecException03() {
+        String msg = null;
+        InvalidKeySpecException tE = new InvalidKeySpecException(msg);
+        assertNull("getMessage() must return null.", tE.getMessage());
+        assertNull("getCause() must return null", tE.getCause());
+        try {
+            throw tE;
+        } catch (Exception e) {
+            assertTrue(createErr(tE, e), tE.equals(e));
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(Throwable)</code> constructor
+     * Assertion: constructs InvalidKeySpecException when <code>cause</code>
+     * is null
+     */
+    public void testInvalidKeySpecException04() {
+        Throwable cause = null;
+        InvalidKeySpecException tE = new InvalidKeySpecException(cause);
+        assertNull("getMessage() must return null.", tE.getMessage());
+        assertNull("getCause() must return null", tE.getCause());
+        try {
+            throw tE;
+        } catch (Exception e) {
+            assertTrue(createErr(tE, e), tE.equals(e));
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(Throwable)</code> constructor
+     * Assertion: constructs InvalidKeySpecException when <code>cause</code>
+     * is not null
+     */
+    public void testInvalidKeySpecException05() {
+        InvalidKeySpecException tE = new InvalidKeySpecException(tCause);
+        if (tE.getMessage() != null) {
+            String toS = tCause.toString();
+            String getM = tE.getMessage();
+            assertTrue("getMessage() should contain ".concat(toS), (getM
+                    .indexOf(toS) != -1));
+        }
+        assertNotNull("getCause() must not return null", tE.getCause());
+        assertEquals("getCause() must return ".concat(tCause.toString()), tE
+                .getCause(), tCause);
+        try {
+            throw tE;
+        } catch (Exception e) {
+            assertTrue(createErr(tE, e), tE.equals(e));
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
+     * constructor Assertion: constructs InvalidKeySpecException when
+     * <code>cause</code> is null <code>msg</code> is null
+     */
+    public void testInvalidKeySpecException06() {
+        InvalidKeySpecException tE = new InvalidKeySpecException(null, null);
+        assertNull("getMessage() must return null", tE.getMessage());
+        assertNull("getCause() must return null", tE.getCause());
+        try {
+            throw tE;
+        } catch (Exception e) {
+            assertTrue(createErr(tE, e), tE.equals(e));
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
+     * constructor Assertion: constructs InvalidKeySpecException when
+     * <code>cause</code> is null <code>msg</code> is not null
+     */
+    public void testInvalidKeySpecException07() {
+        InvalidKeySpecException tE;
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new InvalidKeySpecException(msgs[i], null);
+            assertEquals("getMessage() must return: ".concat(msgs[i]), tE
+                    .getMessage(), msgs[i]);
+            assertNull("getCause() must return null", tE.getCause());
+            try {
+                throw tE;
+            } catch (Exception e) {
+                assertTrue(createErr(tE, e), tE.equals(e));
+            }
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
+     * constructor Assertion: constructs InvalidKeySpecException when
+     * <code>cause</code> is not null <code>msg</code> is null
+     */
+    public void testInvalidKeySpecException08() {
+        InvalidKeySpecException tE = new InvalidKeySpecException(null, tCause);
+        if (tE.getMessage() != null) {
+            String toS = tCause.toString();
+            String getM = tE.getMessage();
+            assertTrue("getMessage() must should ".concat(toS), (getM
+                    .indexOf(toS) != -1));
+        }
+        assertNotNull("getCause() must not return null", tE.getCause());
+        assertEquals("getCause() must return ".concat(tCause.toString()), tE
+                .getCause(), tCause);
+        try {
+            throw tE;
+        } catch (Exception e) {
+            assertTrue(createErr(tE, e), tE.equals(e));
+        }
+    }
+
+    /**
+     * Test for <code>InvalidKeySpecException(String, Throwable)</code>
+     * constructor Assertion: constructs InvalidKeySpecException when
+     * <code>cause</code> is not null <code>msg</code> is not null
+     */
+    public void testInvalidKeySpecException09() {
+        InvalidKeySpecException tE;
+        for (int i = 0; i < msgs.length; i++) {
+            tE = new InvalidKeySpecException(msgs[i], tCause);
+            String getM = tE.getMessage();
+            String toS = tCause.toString();
+            if (msgs[i].length() > 0) {
+                assertTrue("getMessage() must contain ".concat(msgs[i]), getM
+                        .indexOf(msgs[i]) != -1);
+                if (!getM.equals(msgs[i])) {
+                    assertTrue("getMessage() should contain ".concat(toS), getM
+                            .indexOf(toS) != -1);
+                }
+            }
+            assertNotNull("getCause() must not return null", tE.getCause());
+            assertEquals("getCause() must return ".concat(tCause.toString()),
+                    tE.getCause(), tCause);
+
+            try {
+                throw tE;
+            } catch (Exception e) {
+                assertTrue(createErr(tE, e), tE.equals(e));
+            }
+        }
+    }
+}



Mime
View raw message