1/*
2 *  Licensed to the Apache Software Foundation (ASF) under one or more
3 *  contributor license agreements.  See the NOTICE file distributed with
4 *  this work for additional information regarding copyright ownership.
5 *  The ASF licenses this file to You under the Apache License, Version 2.0
6 *  (the "License"); you may not use this file except in compliance with
7 *  the License.  You may obtain a copy of the License at
8 *
9 *     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*/
21
22package java.security;
23
24
25import java.security.spec.AlgorithmParameterSpec;
26
27import org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi;
28
29import junit.framework.TestCase;
30
31
32/**
33 * Tests for <code>AlgorithmParameterGeneratorSpi</code> class constructors
34 * and methods.
35 *
36 */
37
38public class AlgorithmParameterGeneratorSpiTest extends TestCase {
39
40    /**
41     * Constructor for CertPathBuilderTests.
42     *
43     * @param name
44     */
45    public AlgorithmParameterGeneratorSpiTest(String name) {
46        super(name);
47    }
48
49    /**
50     * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor
51     * Assertion: constructs AlgorithmParameterGeneratorSpi
52     */
53    public void testAlgorithmParameterGeneratorSpi01()
54            throws InvalidAlgorithmParameterException {
55        AlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi();
56        AlgorithmParameters param = algParGen.engineGenerateParameters();
57        assertNull("Not null parameters", param);
58        AlgorithmParameterSpec pp = null;
59        algParGen.engineInit(pp, new SecureRandom());
60        try {
61            algParGen.engineInit(pp, null);
62            fail("IllegalArgumentException must be thrown");
63        } catch (IllegalArgumentException e) {
64        }
65        algParGen.engineInit(0, null);
66        algParGen.engineInit(0, new SecureRandom());
67
68        try {
69            algParGen.engineInit(-10, null);
70            fail("IllegalArgumentException must be thrown");
71        } catch (IllegalArgumentException e) {
72        }
73        try {
74            algParGen.engineInit(-10, new SecureRandom());
75            fail("IllegalArgumentException must be thrown");
76        } catch (IllegalArgumentException e) {
77        }
78    }
79}
80