The Android Open Source Project | 0eec464 | 2012-04-01 00:00:00 -0700 | [diff] [blame] | 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 Vera Y. Petrashkova |
| 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.security.spec.InvalidParameterSpecException; |
| 33 | |
| 34 | /** |
| 35 | * Tests for <code>InvalidParameterSpecException</code> class constructors and |
| 36 | * methods. |
| 37 | * |
| 38 | */ |
| 39 | @TestTargetClass(InvalidParameterSpecException.class) |
| 40 | public class InvalidParameterSpecExceptionTest extends TestCase { |
| 41 | |
| 42 | static String[] msgs = { |
| 43 | "", |
| 44 | "Check new message", |
| 45 | "Check new message Check new message Check new message Check new message Check new message" }; |
| 46 | |
| 47 | static Throwable tCause = new Throwable("Throwable for exception"); |
| 48 | |
| 49 | /** |
| 50 | * Test for <code>InvalidParameterSpecException()</code> constructor |
| 51 | * Assertion: constructs InvalidParameterSpecException with no detail |
| 52 | * message |
| 53 | */ |
| 54 | @TestTargetNew( |
| 55 | level = TestLevel.COMPLETE, |
| 56 | notes = "", |
| 57 | method = "InvalidParameterSpecException", |
| 58 | args = {} |
| 59 | ) |
| 60 | public void testInvalidParameterSpecException01() { |
| 61 | InvalidParameterSpecException tE = new InvalidParameterSpecException(); |
| 62 | assertNull("getMessage() must return null.", tE.getMessage()); |
| 63 | assertNull("getCause() must return null", tE.getCause()); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Test for <code>InvalidParameterSpecException(String)</code> constructor |
| 68 | * Assertion: constructs InvalidParameterSpecException with detail message |
| 69 | * msg. Parameter <code>msg</code> is not null. |
| 70 | */ |
| 71 | @TestTargetNew( |
| 72 | level = TestLevel.PARTIAL_COMPLETE, |
| 73 | notes = "", |
| 74 | method = "InvalidParameterSpecException", |
| 75 | args = {java.lang.String.class} |
| 76 | ) |
| 77 | public void testInvalidParameterSpecException02() { |
| 78 | InvalidParameterSpecException tE; |
| 79 | for (int i = 0; i < msgs.length; i++) { |
| 80 | tE = new InvalidParameterSpecException(msgs[i]); |
| 81 | assertEquals("getMessage() must return: ".concat(msgs[i]), tE |
| 82 | .getMessage(), msgs[i]); |
| 83 | assertNull("getCause() must return null", tE.getCause()); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Test for <code>InvalidParameterSpecException(String)</code> constructor |
| 89 | * Assertion: constructs InvalidParameterSpecException when <code>msg</code> |
| 90 | * is null |
| 91 | */ |
| 92 | @TestTargetNew( |
| 93 | level = TestLevel.PARTIAL_COMPLETE, |
| 94 | notes = "Verifies null as a parameter.", |
| 95 | method = "InvalidParameterSpecException", |
| 96 | args = {java.lang.String.class} |
| 97 | ) |
| 98 | public void testInvalidParameterSpecException03() { |
| 99 | String msg = null; |
| 100 | InvalidParameterSpecException tE = new InvalidParameterSpecException( |
| 101 | msg); |
| 102 | assertNull("getMessage() must return null.", tE.getMessage()); |
| 103 | assertNull("getCause() must return null", tE.getCause()); |
| 104 | } |
| 105 | } |