public abstract class AbstractMapTest extends Object
Maps are generally constructed with either a zero argument constructor or a constructor that gives an initial map. Subclasses of this class must implement the methods to create the Maps using these two common concrete schemes.
Other protected methods in this class control whether or not the Map implementation implements some of the optional features of the Map interface.
Modifier and Type | Field and Description |
---|---|
protected static String |
FOUR_KEY |
protected static String |
FOUR_VALUE |
protected static String |
NULL_KEY |
protected static String |
NULL_VALUE |
protected static String |
ONE_KEY |
protected static String |
ONE_VALUE |
protected static String |
THREE_KEY |
protected static String |
THREE_VALUE |
protected static String |
TWO_KEY |
protected static String |
TWO_VALUE |
Constructor and Description |
---|
AbstractMapTest() |
Modifier and Type | Method and Description |
---|---|
protected abstract Map<?,?> |
createMap()
Subclasses must override this method in order to construct
an empty Map with the null argument constructor.
|
protected abstract Map<?,?> |
createMap(Map<?,?> input)
Subclasses must override this method in order to construct
a Map with the elements found in the input Map.
|
protected boolean |
doesMapAllowNullKeys()
Subclasses should override this method if their Map
implementation does not support null as an key in
the Map.
|
protected boolean |
doesMapAllowNullValues()
Subclasses should override this method if their Map
implementation does not support null as an value in
the Map.
|
protected boolean |
doesMapDelegateFromOriginalMap()
Subclasses should override this method if their Map
implementation delegates to the passed in Map.
|
protected boolean |
doesMapSupportRemove()
Subclasses should override this method if their Map
does not support the optional remove method.
|
protected TestCollectionElement |
getElement(String data)
This returns an implementation of TestCollectionElement that
will be put into the Collection implementation.
|
protected boolean |
isMapArgumentConstructorSupported()
Subclasses should override this method if their Map
implementation does not support a Map argument
constructor.
|
protected boolean |
isNullArgumentConstructorSupported()
Subclasses should override this method if their Map
implementation does not support a null argument
constructor.
|
void |
testAddOneThousandEntries()
Tries to test the resizing of the collection
by adding 1000 items
|
void |
testCanAddToMap()
Tests that a single element can be added to the list
|
void |
testCanCollectionHaveNullAndNonNullEntries()
Tests that maps can have null keys and values
interspersed with non-null entries
|
void |
testCanMapHaveNullKeys()
Tests that the map functions properly with
a null key added
|
void |
testCanMapHaveNullValues()
Tests that the map functions properly with
a null value added
|
void |
testClearOnEmptyMap()
This test ensures that clear works on
an empty map
|
void |
testClearOnNonEmptyMap()
This test ensures that putAll works with
an non-empty map and an non-empty adding map
|
void |
testContainsAfterPut()
Tests that contains works properly
|
void |
testEntrySetOnEmptyMap()
This test ensures that entrySet works with
an empty map
|
void |
testEntrySetOnNonEmptyMap()
This test ensures that entrySet works with
an non-empty map
|
void |
testKeySetOnEmptyMap()
This test ensures that keySet works with
an empty map
|
void |
testKeySetOnNonEmptyMap()
This test ensures that keySet works with
an non-empty map
|
void |
testMapConstructedWithNullMapThrows()
Tests that a list constructed from the empty collection
constructor has size zero
|
void |
testMapFromMapConstructorHasZeroSize()
Tests that a list constructed from the empty collection
constructor has size zero
|
void |
testMapFromNullConstructorHasZeroSize()
Tests that a list constructed from the null constructor has
size zero
|
void |
testModifyingOriginalCollectionDoesNotAffectNewCollection()
Tests that modifying the elements in the original collection
do not affect the elements in the newly created collection
|
void |
testPutAllEmptyOriginalEmptyAdding()
This test ensures that putAll works with
an empty map and an empty adding map
|
void |
testPutAllEmptyOriginalNonEmptyAdding()
This test ensures that putAll works with
an empty map and an non-empty adding map
|
void |
testPutAllNonEmptyOriginalEmptyAdding()
This test ensures that putAll works with
an non-empty map and an empty adding map
|
void |
testPutAllNonEmptyOriginalNonEmptyAdding()
This test ensures that putAll works with
an non-empty map and an non-empty adding map
|
void |
testRemoveFirstThingFromMultiElementMap()
This test ensures that remove can remove the
first item added to the collection
|
void |
testRemoveFromEmptyMap()
This test ensures that remove works properly in an empty map
|
void |
testRemoveFromOneElementMap()
This test ensures that remove returns the proper value
|
void |
testRemoveLastThingFromMultiElementMap()
This test ensures that remove can remove the
first item added to the map
|
void |
testRemoveMiddleThingFromMultiElementMap()
This test ensures that remove can remove the
first item added to the map
|
void |
testValuesOnEmptyMap()
This test ensures that values works with
an empty map
|
void |
testValuesOnNonEmptyMap()
This test ensures that values works with
an non-empty map
|
protected static final String NULL_KEY
protected static final String NULL_VALUE
protected static final String ONE_KEY
protected static final String ONE_VALUE
protected static final String TWO_KEY
protected static final String TWO_VALUE
protected static final String THREE_KEY
protected static final String THREE_VALUE
protected static final String FOUR_KEY
protected static final String FOUR_VALUE
protected boolean isNullArgumentConstructorSupported()
protected boolean isMapArgumentConstructorSupported()
protected boolean doesMapDelegateFromOriginalMap()
protected boolean doesMapAllowNullKeys()
protected boolean doesMapAllowNullValues()
protected boolean doesMapSupportRemove()
protected abstract Map<?,?> createMap()
protected abstract Map<?,?> createMap(Map<?,?> input)
input
- A possibly empty map of items
to seed the Map withprotected TestCollectionElement getElement(String data)
data
- The string that must be returned via the listElementReturn
methodpublic void testMapFromNullConstructorHasZeroSize()
public void testMapFromMapConstructorHasZeroSize()
public void testMapConstructedWithNullMapThrows()
public void testCanAddToMap()
public void testModifyingOriginalCollectionDoesNotAffectNewCollection()
public void testContainsAfterPut()
public void testCanMapHaveNullKeys()
public void testCanMapHaveNullValues()
public void testCanCollectionHaveNullAndNonNullEntries()
public void testRemoveFromEmptyMap()
public void testRemoveFromOneElementMap()
public void testRemoveFirstThingFromMultiElementMap()
public void testRemoveLastThingFromMultiElementMap()
public void testRemoveMiddleThingFromMultiElementMap()
public void testPutAllEmptyOriginalEmptyAdding()
public void testPutAllEmptyOriginalNonEmptyAdding()
public void testPutAllNonEmptyOriginalEmptyAdding()
public void testPutAllNonEmptyOriginalNonEmptyAdding()
public void testClearOnEmptyMap()
public void testClearOnNonEmptyMap()
public void testKeySetOnEmptyMap()
public void testKeySetOnNonEmptyMap()
public void testValuesOnEmptyMap()
public void testValuesOnNonEmptyMap()
public void testEntrySetOnEmptyMap()
public void testEntrySetOnNonEmptyMap()
public void testAddOneThousandEntries()
Copyright © 2009-2017, Oracle and/or its affiliates. All Rights Reserved.