Class AbstractMapTester<K,V>
- java.lang.Object
-
- junit.framework.Assert
-
- junit.framework.TestCase
-
- com.google.common.collect.testing.AbstractTester<OneSizeTestContainerGenerator<C,E>>
-
- com.google.common.collect.testing.AbstractContainerTester<java.util.Map<K,V>,java.util.Map.Entry<K,V>>
-
- com.google.common.collect.testing.AbstractMapTester<K,V>
-
- Type Parameters:
K
- the key type of the map to be tested.V
- the value type of the map to be tested.
- All Implemented Interfaces:
junit.framework.Test
- Direct Known Subclasses:
AbstractBiMapTester
,ConcurrentMapPutIfAbsentTester
,ConcurrentMapRemoveTester
,ConcurrentMapReplaceEntryTester
,ConcurrentMapReplaceTester
,MapClearTester
,MapContainsKeyTester
,MapContainsValueTester
,MapCreationTester
,MapEntrySetTester
,MapEqualsTester
,MapGetTester
,MapHashCodeTester
,MapIsEmptyTester
,MapPutAllTester
,MapPutTester
,MapRemoveTester
,MapSerializationTester
,MapSizeTester
,MapToStringTester
,NavigableMapNavigationTester
,SortedMapNavigationTester
@GwtCompatible public abstract class AbstractMapTester<K,V> extends AbstractContainerTester<java.util.Map<K,V>,java.util.Map.Entry<K,V>>
Base class for map testers. TODO: see how much of this is actually needed once Map testers are written. (It was cloned from AbstractCollectionTester.)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.common.collect.testing.AbstractContainerTester
AbstractContainerTester.ArrayWithDuplicate<E>
-
-
Field Summary
-
Fields inherited from class com.google.common.collect.testing.AbstractContainerTester
container, samples
-
-
Constructor Summary
Constructors Constructor Description AbstractMapTester()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<java.util.Map.Entry<K,V>>
actualContents()
protected java.util.Map.Entry<K,V>[]
createArrayWithNullKey()
protected java.util.Map.Entry<K,V>[]
createArrayWithNullValue()
protected MinimalCollection<java.util.Map.Entry<K,V>>
createDisjointCollection()
protected java.util.Map.Entry<K,V>
entry(K key, V value)
protected void
expectContents(java.util.Collection<java.util.Map.Entry<K,V>> expected)
Asserts that the collection under test contains exactly the given elements, respecting cardinality but not order.protected void
expectMissing(java.util.Map.Entry<K,V>... entries)
protected void
expectMissingKeys(K... elements)
protected void
expectMissingValues(V... elements)
protected void
expectNullKeyMissingWhenNullKeysUnsupported(java.lang.String message)
Equivalent toexpectMissingKeys
(null)
except that the call tocontains(null)
is permitted to throw aNullPointerException
.protected void
expectNullValueMissingWhenNullValuesUnsupported(java.lang.String message)
Equivalent toexpectMissingValues
(null)
except that the call tocontains(null)
is permitted to throw aNullPointerException
.protected void
expectReplacement(java.util.Map.Entry<K,V> newEntry)
protected V
get(K key)
Wrapper forMap.get(Object)
that forces the caller to pass in a key of the same type as the map.protected K
getKeyForNullValue()
protected java.util.Map<K,V>
getMap()
protected int
getNumEntries()
protected java.util.Collection<java.util.Map.Entry<K,V>>
getSampleEntries()
protected java.util.Collection<java.util.Map.Entry<K,V>>
getSampleEntries(int howMany)
protected V
getValueForNullKey()
protected void
initMapWithNullKey()
protected void
initMapWithNullValue()
protected K
k0()
protected K
k1()
protected K
k2()
protected K
k3()
protected K
k4()
protected void
resetMap()
protected void
resetMap(java.util.Map.Entry<K,V>[] entries)
void
setUp()
protected V
v0()
protected V
v1()
protected V
v2()
protected V
v3()
protected V
v4()
-
Methods inherited from class com.google.common.collect.testing.AbstractContainerTester
createArrayWithDuplicateElement, createOrderedArray, createSamplesArray, e0, e1, e2, e3, e4, emptyCollection, expectAdded, expectAdded, expectAdded, expectContents, expectUnchanged, getNullLocation, getNumElements, getOrderedElements, getSampleElements, getSampleElements, resetContainer, resetContainer
-
Methods inherited from class com.google.common.collect.testing.AbstractTester
getName, getSubjectGenerator, getTestMethodName, init, init, tearDown
-
Methods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, run, run, runBare, runTest, setName, toString
-
-
-
-
Method Detail
-
setUp
public void setUp() throws java.lang.Exception
-
actualContents
protected java.util.Collection<java.util.Map.Entry<K,V>> actualContents()
- Specified by:
actualContents
in classAbstractContainerTester<java.util.Map<K,V>,java.util.Map.Entry<K,V>>
- Returns:
- the contents of the container under test, for use by
expectContents(E...)
and its friends.
-
resetMap
protected void resetMap()
- See Also:
AbstractContainerTester.resetContainer()
-
expectMissingKeys
protected void expectMissingKeys(K... elements)
-
expectMissingValues
protected void expectMissingValues(V... elements)
-
createArrayWithNullKey
protected java.util.Map.Entry<K,V>[] createArrayWithNullKey()
- Returns:
- an array of the proper size with
null
as the key of the middle element.
-
getValueForNullKey
protected V getValueForNullKey()
-
getKeyForNullValue
protected K getKeyForNullValue()
-
createArrayWithNullValue
protected java.util.Map.Entry<K,V>[] createArrayWithNullValue()
- Returns:
- an array of the proper size with
null
as the value of the middle element.
-
initMapWithNullKey
protected void initMapWithNullKey()
-
initMapWithNullValue
protected void initMapWithNullValue()
-
expectNullKeyMissingWhenNullKeysUnsupported
protected void expectNullKeyMissingWhenNullKeysUnsupported(java.lang.String message)
Equivalent toexpectMissingKeys
(null)
except that the call tocontains(null)
is permitted to throw aNullPointerException
.- Parameters:
message
- message to use upon assertion failure
-
expectNullValueMissingWhenNullValuesUnsupported
protected void expectNullValueMissingWhenNullValuesUnsupported(java.lang.String message)
Equivalent toexpectMissingValues
(null)
except that the call tocontains(null)
is permitted to throw aNullPointerException
.- Parameters:
message
- message to use upon assertion failure
-
createDisjointCollection
protected MinimalCollection<java.util.Map.Entry<K,V>> createDisjointCollection()
- Overrides:
createDisjointCollection
in classAbstractContainerTester<java.util.Map<K,V>,java.util.Map.Entry<K,V>>
-
getNumEntries
protected int getNumEntries()
-
getSampleEntries
protected java.util.Collection<java.util.Map.Entry<K,V>> getSampleEntries(int howMany)
-
expectMissing
protected void expectMissing(java.util.Map.Entry<K,V>... entries)
- Overrides:
expectMissing
in classAbstractContainerTester<java.util.Map<K,V>,java.util.Map.Entry<K,V>>
-
expectContents
protected void expectContents(java.util.Collection<java.util.Map.Entry<K,V>> expected)
Description copied from class:AbstractContainerTester
Asserts that the collection under test contains exactly the given elements, respecting cardinality but not order. Subclasses may override this method to provide stronger assertions, e.g., to check ordering in lists, but realize that unless a test extendsAbstractListTester
, a call toexpectContents()
invokes this version.- Overrides:
expectContents
in classAbstractContainerTester<java.util.Map<K,V>,java.util.Map.Entry<K,V>>
- Parameters:
expected
- expected value ofAbstractContainerTester.container
-
get
protected V get(K key)
Wrapper forMap.get(Object)
that forces the caller to pass in a key of the same type as the map. Besides being slightly shorter than code that usesgetMap()
, it also ensures that callers don't pass anMap.Entry
by mistake.
-
k0
protected final K k0()
-
v0
protected final V v0()
-
k1
protected final K k1()
-
v1
protected final V v1()
-
k2
protected final K k2()
-
v2
protected final V v2()
-
k3
protected final K k3()
-
v3
protected final V v3()
-
k4
protected final K k4()
-
v4
protected final V v4()
-
-