| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.common.collect.testing.testers; |
| 18 |
|
| 19 |
import static com.google.common.collect.testing.features.CollectionSize.ZERO; |
| 20 |
import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_KEY_QUERIES; |
| 21 |
import static com.google.common.collect.testing.features.MapFeature.ALLOWS_NULL_VALUE_QUERIES; |
| 22 |
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE; |
| 23 |
|
| 24 |
import com.google.common.annotations.GwtCompatible; |
| 25 |
import com.google.common.collect.testing.AbstractMapTester; |
| 26 |
import com.google.common.collect.testing.features.CollectionSize; |
| 27 |
import com.google.common.collect.testing.features.MapFeature; |
| 28 |
import java.util.concurrent.ConcurrentMap; |
| 29 |
import org.junit.Ignore; |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@GwtCompatible |
| 38 |
@Ignore |
| 39 |
public class ConcurrentMapRemoveTester<K, V> extends AbstractMapTester<K, V> { |
| 40 |
@Override |
| 41 |
protected ConcurrentMap<K, V> getMap() { |
| 42 |
return (ConcurrentMap<K, V>) super.getMap(); |
| 43 |
} |
| 44 |
|
| 45 |
@MapFeature.Require(SUPPORTS_REMOVE) |
| 46 |
@CollectionSize.Require(absent = ZERO) |
| 47 |
public void testRemove_supportedPresent() { |
| 48 |
assertTrue(getMap().remove(k0(), v0())); |
| 49 |
expectMissing(e0()); |
| 50 |
} |
| 51 |
|
| 52 |
@MapFeature.Require(SUPPORTS_REMOVE) |
| 53 |
public void testRemove_supportedPresentKeyWrongValue() { |
| 54 |
assertFalse(getMap().remove(k0(), v3())); |
| 55 |
expectUnchanged(); |
| 56 |
} |
| 57 |
|
| 58 |
@MapFeature.Require(SUPPORTS_REMOVE) |
| 59 |
public void testRemove_supportedWrongKeyPresentValue() { |
| 60 |
assertFalse(getMap().remove(k3(), v0())); |
| 61 |
expectUnchanged(); |
| 62 |
} |
| 63 |
|
| 64 |
@MapFeature.Require(SUPPORTS_REMOVE) |
| 65 |
public void testRemove_supportedAbsentKeyAbsentValue() { |
| 66 |
assertFalse(getMap().remove(k3(), v3())); |
| 67 |
expectUnchanged(); |
| 68 |
} |
| 69 |
|
| 70 |
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_KEY_QUERIES) |
| 71 |
public void testRemove_nullKeyQueriesUnsupported() { |
| 72 |
try { |
| 73 |
assertFalse(getMap().remove(null, v3())); |
| 74 |
} catch (NullPointerException tolerated) { |
| 75 |
|
| 76 |
} |
| 77 |
expectUnchanged(); |
| 78 |
} |
| 79 |
|
| 80 |
@MapFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_VALUE_QUERIES) |
| 81 |
public void testRemove_nullValueQueriesUnsupported() { |
| 82 |
try { |
| 83 |
assertFalse(getMap().remove(k3(), null)); |
| 84 |
} catch (NullPointerException tolerated) { |
| 85 |
|
| 86 |
} |
| 87 |
expectUnchanged(); |
| 88 |
} |
| 89 |
|
| 90 |
@MapFeature.Require(absent = SUPPORTS_REMOVE) |
| 91 |
@CollectionSize.Require(absent = ZERO) |
| 92 |
public void testRemove_unsupportedPresent() { |
| 93 |
try { |
| 94 |
getMap().remove(k0(), v0()); |
| 95 |
fail("Expected UnsupportedOperationException"); |
| 96 |
} catch (UnsupportedOperationException expected) { |
| 97 |
} |
| 98 |
expectUnchanged(); |
| 99 |
} |
| 100 |
|
| 101 |
@MapFeature.Require(absent = SUPPORTS_REMOVE) |
| 102 |
public void testRemove_unsupportedAbsent() { |
| 103 |
try { |
| 104 |
assertFalse(getMap().remove(k0(), v3())); |
| 105 |
} catch (UnsupportedOperationException tolerated) { |
| 106 |
|
| 107 |
} |
| 108 |
expectUnchanged(); |
| 109 |
} |
| 110 |
} |