You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ml...@apache.org on 2006/06/20 10:11:19 UTC
svn commit: r415555 [16/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/...
Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java?rev=415555&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECFieldF2m_ImplTest.java Tue Jun 20 01:11:04 2006
@@ -0,0 +1,219 @@
+/*
+ * 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.ECFieldF2m;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ECFieldF2m</code> class fields and methods.
+ *
+ */
+public class ECFieldF2m_ImplTest extends TestCase {
+
+ /**
+ * Support class for this test.
+ * Incapsulates <code>ECFieldF2m</code> testing
+ * domain parameters.
+ *
+ */
+ private static final class ECFieldF2mDomainParams {
+
+ /**
+ * <code>NPE</code> reference object of class NullPointerException.
+ * NullPointerException must be thrown by <code>ECFieldF2m</code>
+ * ctors in some circumstances
+ */
+ static final NullPointerException NPE = new NullPointerException();
+ /**
+ * <code>IArgE</code> reference object of class IllegalArgumentException.
+ * IllegalArgumentException must be thrown by <code>ECFieldF2m</code>
+ * ctors in some circumstances
+ */
+ static final IllegalArgumentException IArgE = new IllegalArgumentException();
+
+ /**
+ * The <code>m</code> parameter for <code>ECFieldF2m</code>
+ * ctor for the current test.
+ */
+ final int m;
+ /**
+ * The <code>rp</code> parameter for <code>ECFieldF2m</code>
+ * ctor for the current test.
+ */
+ final BigInteger rp;
+ /**
+ * The <code>ks</code> parameter for <code>ECFieldF2m</code>
+ * ctor for the current test.
+ */
+ final int[] ks;
+
+
+ /**
+ * Exception expected with this parameters set or <code>null</code>
+ * if no exception expected.
+ */
+ final Exception x;
+
+ /**
+ * Constructs ECFieldF2mDomainParams
+ *
+ * @param m
+ * @param rp
+ * @param ks
+ * @param expectedException
+ */
+ ECFieldF2mDomainParams(final int m,
+ final BigInteger rp,
+ final int[] ks,
+ final Exception expectedException) {
+ this.m = m;
+ this.rp = rp;
+ this.ks = ks;
+ this.x = expectedException;
+ }
+ }
+
+
+ /**
+ * Set of parameters used for <code>ECFieldF2m(int, BigInteger)</code>
+ * constructor tests.
+ */
+ private final ECFieldF2mDomainParams[] intBigIntegerCtorTestParameters =
+ new ECFieldF2mDomainParams[] {
+ // set 0: valid m and rp - trinomial basis params
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1999),
+ null,
+ null),
+ // set 1: valid m and rp - pentanomial basis params
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(981).setBit(2000),
+ null,
+ null),
+ // set 2: valid m, invalid (null) rp
+ new ECFieldF2mDomainParams(
+ 1963,
+ (BigInteger)null,
+ null,
+ ECFieldF2mDomainParams.NPE),
+ // set 3: valid m, invalid rp - bit 0 not set
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(1).setBit(367).setBit(1999),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 4: valid m, invalid rp - bit m not set
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(0).setBit(367).setBit(1998),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 5: valid m, invalid rp - bit k improperly set
+ new ECFieldF2mDomainParams(
+ 1999,
+ BigInteger.valueOf(0L).setBit(0).setBit(2367).setBit(1999),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 6: valid m, invalid rp - k1 k2 k3
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(2001).setBit(2002).setBit(2003).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 7: valid m, invalid rp - number of bits set
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 8: valid m, invalid rp - number of bits set
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 9: valid m, invalid rp - number of bits set
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
+ setBit(981).setBit(985).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 10: valid m, invalid rp
+ new ECFieldF2mDomainParams(
+ 2000,
+ BigInteger.valueOf(0L),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ // set 11: invalid m
+ new ECFieldF2mDomainParams(
+ -2000,
+ BigInteger.valueOf(0L).setBit(0).setBit(1).setBit(2).
+ setBit(981).setBit(2000),
+ null,
+ ECFieldF2mDomainParams.IArgE),
+ };
+
+ /**
+ * Tests for constructor <code>ECFieldF2m(int, BigInteger)</code><br>
+ *
+ * Assertion: constructs new <code>ECFieldF2m</code> object
+ * using valid parameters m and rp. rp represents trinomial basis.
+ *
+ * Assertion: constructs new <code>ECFieldF2m</code> object
+ * using valid parameters m and rp. rp represents pentanomial basis.
+ *
+ * Assertion: IllegalArgumentException if m is not positive.
+ *
+ * Assertion: NullPointerException if rp is null.
+ *
+ * Assertion: IllegalArgumentException if rp is invalid.
+ */
+ public final void testECFieldF2mintBigInteger() {
+ for(int i=0; i<intBigIntegerCtorTestParameters.length; i++) {
+ ECFieldF2mDomainParams tp = intBigIntegerCtorTestParameters[i];
+ try {
+ // perform test
+ new ECFieldF2m(tp.m, tp.rp);
+
+ if (tp.x != null) {
+ // exception has been expected
+ fail(getName() + ", set " + i +
+ " FAILED: expected exception has not been thrown");
+ }
+ } catch (Exception e){
+ if (tp.x == null || !e.getClass().isInstance(tp.x)) {
+ // exception: failure
+ // if it has not been expected
+ // or wrong one has been thrown
+ fail(getName() + ", set " + i +
+ " FAILED: unexpected " + e);
+ }
+ }
+ }
+ }
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECParameterSpecTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECParameterSpecTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECParameterSpecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECParameterSpec_ImplTest.java Tue Jun 20 01:11:04 2006
@@ -1,269 +1,264 @@
-/*
- * 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 junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ECParameterSpec</code> class fields and methods.
- *
- */
-public class ECParameterSpecTest extends TestCase {
-
- /**
- * Constructor for ECParameterSpecTest.
- * @param name
- */
- public ECParameterSpecTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
- // NOTE: the following tests use EC domain parameters
- // which are invalid for real EC cryptography application
- // but must be acceptable by the class under test according
- // to the API specification
- //
-
- /**
- * Test #1 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
- * Assertion: creates <code>ECParameterSpec</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECParameterSpec01() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
- }
-
- /**
- * Test #2 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if
- * <code>curve</code>, <code>generator</code> or <code>order</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 testECParameterSpec02() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
-
- // Test case 1: curve is null
- try {
- new ECParameterSpec(null, generator, order, 10);
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 2: generator is null
- try {
- new ECParameterSpec(curve, null, order, 10);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 3: order is null
- try {
- new ECParameterSpec(curve, generator, null, 10);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 4: all above are null
- try {
- new ECParameterSpec(null, null, null, 10);
- fail("#4: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>order</code> or <code>cofactor</code> is not positive<br>
- * Test preconditions: pass not positive as mentioned parameters<br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testECParameterSpec03() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
-
- // Test case 1: order is negative
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 10);
- fail("#1: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 2: order == 0
- try {
- new ECParameterSpec(curve, generator, BigInteger.ZERO, 10);
- fail("#2: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 3: cofactor is negative
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), -10);
- fail("#3: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 4: cofactor == 0
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), 0);
- fail("#4: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
-
-
- // Test case 5: both order and cofactor are not positive
- try {
- new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 0);
- fail("#5: Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test for <code>getCofactor()</code> method<br>
- * Assertion: returns cofactor<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return cofactor value which is equal
- * to the one passed to the constructor
- */
- public final void testGetCofactor() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- assertEquals(cofactor, ps.getCofactor());
- }
-
- /**
- * Test for <code>getCurve()</code> method<br>
- * Assertion: returns curve<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return ref to the <code>EllipticCurve</code> object
- * which is equal to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetCurve() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- EllipticCurve curveRet = ps.getCurve();
- assertEquals(curve, curveRet);
- assertSame(curve, curveRet);
- }
-
- /**
- * Test for <code>getGenerator()</code> method<br>
- * Assertion: returns generator<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return ref to the <code>ECPoint</code> object
- * which is equal to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetGenerator() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- ECPoint generatorRet = ps.getGenerator();
- assertEquals(generator, generatorRet);
- assertSame(generator, generatorRet);
- }
-
- /**
- * Test for <code>getOrder()</code> method<br>
- * Assertion: returns order<br>
- * Test preconditions: <code>ECParameterSpec</code> instance
- * created using valid parameters<br>
- * Expected: must return ref to the <code>BigInteger</code> object
- * which is equal to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetOrder() {
- // Valid (see note below) parameters set
- EllipticCurve curve =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- BigInteger order = BigInteger.valueOf(5L);
- int cofactor = 10;
- ECParameterSpec ps =
- new ECParameterSpec(curve, generator, order, cofactor);
- BigInteger orderRet = ps.getOrder();
- assertEquals(order, orderRet);
- assertSame(order, orderRet);
- }
-
-}
+/*
+ * 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.ECFieldFp;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.EllipticCurve;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ECParameterSpec</code> class fields and methods.
+ *
+ */
+public class ECParameterSpec_ImplTest extends TestCase {
+
+ //
+ // Tests
+ //
+ // NOTE: the following tests use EC domain parameters
+ // which are invalid for real EC cryptography application
+ // but must be acceptable by the class under test according
+ // to the API specification
+ //
+
+ /**
+ * Test #1 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
+ * Assertion: creates <code>ECParameterSpec</code> instance<br>
+ * Test preconditions: valid parameters passed<br>
+ * Expected: must pass without any exceptions
+ */
+ public final void testECParameterSpec01() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
+ }
+
+ /**
+ * Test #2 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
+ * Assertion: throws <code>NullPointerException</code> if
+ * <code>curve</code>, <code>generator</code> or <code>order</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 testECParameterSpec02() {
+ // Valid (see note below) parameters set
+ EllipticCurve curve =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ BigInteger order = BigInteger.valueOf(5L);
+
+ // Test case 1: curve is null
+ try {
+ new ECParameterSpec(null, generator, order, 10);
+ fail("#1: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 2: generator is null
+ try {
+ new ECParameterSpec(curve, null, order, 10);
+ fail("#2: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 3: order is null
+ try {
+ new ECParameterSpec(curve, generator, null, 10);
+ fail("#3: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 4: all above are null
+ try {
+ new ECParameterSpec(null, null, null, 10);
+ fail("#4: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+ }
+
+ /**
+ * Test #3 for <code>ECParameterSpec(EllipticCurve, ECPoint, BigInteger, int)</code> constructor<br>
+ * Assertion: throws <code>IllegalArgumentException</code> if
+ * <code>order</code> or <code>cofactor</code> is not positive<br>
+ * Test preconditions: pass not positive as mentioned parameters<br>
+ * Expected: must throw <code>IllegalArgumentException</code>
+ */
+ public final void testECParameterSpec03() {
+ // Valid (see note below) parameters set
+ EllipticCurve curve =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+
+
+ // Test case 1: order is negative
+ try {
+ new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 10);
+ fail("#1: Expected IAE not thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+
+ // Test case 2: order == 0
+ try {
+ new ECParameterSpec(curve, generator, BigInteger.ZERO, 10);
+ fail("#2: Expected IAE not thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+
+ // Test case 3: cofactor is negative
+ try {
+ new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), -10);
+ fail("#3: Expected IAE not thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+
+ // Test case 4: cofactor == 0
+ try {
+ new ECParameterSpec(curve, generator, BigInteger.valueOf(5L), 0);
+ fail("#4: Expected IAE not thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+
+
+ // Test case 5: both order and cofactor are not positive
+ try {
+ new ECParameterSpec(curve, generator, BigInteger.valueOf(-5L), 0);
+ fail("#5: Expected IAE not thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+ }
+
+ /**
+ * Test for <code>getCofactor()</code> method<br>
+ * Assertion: returns cofactor<br>
+ * Test preconditions: <code>ECParameterSpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return cofactor value which is equal
+ * to the one passed to the constructor
+ */
+ public final void testGetCofactor() {
+ // Valid (see note below) parameters set
+ EllipticCurve curve =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ BigInteger order = BigInteger.valueOf(5L);
+ int cofactor = 10;
+ ECParameterSpec ps =
+ new ECParameterSpec(curve, generator, order, cofactor);
+ assertEquals(cofactor, ps.getCofactor());
+ }
+
+ /**
+ * Test for <code>getCurve()</code> method<br>
+ * Assertion: returns curve<br>
+ * Test preconditions: <code>ECParameterSpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return ref to the <code>EllipticCurve</code> object
+ * which is equal to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetCurve() {
+ // Valid (see note below) parameters set
+ EllipticCurve curve =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ BigInteger order = BigInteger.valueOf(5L);
+ int cofactor = 10;
+ ECParameterSpec ps =
+ new ECParameterSpec(curve, generator, order, cofactor);
+ EllipticCurve curveRet = ps.getCurve();
+ assertEquals(curve, curveRet);
+ assertSame(curve, curveRet);
+ }
+
+ /**
+ * Test for <code>getGenerator()</code> method<br>
+ * Assertion: returns generator<br>
+ * Test preconditions: <code>ECParameterSpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return ref to the <code>ECPoint</code> object
+ * which is equal to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetGenerator() {
+ // Valid (see note below) parameters set
+ EllipticCurve curve =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ BigInteger order = BigInteger.valueOf(5L);
+ int cofactor = 10;
+ ECParameterSpec ps =
+ new ECParameterSpec(curve, generator, order, cofactor);
+ ECPoint generatorRet = ps.getGenerator();
+ assertEquals(generator, generatorRet);
+ assertSame(generator, generatorRet);
+ }
+
+ /**
+ * Test for <code>getOrder()</code> method<br>
+ * Assertion: returns order<br>
+ * Test preconditions: <code>ECParameterSpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return ref to the <code>BigInteger</code> object
+ * which is equal to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetOrder() {
+ // Valid (see note below) parameters set
+ EllipticCurve curve =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint generator = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ BigInteger order = BigInteger.valueOf(5L);
+ int cofactor = 10;
+ ECParameterSpec ps =
+ new ECParameterSpec(curve, generator, order, cofactor);
+ BigInteger orderRet = ps.getOrder();
+ assertEquals(order, orderRet);
+ assertSame(order, orderRet);
+ }
+
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECPrivateKeySpecTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECPrivateKeySpecTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECPrivateKeySpecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPrivateKeySpec_ImplTest.java Tue Jun 20 01:11:04 2006
@@ -1,162 +1,158 @@
-/*
- * 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 junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ECPrivateKeySpec</code> class fields and methods.
- *
- */
-public class ECPrivateKeySpecTest extends TestCase {
-
- /**
- * Constructor for ECPrivateKeySpecTest.
- * @param name
- */
- public ECPrivateKeySpecTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
- // NOTE: the following tests use EC domain parameters
- // which are invalid for real EC cryptography application
- // but must be acceptable by the class under test according
- // to the API specification
- //
-
- /**
- * Test #1 for <code>ECPrivateKeySpec(BigInteger, ECParameterSpec)</code> constructor<br>
- * Assertion: creates <code>ECPrivateKeySpec</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECPrivateKeySpec01() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- new ECPrivateKeySpec(BigInteger.ZERO,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
-
- }
-
- /**
- * Test #2 for <code>ECPrivateKeySpec(BigInteger, ECParameterSpec)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if
- * <code>s</code> or <code>params</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 testECPrivateKeySpec02() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
- // Test case 1: s is null
- try {
- new ECPrivateKeySpec(null,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 2: params is null
- try {
- new ECPrivateKeySpec(BigInteger.valueOf(0L), null);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 3: both s and params are null
- try {
- new ECPrivateKeySpec(null, null);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test for <code>getParams()</code> method<br>
- * Assertion: returns associated EC parameters<br>
- * Test preconditions: <code>ECPrivateKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return params value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetParams() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
-
- ECPrivateKeySpec ks = new ECPrivateKeySpec(BigInteger.ZERO, params);
- ECParameterSpec paramsRet = ks.getParams();
-
- assertEquals(params, paramsRet);
- assertSame(params, paramsRet);
- }
-
- /**
- * Test for <code>getS()</code> method<br>
- * Assertion: returns associated private value<br>
- * Test preconditions: <code>ECPrivateKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return s value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetS() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
- BigInteger s = BigInteger.valueOf(5L);
-
- ECPrivateKeySpec ks = new ECPrivateKeySpec(s, params);
- BigInteger sRet = ks.getS();
-
- assertEquals(s, sRet);
- assertSame(s, sRet);
- }
-}
+/*
+ * 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.ECFieldFp;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPrivateKeySpec;
+import java.security.spec.EllipticCurve;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ECPrivateKeySpec</code> class fields and methods.
+ *
+ */
+public class ECPrivateKeySpec_ImplTest extends TestCase {
+
+ //
+ // Tests
+ //
+ // NOTE: the following tests use EC domain parameters
+ // which are invalid for real EC cryptography application
+ // but must be acceptable by the class under test according
+ // to the API specification
+ //
+
+ /**
+ * Test #1 for <code>ECPrivateKeySpec(BigInteger, ECParameterSpec)</code> constructor<br>
+ * Assertion: creates <code>ECPrivateKeySpec</code> instance<br>
+ * Test preconditions: valid parameters passed<br>
+ * Expected: must pass without any exceptions
+ */
+ public final void testECPrivateKeySpec01() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ new ECPrivateKeySpec(BigInteger.ZERO,
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
+
+ }
+
+ /**
+ * Test #2 for <code>ECPrivateKeySpec(BigInteger, ECParameterSpec)</code> constructor<br>
+ * Assertion: throws <code>NullPointerException</code> if
+ * <code>s</code> or <code>params</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 testECPrivateKeySpec02() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+
+ // Test case 1: s is null
+ try {
+ new ECPrivateKeySpec(null,
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
+ fail("#1: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 2: params is null
+ try {
+ new ECPrivateKeySpec(BigInteger.valueOf(0L), null);
+ fail("#2: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 3: both s and params are null
+ try {
+ new ECPrivateKeySpec(null, null);
+ fail("#3: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+ }
+
+ /**
+ * Test for <code>getParams()</code> method<br>
+ * Assertion: returns associated EC parameters<br>
+ * Test preconditions: <code>ECPrivateKeySpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return params value which is equal
+ * to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetParams() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ ECParameterSpec params =
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
+
+ ECPrivateKeySpec ks = new ECPrivateKeySpec(BigInteger.ZERO, params);
+ ECParameterSpec paramsRet = ks.getParams();
+
+ assertEquals(params, paramsRet);
+ assertSame(params, paramsRet);
+ }
+
+ /**
+ * Test for <code>getS()</code> method<br>
+ * Assertion: returns associated private value<br>
+ * Test preconditions: <code>ECPrivateKeySpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return s value which is equal
+ * to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetS() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ ECParameterSpec params =
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
+ BigInteger s = BigInteger.valueOf(5L);
+
+ ECPrivateKeySpec ks = new ECPrivateKeySpec(s, params);
+ BigInteger sRet = ks.getS();
+
+ assertEquals(s, sRet);
+ assertSame(s, sRet);
+ }
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECPublicKeySpecTest.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECPublicKeySpecTest.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/spec/ECPublicKeySpecTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/ECPublicKeySpec_ImplTest.java Tue Jun 20 01:11:04 2006
@@ -1,185 +1,181 @@
-/*
- * 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 junit.framework.TestCase;
-
-
-/**
- * Tests for <code>ECPublicKeySpec</code> class fields and methods.
- *
- */
-public class ECPublicKeySpecTest extends TestCase {
-
- /**
- * Constructor for ECPublicKeySpecTest.
- * @param name
- */
- public ECPublicKeySpecTest(String name) {
- super(name);
- }
-
- //
- // Tests
- //
- // NOTE: the following tests use EC domain parameters
- // which are invalid for real EC cryptography application
- // but must be acceptable by the class under test according
- // to the API specification
- //
-
- /**
- * Test #1 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
- * Assertion: creates <code>ECPublicKeySpec</code> instance<br>
- * Test preconditions: valid parameters passed<br>
- * Expected: must pass without any exceptions
- */
- public final void testECPublicKeySpec01() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- new ECPublicKeySpec(g,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
-
- }
-
- /**
- * Test #2 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
- * Assertion: throws <code>NullPointerException</code> if
- * <code>w</code> or <code>params</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 testECPublicKeySpec02() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
- // Test case 1: w is null
- try {
- new ECPublicKeySpec(null,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
- fail("#1: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 2: params is null
- try {
- new ECPublicKeySpec(g, null);
- fail("#2: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
-
-
- // Test case 3: both w and params are null
- try {
- new ECPublicKeySpec(null, null);
- fail("#3: Expected NPE not thrown");
- } catch (NullPointerException ok) {
- }
- }
-
- /**
- * Test #3 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
- * Assertion: throws <code>IllegalArgumentException</code> if
- * <code>w</code> is point at infinity<br>
- * Test preconditions: pass <code>ECPoint.POINT_INFINITY</code>
- * as mentioned parameter value<br>
- * Expected: must throw <code>IllegalArgumentException</code>
- */
- public final void testECPublicKeySpec03() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
-
- try {
- new ECPublicKeySpec(ECPoint.POINT_INFINITY,
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
- fail("Expected IAE not thrown");
- } catch (IllegalArgumentException ok) {
- }
- }
-
- /**
- * Test for <code>getParams()</code> method<br>
- * Assertion: returns associated EC parameters<br>
- * Test preconditions: <code>ECPublicKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return params value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetParams() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
-
- ECPublicKeySpec ks = new ECPublicKeySpec(g, params);
- ECParameterSpec paramsRet = ks.getParams();
-
- assertEquals(params, paramsRet);
- assertSame(params, paramsRet);
- }
-
- /**
- * Test for <code>getW()</code> method<br>
- * Assertion: returns associated public point<br>
- * Test preconditions: <code>ECPublicKeySpec</code> instance
- * created using valid parameters<br>
- * Expected: must return w value which is equal
- * to the one passed to the constructor; (both must refer
- * the same object)
- */
- public final void testGetW() {
- // Valid (see note below) parameters set
- EllipticCurve c =
- new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
- BigInteger.ZERO,
- BigInteger.valueOf(4L));
- ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
- ECParameterSpec params =
- new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
-
- ECPublicKeySpec ks = new ECPublicKeySpec(g, params);
- ECPoint wRet = ks.getW();
-
- assertEquals(g, wRet);
- assertSame(g, wRet);
- }
-}
+/*
+ * 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.ECFieldFp;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.ECPublicKeySpec;
+import java.security.spec.EllipticCurve;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>ECPublicKeySpec</code> class fields and methods.
+ *
+ */
+public class ECPublicKeySpec_ImplTest extends TestCase {
+
+ //
+ // Tests
+ //
+ // NOTE: the following tests use EC domain parameters
+ // which are invalid for real EC cryptography application
+ // but must be acceptable by the class under test according
+ // to the API specification
+ //
+
+ /**
+ * Test #1 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
+ * Assertion: creates <code>ECPublicKeySpec</code> instance<br>
+ * Test preconditions: valid parameters passed<br>
+ * Expected: must pass without any exceptions
+ */
+ public final void testECPublicKeySpec01() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ new ECPublicKeySpec(g,
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
+
+ }
+
+ /**
+ * Test #2 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
+ * Assertion: throws <code>NullPointerException</code> if
+ * <code>w</code> or <code>params</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 testECPublicKeySpec02() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+
+ // Test case 1: w is null
+ try {
+ new ECPublicKeySpec(null,
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
+ fail("#1: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 2: params is null
+ try {
+ new ECPublicKeySpec(g, null);
+ fail("#2: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+
+
+ // Test case 3: both w and params are null
+ try {
+ new ECPublicKeySpec(null, null);
+ fail("#3: Expected NPE not thrown");
+ } catch (NullPointerException ok) {
+ }
+ }
+
+ /**
+ * Test #3 for <code>ECPublicKeySpec(ECPoint, ECParameterSpec)</code> constructor<br>
+ * Assertion: throws <code>IllegalArgumentException</code> if
+ * <code>w</code> is point at infinity<br>
+ * Test preconditions: pass <code>ECPoint.POINT_INFINITY</code>
+ * as mentioned parameter value<br>
+ * Expected: must throw <code>IllegalArgumentException</code>
+ */
+ public final void testECPublicKeySpec03() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+
+ try {
+ new ECPublicKeySpec(ECPoint.POINT_INFINITY,
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10));
+ fail("Expected IAE not thrown");
+ } catch (IllegalArgumentException ok) {
+ }
+ }
+
+ /**
+ * Test for <code>getParams()</code> method<br>
+ * Assertion: returns associated EC parameters<br>
+ * Test preconditions: <code>ECPublicKeySpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return params value which is equal
+ * to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetParams() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ ECParameterSpec params =
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
+
+ ECPublicKeySpec ks = new ECPublicKeySpec(g, params);
+ ECParameterSpec paramsRet = ks.getParams();
+
+ assertEquals(params, paramsRet);
+ assertSame(params, paramsRet);
+ }
+
+ /**
+ * Test for <code>getW()</code> method<br>
+ * Assertion: returns associated public point<br>
+ * Test preconditions: <code>ECPublicKeySpec</code> instance
+ * created using valid parameters<br>
+ * Expected: must return w value which is equal
+ * to the one passed to the constructor; (both must refer
+ * the same object)
+ */
+ public final void testGetW() {
+ // Valid (see note below) parameters set
+ EllipticCurve c =
+ new EllipticCurve(new ECFieldFp(BigInteger.valueOf(5L)),
+ BigInteger.ZERO,
+ BigInteger.valueOf(4L));
+ ECPoint g = new ECPoint(BigInteger.ZERO, BigInteger.valueOf(2L));
+ ECParameterSpec params =
+ new ECParameterSpec(c, g, BigInteger.valueOf(5L), 10);
+
+ ECPublicKeySpec ks = new ECPublicKeySpec(g, params);
+ ECPoint wRet = ks.getW();
+
+ assertEquals(g, wRet);
+ assertSame(g, wRet);
+ }
+}
Added: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java?rev=415555&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/impl/java/org/apache/harmony/security/tests/java/security/spec/EllipticCurve_ImplTest.java Tue Jun 20 01:11:04 2006
@@ -0,0 +1,111 @@
+/*
+ * 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.ECFieldF2m;
+import java.security.spec.ECFieldFp;
+import java.security.spec.EllipticCurve;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for <code>EllipticCurve</code> class fields and methods.
+ *
+ */
+public class EllipticCurve_ImplTest extends TestCase {
+
+ /**
+ * 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));
+ }
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertPathBuilderSpi.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertPathBuilderSpi.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertPathBuilderSpi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathBuilderSpi.java Tue Jun 20 01:11:04 2006
@@ -1,42 +1,46 @@
-/*
- * 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.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-
-/**
- * Additional class for verification CertPathBuilderSpi
- * and CertPathBuilder
-
- */
-
-public class MyCertPathBuilderSpi extends CertPathBuilderSpi {
- private int swi = 0;
- public CertPathBuilderResult engineBuild(CertPathParameters params)
- throws CertPathBuilderException, InvalidAlgorithmParameterException {
- swi++;
- if ((params == null) && ((swi %2 ) != 0)) {
- throw new CertPathBuilderException("Null parameter");
- }
- return null;
- }
+/*
+ * 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.support.cert;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertPathBuilderException;
+import java.security.cert.CertPathBuilderResult;
+import java.security.cert.CertPathBuilderSpi;
+import java.security.cert.CertPathParameters;
+
+/**
+ * Additional class for verification CertPathBuilderSpi
+ * and CertPathBuilder
+
+ */
+
+public class MyCertPathBuilderSpi extends CertPathBuilderSpi {
+ private int swi = 0;
+ public CertPathBuilderResult engineBuild(CertPathParameters params)
+ throws CertPathBuilderException, InvalidAlgorithmParameterException {
+ swi++;
+ if ((params == null) && ((swi %2 ) != 0)) {
+ throw new CertPathBuilderException("Null parameter");
+ }
+ return null;
+ }
}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertPathValidatorSpi.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertPathValidatorSpi.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertPathValidatorSpi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertPathValidatorSpi.java Tue Jun 20 01:11:04 2006
@@ -1,50 +1,55 @@
-/*
- * 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.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-
-/**
- * Additional class for verification of CertPathValidatorSpi
- * and CertPathValidator
- *
- */
-
-public class MyCertPathValidatorSpi extends CertPathValidatorSpi {
- private int sw = 0;
- public CertPathValidatorResult engineValidate(CertPath certPath,
- CertPathParameters params) throws CertPathValidatorException,
- InvalidAlgorithmParameterException {
- ++sw;
- if (certPath == null) {
- if ((sw % 2) == 0) {
- throw new CertPathValidatorException("certPath null");
- }
- }
- if (params == null) {
- if ((sw % 3) == 0) {
- throw new InvalidAlgorithmParameterException("params null");
- }
- }
- return null;
- }
-}
+/*
+ * 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.support.cert;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CertPath;
+import java.security.cert.CertPathParameters;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.CertPathValidatorResult;
+import java.security.cert.CertPathValidatorSpi;
+
+/**
+ * Additional class for verification of CertPathValidatorSpi
+ * and CertPathValidator
+ *
+ */
+
+public class MyCertPathValidatorSpi extends CertPathValidatorSpi {
+ private int sw = 0;
+ public CertPathValidatorResult engineValidate(CertPath certPath,
+ CertPathParameters params) throws CertPathValidatorException,
+ InvalidAlgorithmParameterException {
+ ++sw;
+ if (certPath == null) {
+ if ((sw % 2) == 0) {
+ throw new CertPathValidatorException("certPath null");
+ }
+ }
+ if (params == null) {
+ if ((sw % 3) == 0) {
+ throw new InvalidAlgorithmParameterException("params null");
+ }
+ }
+ return null;
+ }
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertStoreParameters.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertStoreParameters.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertStoreParameters.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreParameters.java Tue Jun 20 01:11:04 2006
@@ -1,40 +1,42 @@
-/*
- * 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.cert;
-
-/**
- * Class for verification of CertStore and CertStoreSpi
- *
- */
-
-public class MyCertStoreParameters implements CertStoreParameters {
- public MyCertStoreParameters() {
- super();
- }
- public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- return null;
- }
- }
-}
+/*
+ * 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.support.cert;
+
+import java.security.cert.CertStoreParameters;
+
+/**
+ * Class for verification of CertStore and CertStoreSpi
+ *
+ */
+
+public class MyCertStoreParameters implements CertStoreParameters {
+ public MyCertStoreParameters() {
+ super();
+ }
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ return null;
+ }
+ }
+}
Copied: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java (from r414728, incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertStoreSpi.java)
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertStoreSpi.java&r1=414728&r2=415555&rev=415555&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java.injected/java/security/cert/MyCertStoreSpi.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/support/common/java/org/apache/harmony/security/tests/support/cert/MyCertStoreSpi.java Tue Jun 20 01:11:04 2006
@@ -1,58 +1,63 @@
-/*
- * 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.cert;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.util.Collection;
-
-/**
- * Additional class for verification CertStoreSpi
- * and CertStore
- *
- */
-
-public class MyCertStoreSpi extends CertStoreSpi {
-
- public MyCertStoreSpi(CertStoreParameters params)
- throws InvalidAlgorithmParameterException {
- super(params);
- if (!(params instanceof MyCertStoreParameters)) {
- throw new InvalidAlgorithmParameterException("Invalid params");
- }
- }
-
- public Collection engineGetCertificates(CertSelector selector)
- throws CertStoreException {
- if (selector == null) {
- throw new CertStoreException("Parameter is null");
- }
- return null;
- }
-
- public Collection engineGetCRLs(CRLSelector selector)
- throws CertStoreException {
- if (selector == null) {
- throw new CertStoreException("Parameter is null");
- }
- return null;
- }
-}
+/*
+ * 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.support.cert;
+
+import java.security.InvalidAlgorithmParameterException;
+import java.security.cert.CRLSelector;
+import java.security.cert.CertSelector;
+import java.security.cert.CertStoreException;
+import java.security.cert.CertStoreParameters;
+import java.security.cert.CertStoreSpi;
+import java.util.Collection;
+
+/**
+ * Additional class for verification CertStoreSpi
+ * and CertStore
+ *
+ */
+
+public class MyCertStoreSpi extends CertStoreSpi {
+
+ public MyCertStoreSpi(CertStoreParameters params)
+ throws InvalidAlgorithmParameterException {
+ super(params);
+ if (!(params instanceof MyCertStoreParameters)) {
+ throw new InvalidAlgorithmParameterException("Invalid params");
+ }
+ }
+
+ public Collection engineGetCertificates(CertSelector selector)
+ throws CertStoreException {
+ if (selector == null) {
+ throw new CertStoreException("Parameter is null");
+ }
+ return null;
+ }
+
+ public Collection engineGetCRLs(CRLSelector selector)
+ throws CertStoreException {
+ if (selector == null) {
+ throw new CertStoreException("Parameter is null");
+ }
+ return null;
+ }
+}