001/*
002 * Copyright (C) 2015 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014
015package com.google.common.collect.testing;
016
017import static com.google.common.collect.testing.Helpers.copyToList;
018import static java.util.Arrays.asList;
019
020import com.google.common.annotations.GwtIncompatible;
021import com.google.common.collect.testing.testers.ConcurrentMapPutIfAbsentTester;
022import com.google.common.collect.testing.testers.ConcurrentMapRemoveTester;
023import com.google.common.collect.testing.testers.ConcurrentMapReplaceEntryTester;
024import com.google.common.collect.testing.testers.ConcurrentMapReplaceTester;
025import java.util.List;
026
027/**
028 * Creates, based on your criteria, a JUnit test suite that exhaustively tests a ConcurrentMap
029 * implementation.
030 *
031 * @author Louis Wasserman
032 */
033@GwtIncompatible
034public class ConcurrentMapTestSuiteBuilder<K, V> extends MapTestSuiteBuilder<K, V> {
035  public static <K, V> ConcurrentMapTestSuiteBuilder<K, V> using(TestMapGenerator<K, V> generator) {
036    ConcurrentMapTestSuiteBuilder<K, V> result = new ConcurrentMapTestSuiteBuilder<>();
037    result.usingGenerator(generator);
038    return result;
039  }
040
041  @SuppressWarnings("rawtypes") // class literals
042  static final List<? extends Class<? extends AbstractTester>> TESTERS =
043      asList(
044          ConcurrentMapPutIfAbsentTester.class,
045          ConcurrentMapRemoveTester.class,
046          ConcurrentMapReplaceTester.class,
047          ConcurrentMapReplaceEntryTester.class);
048
049  @SuppressWarnings("rawtypes") // class literals
050  @Override
051  protected List<Class<? extends AbstractTester>> getTesters() {
052    List<Class<? extends AbstractTester>> testers = copyToList(super.getTesters());
053    testers.addAll(TESTERS);
054    return testers;
055  }
056}