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 * @version $Revision$ 21 */ 22 23package tests.java.security; 24 25import java.security.AlgorithmParameters; 26import java.security.InvalidAlgorithmParameterException; 27import java.security.SecureRandom; 28import java.security.spec.AlgorithmParameterSpec; 29 30import org.apache.harmony.security.tests.support.MyAlgorithmParameterGeneratorSpi; 31 32import junit.framework.TestCase; 33 34/** 35 * Tests for <code>AlgorithmParameterGeneratorSpi</code> class constructors 36 * and methods. 37 * 38 */ 39public class AlgorithmParameterGeneratorSpiTest extends TestCase { 40 41 /** 42 * Test for <code>AlgorithmParameterGeneratorSpi</code> constructor 43 * Assertion: constructs AlgorithmParameterGeneratorSpi 44 */ 45 public void testAlgorithmParameterGeneratorSpi01() 46 throws InvalidAlgorithmParameterException { 47 MyAlgorithmParameterGeneratorSpi algParGen = new MyAlgorithmParameterGeneratorSpi(); 48 AlgorithmParameters param = algParGen.engineGenerateParameters(); 49 assertNull("Not null parameters", param); 50 AlgorithmParameterSpec pp = null; 51 algParGen.engineInit(pp, new SecureRandom()); 52 try { 53 algParGen.engineInit(pp, null); 54 fail("IllegalArgumentException must be thrown"); 55 } catch (IllegalArgumentException e) { 56 } 57 algParGen.engineInit(0, null); 58 algParGen.engineInit(0, new SecureRandom()); 59 60 try { 61 algParGen.engineInit(-10, null); 62 fail("IllegalArgumentException must be thrown"); 63 } catch (IllegalArgumentException e) { 64 } 65 try { 66 algParGen.engineInit(-10, new SecureRandom()); 67 fail("IllegalArgumentException must be thrown"); 68 } catch (IllegalArgumentException e) { 69 } 70 } 71 72 73} 74