mirror of
https://github.com/apache/commons-collections.git
synced 2025-02-17 15:35:00 +00:00
Add a test case in AbstractMultiValuedMapTest for AbstractMultiValuedMapTest.MultiValuedMapIterator (#108)
This commit is contained in:
parent
37c770f29e
commit
954c29f969
@ -104,6 +104,17 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the maps produced by {@link #makeObject()} and
|
||||
* {@link #makeFullMap()} supports set value.
|
||||
* <p>
|
||||
* Default implementation returns false. Override if your collection class
|
||||
* supports set value.
|
||||
*/
|
||||
public boolean isHashSetValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTestSerialization() {
|
||||
return true;
|
||||
@ -778,6 +789,56 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
||||
}
|
||||
}
|
||||
|
||||
public void testMultiValuedMapIterator() {
|
||||
final MultiValuedMap<K, V> map = makeFullMap();
|
||||
final MapIterator<K, V> it = map.mapIterator();
|
||||
|
||||
try {
|
||||
it.getKey();
|
||||
fail();
|
||||
} catch (final IllegalStateException ise) {
|
||||
}
|
||||
try {
|
||||
it.getValue();
|
||||
fail();
|
||||
} catch (final IllegalStateException ise) {
|
||||
}
|
||||
if (isAddSupported()) {
|
||||
try {
|
||||
it.setValue((V) "V");
|
||||
fail();
|
||||
} catch (final IllegalStateException ise) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isHashSetValue() && isAddSupported()) {
|
||||
assertTrue(it.hasNext() );
|
||||
assertEquals("one", it.next());
|
||||
assertEquals("one", it.getKey());
|
||||
assertEquals("uno", it.getValue());
|
||||
assertEquals("one", it.next());
|
||||
assertEquals("one", it.getKey());
|
||||
assertEquals("un", it.getValue());
|
||||
assertEquals("two", it.next());
|
||||
assertEquals("two", it.getKey());
|
||||
assertEquals("dos", it.getValue());
|
||||
assertEquals("two", it.next());
|
||||
assertEquals("two", it.getKey());
|
||||
assertEquals("deux", it.getValue());
|
||||
assertEquals("three", it.next());
|
||||
assertEquals("three", it.getKey());
|
||||
assertEquals("tres", it.getValue());
|
||||
assertEquals("three", it.next());
|
||||
assertEquals("three", it.getKey());
|
||||
assertEquals("trois", it.getValue());
|
||||
try {
|
||||
it.setValue((V) "threetrois");
|
||||
fail();
|
||||
} catch (final UnsupportedOperationException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Manual serialization testing as this class cannot easily
|
||||
// extend the AbstractTestMap
|
||||
|
@ -53,6 +53,11 @@ public class HashSetValuedHashMapTest<K, V> extends AbstractMultiValuedMapTest<K
|
||||
return new HashSetValuedHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHashSetValue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSetValuedMapAdd() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user