TypeNotPresentExceptionTest.java revision 89c1feb0a69a7707b271086e749975b3f7acacf7
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.TestInfo; 20import dalvik.annotation.TestLevel; 21import dalvik.annotation.TestTarget; 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 @TestInfo( 33 level = TestLevel.COMPLETE, 34 purpose = "", 35 targets = { 36 @TestTarget( 37 methodName = "TypeNotPresentException", 38 methodArgs = {java.lang.String.class, java.lang.Throwable.class} 39 ) 40 }) 41 public void test_constructorLjava_lang_StringLjava_lang_Throwable() { 42 TypeNotPresentException e = new TypeNotPresentException(null, null); 43 assertNotNull(e); 44 String m = e.getMessage(); 45 assertNotNull(m); 46 47 e = new TypeNotPresentException(getClass().getName(), null); 48 assertNotNull(e); 49 m = e.getMessage(); 50 assertNotNull(m); 51 52 NullPointerException npe = new NullPointerException(); 53 e = new TypeNotPresentException(getClass().getName(), npe); 54 assertNotNull(e.getMessage()); 55 assertSame(npe, e.getCause()); 56 } 57 58 /** 59 * @tests java.lang.TypeNotPresentException.typeName() 60 */ 61 @TestInfo( 62 level = TestLevel.COMPLETE, 63 purpose = "", 64 targets = { 65 @TestTarget( 66 methodName = "typeName", 67 methodArgs = {} 68 ) 69 }) 70 public void test_typeName() { 71 TypeNotPresentException e = new TypeNotPresentException(null, null); 72 assertNull(e.typeName()); 73 74 e = new TypeNotPresentException(getClass().getName(), null); 75 assertEquals(getClass().getName(), e.typeName()); 76 } 77 78} 79