2
* Copyright (C) 2009 The Guava Authors
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
package com.google.common.collect.testing;
19
import static com.google.common.collect.Lists.newArrayList;
20
import static com.google.common.collect.testing.testers.CollectionAddAllTester.getAddAllUnsupportedNonePresentMethod;
21
import static com.google.common.collect.testing.testers.CollectionAddAllTester.getAddAllUnsupportedSomePresentMethod;
22
import static com.google.common.collect.testing.testers.CollectionAddTester.getAddUnsupportedNotPresentMethod;
23
import static com.google.common.collect.testing.testers.CollectionCreationTester.getCreateWithNullUnsupportedMethod;
24
import static com.google.common.collect.testing.testers.MapCreationTester.getCreateWithNullKeyUnsupportedMethod;
25
import static com.google.common.collect.testing.testers.MapEntrySetTester.getContainsEntryWithIncomparableKeyMethod;
26
import static com.google.common.collect.testing.testers.MapEntrySetTester.getContainsEntryWithIncomparableValueMethod;
27
import static com.google.common.collect.testing.testers.MapMergeTester.getMergeNullValueMethod;
28
import static com.google.common.collect.testing.testers.MapPutAllTester.getPutAllNullKeyUnsupportedMethod;
29
import static com.google.common.collect.testing.testers.MapPutTester.getPutNullKeyUnsupportedMethod;
31
import java.lang.reflect.Method;
32
import java.util.Arrays;
33
import java.util.Collection;
36
import junit.framework.Test;
39
* Tests the {@link Map} implementations of {@link java.util}, suppressing tests that trip known
40
* bugs in OpenJDK 6 or higher.
42
* @author Kevin Bourrillion
45
* TODO(cpovirk): consider renaming this class in light of our now running it
48
public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
49
public static Test suite() {
50
return new OpenJdk6MapTests().allTests();
54
protected Collection<Method> suppressForTreeMapNatural() {
56
getPutNullKeyUnsupportedMethod(),
57
getPutAllNullKeyUnsupportedMethod(),
58
getCreateWithNullKeyUnsupportedMethod(),
59
getCreateWithNullUnsupportedMethod(), // for keySet
60
getContainsEntryWithIncomparableKeyMethod(),
61
getContainsEntryWithIncomparableValueMethod());
65
protected Collection<Method> suppressForConcurrentHashMap() {
67
* The entrySet() of ConcurrentHashMap, unlike that of other Map
68
* implementations, supports add() under JDK8. This seems problematic, but I
69
* didn't see that discussed in the review, which included many other
70
* changes: https://mail.openjdk.org/pipermail/core-libs-dev/2013-May/thread.html#17367
72
* TODO(cpovirk): decide what the best long-term action here is: force users
73
* to suppress (as we do now), stop testing entrySet().add() at all, make
74
* entrySet().add() tests tolerant of either behavior, introduce a map
75
* feature for entrySet() that supports add(), or something else
78
getAddUnsupportedNotPresentMethod(),
79
getAddAllUnsupportedNonePresentMethod(),
80
getAddAllUnsupportedSomePresentMethod());
84
protected Collection<Method> suppressForConcurrentSkipListMap() {
85
List<Method> methods = newArrayList();
86
methods.addAll(super.suppressForConcurrentSkipListMap());
87
methods.add(getContainsEntryWithIncomparableKeyMethod());
88
methods.add(getContainsEntryWithIncomparableValueMethod());
93
protected Collection<Method> suppressForHashtable() {
94
return Arrays.asList(getMergeNullValueMethod());