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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @author Vladimir N. Molotkov
23 package tests.security.spec;
25 import dalvik.annotation.TestTargets;
26 import dalvik.annotation.TestLevel;
27 import dalvik.annotation.TestTargetNew;
28 import dalvik.annotation.TestTargetClass;
30 import junit.framework.TestCase;
32 import java.math.BigInteger;
33 import java.security.spec.RSAOtherPrimeInfo;
36 * Tests for <code>RSAOtherPrimeInfo</code> class fields and methods.
39 @TestTargetClass(RSAOtherPrimeInfo.class)
40 public class RSAOtherPrimeInfoTest extends TestCase {
43 * Test #1 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
44 * Assertion: constructs <code>RSAOtherPrimeInfo</code>
45 * object using valid parameter
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}
53 public final void testRSAOtherPrimeInfo01() {
55 new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
56 BigInteger.valueOf(2L),
57 BigInteger.valueOf(3L));
58 assertTrue(o instanceof RSAOtherPrimeInfo);
62 * Test #2 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
63 * Assertion: NullPointerException if prime is null
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}
71 public final void testRSAOtherPrimeInfo02() {
73 new RSAOtherPrimeInfo(null,
74 BigInteger.valueOf(2L),
75 BigInteger.valueOf(3L));
76 fail("Expected NPE not thrown");
77 } catch (NullPointerException e) {
82 * Test #3 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
83 * Assertion: NullPointerException if primeExponent is null
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}
91 public final void testRSAOtherPrimeInfo03() {
93 new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
95 BigInteger.valueOf(3L));
96 fail("Expected NPE not thrown");
97 } catch (NullPointerException e) {
102 * Test #4 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
103 * Assertion: NullPointerException if crtCoefficient is null
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}
111 public final void testRSAOtherPrimeInfo04() {
113 new RSAOtherPrimeInfo(BigInteger.valueOf(1L),
114 BigInteger.valueOf(2L),
116 fail("Expected NPE not thrown");
117 } catch (NullPointerException e) {
122 * Test #5 for <code>RSAOtherPrimeInfo(BigInteger,BigInteger,BigInteger)</code> ctor
123 * Assertion: NullPointerException if prime and crtCoefficient is null
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}
131 public final void testRSAOtherPrimeInfo05() {
133 new RSAOtherPrimeInfo(null,
134 BigInteger.valueOf(2L),
136 fail("Expected NPE not thrown");
137 } catch (NullPointerException e) {
142 * Test for <code>getCrtCoefficient()</code> method<br>
143 * Assertion: returns CRT coefficient value
146 level = TestLevel.COMPLETE,
148 method = "getCrtCoefficient",
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());
160 * Test for <code>getPrime()</code> method<br>
161 * Assertion: returns prime value
164 level = TestLevel.COMPLETE,
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());
178 * Test for <code>getExponent()</code> method<br>
179 * Assertion: returns prime exponent value
182 level = TestLevel.COMPLETE,
184 method = "getExponent",
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());