• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 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 static com.google.common.collect.testing.testers.CollectionAddAllTester.getAddAllUnsupportedNonePresentMethod;
20 import static com.google.common.collect.testing.testers.CollectionAddAllTester.getAddAllUnsupportedSomePresentMethod;
21 import static com.google.common.collect.testing.testers.CollectionAddTester.getAddUnsupportedNotPresentMethod;
22 import static com.google.common.collect.testing.testers.CollectionCreationTester.getCreateWithNullUnsupportedMethod;
23 import static com.google.common.collect.testing.testers.MapCreationTester.getCreateWithNullKeyUnsupportedMethod;
24 import static com.google.common.collect.testing.testers.MapEntrySetTester.getContainsEntryWithIncomparableKeyMethod;
25 import static com.google.common.collect.testing.testers.MapEntrySetTester.getContainsEntryWithIncomparableValueMethod;
26 import static com.google.common.collect.testing.testers.MapPutAllTester.getPutAllNullKeyUnsupportedMethod;
27 import static com.google.common.collect.testing.testers.MapPutTester.getPutNullKeyUnsupportedMethod;
28 
29 import junit.framework.Test;
30 
31 import java.lang.reflect.Method;
32 import java.util.Arrays;
33 import java.util.Collection;
34 import java.util.Map;
35 
36 /**
37  * Tests the {@link Map} implementations of {@link java.util}, suppressing
38  * tests that trip known bugs in OpenJDK 6 or higher.
39  *
40  * @author Kevin Bourrillion
41  */
42 /*
43  * TODO(cpovirk): consider renaming this class in light of our now running it
44  * under JDK7
45  */
46 public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
suite()47   public static Test suite() {
48     return new OpenJdk6MapTests().allTests();
49   }
50 
suppressForTreeMapNatural()51   @Override protected Collection<Method> suppressForTreeMapNatural() {
52     return Arrays.asList(
53         getPutNullKeyUnsupportedMethod(),
54         getPutAllNullKeyUnsupportedMethod(),
55         getCreateWithNullKeyUnsupportedMethod(),
56         getCreateWithNullUnsupportedMethod(), // for keySet
57         getContainsEntryWithIncomparableKeyMethod(),
58         getContainsEntryWithIncomparableValueMethod());
59   }
60 
61   @Override
suppressForConcurrentHashMap()62   protected Collection<Method> suppressForConcurrentHashMap() {
63     /*
64      * The entrySet() of ConcurrentHashMap, unlike that of other Map
65      * implementations, supports add() under JDK8. This seems problematic, but I
66      * didn't see that discussed in the review, which included many other
67      * changes: http://goo.gl/okTTdr
68      *
69      * TODO(cpovirk): decide what the best long-term action here is: force users
70      * to suppress (as we do now), stop testing entrySet().add() at all, make
71      * entrySet().add() tests tolerant of either behavior, introduce a map
72      * feature for entrySet() that supports add(), or something else
73      */
74     return Arrays.asList(
75         getAddUnsupportedNotPresentMethod(),
76         getAddAllUnsupportedNonePresentMethod(),
77         getAddAllUnsupportedSomePresentMethod());
78   }
79 
80   @Override
suppressForConcurrentSkipListMap()81   protected Collection<Method> suppressForConcurrentSkipListMap() {
82     return Arrays.asList(
83         getContainsEntryWithIncomparableKeyMethod(),
84         getContainsEntryWithIncomparableValueMethod());
85   }
86 }
87