01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /**
19: * @author Vera Y. Petrashkova
20: * @version $Revision$
21: */package java.security;
22:
23: import java.security.spec.AlgorithmParameterSpec;
24:
25: import org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi;
26:
27: import junit.framework.TestCase;
28:
29: /**
30: * Tests for <code>AlgorithmParameterGeneratorSpi</code> class constructors
31: * and methods.
32: *
33: */
34:
35: public class AlgorithmParameterGeneratorSpiTest extends TestCase {
36:
37: /**
38: * Constructor for CertPathBuilderTests.
39: *
40: * @param name
41: */
42: public AlgorithmParameterGeneratorSpiTest(String name) {
43: super (name);
44: }
45:
46: /**
47: * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor
48: * Assertion: constructs AlgorithmParameterGeneratorSpi
49: */
50: public void testAlgorithmParameterGeneratorSpi01()
51: throws InvalidAlgorithmParameterException {
52: AlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi();
53: AlgorithmParameters param = algParGen
54: .engineGenerateParameters();
55: assertNull("Not null parameters", param);
56: AlgorithmParameterSpec pp = null;
57: algParGen.engineInit(pp, new SecureRandom());
58: try {
59: algParGen.engineInit(pp, null);
60: fail("IllegalArgumentException must be thrown");
61: } catch (IllegalArgumentException e) {
62: }
63: algParGen.engineInit(0, null);
64: algParGen.engineInit(0, new SecureRandom());
65:
66: try {
67: algParGen.engineInit(-10, null);
68: fail("IllegalArgumentException must be thrown");
69: } catch (IllegalArgumentException e) {
70: }
71: try {
72: algParGen.engineInit(-10, new SecureRandom());
73: fail("IllegalArgumentException must be thrown");
74: } catch (IllegalArgumentException e) {
75: }
76: }
77: }
|