Java

Форк
0
96 строк · 4.1 Кб
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.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;
30

31
import java.lang.reflect.Method;
32
import java.util.Arrays;
33
import java.util.Collection;
34
import java.util.List;
35
import java.util.Map;
36
import junit.framework.Test;
37

38
/**
39
 * Tests the {@link Map} implementations of {@link java.util}, suppressing tests that trip known
40
 * bugs in OpenJDK 6 or higher.
41
 *
42
 * @author Kevin Bourrillion
43
 */
44
/*
45
 * TODO(cpovirk): consider renaming this class in light of our now running it
46
 * under JDK7
47
 */
48
public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
49
  public static Test suite() {
50
    return new OpenJdk6MapTests().allTests();
51
  }
52

53
  @Override
54
  protected Collection<Method> suppressForTreeMapNatural() {
55
    return Arrays.asList(
56
        getPutNullKeyUnsupportedMethod(),
57
        getPutAllNullKeyUnsupportedMethod(),
58
        getCreateWithNullKeyUnsupportedMethod(),
59
        getCreateWithNullUnsupportedMethod(), // for keySet
60
        getContainsEntryWithIncomparableKeyMethod(),
61
        getContainsEntryWithIncomparableValueMethod());
62
  }
63

64
  @Override
65
  protected Collection<Method> suppressForConcurrentHashMap() {
66
    /*
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
71
     *
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
76
     */
77
    return Arrays.asList(
78
        getAddUnsupportedNotPresentMethod(),
79
        getAddAllUnsupportedNonePresentMethod(),
80
        getAddAllUnsupportedSomePresentMethod());
81
  }
82

83
  @Override
84
  protected Collection<Method> suppressForConcurrentSkipListMap() {
85
    List<Method> methods = newArrayList();
86
    methods.addAll(super.suppressForConcurrentSkipListMap());
87
    methods.add(getContainsEntryWithIncomparableKeyMethod());
88
    methods.add(getContainsEntryWithIncomparableValueMethod());
89
    return methods;
90
  }
91

92
  @Override
93
  protected Collection<Method> suppressForHashtable() {
94
    return Arrays.asList(getMergeNullValueMethod());
95
  }
96
}
97

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.