ArrayIndexOutOfBoundsExceptionTest.java revision f6c387128427e121477c1b32ad35cdcaa5101ba3
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 25import junit.framework.TestCase; 26 27@TestTargetClass(ArrayIndexOutOfBoundsException.class) 28public class ArrayIndexOutOfBoundsExceptionTest extends TestCase { 29 30 /** 31 * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException(int) 32 */ 33 @TestTargetNew( 34 level = TestLevel.COMPLETE, 35 notes = "", 36 method = "ArrayIndexOutOfBoundsException", 37 args = {int.class} 38 ) 39 public void test_ConstructorI() { 40 ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException(-1); 41 assertNotNull(e.getMessage()); 42 assertTrue("Unable to find index value in 'message' property.", e.getMessage().indexOf( 43 "-1", 0) >= 0); 44 45 } 46 47 /** 48 * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException() 49 */ 50 @TestTargetNew( 51 level = TestLevel.COMPLETE, 52 notes = "", 53 method = "ArrayIndexOutOfBoundsException", 54 args = {} 55 ) 56 public void test_Constructor() { 57 ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException(); 58 assertNull(e.getMessage()); 59 assertNull(e.getCause()); 60 } 61 62 /** 63 * @tests java.lang.ArrayIndexOutOfBoundsException#ArrayIndexOutOfBoundsException(java.lang.String) 64 */ 65 @TestTargetNew( 66 level = TestLevel.COMPLETE, 67 notes = "", 68 method = "ArrayIndexOutOfBoundsException", 69 args = {java.lang.String.class} 70 ) 71 public void test_ConstructorLjava_lang_String() { 72 ArrayIndexOutOfBoundsException e = new ArrayIndexOutOfBoundsException("fixture"); 73 assertEquals("fixture", e.getMessage()); 74 assertNull(e.getCause()); 75 } 76} 77