OSDN Git Service

original
[gb-231r1-is01/Gingerbread_2.3.3_r1_IS01.git] / libcore / luni / src / test / java / tests / security / spec / RSAOtherPrimeInfoTest.java
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 dalvik.annotation.TestTargets;
26 import dalvik.annotation.TestLevel;
27 import dalvik.annotation.TestTargetNew;
28 import dalvik.annotation.TestTargetClass;
29
30 import junit.framework.TestCase;
31
32 import java.math.BigInteger;
33 import java.security.spec.RSAOtherPrimeInfo;
34
35 /**
36  * Tests for <code>RSAOtherPrimeInfo</code> class fields and methods.
37  *
38  */
39 @TestTargetClass(RSAOtherPrimeInfo.class)
40 public class RSAOtherPrimeInfoTest extends TestCase {
41
42     /**
43      * Test #1 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
44      * Assertion: constructs <code>RSAOtherPrimeInfo</code>
45      * object using valid parameter
46      */
47     @TestTargetNew(
48         level = TestLevel.PARTIAL_COMPLETE,
49         notes = "Verifies constructor with valid parameters.",
50         method = "RSAOtherPrimeInfo",
51         args = {java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class}
52     )
53     public final void testRSAOtherPrimeInfo01() {
54         Object o =
55             new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
56                                   BigInteger.valueOf(2L),
57                                   BigInteger.valueOf(3L));
58         assertTrue(o instanceof RSAOtherPrimeInfo);
59     }
60
61     /**
62      * Test #2 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
63      * Assertion: NullPointerException if prime is null
64      */
65     @TestTargetNew(
66         level = TestLevel.PARTIAL_COMPLETE,
67         notes = "Verifies NullPointerException.",
68         method = "RSAOtherPrimeInfo",
69         args = {java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class}
70     )
71     public final void testRSAOtherPrimeInfo02() {
72         try {
73             new RSAOtherPrimeInfo(null,
74                                   BigInteger.valueOf(2L),
75                                   BigInteger.valueOf(3L));
76             fail("Expected NPE not thrown");
77         } catch (NullPointerException e) {
78         }
79     }
80
81     /**
82      * Test #3 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
83      * Assertion: NullPointerException if primeExponent is null
84      */
85     @TestTargetNew(
86         level = TestLevel.PARTIAL_COMPLETE,
87         notes = "Verifies NullPointerException.",
88         method = "RSAOtherPrimeInfo",
89         args = {java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class}
90     )
91     public final void testRSAOtherPrimeInfo03() {
92         try {
93             new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
94                                   null,
95                                   BigInteger.valueOf(3L));
96             fail("Expected NPE not thrown");
97         } catch (NullPointerException e) {
98         }
99     }
100
101     /**
102      * Test #4 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
103      * Assertion: NullPointerException if crtCoefficient is null
104      */
105     @TestTargetNew(
106         level = TestLevel.PARTIAL_COMPLETE,
107         notes = "Verifies NullPointerException.",
108         method = "RSAOtherPrimeInfo",
109         args = {java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class}
110     )
111     public final void testRSAOtherPrimeInfo04() {
112         try {
113             new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
114                                   BigInteger.valueOf(2L),
115                                   null);
116             fail("Expected NPE not thrown");
117         } catch (NullPointerException e) {
118         }
119     }
120
121     /**
122      * Test #5 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
123      * Assertion: NullPointerException if prime and crtCoefficient is null
124      */
125     @TestTargetNew(
126         level = TestLevel.PARTIAL_COMPLETE,
127         notes = "Verifies NullPointerException.",
128         method = "RSAOtherPrimeInfo",
129         args = {java.math.BigInteger.class, java.math.BigInteger.class, java.math.BigInteger.class}
130     )
131     public final void testRSAOtherPrimeInfo05() {
132         try {
133             new RSAOtherPrimeInfo(null,
134                                   BigInteger.valueOf(2L),
135                                   null);
136             fail("Expected NPE not thrown");
137         } catch (NullPointerException e) {
138         }
139     }
140
141     /**
142      * Test for <code>getCrtCoefficient()</code> method<br>
143      * Assertion: returns CRT coefficient value
144      */
145     @TestTargetNew(
146         level = TestLevel.COMPLETE,
147         notes = "",
148         method = "getCrtCoefficient",
149         args = {}
150     )
151     public final void testGetCrtCoefficient() {
152         RSAOtherPrimeInfo ropi =
153             new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
154                                   BigInteger.valueOf(2L),
155                                   BigInteger.valueOf(3L));
156         assertEquals(3L, ropi.getCrtCoefficient().longValue());
157     }
158
159     /**
160      * Test for <code>getPrime()</code> method<br>
161      * Assertion: returns prime value
162      */
163     @TestTargetNew(
164         level = TestLevel.COMPLETE,
165         notes = "",
166         method = "getPrime",
167         args = {}
168     )
169     public final void testGetPrime() {
170         RSAOtherPrimeInfo ropi =
171             new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
172                                   BigInteger.valueOf(2L),
173                                   BigInteger.valueOf(3L));
174         assertEquals(1L, ropi.getPrime().longValue());
175     }
176
177     /**
178      * Test for <code>getExponent()</code> method<br>
179      * Assertion: returns prime exponent value
180      */
181     @TestTargetNew(
182         level = TestLevel.COMPLETE,
183         notes = "",
184         method = "getExponent",
185         args = {}
186     )
187     public final void testGetExponent() {
188         RSAOtherPrimeInfo ropi =
189             new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
190                                   BigInteger.valueOf(2L),
191                                   BigInteger.valueOf(3L));
192         assertEquals(2L, ropi.getExponent().longValue());
193     }
194
195 }