1 /* 2 * Copyright (C) 2008 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * 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 17 package com.google.common.collect.testing; 18 19 import com.google.common.collect.testing.testers.CollectionAddAllTester; 20 import com.google.common.collect.testing.testers.CollectionAddTester; 21 import com.google.common.collect.testing.testers.CollectionClearTester; 22 import com.google.common.collect.testing.testers.CollectionContainsAllTester; 23 import com.google.common.collect.testing.testers.CollectionContainsTester; 24 import com.google.common.collect.testing.testers.CollectionCreationTester; 25 import com.google.common.collect.testing.testers.CollectionEqualsTester; 26 import com.google.common.collect.testing.testers.CollectionIsEmptyTester; 27 import com.google.common.collect.testing.testers.CollectionIteratorTester; 28 import com.google.common.collect.testing.testers.CollectionRemoveAllTester; 29 import com.google.common.collect.testing.testers.CollectionRemoveTester; 30 import com.google.common.collect.testing.testers.CollectionRetainAllTester; 31 import com.google.common.collect.testing.testers.CollectionSizeTester; 32 import com.google.common.collect.testing.testers.CollectionToArrayTester; 33 import com.google.common.collect.testing.testers.CollectionToStringTester; 34 35 import junit.framework.TestSuite; 36 37 import java.util.Arrays; 38 import java.util.Collection; 39 import java.util.Collections; 40 import java.util.List; 41 42 /** 43 * Abstract superclass of all test-suite builders for collection interfaces. 44 * 45 * @author George van den Driessche 46 */ 47 public abstract class AbstractCollectionTestSuiteBuilder< 48 B extends AbstractCollectionTestSuiteBuilder<B, E>, E> 49 extends PerCollectionSizeTestSuiteBuilder< 50 B, TestCollectionGenerator<E>, Collection<E>, E> { 51 // Class parameters must be raw. 52 @SuppressWarnings("unchecked") 53 @Override protected List<Class<? extends AbstractTester>> getTesters() { 54 return Arrays.<Class<? extends AbstractTester>>asList( 55 CollectionAddAllTester.class, 56 CollectionAddTester.class, 57 CollectionClearTester.class, 58 CollectionContainsAllTester.class, 59 CollectionContainsTester.class, 60 CollectionCreationTester.class, 61 CollectionEqualsTester.class, 62 CollectionIsEmptyTester.class, 63 CollectionIteratorTester.class, 64 CollectionRemoveAllTester.class, 65 CollectionRemoveTester.class, 66 CollectionRetainAllTester.class, 67 CollectionSizeTester.class, 68 CollectionToArrayTester.class, 69 CollectionToStringTester.class 70 ); 71 } 72 73 @Override List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder< 74 ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>> 75 parentBuilder) { 76 DerivedIteratorTestSuiteBuilder<?> iteratorTestSuiteBuilder = 77 new DerivedIteratorTestSuiteBuilder<E>() 78 .named(parentBuilder.getName()) 79 .usingGenerator(parentBuilder.getSubjectGenerator()) 80 .withFeatures(parentBuilder.getFeatures()); 81 82 return Collections.singletonList( 83 iteratorTestSuiteBuilder.createTestSuite()); 84 } 85 } 86