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