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 dalvik.annotation.TestTargets; 26import dalvik.annotation.TestLevel; 27import dalvik.annotation.TestTargetNew; 28import dalvik.annotation.TestTargetClass; 29 30import junit.framework.TestCase; 31 32import java.math.BigInteger; 33import java.security.spec.DSAPrivateKeySpec; 34import java.security.spec.KeySpec; 35 36/** 37 * Tests for <code>DSAPrivateKeySpec</code> 38 * 39 */ 40@TestTargetClass(DSAPrivateKeySpec.class) 41public class DSAPrivateKeySpecTest extends TestCase { 42 43 /** 44 * Test for constructor 45 */ 46 @TestTargetNew( 47 level = TestLevel.COMPLETE, 48 notes = "", 49 method = "DSAPrivateKeySpec", 50 args = {java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class} 51 ) 52 public final void testDSAPrivateKeySpec() { 53 KeySpec ks = new DSAPrivateKeySpec( 54 new BigInteger("1"), 55 new BigInteger("2"), 56 new BigInteger("3"), 57 new BigInteger("4")); 58 59 assertTrue(ks instanceof DSAPrivateKeySpec); 60 } 61 62 /** 63 * getG() test 64 */ 65 @TestTargetNew( 66 level = TestLevel.COMPLETE, 67 notes = "", 68 method = "getG", 69 args = {} 70 ) 71 public final void testGetG() { 72 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 73 new BigInteger("1"), 74 new BigInteger("2"), 75 new BigInteger("3"), 76 new BigInteger("4")); 77 78 assertEquals(4, dpks.getG().intValue()); 79 } 80 81 /** 82 * getP() test 83 */ 84 @TestTargetNew( 85 level = TestLevel.COMPLETE, 86 notes = "", 87 method = "getP", 88 args = {} 89 ) 90 public final void testGetP() { 91 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 92 new BigInteger("1"), 93 new BigInteger("2"), 94 new BigInteger("3"), 95 new BigInteger("4")); 96 97 assertEquals(2, dpks.getP().intValue()); 98 } 99 100 /** 101 * getQ() test 102 */ 103 @TestTargetNew( 104 level = TestLevel.COMPLETE, 105 notes = "", 106 method = "getQ", 107 args = {} 108 ) 109 public final void testGetQ() { 110 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 111 new BigInteger("1"), 112 new BigInteger("2"), 113 new BigInteger("3"), 114 new BigInteger("4")); 115 116 assertEquals(3, dpks.getQ().intValue()); 117 } 118 119 /** 120 * getX() test 121 */ 122 @TestTargetNew( 123 level = TestLevel.COMPLETE, 124 notes = "", 125 method = "getX", 126 args = {} 127 ) 128 public final void testGetX() { 129 DSAPrivateKeySpec dpks = new DSAPrivateKeySpec( 130 new BigInteger("1"), 131 new BigInteger("2"), 132 new BigInteger("3"), 133 new BigInteger("4")); 134 135 assertEquals(1, dpks.getX().intValue()); 136 } 137 138} 139