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
37public class AlgorithmParameterGeneratorSpiTest extends TestCase {
38
39    /**
40     * Constructor for CertPathBuilderTests.
41     *
42     * @param name
43     */
44    public AlgorithmParameterGeneratorSpiTest(String name) {
45        super(name);
46    }
47
48    /**
49     * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor
50     * Assertion: constructs AlgorithmParameterGeneratorSpi
51     */
52    public void testAlgorithmParameterGeneratorSpi01()
53            throws InvalidAlgorithmParameterException {
54        AlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi();
55        AlgorithmParameters param = algParGen.engineGenerateParameters();
56        assertNull("Not null parameters", param);
57        AlgorithmParameterSpec pp = null;
58        algParGen.engineInit(pp, new SecureRandom());
59        try {
60            algParGen.engineInit(pp, null);
61            fail("IllegalArgumentException must be thrown");
62        } catch (IllegalArgumentException e) {
63        }
64        algParGen.engineInit(0, null);
65        algParGen.engineInit(0, new SecureRandom());
66
67        try {
68            algParGen.engineInit(-10, null);
69            fail("IllegalArgumentException must be thrown");
70        } catch (IllegalArgumentException e) {
71        }
72        try {
73            algParGen.engineInit(-10, new SecureRandom());
74            fail("IllegalArgumentException must be thrown");
75        } catch (IllegalArgumentException e) {
76        }
77    }
78}
79