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 23package org.apache.harmony.crypto.tests.javax.crypto; 24 25import dalvik.annotation.TestTargetClass; 26import dalvik.annotation.TestTargets; 27import dalvik.annotation.TestLevel; 28import dalvik.annotation.TestTargetNew; 29 30import javax.crypto.NoSuchPaddingException; 31 32import junit.framework.TestCase; 33 34 35@TestTargetClass(NoSuchPaddingException.class) 36/** 37 * Tests for <code>NoSuchPaddingException</code> class constructors and 38 * methods. 39 * 40 */ 41public class NoSuchPaddingExceptionTest extends TestCase { 42 43 static String[] msgs = { 44 "", 45 "Check new message", 46 "Check new message Check new message Check new message Check new message Check new message" }; 47 48 static Throwable tCause = new Throwable("Throwable for exception"); 49 50 /** 51 * Test for <code>NoSuchPaddingException()</code> constructor Assertion: 52 * constructs NoSuchPaddingException with no detail message 53 */ 54 @TestTargetNew( 55 level = TestLevel.COMPLETE, 56 notes = "", 57 method = "NoSuchPaddingException", 58 args = {} 59 ) 60 public void testNoSuchPaddingException01() { 61 NoSuchPaddingException tE = new NoSuchPaddingException(); 62 assertNull("getMessage() must return null.", tE.getMessage()); 63 assertNull("getCause() must return null", tE.getCause()); 64 } 65 66 /** 67 * Test for <code>NoSuchPaddingException(String)</code> constructor 68 * Assertion: constructs NoSuchPaddingException with detail message msg. 69 * Parameter <code>msg</code> is not null. 70 */ 71 @TestTargetNew( 72 level = TestLevel.COMPLETE, 73 notes = "", 74 method = "NoSuchPaddingException", 75 args = {java.lang.String.class} 76 ) 77 public void testNoSuchPaddingException02() { 78 NoSuchPaddingException tE; 79 for (int i = 0; i < msgs.length; i++) { 80 tE = new NoSuchPaddingException(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>NoSuchPaddingException(String)</code> constructor 89 * Assertion: constructs NoSuchPaddingException when <code>msg</code> is 90 * null 91 */ 92 @TestTargetNew( 93 level = TestLevel.COMPLETE, 94 notes = "", 95 method = "NoSuchPaddingException", 96 args = {java.lang.String.class} 97 ) 98 public void testNoSuchPaddingException03() { 99 String msg = null; 100 NoSuchPaddingException tE = new NoSuchPaddingException(msg); 101 assertNull("getMessage() must return null.", tE.getMessage()); 102 assertNull("getCause() must return null", tE.getCause()); 103 } 104} 105