TypeNotPresentExceptionTest.java revision f6c387128427e121477c1b32ad35cdcaa5101ba3
1/* Licensed to the Apache Software Foundation (ASF) under one or more 2 * contributor license agreements. See the NOTICE file distributed with 3 * this work for additional information regarding copyright ownership. 4 * The ASF licenses this file to You under the Apache License, Version 2.0 5 * (the "License"); you may not use this file except in compliance with 6 * the License. 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 */ 16 17package org.apache.harmony.luni.tests.java.lang; 18 19import dalvik.annotation.TestTargets; 20import dalvik.annotation.TestLevel; 21import dalvik.annotation.TestTargetNew; 22import dalvik.annotation.TestTargetClass; 23 24import junit.framework.TestCase; 25 26@TestTargetClass(TypeNotPresentException.class) 27public class TypeNotPresentExceptionTest extends TestCase { 28 29 /** 30 * @tests java.lang.TypeNotPresentException.TypeNotPresentException(String, Throwable) 31 */ 32 @TestTargetNew( 33 level = TestLevel.COMPLETE, 34 notes = "", 35 method = "TypeNotPresentException", 36 args = {java.lang.String.class, java.lang.Throwable.class} 37 ) 38 public void test_constructorLjava_lang_StringLjava_lang_Throwable() { 39 TypeNotPresentException e = new TypeNotPresentException(null, null); 40 assertNotNull(e); 41 String m = e.getMessage(); 42 assertNotNull(m); 43 44 e = new TypeNotPresentException(getClass().getName(), null); 45 assertNotNull(e); 46 m = e.getMessage(); 47 assertNotNull(m); 48 49 NullPointerException npe = new NullPointerException(); 50 e = new TypeNotPresentException(getClass().getName(), npe); 51 assertNotNull(e.getMessage()); 52 assertSame(npe, e.getCause()); 53 } 54 55 /** 56 * @tests java.lang.TypeNotPresentException.typeName() 57 */ 58 @TestTargetNew( 59 level = TestLevel.COMPLETE, 60 notes = "", 61 method = "typeName", 62 args = {} 63 ) 64 public void test_typeName() { 65 TypeNotPresentException e = new TypeNotPresentException(null, null); 66 assertNull(e.typeName()); 67 68 e = new TypeNotPresentException(getClass().getName(), null); 69 assertEquals(getClass().getName(), e.typeName()); 70 } 71 72} 73