Java
70 строк · 2.5 Кб
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
17package com.google.common.collect.testing;18
19import com.google.common.annotations.GwtIncompatible;20import com.google.common.collect.testing.testers.QueueElementTester;21import com.google.common.collect.testing.testers.QueueOfferTester;22import com.google.common.collect.testing.testers.QueuePeekTester;23import com.google.common.collect.testing.testers.QueuePollTester;24import com.google.common.collect.testing.testers.QueueRemoveTester;25import com.google.errorprone.annotations.CanIgnoreReturnValue;26import java.util.ArrayList;27import java.util.List;28
29/**
30* Creates, based on your criteria, a JUnit test suite that exhaustively tests a queue
31* implementation.
32*
33* @author Jared Levy
34*/
35@GwtIncompatible
36public final class QueueTestSuiteBuilder<E>37extends AbstractCollectionTestSuiteBuilder<QueueTestSuiteBuilder<E>, E> {38public static <E> QueueTestSuiteBuilder<E> using(TestQueueGenerator<E> generator) {39return new QueueTestSuiteBuilder<E>().usingGenerator(generator);40}41
42private boolean runCollectionTests = true;43
44/**45* Specify whether to skip the general collection tests. Call this method when testing a
46* collection that's both a queue and a list, to avoid running the common collection tests twice.
47* By default, collection tests do run.
48*/
49@CanIgnoreReturnValue50public QueueTestSuiteBuilder<E> skipCollectionTests() {51runCollectionTests = false;52return this;53}54
55@SuppressWarnings("rawtypes") // class literals56@Override57protected List<Class<? extends AbstractTester>> getTesters() {58List<Class<? extends AbstractTester>> testers = new ArrayList<>();59if (runCollectionTests) {60testers.addAll(super.getTesters());61}62
63testers.add(QueueElementTester.class);64testers.add(QueueOfferTester.class);65testers.add(QueuePeekTester.class);66testers.add(QueuePollTester.class);67testers.add(QueueRemoveTester.class);68return testers;69}70}
71