• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.CollectionSerializationTester;
32 import com.google.common.collect.testing.testers.CollectionSizeTester;
33 import com.google.common.collect.testing.testers.CollectionToArrayTester;
34 import com.google.common.collect.testing.testers.CollectionToStringTester;
35 
36 import junit.framework.TestSuite;
37 
38 import java.util.Arrays;
39 import java.util.Collection;
40 import java.util.Collections;
41 import java.util.List;
42 
43 /**
44  * Abstract superclass of all test-suite builders for collection interfaces.
45  *
46  * @author George van den Driessche
47  */
48 public abstract class AbstractCollectionTestSuiteBuilder<
49     B extends AbstractCollectionTestSuiteBuilder<B, E>, E>
50     extends PerCollectionSizeTestSuiteBuilder<
51         B, TestCollectionGenerator<E>, Collection<E>, E> {
52   // Class parameters must be raw.
53   @SuppressWarnings("unchecked")
getTesters()54   @Override protected List<Class<? extends AbstractTester>> getTesters() {
55     return Arrays.<Class<? extends AbstractTester>>asList(
56         CollectionAddAllTester.class,
57         CollectionAddTester.class,
58         CollectionClearTester.class,
59         CollectionContainsAllTester.class,
60         CollectionContainsTester.class,
61         CollectionCreationTester.class,
62         CollectionEqualsTester.class,
63         CollectionIsEmptyTester.class,
64         CollectionIteratorTester.class,
65         CollectionRemoveAllTester.class,
66         CollectionRemoveTester.class,
67         CollectionRetainAllTester.class,
68         CollectionSerializationTester.class,
69         CollectionSizeTester.class,
70         CollectionToArrayTester.class,
71         CollectionToStringTester.class
72     );
73   }
74 
75   @Override
createDerivedSuites(FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>> parentBuilder)76   protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<
77       ?, ? extends OneSizeTestContainerGenerator<Collection<E>, E>>
78           parentBuilder) {
79     DerivedIteratorTestSuiteBuilder<?> iteratorTestSuiteBuilder =
80         new DerivedIteratorTestSuiteBuilder<E>()
81             .named(parentBuilder.getName())
82             .usingGenerator(parentBuilder.getSubjectGenerator())
83             .withFeatures(parentBuilder.getFeatures());
84 
85     return Collections.singletonList(
86         iteratorTestSuiteBuilder.createTestSuite());
87   }
88 }
89