DSAParamsTest.java revision cec4dd4b1d33f78997603d0f89c0d0e56e64dbcd
1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package tests.security.interfaces; 17import dalvik.annotation.TestLevel; 18import dalvik.annotation.TestTargetNew; 19import dalvik.annotation.TestTargetClass; 20 21import junit.framework.TestCase; 22 23import java.math.BigInteger; 24import java.security.interfaces.DSAParams; 25import java.security.spec.DSAParameterSpec; 26 27@TestTargetClass(DSAParams.class) 28public class DSAParamsTest extends TestCase { 29 30 private final BigInteger p = new BigInteger("4"); 31 private final BigInteger q = BigInteger.TEN; 32 private final BigInteger g = BigInteger.ZERO; 33 34 /** 35 * @tests java.security.interfaces.DSAParams 36 * #getG() 37 */ 38 @TestTargetNew( 39 level = TestLevel.COMPLETE, 40 notes = "", 41 method = "getG", 42 args = {} 43 ) 44 public void test_getG() { 45 DSAParams params = new DSAParameterSpec(p, q, g); 46 assertEquals("Invalid G", g, params.getG()); 47 } 48 49 /** 50 * @tests java.security.interfaces.DSAParams 51 * #getP() 52 */ 53 @TestTargetNew( 54 level = TestLevel.COMPLETE, 55 notes = "", 56 method = "getP", 57 args = {} 58 ) 59 public void test_getP() { 60 DSAParams params = new DSAParameterSpec(p, q, g); 61 assertEquals("Invalid P", p, params.getP()); 62 } 63 64 /** 65 * @tests java.security.interfaces.DSAParams 66 * #getQ() 67 */ 68 @TestTargetNew( 69 level = TestLevel.COMPLETE, 70 notes = "", 71 method = "getQ", 72 args = {} 73 ) 74 public void test_getQ() { 75 DSAParams params = new DSAParameterSpec(p, q, g); 76 assertEquals("Invalid Q", q, params.getQ()); 77 } 78} 79