AbstractSequentialListTest.java revision 89c1feb0a69a7707b271086e749975b3f7acacf7
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 */ 17package tests.api.java.util; 18 19import dalvik.annotation.TestTarget; 20import dalvik.annotation.TestInfo; 21import dalvik.annotation.TestLevel; 22import dalvik.annotation.TestTargetClass; 23 24import java.util.AbstractSequentialList; 25import java.util.Arrays; 26import java.util.Collection; 27import java.util.LinkedList; 28import java.util.ListIterator; 29 30import junit.framework.TestCase; 31 32@TestTargetClass(AbstractSequentialList.class) 33public class AbstractSequentialListTest extends TestCase { 34 35 @Override 36 protected void setUp() throws Exception { 37 super.setUp(); 38 } 39 40 @Override 41 protected void tearDown() throws Exception { 42 super.tearDown(); 43 } 44 45 class ASLT<E> extends AbstractSequentialList<E> { 46 47 LinkedList<E> l = new LinkedList<E>(); 48 49 @Override 50 public ListIterator<E> listIterator(int index) { 51 return l.listIterator(index); 52 } 53 54 @Override 55 public int size() { 56 return l.size(); 57 } 58 } 59 60 /** 61 * @tests {@link java.util.AbstractSequentialList#addAll(int, java.util.Collection)} 62 */ 63 @TestInfo( 64 level = TestLevel.PARTIAL, 65 purpose = "Doesn't verify all exceptions according to the specification.", 66 targets = { 67 @TestTarget( 68 methodName = "addAll", 69 methodArgs = {int.class, java.util.Collection.class} 70 ) 71 }) 72 public void test_addAll_ILCollection() { 73 AbstractSequentialList<String> al = new ASLT<String>(); 74 String[] someList = { "Aardvark" , //$NON-NLS-1$ 75 "Bear" , //$NON-NLS-1$ 76 "Chimpanzee", //$NON-NLS-1$ 77 "Duck" }; //$NON-NLS-1$ 78 Collection<String> c = Arrays.asList(someList); 79 al.addAll(c); 80 assertTrue("Should return true", al.addAll(2, c)); //$NON-NLS-1$ 81 } 82 83} 84