Java
54 строки · 2.1 Кб
1/*
2* Copyright (C) 2015 The Guava Authors
3*
4* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5* in compliance with the License. You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software distributed under the License
10* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11* or implied. See the License for the specific language governing permissions and limitations under
12* the License.
13*/
14
15package com.google.common.collect.testing;
16
17import com.google.common.annotations.GwtIncompatible;
18import com.google.common.collect.testing.testers.ConcurrentMapPutIfAbsentTester;
19import com.google.common.collect.testing.testers.ConcurrentMapRemoveTester;
20import com.google.common.collect.testing.testers.ConcurrentMapReplaceEntryTester;
21import com.google.common.collect.testing.testers.ConcurrentMapReplaceTester;
22import java.util.Arrays;
23import java.util.List;
24
25/**
26* Creates, based on your criteria, a JUnit test suite that exhaustively tests a ConcurrentMap
27* implementation.
28*
29* @author Louis Wasserman
30*/
31@GwtIncompatible
32public class ConcurrentMapTestSuiteBuilder<K, V> extends MapTestSuiteBuilder<K, V> {
33public static <K, V> ConcurrentMapTestSuiteBuilder<K, V> using(TestMapGenerator<K, V> generator) {
34ConcurrentMapTestSuiteBuilder<K, V> result = new ConcurrentMapTestSuiteBuilder<>();
35result.usingGenerator(generator);
36return result;
37}
38
39@SuppressWarnings("rawtypes") // class literals
40static final List<? extends Class<? extends AbstractTester>> TESTERS =
41Arrays.asList(
42ConcurrentMapPutIfAbsentTester.class,
43ConcurrentMapRemoveTester.class,
44ConcurrentMapReplaceTester.class,
45ConcurrentMapReplaceEntryTester.class);
46
47@SuppressWarnings("rawtypes") // class literals
48@Override
49protected List<Class<? extends AbstractTester>> getTesters() {
50List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
51testers.addAll(TESTERS);
52return testers;
53}
54}
55