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 18package org.apache.harmony.luni.tests.java.lang; 19 20import dalvik.annotation.TestTargets; 21import dalvik.annotation.TestLevel; 22import dalvik.annotation.TestTargetNew; 23import dalvik.annotation.TestTargetClass; 24 25@TestTargetClass(ExceptionInInitializerError.class) 26public class ExceptionInInitializerErrorTest extends junit.framework.TestCase { 27 28 /** 29 * @tests java.lang.ExceptionInInitializerError#ExceptionInInitializerError() 30 */ 31 @TestTargets({ 32 @TestTargetNew( 33 level = TestLevel.COMPLETE, 34 notes = "", 35 method = "ExceptionInInitializerError", 36 args = {} 37 ), 38 @TestTargetNew( 39 level = TestLevel.COMPLETE, 40 notes = "", 41 method = "getCause", 42 args = {} 43 ) 44 }) 45 public void test_Constructor() { 46 ExceptionInInitializerError e = new ExceptionInInitializerError(); 47 assertNull(e.getMessage()); 48 assertNull(e.getLocalizedMessage()); 49 assertNull(e.getCause()); 50 } 51 52 /** 53 * @tests java.lang.ExceptionInInitializerError#ExceptionInInitializerError(java.lang.String) 54 */ 55 @TestTargets({ 56 @TestTargetNew( 57 level = TestLevel.COMPLETE, 58 notes = "", 59 method = "ExceptionInInitializerError", 60 args = {java.lang.String.class} 61 ), 62 @TestTargetNew( 63 level = TestLevel.COMPLETE, 64 notes = "", 65 method = "getCause", 66 args = {} 67 ) 68 }) 69 public void test_ConstructorLjava_lang_String() { 70 ExceptionInInitializerError e = new ExceptionInInitializerError("fixture"); 71 assertEquals("fixture", e.getMessage()); 72 assertNull(e.getCause()); 73 } 74 75 /** 76 * @tests java.lang.ExceptionInInitializerExceptionInInitializerError#ExceptionInInitializerError(java.lang.Throwable) 77 */ 78 @TestTargets({ 79 @TestTargetNew( 80 level = TestLevel.COMPLETE, 81 notes = "", 82 method = "ExceptionInInitializerError", 83 args = {java.lang.Throwable.class} 84 ), 85 @TestTargetNew( 86 level = TestLevel.COMPLETE, 87 notes = "", 88 method = "getCause", 89 args = {} 90 ), 91 @TestTargetNew( 92 level = TestLevel.COMPLETE, 93 notes = "", 94 method = "getException", 95 args = {} 96 ) 97 }) 98 public void test_ConstructorLjava_lang_Throwable() { 99 NullPointerException npe = new NullPointerException("fixture"); 100 ExceptionInInitializerError e = new ExceptionInInitializerError(npe); 101 assertNull(e.getMessage()); 102 assertNull(e.getLocalizedMessage()); 103 assertSame(npe, e.getException()); 104 assertSame(npe, e.getCause()); 105 } 106 107} 108