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 Vladimir N. Molotkov 20 * @version $Revision$ 21 */ 22 23 package tests.security.spec; 24 25 import junit.framework.TestCase; 26 27 import java.math.BigInteger; 28 import java.security.spec.DSAPrivateKeySpec; 29 import java.security.spec.KeySpec; 30 31 /** 32 * Tests for <code>DSAPrivateKeySpec</code> 33 * 34 */ 35 public class DSAPrivateKeySpecTest extends TestCase { 36 37 /** 38 * Test for constructor 39 */ 40 public final void testDSAPrivateKeySpec() { 41 KeySpec ks = new DSAPrivateKeySpec( 42 new BigInteger("1"), 43 new BigInteger("2"), 44 new BigInteger("3"), 45 new BigInteger("4")); 46 47 assertTrue(ks instanceof DSAPrivateKeySpec); 48 } 49 50 /** 51 * getG() test 52 */ 53 public final void testGetG() { 54 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 55 new BigInteger("1"), 56 new BigInteger("2"), 57 new BigInteger("3"), 58 new BigInteger("4")); 59 60 assertEquals(4, dpks.getG().intValue()); 61 } 62 63 /** 64 * getP() test 65 */ 66 public final void testGetP() { 67 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 68 new BigInteger("1"), 69 new BigInteger("2"), 70 new BigInteger("3"), 71 new BigInteger("4")); 72 73 assertEquals(2, dpks.getP().intValue()); 74 } 75 76 /** 77 * getQ() test 78 */ 79 public final void testGetQ() { 80 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 81 new BigInteger("1"), 82 new BigInteger("2"), 83 new BigInteger("3"), 84 new BigInteger("4")); 85 86 assertEquals(3, dpks.getQ().intValue()); 87 } 88 89 /** 90 * getX() test 91 */ 92 public final void testGetX() { 93 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 94 new BigInteger("1"), 95 new BigInteger("2"), 96 new BigInteger("3"), 97 new BigInteger("4")); 98 99 assertEquals(1, dpks.getX().intValue()); 100 } 101 102 } 103