public void testEmptyMapIterator() {
if (supportsEmptyIterator() == false) {
return;
}
MapIterator it = makeEmptyMapIterator();
Map map = getMap();
assertEquals(false, it.hasNext());
// next() should throw a NoSuchElementException
try {
it.next();
fail();
} catch (NoSuchElementException ex) {}
// getKey() should throw an IllegalStateException
try {
it.getKey();
fail();
} catch (IllegalStateException ex) {}
// getValue() should throw an IllegalStateException
try {
it.getValue();
fail();
} catch (IllegalStateException ex) {}
if (supportsSetValue() == false) {
// setValue() should throw an UnsupportedOperationException/IllegalStateException
try {
it.setValue(addSetValues()[0]);
fail();
} catch (UnsupportedOperationException ex) {
} catch (IllegalStateException ex) {}
} else {
// setValue() should throw an IllegalStateException
try {
it.setValue(addSetValues()[0]);
fail();
} catch (IllegalStateException ex) {}
}
}