Fix whitespace (Checkstyle WhitespaceAround)
This commit is contained in:
parent
765f381bb1
commit
f4ecabd9ac
|
@ -59,6 +59,7 @@ limitations under the License.
|
||||||
<module name="RightCurly"/>
|
<module name="RightCurly"/>
|
||||||
<module name="GenericWhitespace"/>
|
<module name="GenericWhitespace"/>
|
||||||
<module name="WhitespaceAfter"/>
|
<module name="WhitespaceAfter"/>
|
||||||
|
<module name="WhitespaceAround"/>
|
||||||
<module name="NoWhitespaceBefore"/>
|
<module name="NoWhitespaceBefore"/>
|
||||||
<module name="Indentation">
|
<module name="Indentation">
|
||||||
<!-- Indentation style recommended by Oracle -->
|
<!-- Indentation style recommended by Oracle -->
|
||||||
|
|
|
@ -263,5 +263,8 @@ public class BagUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private BagUtils() {}
|
private BagUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,6 +370,8 @@ public class ClosureUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private ClosureUtils() {}
|
private ClosureUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2151,5 +2151,7 @@ public class CollectionUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private CollectionUtils() {}
|
private CollectionUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,6 +238,8 @@ public class ComparatorUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private ComparatorUtils() {}
|
private ComparatorUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,8 @@ public class FactoryUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private FactoryUtils() {}
|
private FactoryUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1438,6 +1438,8 @@ public class IteratorUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private IteratorUtils() {}
|
private IteratorUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -744,5 +744,8 @@ public class ListUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private ListUtils() {}
|
private ListUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,8 @@ public class MultiMapUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private MultiMapUtils() {}
|
private MultiMapUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,8 @@ public class MultiSetUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private MultiSetUtils() {}
|
private MultiSetUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,8 +486,7 @@ public class PredicateUtils {
|
||||||
* @see TransformedPredicate
|
* @see TransformedPredicate
|
||||||
* @since 3.1
|
* @since 3.1
|
||||||
*/
|
*/
|
||||||
public static <T> Predicate<T> transformedPredicate(
|
public static <T> Predicate<T> transformedPredicate(final Transformer<? super T, ? extends T> transformer, final Predicate<? super T> predicate) {
|
||||||
final Transformer<? super T, ? extends T> transformer, final Predicate<? super T> predicate) {
|
|
||||||
return TransformedPredicate.transformedPredicate(transformer, predicate);
|
return TransformedPredicate.transformedPredicate(transformer, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,6 +520,8 @@ public class PredicateUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private PredicateUtils() {}
|
private PredicateUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,8 +113,7 @@ public class QueueUtils {
|
||||||
* @return a transformed queue backed by the given queue
|
* @return a transformed queue backed by the given queue
|
||||||
* @throws NullPointerException if the queue or transformer is null
|
* @throws NullPointerException if the queue or transformer is null
|
||||||
*/
|
*/
|
||||||
public static <E> Queue<E> transformingQueue(final Queue<E> queue,
|
public static <E> Queue<E> transformingQueue(final Queue<E> queue, final Transformer<? super E, ? extends E> transformer) {
|
||||||
final Transformer<? super E, ? extends E> transformer) {
|
|
||||||
return TransformedQueue.transformingQueue(queue, transformer);
|
return TransformedQueue.transformingQueue(queue, transformer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,5 +132,7 @@ public class QueueUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private QueueUtils() {}
|
private QueueUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -652,5 +652,8 @@ public class SetUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private SetUtils() {}
|
private SetUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,8 @@ public class SplitMapUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private SplitMapUtils() {}
|
private SplitMapUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,6 +480,8 @@ public class TransformerUtils {
|
||||||
/**
|
/**
|
||||||
* This class is not normally instantiated.
|
* This class is not normally instantiated.
|
||||||
*/
|
*/
|
||||||
private TransformerUtils() {}
|
private TransformerUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ public class TrieUtils {
|
||||||
/**
|
/**
|
||||||
* Don't allow instances.
|
* Don't allow instances.
|
||||||
*/
|
*/
|
||||||
private TrieUtils() {}
|
private TrieUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,10 @@ final class IndexUtils {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not instantiate
|
/**
|
||||||
private IndexUtils() {}
|
* Don't instantiate.
|
||||||
|
*/
|
||||||
|
private IndexUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,9 @@ public class LayerManager<T extends BloomFilter> implements BloomFilterProducer
|
||||||
* @return A Consumer suitable for the LayerManager {@code cleanup} parameter.
|
* @return A Consumer suitable for the LayerManager {@code cleanup} parameter.
|
||||||
*/
|
*/
|
||||||
public static <T extends BloomFilter> Consumer<Deque<T>> noCleanup() {
|
public static <T extends BloomFilter> Consumer<Deque<T>> noCleanup() {
|
||||||
return x -> {};
|
return x -> {
|
||||||
|
// empty
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -492,10 +492,8 @@ public class LRUMap<K, V>
|
||||||
reuseEntry(entry, hashIndex, hashCode, key, value);
|
reuseEntry(entry, hashIndex, hashCode, key, value);
|
||||||
addEntry(entry, hashIndex);
|
addEntry(entry, hashIndex);
|
||||||
} catch (final NullPointerException ex) {
|
} catch (final NullPointerException ex) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("NPE, entry=" + entry + " entryIsHeader=" + (entry == header) + " key=" + key + " value=" + value + " size=" + size
|
||||||
"NPE, entry=" + entry + " entryIsHeader=" + (entry==header) +
|
+ " maxSize=" + maxSize + " This should not occur if your keys are immutable, and you have used synchronization properly.");
|
||||||
" key=" + key + " value=" + value + " size=" + size + " maxSize=" + maxSize +
|
|
||||||
" This should not occur if your keys are immutable, and you have used synchronization properly.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -299,8 +299,7 @@ public class SequencesComparator<T> {
|
||||||
for (int k = delta - d; k <= delta + d; k += 2) {
|
for (int k = delta - d; k <= delta + d; k += 2) {
|
||||||
// First step
|
// First step
|
||||||
final int i = k + offset - delta;
|
final int i = k + offset - delta;
|
||||||
if (k == delta - d
|
if (k == delta - d || k != delta + d && vUp[i + 1] <= vUp[i - 1]) {
|
||||||
|| k != delta + d && vUp[i+1] <= vUp[i-1]) {
|
|
||||||
vUp[i] = vUp[i + 1] - 1;
|
vUp[i] = vUp[i + 1] - 1;
|
||||||
} else {
|
} else {
|
||||||
vUp[i] = vUp[i - 1];
|
vUp[i] = vUp[i - 1];
|
||||||
|
@ -308,8 +307,7 @@ public class SequencesComparator<T> {
|
||||||
|
|
||||||
int x = vUp[i] - 1;
|
int x = vUp[i] - 1;
|
||||||
int y = x - start1 + start2 - k;
|
int y = x - start1 + start2 - k;
|
||||||
while (x >= start1 && y >= start2
|
while (x >= start1 && y >= start2 && equator.equate(sequence1.get(x), sequence2.get(y))) {
|
||||||
&& equator.equate(sequence1.get(x), sequence2.get(y))) {
|
|
||||||
vUp[i] = x--;
|
vUp[i] = x--;
|
||||||
y--;
|
y--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,12 +31,10 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* Tests base {@link java.util.LinkedList} methods and contracts.
|
* Tests base {@link java.util.LinkedList} methods and contracts.
|
||||||
* <p>
|
* <p>
|
||||||
* To use, simply extend this class, and implement
|
* To use, simply extend this class, and implement the {@link #makeObject()} method.
|
||||||
* the {@link #makeObject()} method.
|
|
||||||
* <p>
|
* <p>
|
||||||
* If your {@link LinkedList} fails one of these tests by design,
|
* If your {@link LinkedList} fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your
|
||||||
* you may still use this base set of cases. Simply override the
|
* {@link List} fails.
|
||||||
* test case (method) your {@link List} fails.
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
|
|
||||||
|
@ -132,15 +130,13 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
@Test
|
@Test
|
||||||
public void testLinkedListGetFirst() {
|
public void testLinkedListGetFirst() {
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(NoSuchElementException.class, () -> getCollection().getFirst(),
|
assertThrows(NoSuchElementException.class, () -> getCollection().getFirst(), "getFirst() should throw a NoSuchElementException for an empty list.");
|
||||||
"getFirst() should throw a NoSuchElementException for an empty list.");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object first = getCollection().getFirst();
|
final Object first = getCollection().getFirst();
|
||||||
final Object confirmedFirst = getConfirmedLinkedList().getFirst();
|
final Object confirmedFirst = getConfirmedLinkedList().getFirst();
|
||||||
assertEquals(confirmedFirst, first,
|
assertEquals(confirmedFirst, first, "Result returned by getFirst() was wrong.");
|
||||||
"Result returned by getFirst() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,15 +146,13 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
@Test
|
@Test
|
||||||
public void testLinkedListGetLast() {
|
public void testLinkedListGetLast() {
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(NoSuchElementException.class, () -> getCollection().getLast(),
|
assertThrows(NoSuchElementException.class, () -> getCollection().getLast(), "getLast() should throw a NoSuchElementException for an empty list.");
|
||||||
"getLast() should throw a NoSuchElementException for an empty list.");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object last = getCollection().getLast();
|
final Object last = getCollection().getLast();
|
||||||
final Object confirmedLast = getConfirmedLinkedList().getLast();
|
final Object confirmedLast = getConfirmedLinkedList().getLast();
|
||||||
assertEquals(confirmedLast, last,
|
assertEquals(confirmedLast, last, "Result returned by getLast() was wrong.");
|
||||||
"Result returned by getLast() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,8 +173,7 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object first = getCollection().removeFirst();
|
final Object first = getCollection().removeFirst();
|
||||||
final Object confirmedFirst = getConfirmedLinkedList().removeFirst();
|
final Object confirmedFirst = getConfirmedLinkedList().removeFirst();
|
||||||
assertEquals(confirmedFirst, first,
|
assertEquals(confirmedFirst, first, "Result returned by removeFirst() was wrong.");
|
||||||
"Result returned by removeFirst() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,15 +187,13 @@ public abstract class AbstractLinkedListTest<T> extends AbstractListTest<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(NoSuchElementException.class, () -> getCollection().removeLast(),
|
assertThrows(NoSuchElementException.class, () -> getCollection().removeLast(), "removeLast() should throw a NoSuchElementException for an empty list.");
|
||||||
"removeLast() should throw a NoSuchElementException for an empty list.");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
final Object last = getCollection().removeLast();
|
final Object last = getCollection().removeLast();
|
||||||
final Object confirmedLast = getConfirmedLinkedList().removeLast();
|
final Object confirmedLast = getConfirmedLinkedList().removeLast();
|
||||||
assertEquals(confirmedLast, last,
|
assertEquals(confirmedLast, last, "Result returned by removeLast() was wrong.");
|
||||||
"Result returned by removeLast() was wrong.");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,5 +76,8 @@ public final class TestUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestUtils() {}
|
private TestUtils() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,7 @@ package org.apache.commons.collections4.bag;
|
||||||
import org.apache.commons.collections4.Bag;
|
import org.apache.commons.collections4.Bag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractBagTest} for exercising the {@link SynchronizedBag}
|
* Extension of {@link AbstractBagTest} for exercising the {@link SynchronizedBag} implementation.
|
||||||
* implementation.
|
|
||||||
*/
|
*/
|
||||||
public class SynchronizedBagTest<T> extends AbstractBagTest<T> {
|
public class SynchronizedBagTest<T> extends AbstractBagTest<T> {
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,9 @@ public abstract class AbstractOrderedBidiMapTest<K, V> extends AbstractBidiMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(bidi.nextKey(null)); // this is allowed too
|
assertNull(bidi.nextKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(bidi.nextKey(null));
|
assertNull(bidi.nextKey(null));
|
||||||
}
|
}
|
||||||
|
@ -182,7 +184,9 @@ public abstract class AbstractOrderedBidiMapTest<K, V> extends AbstractBidiMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(bidi.previousKey(null)); // this is allowed too
|
assertNull(bidi.previousKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ignore) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(bidi.previousKey(null));
|
assertNull(bidi.previousKey(null));
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
|
||||||
|
|
||||||
private static final class IntegerComparator implements Comparator<Integer>, Serializable {
|
private static final class IntegerComparator implements Comparator<Integer>, Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(final Integer o1, final Integer o2) {
|
public int compare(final Integer o1, final Integer o2) {
|
||||||
return o1.compareTo(o2);
|
return o1.compareTo(o2);
|
||||||
|
|
|
@ -221,19 +221,17 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
|
||||||
BitMapProducer bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 1).indices(getTestShape()),
|
BitMapProducer bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 1).indices(getTestShape()),
|
||||||
getTestShape().getNumberOfBits());
|
getTestShape().getNumberOfBits());
|
||||||
assertTrue(bf2.contains(bitMapProducer), "BF2 Should contain this hasher");
|
assertTrue(bf2.contains(bitMapProducer), "BF2 Should contain this hasher");
|
||||||
bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 3).indices(getTestShape()),
|
bitMapProducer = BitMapProducer.fromIndexProducer(new IncrementingHasher(1, 3).indices(getTestShape()), getTestShape().getNumberOfBits());
|
||||||
getTestShape().getNumberOfBits());
|
|
||||||
assertFalse(bf2.contains(bitMapProducer), "BF2 Should not contain this hasher");
|
assertFalse(bf2.contains(bitMapProducer), "BF2 Should not contain this hasher");
|
||||||
|
|
||||||
// Test different lengths
|
// Test different lengths
|
||||||
bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
|
bf1 = createFilter(getTestShape(), TestingHashers.FROM1);
|
||||||
final BloomFilter bf3 = createFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1),
|
final BloomFilter bf3 = createFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1), TestingHashers.FROM1);
|
||||||
TestingHashers.FROM1);
|
|
||||||
assertTrue(bf1.contains(bf3));
|
assertTrue(bf1.contains(bf3));
|
||||||
assertTrue(bf3.contains(bf1));
|
assertTrue(bf3.contains(bf1));
|
||||||
|
|
||||||
final BloomFilter bf4 = TestingHashers.populateRange(createEmptyFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1)),
|
final BloomFilter bf4 = TestingHashers.populateRange(createEmptyFilter(Shape.fromKM(getTestShape().getNumberOfHashFunctions(), Long.SIZE - 1)), 1,
|
||||||
1, 11+getTestShape().getNumberOfHashFunctions());
|
11 + getTestShape().getNumberOfHashFunctions());
|
||||||
|
|
||||||
assertFalse(bf1.contains(bf4));
|
assertFalse(bf1.contains(bf4));
|
||||||
assertTrue(bf4.contains(bf1));
|
assertTrue(bf4.contains(bf1));
|
||||||
|
@ -253,7 +251,6 @@ public abstract class AbstractBloomFilterTest<T extends BloomFilter> {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public final void testEstimateIntersection() {
|
public final void testEstimateIntersection() {
|
||||||
|
|
||||||
final BloomFilter bf = createFilter(getTestShape(), TestingHashers.FROM1);
|
final BloomFilter bf = createFilter(getTestShape(), TestingHashers.FROM1);
|
||||||
final BloomFilter bf2 = TestingHashers.populateFromHashersFrom1AndFrom11(createEmptyFilter(getTestShape()));
|
final BloomFilter bf2 = TestingHashers.populateFromHashersFrom1AndFrom11(createEmptyFilter(getTestShape()));
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ public class BloomFilterProducerFromLayeredBloomFilterTest extends AbstractBloom
|
||||||
protected BloomFilterProducer createUnderTest(final BloomFilter... filters) {
|
protected BloomFilterProducer createUnderTest(final BloomFilter... filters) {
|
||||||
final Shape shape = filters[0].getShape();
|
final Shape shape = filters[0].getShape();
|
||||||
final LayerManager layerManager = LayerManager.builder().setSupplier(() -> new SimpleBloomFilter(shape))
|
final LayerManager layerManager = LayerManager.builder().setSupplier(() -> new SimpleBloomFilter(shape))
|
||||||
.setExtendCheck( LayerManager.ExtendCheck.advanceOnPopulated())
|
.setExtendCheck(LayerManager.ExtendCheck.advanceOnPopulated()).setCleanup(LayerManager.Cleanup.noCleanup()).build();
|
||||||
.setCleanup(LayerManager.Cleanup.noCleanup()).build();
|
|
||||||
final LayeredBloomFilter underTest = new LayeredBloomFilter(shape, layerManager);
|
final LayeredBloomFilter underTest = new LayeredBloomFilter(shape, layerManager);
|
||||||
for (final BloomFilter bf : filters) {
|
for (final BloomFilter bf : filters) {
|
||||||
underTest.merge(bf);
|
underTest.merge(bf);
|
||||||
|
|
|
@ -96,5 +96,8 @@ public class TestingHashers {
|
||||||
/**
|
/**
|
||||||
* Do not instantiate.
|
* Do not instantiate.
|
||||||
*/
|
*/
|
||||||
private TestingHashers() {}
|
private TestingHashers() {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,8 +137,7 @@ public class FixedOrderComparatorTest extends AbstractComparatorTest<String> {
|
||||||
/** Shuffles the keys and asserts that the comparator sorts them back to
|
/** Shuffles the keys and asserts that the comparator sorts them back to
|
||||||
* their original order.
|
* their original order.
|
||||||
*/
|
*/
|
||||||
private void assertComparatorYieldsOrder(final String[] orderedObjects,
|
private void assertComparatorYieldsOrder(final String[] orderedObjects, final Comparator<String> comparator) {
|
||||||
final Comparator<String> comparator) {
|
|
||||||
final String[] keys = orderedObjects.clone();
|
final String[] keys = orderedObjects.clone();
|
||||||
|
|
||||||
// shuffle until the order changes. It's extremely rare that
|
// shuffle until the order changes. It's extremely rare that
|
||||||
|
|
|
@ -159,7 +159,8 @@ public abstract class AbstractIteratorTest<E> extends AbstractObjectTest {
|
||||||
// check for UnsupportedOperationException if not supported
|
// check for UnsupportedOperationException if not supported
|
||||||
try {
|
try {
|
||||||
it.remove();
|
it.remove();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
public int getLength() {
|
public int getLength() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node item(final int index) {
|
public Node item(final int index) {
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
|
@ -79,6 +80,7 @@ public class NodeListIteratorTest extends AbstractIteratorTest<Node> {
|
||||||
public int getLength() {
|
public int getLength() {
|
||||||
return nodes.length;
|
return nodes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Node item(final int index) {
|
public Node item(final int index) {
|
||||||
return nodes[index];
|
return nodes[index];
|
||||||
|
|
|
@ -37,8 +37,7 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
for (int i = 0; i < list.size; i++) {
|
for (int i = 0; i < list.size; i++) {
|
||||||
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
||||||
if (i < list.size - 1) {
|
if (i < list.size - 1) {
|
||||||
assertEquals(list.getNode(i + 1, false).previous,
|
assertEquals(list.getNode(i + 1, false).previous, list.getNode(i, false));
|
||||||
list.getNode(i, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +58,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
if (!isAddSupported()) {
|
if (!isAddSupported()) {
|
||||||
try {
|
try {
|
||||||
list.addFirst(null);
|
list.addFirst(null);
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addFirst((E) "value1");
|
list.addFirst((E) "value1");
|
||||||
|
@ -92,20 +92,16 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
final AbstractLinkedList<E> list = getCollection();
|
final AbstractLinkedList<E> list = getCollection();
|
||||||
// get marker
|
// get marker
|
||||||
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.addFirst((E) "value0");
|
list.addFirst((E) "value0");
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.removeNode(list.getNode(1, false));
|
list.removeNode(list.getNode(1, false));
|
||||||
checkNodes();
|
checkNodes();
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false), "Expecting IndexOutOfBoundsException.");
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true),
|
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -116,7 +112,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
@ -141,7 +138,8 @@ public abstract class AbstractLinkedListTest<E> extends AbstractListTest<E> {
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeLast();
|
list.removeLast();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
|
|
@ -817,11 +817,13 @@ public abstract class AbstractListTest<E> extends AbstractCollectionTest<E> {
|
||||||
resetFull();
|
resetFull();
|
||||||
try {
|
try {
|
||||||
getCollection().listIterator(-1);
|
getCollection().listIterator(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
resetFull();
|
resetFull();
|
||||||
try {
|
try {
|
||||||
getCollection().listIterator(getCollection().size() + 1);
|
getCollection().listIterator(getCollection().size() + 1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
resetFull();
|
resetFull();
|
||||||
for (int i = 0; i <= getConfirmed().size(); i++) {
|
for (int i = 0; i <= getConfirmed().size(); i++) {
|
||||||
forwardTest(getCollection().listIterator(i), i);
|
forwardTest(getCollection().listIterator(i), i);
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
for (int i = 0; i < list.size; i++) {
|
for (int i = 0; i < list.size; i++) {
|
||||||
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
assertEquals(list.getNode(i, false).next, list.getNode(i + 1, true));
|
||||||
if (i < list.size - 1) {
|
if (i < list.size - 1) {
|
||||||
assertEquals(list.getNode(i + 1, false).previous,
|
assertEquals(list.getNode(i + 1, false).previous, list.getNode(i, false));
|
||||||
list.getNode(i, false));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +90,8 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
if (!isAddSupported()) {
|
if (!isAddSupported()) {
|
||||||
try {
|
try {
|
||||||
list.addFirst(null);
|
list.addFirst(null);
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addFirst((E) "value1");
|
list.addFirst((E) "value1");
|
||||||
|
@ -124,20 +124,16 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
final AbstractLinkedListForJava21<E> list = getCollection();
|
final AbstractLinkedListForJava21<E> list = getCollection();
|
||||||
// get marker
|
// get marker
|
||||||
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
assertEquals(list.getNode(0, true).previous, list.getNode(0, true).next);
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(0, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.addFirst((E) "value0");
|
list.addFirst((E) "value0");
|
||||||
checkNodes();
|
checkNodes();
|
||||||
list.removeNode(list.getNode(1, false));
|
list.removeNode(list.getNode(1, false));
|
||||||
checkNodes();
|
checkNodes();
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(2, false), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false), "Expecting IndexOutOfBoundsException.");
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(-1, false),
|
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true), "Expecting IndexOutOfBoundsException.");
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
assertThrows(IndexOutOfBoundsException.class, () -> list.getNode(3, true),
|
|
||||||
"Expecting IndexOutOfBoundsException.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -148,7 +144,8 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeFirst();
|
list.removeFirst();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
@ -173,7 +170,8 @@ public class DefaultAbstractLinkedListForJava21Test<E> extends AbstractListTest<
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
try {
|
try {
|
||||||
list.removeLast();
|
list.removeLast();
|
||||||
} catch (final UnsupportedOperationException ex) {}
|
} catch (final UnsupportedOperationException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
list.addAll(Arrays.asList((E[]) new String[] { "value1", "value2" }));
|
||||||
|
|
|
@ -51,14 +51,10 @@ import org.junit.jupiter.api.Test;
|
||||||
/**
|
/**
|
||||||
* Abstract test class for {@link java.util.Map} methods and contracts.
|
* Abstract test class for {@link java.util.Map} methods and contracts.
|
||||||
* <p>
|
* <p>
|
||||||
* The forces at work here are similar to those in {@link AbstractCollectionTest}.
|
* The forces at work here are similar to those in {@link AbstractCollectionTest}. If your class implements the full Map interface, including optional
|
||||||
* If your class implements the full Map interface, including optional
|
* operations, simply extend this class, and implement the {@link #makeObject()} method.
|
||||||
* operations, simply extend this class, and implement the
|
|
||||||
* {@link #makeObject()} method.
|
|
||||||
* <p>
|
* <p>
|
||||||
* On the other hand, if your map implementation is weird, you may have to
|
* On the other hand, if your map implementation is weird, you may have to override one or more of the other protected methods. They're described below.
|
||||||
* override one or more of the other protected methods. They're described
|
|
||||||
* below.
|
|
||||||
* <p>
|
* <p>
|
||||||
* <b>Entry Population Methods</b>
|
* <b>Entry Population Methods</b>
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -96,46 +92,33 @@ import org.junit.jupiter.api.Test;
|
||||||
*
|
*
|
||||||
* <b>Fixture Methods</b>
|
* <b>Fixture Methods</b>
|
||||||
* <p>
|
* <p>
|
||||||
* For tests on modification operations (puts and removes), fixtures are used
|
* For tests on modification operations (puts and removes), fixtures are used to verify that that operation results in correct state for the map and its
|
||||||
* to verify that that operation results in correct state for the map and its
|
* collection views. Basically, the modification is performed against your map implementation, and an identical modification is performed against a
|
||||||
* collection views. Basically, the modification is performed against your
|
* <I>confirmed</I> map implementation. A confirmed map implementation is something like <Code>java.util.HashMap</Code>, which is known to conform exactly to
|
||||||
* map implementation, and an identical modification is performed against
|
* the {@link Map} contract. After the modification takes place on both your map implementation and the confirmed map implementation, the two maps are compared
|
||||||
* a <I>confirmed</I> map implementation. A confirmed map implementation is
|
* to see if their state is identical. The comparison also compares the collection views to make sure they're still the same.
|
||||||
* something like <Code>java.util.HashMap</Code>, which is known to conform
|
* <P>
|
||||||
* exactly to the {@link Map} contract. After the modification takes place
|
|
||||||
* on both your map implementation and the confirmed map implementation, the
|
|
||||||
* two maps are compared to see if their state is identical. The comparison
|
|
||||||
* also compares the collection views to make sure they're still the same.<P>
|
|
||||||
*
|
*
|
||||||
* The upshot of all that is that <I>any</I> test that modifies the map in
|
* The upshot of all that is that <I>any</I> test that modifies the map in <I>any</I> way will verify that <I>all</I> of the map's state is still correct,
|
||||||
* <I>any</I> way will verify that <I>all</I> of the map's state is still
|
* including the state of its collection views. So for instance if a key is removed by the map's key set's iterator, then the entry set is checked to make sure
|
||||||
* correct, including the state of its collection views. So for instance
|
* the key/value pair no longer appears.
|
||||||
* if a key is removed by the map's key set's iterator, then the entry set
|
* <P>
|
||||||
* is checked to make sure the key/value pair no longer appears.<P>
|
|
||||||
*
|
*
|
||||||
* The {@link #map} field holds an instance of your collection implementation.
|
* The {@link #map} field holds an instance of your collection implementation. The {@link #entrySet}, {@link #keySet} and {@link #values} fields hold that map's
|
||||||
* The {@link #entrySet}, {@link #keySet} and {@link #values} fields hold
|
* collection views. And the {@link #confirmed} field holds an instance of the confirmed collection implementation. The {@link #resetEmpty()} and
|
||||||
* that map's collection views. And the {@link #confirmed} field holds
|
* {@link #resetFull()} methods set these fields to empty or full maps, so that tests can proceed from a known state.
|
||||||
* an instance of the confirmed collection implementation. The
|
* <P>
|
||||||
* {@link #resetEmpty()} and {@link #resetFull()} methods set these fields to
|
|
||||||
* empty or full maps, so that tests can proceed from a known state.<P>
|
|
||||||
*
|
*
|
||||||
* After a modification operation to both {@link #map} and {@link #confirmed},
|
* After a modification operation to both {@link #map} and {@link #confirmed}, the {@link #verify()} method is invoked to compare the results. The
|
||||||
* the {@link #verify()} method is invoked to compare the results. The
|
* {@link #verify} method calls separate methods to verify the map and its three collection views ({@link #verifyMap}, {@link #verifyEntrySet},
|
||||||
* {@link #verify} method calls separate methods to verify the map and its three
|
* {@link #verifyKeySet}, and {@link #verifyValues}). You may want to override one of the verification methods to perform additional verifications. For
|
||||||
* collection views ({@link #verifyMap}, {@link #verifyEntrySet},
|
* instance, TestDoubleOrderedMap would want override its {@link #verifyValues()} method to verify that the values are unique and in ascending order.
|
||||||
* {@link #verifyKeySet}, and {@link #verifyValues}). You may want to override
|
* <P>
|
||||||
* one of the verification methods to perform additional verifications. For
|
|
||||||
* instance, TestDoubleOrderedMap would want override its
|
|
||||||
* {@link #verifyValues()} method to verify that the values are unique and in
|
|
||||||
* ascending order.<P>
|
|
||||||
*
|
*
|
||||||
* <b>Other Notes</b>
|
* <b>Other Notes</b>
|
||||||
* <p>
|
* <p>
|
||||||
* If your {@link Map} fails one of these tests by design, you may still use
|
* If your {@link Map} fails one of these tests by design, you may still use this base set of cases. Simply override the test case (method) your map fails
|
||||||
* this base set of cases. Simply override the test case (method) your map
|
* and/or the methods that define the assumptions used by the test cases. For example, if your map does not allow duplicate values, override
|
||||||
* fails and/or the methods that define the assumptions used by the test
|
|
||||||
* cases. For example, if your map does not allow duplicate values, override
|
|
||||||
* {@link #isAllowDuplicateValues()} and have it return {@code false}
|
* {@link #isAllowDuplicateValues()} and have it return {@code false}
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
@ -329,6 +312,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
AbstractMapTest.this.verify();
|
AbstractMapTest.this.verify();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestMapKeySet extends AbstractSetTest<K> {
|
public class TestMapKeySet extends AbstractSetTest<K> {
|
||||||
public TestMapKeySet() {
|
public TestMapKeySet() {
|
||||||
super(StringUtils.EMPTY);
|
super(StringUtils.EMPTY);
|
||||||
|
@ -537,8 +521,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to add all the mappings described by
|
* Helper method to add all the mappings described by {@link #getSampleKeys()} and {@link #getSampleValues()}.
|
||||||
* {@link #getSampleKeys()} and {@link #getSampleValues()}.
|
|
||||||
*/
|
*/
|
||||||
public void addSampleMappings(final Map<? super K, ? super V> m) {
|
public void addSampleMappings(final Map<? super K, ? super V> m) {
|
||||||
|
|
||||||
|
@ -549,23 +532,18 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
try {
|
try {
|
||||||
m.put(keys[i], values[i]);
|
m.put(keys[i], values[i]);
|
||||||
} catch (final NullPointerException exception) {
|
} catch (final NullPointerException exception) {
|
||||||
assertTrue(keys[i] == null || values[i] == null,
|
assertTrue(keys[i] == null || values[i] == null, "NullPointerException only allowed to be thrown " + "if either the key or value is null.");
|
||||||
"NullPointerException only allowed to be thrown " +
|
|
||||||
"if either the key or value is null.");
|
|
||||||
|
|
||||||
assertTrue(keys[i] == null || !isAllowNullKey(),
|
assertTrue(keys[i] == null || !isAllowNullKey(),
|
||||||
"NullPointerException on null key, but " +
|
"NullPointerException on null key, but " + "isAllowNullKey is not overridden to return false.");
|
||||||
"isAllowNullKey is not overridden to return false.");
|
|
||||||
|
|
||||||
assertTrue(values[i] == null || !isAllowNullValue(),
|
assertTrue(values[i] == null || !isAllowNullValue(),
|
||||||
"NullPointerException on null value, but " +
|
"NullPointerException on null value, but " + "isAllowNullValue is not overridden to return false.");
|
||||||
"isAllowNullValue is not overridden to return false.");
|
|
||||||
|
|
||||||
fail("Unknown reason for NullPointer.");
|
fail("Unknown reason for NullPointer.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(keys.length, m.size(),
|
assertEquals(keys.length, m.size(), "size must reflect number of mappings added.");
|
||||||
"size must reflect number of mappings added.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areEqualElementsDistinguishable() {
|
public boolean areEqualElementsDistinguishable() {
|
||||||
|
@ -573,10 +551,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bulk test {@link Map#entrySet()}. This method runs through all of
|
* Bulk test {@link Map#entrySet()}. This method runs through all of the tests in {@link AbstractSetTest}. After modification operations, {@link #verify()}
|
||||||
* the tests in {@link AbstractSetTest}.
|
* is invoked to ensure that the map and the other collection views are still valid.
|
||||||
* After modification operations, {@link #verify()} is invoked to ensure
|
|
||||||
* that the map and the other collection views are still valid.
|
|
||||||
*
|
*
|
||||||
* @return a {@link AbstractSetTest} instance for testing the map's entry set
|
* @return a {@link AbstractSetTest} instance for testing the map's entry set
|
||||||
*/
|
*/
|
||||||
|
@ -585,10 +561,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bulk test {@link Map#keySet()}. This method runs through all of
|
* Bulk test {@link Map#keySet()}. This method runs through all of the tests in {@link AbstractSetTest}. After modification operations, {@link #verify()} is
|
||||||
* the tests in {@link AbstractSetTest}.
|
* invoked to ensure that the map and the other collection views are still valid.
|
||||||
* After modification operations, {@link #verify()} is invoked to ensure
|
|
||||||
* that the map and the other collection views are still valid.
|
|
||||||
*
|
*
|
||||||
* @return a {@link AbstractSetTest} instance for testing the map's key set
|
* @return a {@link AbstractSetTest} instance for testing the map's key set
|
||||||
*/
|
*/
|
||||||
|
@ -597,13 +571,10 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bulk test {@link Map#values()}. This method runs through all of
|
* Bulk test {@link Map#values()}. This method runs through all of the tests in {@link AbstractCollectionTest}. After modification operations,
|
||||||
* the tests in {@link AbstractCollectionTest}.
|
* {@link #verify()} is invoked to ensure that the map and the other collection views are still valid.
|
||||||
* After modification operations, {@link #verify()} is invoked to ensure
|
|
||||||
* that the map and the other collection views are still valid.
|
|
||||||
*
|
*
|
||||||
* @return a {@link AbstractCollectionTest} instance for testing the map's
|
* @return a {@link AbstractCollectionTest} instance for testing the map's values collection
|
||||||
* values collection
|
|
||||||
*/
|
*/
|
||||||
public BulkTest bulkTestMapValues() {
|
public BulkTest bulkTestMapValues() {
|
||||||
return new TestMapValues();
|
return new TestMapValues();
|
||||||
|
@ -628,6 +599,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the confirmed.
|
* Gets the confirmed.
|
||||||
|
*
|
||||||
* @return Map<K, V>
|
* @return Map<K, V>
|
||||||
*/
|
*/
|
||||||
public Map<K, V> getConfirmed() {
|
public Map<K, V> getConfirmed() {
|
||||||
|
@ -635,9 +607,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a flag specifying the iteration behavior of the collection.
|
* Return a flag specifying the iteration behavior of the collection. This is used to change the assertions used by specific tests. The default
|
||||||
* This is used to change the assertions used by specific tests.
|
* implementation returns 0 which indicates ordered iteration behavior.
|
||||||
* The default implementation returns 0 which indicates ordered iteration behavior.
|
|
||||||
*
|
*
|
||||||
* @return the iteration behavior
|
* @return the iteration behavior
|
||||||
* @see AbstractCollectionTest#UNORDERED
|
* @see AbstractCollectionTest#UNORDERED
|
||||||
|
@ -648,6 +619,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map.
|
* Gets the map.
|
||||||
|
*
|
||||||
* @return Map<K, V>
|
* @return Map<K, V>
|
||||||
*/
|
*/
|
||||||
public Map<K, V> getMap() {
|
public Map<K, V> getMap() {
|
||||||
|
@ -655,26 +627,16 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of values that can be used to replace the values
|
* Returns a set of values that can be used to replace the values returned from {@link #getSampleValues()}. This method must return an array with the same
|
||||||
* returned from {@link #getSampleValues()}. This method must return an
|
* length as {@link #getSampleValues()}. The values returned from this method should not be the same as those returned from {@link #getSampleValues()}. The
|
||||||
* array with the same length as {@link #getSampleValues()}. The values
|
* default implementation constructs a set of String values and includes a single null value if {@link #isAllowNullValue()} returns {@code true}, and
|
||||||
* returned from this method should not be the same as those returned from
|
* includes two values that are the same if {@link #isAllowDuplicateValues()} returns {@code true}.
|
||||||
* {@link #getSampleValues()}. The default implementation constructs a
|
|
||||||
* set of String values and includes a single null value if
|
|
||||||
* {@link #isAllowNullValue()} returns {@code true}, and includes two values
|
|
||||||
* that are the same if {@link #isAllowDuplicateValues()} returns
|
|
||||||
* {@code true}.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public V[] getNewSampleValues() {
|
public V[] getNewSampleValues() {
|
||||||
final Object[] result = {
|
final Object[] result = { isAllowNullValue() && isAllowDuplicateValues() ? null : "newnonnullvalue", "newvalue",
|
||||||
isAllowNullValue() && isAllowDuplicateValues() ? null : "newnonnullvalue",
|
isAllowDuplicateValues() ? "newvalue" : "newvalue2", "newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv", "newgollyv", "newgeev",
|
||||||
"newvalue",
|
"newhellov", "newgoodbyev", "newwe'llv", "newseev", "newyouv", "newallv", "newagainv" };
|
||||||
isAllowDuplicateValues() ? "newvalue" : "newvalue2",
|
|
||||||
"newblahv", "newfoov", "newbarv", "newbazv", "newtmpv", "newgoshv",
|
|
||||||
"newgollyv", "newgeev", "newhellov", "newgoodbyev", "newwe'llv",
|
|
||||||
"newseev", "newyouv", "newallv", "newagainv",
|
|
||||||
};
|
|
||||||
return (V[]) result;
|
return (V[]) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,18 +646,15 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of string elements suitable for return by
|
* Returns a list of string elements suitable for return by {@link #getOtherKeys()} or {@link #getOtherValues}.
|
||||||
* {@link #getOtherKeys()} or {@link #getOtherValues}.
|
|
||||||
*
|
*
|
||||||
* <p>Override getOtherElements to return the results of this method if your
|
* <p>
|
||||||
* collection does not support heterogeneous elements or the null element.
|
* Override getOtherElements to return the results of this method if your collection does not support heterogeneous elements or the null element.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public Object[] getOtherNonNullStringElements() {
|
public Object[] getOtherNonNullStringElements() {
|
||||||
return new Object[] {
|
return new Object[] { "For", "then", "despite", /* of */"space", "I", "would", "be", "brought", "From", "limits", "far", "remote", "where", "thou",
|
||||||
"For", "then", "despite", /* of */"space", "I", "would", "be", "brought",
|
"dost", "stay" };
|
||||||
"From", "limits", "far", "remote", "where", "thou", "dost", "stay"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -704,113 +663,80 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the set of keys in the mappings used to test the map. This
|
* Returns the set of keys in the mappings used to test the map. This method must return an array with the same length as {@link #getSampleValues()} and all
|
||||||
* method must return an array with the same length as {@link
|
* array elements must be different. The default implementation constructs a set of String keys, and includes a single null key if {@link #isAllowNullKey()}
|
||||||
* #getSampleValues()} and all array elements must be different. The
|
* returns {@code true}.
|
||||||
* default implementation constructs a set of String keys, and includes a
|
|
||||||
* single null key if {@link #isAllowNullKey()} returns {@code true}.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public K[] getSampleKeys() {
|
public K[] getSampleKeys() {
|
||||||
final Object[] result = {
|
final Object[] result = { "blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee", "hello", "goodbye", "we'll", "see", "you", "all", "again", "key",
|
||||||
"blah", "foo", "bar", "baz", "tmp", "gosh", "golly", "gee",
|
"key2", isAllowNullKey() ? null : "nonnullkey" };
|
||||||
"hello", "goodbye", "we'll", "see", "you", "all", "again",
|
|
||||||
"key",
|
|
||||||
"key2",
|
|
||||||
isAllowNullKey() ? null : "nonnullkey"
|
|
||||||
};
|
|
||||||
return (K[]) result;
|
return (K[]) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the set of values in the mappings used to test the map. This
|
* Returns the set of values in the mappings used to test the map. This method must return an array with the same length as {@link #getSampleKeys()}. The
|
||||||
* method must return an array with the same length as
|
* default implementation constructs a set of String values and includes a single null value if {@link #isAllowNullValue()} returns {@code true}, and
|
||||||
* {@link #getSampleKeys()}. The default implementation constructs a set of
|
* includes two values that are the same if {@link #isAllowDuplicateValues()} returns {@code true}.
|
||||||
* String values and includes a single null value if
|
|
||||||
* {@link #isAllowNullValue()} returns {@code true}, and includes
|
|
||||||
* two values that are the same if {@link #isAllowDuplicateValues()} returns
|
|
||||||
* {@code true}.
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public V[] getSampleValues() {
|
public V[] getSampleValues() {
|
||||||
final Object[] result = {
|
final Object[] result = { "blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev", "hellov", "goodbyev", "we'llv", "seev", "youv", "allv",
|
||||||
"blahv", "foov", "barv", "bazv", "tmpv", "goshv", "gollyv", "geev",
|
"againv", isAllowNullValue() ? null : "nonnullvalue", "value", isAllowDuplicateValues() ? "value" : "value2", };
|
||||||
"hellov", "goodbyev", "we'llv", "seev", "youv", "allv", "againv",
|
|
||||||
isAllowNullValue() ? null : "nonnullvalue",
|
|
||||||
"value",
|
|
||||||
isAllowDuplicateValues() ? "value" : "value2",
|
|
||||||
};
|
|
||||||
return (V[]) result;
|
return (V[]) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} supports duplicate values.
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
|
||||||
* supports duplicate values.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support duplicate values.
|
||||||
* Override if your collection class does not support duplicate values.
|
|
||||||
*/
|
*/
|
||||||
public boolean isAllowDuplicateValues() {
|
public boolean isAllowDuplicateValues() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} supports null keys.
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
|
||||||
* supports null keys.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support null keys.
|
||||||
* Override if your collection class does not support null keys.
|
|
||||||
*/
|
*/
|
||||||
public boolean isAllowNullKey() {
|
public boolean isAllowNullKey() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} supports null values.
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
|
||||||
* supports null values.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support null values.
|
||||||
* Override if your collection class does not support null values.
|
|
||||||
*/
|
*/
|
||||||
public boolean isAllowNullValue() {
|
public boolean isAllowNullValue() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} provide fail-fast behavior on their various iterators.
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
|
||||||
* provide fail-fast behavior on their various iterators.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support fast failure.
|
||||||
* Override if your collection class does not support fast failure.
|
|
||||||
*/
|
*/
|
||||||
public boolean isFailFastExpected() {
|
public boolean isFailFastExpected() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} can cause structural modification on a get(). The example is
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
* LRUMap.
|
||||||
* can cause structural modification on a get(). The example is LRUMap.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns false.
|
* Default implementation returns false. Override if your map class structurally modifies on get.
|
||||||
* Override if your map class structurally modifies on get.
|
|
||||||
*/
|
*/
|
||||||
public boolean isGetStructuralModify() {
|
public boolean isGetStructuralModify() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} support the {@code put} and {@code putAll} operations adding new
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
* mappings.
|
||||||
* support the {@code put} and {@code putAll} operations
|
|
||||||
* adding new mappings.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support put adding.
|
||||||
* Override if your collection class does not support put adding.
|
|
||||||
*/
|
*/
|
||||||
public boolean isPutAddSupported() {
|
public boolean isPutAddSupported() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -822,47 +748,36 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
// test methods.
|
// test methods.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} support the {@code put} and {@code putAll} operations changing
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
* existing mappings.
|
||||||
* support the {@code put} and {@code putAll} operations
|
|
||||||
* changing existing mappings.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support put changing.
|
||||||
* Override if your collection class does not support put changing.
|
|
||||||
*/
|
*/
|
||||||
public boolean isPutChangeSupported() {
|
public boolean isPutChangeSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} support the {@code remove} and {@code clear} operations.
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
|
||||||
* support the {@code remove} and {@code clear} operations.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns true.
|
* Default implementation returns true. Override if your collection class does not support removal operations.
|
||||||
* Override if your collection class does not support removal operations.
|
|
||||||
*/
|
*/
|
||||||
public boolean isRemoveSupported() {
|
public boolean isRemoveSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the maps produced by
|
* Returns true if the maps produced by {@link #makeObject()} and {@link #makeFullMap()} support the {@code setValue} operation on entrySet entries.
|
||||||
* {@link #makeObject()} and {@link #makeFullMap()}
|
|
||||||
* support the {@code setValue} operation on entrySet entries.
|
|
||||||
* <p>
|
* <p>
|
||||||
* Default implementation returns isPutChangeSupported().
|
* Default implementation returns isPutChangeSupported(). Override if your collection class does not support setValue but does support put changing.
|
||||||
* Override if your collection class does not support setValue but does
|
|
||||||
* support put changing.
|
|
||||||
*/
|
*/
|
||||||
public boolean isSetValueSupported() {
|
public boolean isSetValueSupported() {
|
||||||
return isPutChangeSupported();
|
return isPutChangeSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the sub map views of SortedMap are serializable.
|
* Returns whether the sub map views of SortedMap are serializable. If the class being tested is based around a TreeMap then you should override and return
|
||||||
* If the class being tested is based around a TreeMap then you should
|
* false as TreeMap has a bug in deserialization.
|
||||||
* override and return false as TreeMap has a bug in deserialization.
|
|
||||||
*
|
*
|
||||||
* @return false
|
* @return false
|
||||||
*/
|
*/
|
||||||
|
@ -880,8 +795,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods to create an array of Map.Entry objects
|
* Utility methods to create an array of Map.Entry objects out of the given key and value arrays.
|
||||||
* out of the given key and value arrays.<P>
|
* <P>
|
||||||
*
|
*
|
||||||
* @param keys the array of keys
|
* @param keys the array of keys
|
||||||
* @param values the array of values
|
* @param values the array of values
|
||||||
|
@ -899,11 +814,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new, populated map. The mappings in the map should match the
|
* Return a new, populated map. The mappings in the map should match the keys and values returned from {@link #getSampleKeys()} and
|
||||||
* keys and values returned from {@link #getSampleKeys()} and
|
* {@link #getSampleValues()}. The default implementation uses makeEmptyMap() and calls {@link #addSampleMappings} to add all the mappings to the map.
|
||||||
* {@link #getSampleValues()}. The default implementation uses makeEmptyMap()
|
|
||||||
* and calls {@link #addSampleMappings} to add all the mappings to the
|
|
||||||
* map.
|
|
||||||
*
|
*
|
||||||
* @return the map to be tested
|
* @return the map to be tested
|
||||||
*/
|
*/
|
||||||
|
@ -922,8 +834,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
public abstract Map<K, V> makeObject();
|
public abstract Map<K, V> makeObject();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the {@link #map}, {@link #entrySet}, {@link #keySet},
|
* Resets the {@link #map}, {@link #entrySet}, {@link #keySet}, {@link #values} and {@link #confirmed} fields to empty.
|
||||||
* {@link #values} and {@link #confirmed} fields to empty.
|
|
||||||
*/
|
*/
|
||||||
public void resetEmpty() {
|
public void resetEmpty() {
|
||||||
this.map = makeObject();
|
this.map = makeObject();
|
||||||
|
@ -932,8 +843,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the {@link #map}, {@link #entrySet}, {@link #keySet},
|
* Resets the {@link #map}, {@link #entrySet}, {@link #keySet}, {@link #values} and {@link #confirmed} fields to full.
|
||||||
* {@link #values} and {@link #confirmed} fields to full.
|
|
||||||
*/
|
*/
|
||||||
public void resetFull() {
|
public void resetFull() {
|
||||||
this.map = makeFullMap();
|
this.map = makeFullMap();
|
||||||
|
@ -959,17 +869,14 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the current serialized form of the Map
|
* Compare the current serialized form of the Map against the canonical version in SCM.
|
||||||
* against the canonical version in SCM.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyMapCompatibility() throws Exception {
|
public void testEmptyMapCompatibility() throws Exception {
|
||||||
/*
|
/*
|
||||||
* Create canonical objects with this code
|
* Create canonical objects with this code Map map = makeEmptyMap(); if (!(map instanceof Serializable)) return;
|
||||||
Map map = makeEmptyMap();
|
*
|
||||||
if (!(map instanceof Serializable)) return;
|
* writeExternalFormToDisk((Serializable) map, getCanonicalEmptyCollectionName(map));
|
||||||
|
|
||||||
writeExternalFormToDisk((Serializable) map, getCanonicalEmptyCollectionName(map));
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// test to make sure the canonical form has been preserved
|
// test to make sure the canonical form has been preserved
|
||||||
|
@ -982,8 +889,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the {@link Map#entrySet()} collection is backed by
|
* Tests that the {@link Map#entrySet()} collection is backed by the underlying map for clear().
|
||||||
* the underlying map for clear().
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEntrySetClearChangesMap() {
|
public void testEntrySetClearChangesMap() {
|
||||||
|
@ -1146,9 +1052,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the {@link Map#entrySet} set is backed by
|
* Tests that the {@link Map#entrySet} set is backed by the underlying map by removing from the entrySet set and testing if the entry was removed from the
|
||||||
* the underlying map by removing from the entrySet set
|
* map.
|
||||||
* and testing if the entry was removed from the map.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEntrySetRemoveChangesMap() {
|
public void testEntrySetRemoveChangesMap() {
|
||||||
|
@ -1204,17 +1109,14 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare the current serialized form of the Map
|
* Compare the current serialized form of the Map against the canonical version in SCM.
|
||||||
* against the canonical version in SCM.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFullMapCompatibility() throws Exception {
|
public void testFullMapCompatibility() throws Exception {
|
||||||
/*
|
/*
|
||||||
* Create canonical objects with this code
|
* Create canonical objects with this code Map map = makeFullMap(); if (!(map instanceof Serializable)) return;
|
||||||
Map map = makeFullMap();
|
*
|
||||||
if (!(map instanceof Serializable)) return;
|
* writeExternalFormToDisk((Serializable) map, getCanonicalFullCollectionName(map));
|
||||||
|
|
||||||
writeExternalFormToDisk((Serializable) map, getCanonicalFullCollectionName(map));
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// test to make sure the canonical form has been preserved
|
// test to make sure the canonical form has been preserved
|
||||||
|
@ -1227,8 +1129,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the {@link Map#keySet} collection is backed by
|
* Tests that the {@link Map#keySet} collection is backed by the underlying map for clear().
|
||||||
* the underlying map for clear().
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testKeySetClearChangesMap() {
|
public void testKeySetClearChangesMap() {
|
||||||
|
@ -1298,9 +1199,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the {@link Map#keySet} set is backed by
|
* Tests that the {@link Map#keySet} set is backed by the underlying map by removing from the keySet set and testing if the key was removed from the map.
|
||||||
* the underlying map by removing from the keySet set
|
|
||||||
* and testing if the key was removed from the map.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testKeySetRemoveChangesMap() {
|
public void testKeySetRemoveChangesMap() {
|
||||||
|
@ -1344,8 +1243,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to ensure that makeEmptyMap and makeFull returns a new non-null
|
* Test to ensure that makeEmptyMap and makeFull returns a new non-null map with each invocation.
|
||||||
* map with each invocation.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMakeMap() {
|
public void testMakeMap() {
|
||||||
|
@ -1355,8 +1253,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
final Map<K, V> em2 = makeObject();
|
final Map<K, V> em2 = makeObject();
|
||||||
assertNotNull(em, "failure in test: makeEmptyMap must return a non-null map.");
|
assertNotNull(em, "failure in test: makeEmptyMap must return a non-null map.");
|
||||||
|
|
||||||
assertNotSame(em, em2, "failure in test: makeEmptyMap must return a new map " +
|
assertNotSame(em, em2, "failure in test: makeEmptyMap must return a new map " + "with each invocation.");
|
||||||
"with each invocation.");
|
|
||||||
|
|
||||||
final Map<K, V> fm = makeFullMap();
|
final Map<K, V> fm = makeFullMap();
|
||||||
assertNotNull(fm, "failure in test: makeFullMap must return a non-null map.");
|
assertNotNull(fm, "failure in test: makeFullMap must return a non-null map.");
|
||||||
|
@ -1364,24 +1261,19 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
final Map<K, V> fm2 = makeFullMap();
|
final Map<K, V> fm2 = makeFullMap();
|
||||||
assertNotNull(fm2, "failure in test: makeFullMap must return a non-null map.");
|
assertNotNull(fm2, "failure in test: makeFullMap must return a non-null map.");
|
||||||
|
|
||||||
assertNotSame(fm, fm2, "failure in test: makeFullMap must return a new map " +
|
assertNotSame(fm, fm2, "failure in test: makeFullMap must return a new map " + "with each invocation.");
|
||||||
"with each invocation.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link Map#clear()}. If the map {@link #isRemoveSupported()
|
* Tests {@link Map#clear()}. If the map {@link #isRemoveSupported() can add and remove elements}, then {@link Map#size()} and {@link Map#isEmpty()} are
|
||||||
* can add and remove elements}, then {@link Map#size()} and
|
* used to ensure that map has no elements after a call to clear. If the map does not support adding and removing elements, this method checks to ensure
|
||||||
* {@link Map#isEmpty()} are used to ensure that map has no elements after
|
* clear throws an UnsupportedOperationException.
|
||||||
* a call to clear. If the map does not support adding and removing
|
|
||||||
* elements, this method checks to ensure clear throws an
|
|
||||||
* UnsupportedOperationException.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMapClear() {
|
public void testMapClear() {
|
||||||
if (!isRemoveSupported()) {
|
if (!isRemoveSupported()) {
|
||||||
resetFull();
|
resetFull();
|
||||||
assertThrows(UnsupportedOperationException.class, () -> getMap().clear(),
|
assertThrows(UnsupportedOperationException.class, () -> getMap().clear(), "Expected UnsupportedOperationException on clear");
|
||||||
"Expected UnsupportedOperationException on clear");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1397,9 +1289,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests Map.containsKey(Object) by verifying it returns false for all
|
* Tests Map.containsKey(Object) by verifying it returns false for all sample keys on a map created using an empty map and returns true for all sample keys
|
||||||
* sample keys on a map created using an empty map and returns true for
|
* returned on a full map.
|
||||||
* all sample keys returned on a full map.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMapContainsKey() {
|
public void testMapContainsKey() {
|
||||||
|
@ -1413,16 +1304,13 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
for (final Object key : keys) {
|
for (final Object key : keys) {
|
||||||
assertTrue(getMap().containsKey(key), "Map must contain key for a mapping in the map. " +
|
assertTrue(getMap().containsKey(key), "Map must contain key for a mapping in the map. " + "Missing: " + key);
|
||||||
"Missing: " + key);
|
|
||||||
}
|
}
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests Map.containsValue(Object) by verifying it returns false for all
|
* Tests Map.containsValue(Object) by verifying it returns false for all sample values on an empty map and returns true for all sample values on a full map.
|
||||||
* sample values on an empty map and returns true for all sample values on
|
|
||||||
* a full map.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMapContainsValue() {
|
public void testMapContainsValue() {
|
||||||
|
@ -1436,8 +1324,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
for (final Object value : values) {
|
for (final Object value : values) {
|
||||||
assertTrue(getMap().containsValue(value),
|
assertTrue(getMap().containsValue(value), "Map must contain value for a mapping in the map.");
|
||||||
"Map must contain value for a mapping in the map.");
|
|
||||||
}
|
}
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
@ -1486,8 +1373,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
assertEquals(values[i], getMap().get(keys[i]),
|
assertEquals(values[i], getMap().get(keys[i]), "Full map.get() should return value from mapping.");
|
||||||
"Full map.get() should return value from mapping.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1533,10 +1419,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
getConfirmed().put(keys[i], values[i]);
|
getConfirmed().put(keys[i], values[i]);
|
||||||
verify();
|
verify();
|
||||||
assertNull(o, "First map.put should return null");
|
assertNull(o, "First map.put should return null");
|
||||||
assertTrue(getMap().containsKey(keys[i]),
|
assertTrue(getMap().containsKey(keys[i]), "Map should contain key after put");
|
||||||
"Map should contain key after put");
|
assertTrue(getMap().containsValue(values[i]), "Map should contain value after put");
|
||||||
assertTrue(getMap().containsValue(values[i]),
|
|
||||||
"Map should contain value after put");
|
|
||||||
}
|
}
|
||||||
if (isPutChangeSupported()) {
|
if (isPutChangeSupported()) {
|
||||||
for (int i = 0; i < keys.length; i++) {
|
for (int i = 0; i < keys.length; i++) {
|
||||||
|
@ -1544,10 +1428,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
getConfirmed().put(keys[i], newValues[i]);
|
getConfirmed().put(keys[i], newValues[i]);
|
||||||
verify();
|
verify();
|
||||||
assertEquals(values[i], o, "Map.put should return previous value when changed");
|
assertEquals(values[i], o, "Map.put should return previous value when changed");
|
||||||
assertTrue(getMap().containsKey(keys[i]),
|
assertTrue(getMap().containsKey(keys[i]), "Map should still contain key after put when changed");
|
||||||
"Map should still contain key after put when changed");
|
assertTrue(getMap().containsValue(newValues[i]), "Map should contain new value after put when changed");
|
||||||
assertTrue(getMap().containsValue(newValues[i]),
|
|
||||||
"Map should contain new value after put when changed");
|
|
||||||
|
|
||||||
// if duplicates are allowed, we're not guaranteed that the value
|
// if duplicates are allowed, we're not guaranteed that the value
|
||||||
// no longer exists, so don't try checking that.
|
// no longer exists, so don't try checking that.
|
||||||
|
@ -1582,10 +1464,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
final V value = getConfirmed().put(key, newValues[i]);
|
final V value = getConfirmed().put(key, newValues[i]);
|
||||||
verify();
|
verify();
|
||||||
assertEquals(value, o, "Map.put should return previous value when changed");
|
assertEquals(value, o, "Map.put should return previous value when changed");
|
||||||
assertTrue(getMap().containsKey(key),
|
assertTrue(getMap().containsKey(key), "Map should still contain key after put when changed");
|
||||||
"Map should still contain key after put when changed");
|
assertTrue(getMap().containsValue(newValues[i]), "Map should contain new value after put when changed");
|
||||||
assertTrue(getMap().containsValue(newValues[i]),
|
|
||||||
"Map should contain new value after put when changed");
|
|
||||||
|
|
||||||
// if duplicates are allowed, we're not guaranteed that the value
|
// if duplicates are allowed, we're not guaranteed that the value
|
||||||
// no longer exists, so don't try checking that.
|
// no longer exists, so don't try checking that.
|
||||||
|
@ -1594,8 +1474,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assertThrows(UnsupportedOperationException.class, () -> getMap().put(keys[0], values[0]),
|
assertThrows(UnsupportedOperationException.class, () -> getMap().put(keys[0], values[0]), "Expected UnsupportedOperationException on put (add)");
|
||||||
"Expected UnsupportedOperationException on put (add)");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,8 +1487,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
if (!isPutChangeSupported()) {
|
if (!isPutChangeSupported()) {
|
||||||
final Map<K, V> temp = makeFullMap();
|
final Map<K, V> temp = makeFullMap();
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertThrows(UnsupportedOperationException.class, () -> getMap().putAll(temp),
|
assertThrows(UnsupportedOperationException.class, () -> getMap().putAll(temp), "Expected UnsupportedOperationException on putAll");
|
||||||
"Expected UnsupportedOperationException on putAll");
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1674,7 +1552,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
try {
|
try {
|
||||||
getMap().put(null, values[0]);
|
getMap().put(null, values[0]);
|
||||||
fail("put(null, value) should throw NPE/IAE");
|
fail("put(null, value) should throw NPE/IAE");
|
||||||
} catch (final NullPointerException | IllegalArgumentException ex) {}
|
} catch (final NullPointerException | IllegalArgumentException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1694,7 +1573,8 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
try {
|
try {
|
||||||
getMap().put(keys[0], null);
|
getMap().put(keys[0], null);
|
||||||
fail("put(key, null) should throw NPE/IAE");
|
fail("put(key, null) should throw NPE/IAE");
|
||||||
} catch (final NullPointerException | IllegalArgumentException ex) {}
|
} catch (final NullPointerException | IllegalArgumentException ex) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1728,8 +1608,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
getConfirmed().remove(keys[i]);
|
getConfirmed().remove(keys[i]);
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
assertEquals(values[i], o,
|
assertEquals(values[i], o, "map.remove with valid key should return value");
|
||||||
"map.remove with valid key should return value");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Object[] other = getOtherKeys();
|
final Object[] other = getOtherKeys();
|
||||||
|
@ -1739,8 +1618,7 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
for (final Object element : other) {
|
for (final Object element : other) {
|
||||||
final Object o = getMap().remove(element);
|
final Object o = getMap().remove(element);
|
||||||
assertNull(o, "map.remove for nonexistent key should return null");
|
assertNull(o, "map.remove for nonexistent key should return null");
|
||||||
assertEquals(size, getMap().size(),
|
assertEquals(size, getMap().size(), "map.remove for nonexistent key should not " + "shrink map");
|
||||||
"map.remove for nonexistent key should not " + "shrink map");
|
|
||||||
}
|
}
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
@ -1751,24 +1629,18 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
@Test
|
@Test
|
||||||
public void testMapSize() {
|
public void testMapSize() {
|
||||||
resetEmpty();
|
resetEmpty();
|
||||||
assertEquals(0, getMap().size(),
|
assertEquals(0, getMap().size(), "Map.size() should be 0 with an empty map");
|
||||||
"Map.size() should be 0 with an empty map");
|
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
assertEquals(getSampleKeys().length, getMap().size(),
|
assertEquals(getSampleKeys().length, getMap().size(), "Map.size() should equal the number of entries " + "in the map");
|
||||||
"Map.size() should equal the number of entries " + "in the map");
|
|
||||||
verify();
|
verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests Map.toString(). Since the format of the string returned by the
|
* Tests Map.toString(). Since the format of the string returned by the toString() method is not defined in the Map interface, there is no common way to
|
||||||
* toString() method is not defined in the Map interface, there is no
|
* test the results of the toString() method. Therefore, it is encouraged that Map implementations override this test with one that checks the format
|
||||||
* common way to test the results of the toString() method. Therefore,
|
* matches any format defined in its API. This default implementation just verifies that the toString() method does not return null.
|
||||||
* it is encouraged that Map implementations override this test with one
|
|
||||||
* that checks the format matches any format defined in its API. This
|
|
||||||
* default implementation just verifies that the toString() method does
|
|
||||||
* not return null.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMapToString() {
|
public void testMapToString() {
|
||||||
|
@ -1782,14 +1654,10 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to ensure the test setup is working properly. This method checks
|
* Test to ensure the test setup is working properly. This method checks to ensure that the getSampleKeys and getSampleValues methods are returning results
|
||||||
* to ensure that the getSampleKeys and getSampleValues methods are
|
* that look appropriate. That is, they both return a non-null array of equal length. The keys array must not have any duplicate values, and may only
|
||||||
* returning results that look appropriate. That is, they both return a
|
* contain a (single) null key if isNullKeySupported() returns true. The values array must only have a null value if useNullValue() is true and may only
|
||||||
* non-null array of equal length. The keys array must not have any
|
* have duplicate values if isAllowDuplicateValues() returns true.
|
||||||
* duplicate values, and may only contain a (single) null key if
|
|
||||||
* isNullKeySupported() returns true. The values array must only have a null
|
|
||||||
* value if useNullValue() is true and may only have duplicate values if
|
|
||||||
* isAllowDuplicateValues() returns true.
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSampleMappings() {
|
public void testSampleMappings() {
|
||||||
|
@ -1797,42 +1665,33 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
final Object[] values = getSampleValues();
|
final Object[] values = getSampleValues();
|
||||||
final Object[] newValues = getNewSampleValues();
|
final Object[] newValues = getNewSampleValues();
|
||||||
|
|
||||||
assertNotNull(keys, "failure in test: Must have keys returned from " +
|
assertNotNull(keys, "failure in test: Must have keys returned from " + "getSampleKeys.");
|
||||||
"getSampleKeys.");
|
|
||||||
|
|
||||||
assertNotNull(values, "failure in test: Must have values returned from " +
|
assertNotNull(values, "failure in test: Must have values returned from " + "getSampleValues.");
|
||||||
"getSampleValues.");
|
|
||||||
|
|
||||||
// verify keys and values have equivalent lengths (in case getSampleX are
|
// verify keys and values have equivalent lengths (in case getSampleX are
|
||||||
// overridden)
|
// overridden)
|
||||||
assertEquals(keys.length, values.length, "failure in test: not the same number of sample " +
|
assertEquals(keys.length, values.length, "failure in test: not the same number of sample " + "keys and values.");
|
||||||
"keys and values.");
|
|
||||||
|
|
||||||
assertEquals(values.length, newValues.length,
|
assertEquals(values.length, newValues.length, "failure in test: not the same number of values and new values.");
|
||||||
"failure in test: not the same number of values and new values.");
|
|
||||||
|
|
||||||
// verify there aren't duplicate keys, and check values
|
// verify there aren't duplicate keys, and check values
|
||||||
for (int i = 0; i < keys.length - 1; i++) {
|
for (int i = 0; i < keys.length - 1; i++) {
|
||||||
for (int j = i + 1; j < keys.length; j++) {
|
for (int j = i + 1; j < keys.length; j++) {
|
||||||
assertTrue(keys[i] != null || keys[j] != null,
|
assertTrue(keys[i] != null || keys[j] != null, "failure in test: duplicate null keys.");
|
||||||
"failure in test: duplicate null keys.");
|
|
||||||
assertTrue(keys[i] == null || keys[j] == null || !keys[i].equals(keys[j]) && !keys[j].equals(keys[i]),
|
assertTrue(keys[i] == null || keys[j] == null || !keys[i].equals(keys[j]) && !keys[j].equals(keys[i]),
|
||||||
"failure in test: duplicate non-null key.");
|
"failure in test: duplicate non-null key.");
|
||||||
}
|
}
|
||||||
assertTrue(keys[i] != null || isAllowNullKey(),
|
assertTrue(keys[i] != null || isAllowNullKey(), "failure in test: found null key, but isNullKeySupported " + "is false.");
|
||||||
"failure in test: found null key, but isNullKeySupported " + "is false.");
|
assertTrue(values[i] != null || isAllowNullValue(), "failure in test: found null value, but isNullValueSupported " + "is false.");
|
||||||
assertTrue(values[i] != null || isAllowNullValue(),
|
assertTrue(newValues[i] != null || isAllowNullValue(), "failure in test: found null new value, but isNullValueSupported " + "is false.");
|
||||||
"failure in test: found null value, but isNullValueSupported " + "is false.");
|
|
||||||
assertTrue(newValues[i] != null || isAllowNullValue(),
|
|
||||||
"failure in test: found null new value, but isNullValueSupported " + "is false.");
|
|
||||||
assertTrue(values[i] != newValues[i] && (values[i] == null || !values[i].equals(newValues[i])),
|
assertTrue(values[i] != newValues[i] && (values[i] == null || !values[i].equals(newValues[i])),
|
||||||
"failure in test: values should not be the same as new value");
|
"failure in test: values should not be the same as new value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the {@link Map#bitMaps} collection is backed by
|
* Tests that the {@link Map#bitMaps} collection is backed by the underlying map for clear().
|
||||||
* the underlying map for clear().
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testValuesClearChangesMap() {
|
public void testValuesClearChangesMap() {
|
||||||
|
@ -1919,18 +1778,14 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that the {@link Map#bitMaps} collection is backed by
|
* Tests that the {@link Map#bitMaps} collection is backed by the underlying map by removing from the values collection and testing if the value was removed
|
||||||
* the underlying map by removing from the values collection
|
* from the map.
|
||||||
* and testing if the value was removed from the map.
|
|
||||||
* <p>
|
* <p>
|
||||||
* We should really test the "vice versa" case--that values removed
|
* We should really test the "vice versa" case--that values removed from the map are removed from the values collection--also, but that's a more difficult
|
||||||
* from the map are removed from the values collection--also,
|
* test to construct (lacking a "removeValue" method.)
|
||||||
* but that's a more difficult test to construct (lacking a
|
|
||||||
* "removeValue" method.)
|
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* See bug <a href="https://issues.apache.org/jira/browse/COLLECTIONS-92">
|
* See bug <a href="https://issues.apache.org/jira/browse/COLLECTIONS-92"> COLLECTIONS-92</a>.
|
||||||
* COLLECTIONS-92</a>.
|
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
|
@ -1984,14 +1839,9 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that {@link #map} is still equal to {@link #confirmed}.
|
* Verifies that {@link #map} is still equal to {@link #confirmed}. This method checks that the map is equal to the HashMap, <I>and</I> that the map's
|
||||||
* This method checks that the map is equal to the HashMap,
|
* collection views are still equal to the HashMap's collection views. An <Code>equals</Code> test is done on the maps and their collection views; their
|
||||||
* <I>and</I> that the map's collection views are still equal to
|
* size and <Code>isEmpty</Code> results are compared; their hashCodes are compared; and <Code>containsAll</Code> tests are run on the collection views.
|
||||||
* the HashMap's collection views. An <Code>equals</Code> test
|
|
||||||
* is done on the maps and their collection views; their size and
|
|
||||||
* <Code>isEmpty</Code> results are compared; their hashCodes are
|
|
||||||
* compared; and <Code>containsAll</Code> tests are run on the
|
|
||||||
* collection views.
|
|
||||||
*/
|
*/
|
||||||
public void verify() {
|
public void verify() {
|
||||||
verifyMap();
|
verifyMap();
|
||||||
|
@ -2003,39 +1853,25 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
public void verifyEntrySet() {
|
public void verifyEntrySet() {
|
||||||
final int size = getConfirmed().size();
|
final int size = getConfirmed().size();
|
||||||
final boolean empty = getConfirmed().isEmpty();
|
final boolean empty = getConfirmed().isEmpty();
|
||||||
assertEquals(size, entrySet.size(),
|
assertEquals(size, entrySet.size(), "entrySet should be same size as HashMap's" + "\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
||||||
"entrySet should be same size as HashMap's" +
|
assertEquals(empty, entrySet.isEmpty(), "entrySet should be empty if HashMap is" + "\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
||||||
"\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
|
||||||
assertEquals(empty, entrySet.isEmpty(),
|
|
||||||
"entrySet should be empty if HashMap is" +
|
|
||||||
"\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
|
||||||
assertTrue(entrySet.containsAll(getConfirmed().entrySet()),
|
assertTrue(entrySet.containsAll(getConfirmed().entrySet()),
|
||||||
"entrySet should contain all HashMap's elements" +
|
"entrySet should contain all HashMap's elements" + "\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
||||||
"\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
|
||||||
assertEquals(getConfirmed().entrySet().hashCode(), entrySet.hashCode(),
|
assertEquals(getConfirmed().entrySet().hashCode(), entrySet.hashCode(),
|
||||||
"entrySet hashCodes should be the same" +
|
"entrySet hashCodes should be the same" + "\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
||||||
"\nTest: " + entrySet + "\nReal: " + getConfirmed().entrySet());
|
assertEquals(getConfirmed().entrySet(), entrySet, "Map's entry set should still equal HashMap's");
|
||||||
assertEquals(getConfirmed().entrySet(), entrySet,
|
|
||||||
"Map's entry set should still equal HashMap's");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyKeySet() {
|
public void verifyKeySet() {
|
||||||
final int size = getConfirmed().size();
|
final int size = getConfirmed().size();
|
||||||
final boolean empty = getConfirmed().isEmpty();
|
final boolean empty = getConfirmed().isEmpty();
|
||||||
assertEquals(size, keySet.size(),
|
assertEquals(size, keySet.size(), "keySet should be same size as HashMap's" + "\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
||||||
"keySet should be same size as HashMap's" +
|
assertEquals(empty, keySet.isEmpty(), "keySet should be empty if HashMap is" + "\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
||||||
"\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
|
||||||
assertEquals(empty, keySet.isEmpty(),
|
|
||||||
"keySet should be empty if HashMap is" +
|
|
||||||
"\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
|
||||||
assertTrue(keySet.containsAll(getConfirmed().keySet()),
|
assertTrue(keySet.containsAll(getConfirmed().keySet()),
|
||||||
"keySet should contain all HashMap's elements" +
|
"keySet should contain all HashMap's elements" + "\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
||||||
"\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
|
||||||
assertEquals(getConfirmed().keySet().hashCode(), keySet.hashCode(),
|
assertEquals(getConfirmed().keySet().hashCode(), keySet.hashCode(),
|
||||||
"keySet hashCodes should be the same" +
|
"keySet hashCodes should be the same" + "\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
||||||
"\nTest: " + keySet + "\nReal: " + getConfirmed().keySet());
|
assertEquals(getConfirmed().keySet(), keySet, "Map's key set should still equal HashMap's");
|
||||||
assertEquals(getConfirmed().keySet(), keySet,
|
|
||||||
"Map's key set should still equal HashMap's");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyMap() {
|
public void verifyMap() {
|
||||||
|
@ -2062,18 +1898,10 @@ public abstract class AbstractMapTest<K, V> extends AbstractObjectTest {
|
||||||
|
|
||||||
final int size = getConfirmed().size();
|
final int size = getConfirmed().size();
|
||||||
final boolean empty = getConfirmed().isEmpty();
|
final boolean empty = getConfirmed().isEmpty();
|
||||||
assertEquals(size, values.size(),
|
assertEquals(size, values.size(), "values should be same size as HashMap's" + "\nTest: " + test + "\nReal: " + known);
|
||||||
"values should be same size as HashMap's" +
|
assertEquals(empty, values.isEmpty(), "values should be empty if HashMap is" + "\nTest: " + test + "\nReal: " + known);
|
||||||
"\nTest: " + test + "\nReal: " + known);
|
assertTrue(test.containsAll(known), "values should contain all HashMap's elements" + "\nTest: " + test + "\nReal: " + known);
|
||||||
assertEquals(empty, values.isEmpty(),
|
assertTrue(known.containsAll(test), "values should contain all HashMap's elements" + "\nTest: " + test + "\nReal: " + known);
|
||||||
"values should be empty if HashMap is" +
|
|
||||||
"\nTest: " + test + "\nReal: " + known);
|
|
||||||
assertTrue(test.containsAll(known),
|
|
||||||
"values should contain all HashMap's elements" +
|
|
||||||
"\nTest: " + test + "\nReal: " + known);
|
|
||||||
assertTrue(known.containsAll(test),
|
|
||||||
"values should contain all HashMap's elements" +
|
|
||||||
"\nTest: " + test + "\nReal: " + known);
|
|
||||||
// originally coded to use a HashBag, but now separate jar so...
|
// originally coded to use a HashBag, but now separate jar so...
|
||||||
for (final V v : known) {
|
for (final V v : known) {
|
||||||
final boolean removed = test.remove(v);
|
final boolean removed = test.remove(v);
|
||||||
|
|
|
@ -114,8 +114,7 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The only confirmed collection we have that is ordered is the sorted one.
|
* The only confirmed collection we have that is ordered is the sorted one. Thus, sort the keys.
|
||||||
* Thus, sort the keys.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -186,7 +185,8 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(ordered.nextKey(null)); // this is allowed too
|
assertNull(ordered.nextKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(ordered.nextKey(null));
|
assertNull(ordered.nextKey(null));
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,8 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
|
||||||
if (!isAllowNullKey()) {
|
if (!isAllowNullKey()) {
|
||||||
try {
|
try {
|
||||||
assertNull(ordered.previousKey(null)); // this is allowed too
|
assertNull(ordered.previousKey(null)); // this is allowed too
|
||||||
} catch (final NullPointerException ex) {}
|
} catch (final NullPointerException ex) {
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assertNull(ordered.previousKey(null));
|
assertNull(ordered.previousKey(null));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,22 +57,27 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
public boolean isNullSupported() {
|
public boolean isNullSupported() {
|
||||||
return LinkedMapTest.this.isAllowNullKey();
|
return LinkedMapTest.this.isAllowNullKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRemoveSupported() {
|
public boolean isRemoveSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSetSupported() {
|
public boolean isSetSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTestSerialization() {
|
public boolean isTestSerialization() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeFullCollection() {
|
public List<K> makeFullCollection() {
|
||||||
return LinkedMapTest.this.makeFullMap().asList();
|
return LinkedMapTest.this.makeFullMap().asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeObject() {
|
public List<K> makeObject() {
|
||||||
return LinkedMapTest.this.makeObject().asList();
|
return LinkedMapTest.this.makeObject().asList();
|
||||||
|
@ -129,19 +134,23 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
LinkedMap<K, V> lm = getMap();
|
LinkedMap<K, V> lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.get(0);
|
lm.get(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.get(-1);
|
lm.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lm = getMap();
|
lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.get(-1);
|
lm.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.get(lm.size());
|
lm.get(lm.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -155,19 +164,23 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
LinkedMap<K, V> lm = getMap();
|
LinkedMap<K, V> lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.getValue(0);
|
lm.getValue(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.getValue(-1);
|
lm.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lm = getMap();
|
lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.getValue(-1);
|
lm.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.getValue(lm.size());
|
lm.getValue(lm.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -263,19 +276,23 @@ public class LinkedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
LinkedMap<K, V> lm = getMap();
|
LinkedMap<K, V> lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.remove(0);
|
lm.remove(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.remove(-1);
|
lm.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lm = getMap();
|
lm = getMap();
|
||||||
try {
|
try {
|
||||||
lm.remove(-1);
|
lm.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lm.remove(lm.size());
|
lm.remove(lm.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
final List<K> list = new ArrayList<>();
|
final List<K> list = new ArrayList<>();
|
||||||
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext();) {
|
for (final MapIterator<K, V> it = lm.mapIterator(); it.hasNext();) {
|
||||||
|
|
|
@ -29,8 +29,7 @@ import org.apache.commons.collections4.list.AbstractListTest;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap}
|
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap} implementation.
|
||||||
* implementation.
|
|
||||||
*/
|
*/
|
||||||
public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
|
|
||||||
|
@ -54,22 +53,27 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
public boolean isNullSupported() {
|
public boolean isNullSupported() {
|
||||||
return ListOrderedMap2Test.this.isAllowNullKey();
|
return ListOrderedMap2Test.this.isAllowNullKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRemoveSupported() {
|
public boolean isRemoveSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSetSupported() {
|
public boolean isSetSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTestSerialization() {
|
public boolean isTestSerialization() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeFullCollection() {
|
public List<K> makeFullCollection() {
|
||||||
return ListOrderedMap2Test.this.makeFullMap().asList();
|
return ListOrderedMap2Test.this.makeFullMap().asList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<K> makeObject() {
|
public List<K> makeObject() {
|
||||||
return ListOrderedMap2Test.this.makeObject().asList();
|
return ListOrderedMap2Test.this.makeObject().asList();
|
||||||
|
@ -116,19 +120,23 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(0);
|
lom.get(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(lom.size());
|
lom.get(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -142,19 +150,23 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(0);
|
lom.getValue(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(lom.size());
|
lom.getValue(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -197,19 +209,23 @@ public class ListOrderedMap2Test<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(0);
|
lom.remove(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(lom.size());
|
lom.remove(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
final List<K> list = new ArrayList<>();
|
final List<K> list = new ArrayList<>();
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
||||||
|
|
|
@ -35,8 +35,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap}
|
* Extension of {@link AbstractOrderedMapTest} for exercising the {@link ListOrderedMap} implementation.
|
||||||
* implementation.
|
|
||||||
*/
|
*/
|
||||||
public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
|
|
||||||
|
@ -210,19 +209,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(0);
|
lom.get(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.get(-1);
|
lom.get(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.get(lom.size());
|
lom.get(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -236,19 +239,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(0);
|
lom.getValue(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.getValue(-1);
|
lom.getValue(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.getValue(lom.size());
|
lom.getValue(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext(); i++) {
|
||||||
|
@ -285,8 +292,7 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(1, (K) "testInsert1", (V) "testInsert1v"),
|
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(1, (K) "testInsert1", (V) "testInsert1v"),
|
||||||
"should not be able to insert at pos 1 in empty Map"),
|
"should not be able to insert at pos 1 in empty Map"),
|
||||||
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(-1, (K) "testInsert-1", (V) "testInsert-1v"),
|
() -> assertThrows(IndexOutOfBoundsException.class, () -> finalLom.put(-1, (K) "testInsert-1", (V) "testInsert-1v"),
|
||||||
"should not be able to insert at pos -1 in empty Map")
|
"should not be able to insert at pos -1 in empty Map"));
|
||||||
);
|
|
||||||
|
|
||||||
// put where key doesn't exist
|
// put where key doesn't exist
|
||||||
lom.put(0, (K) "testInsert1", (V) "testInsert1v");
|
lom.put(0, (K) "testInsert1", (V) "testInsert1v");
|
||||||
|
@ -450,19 +456,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(0);
|
lom.remove(0);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.remove(-1);
|
lom.remove(-1);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.remove(lom.size());
|
lom.remove(lom.size());
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
final List<K> list = new ArrayList<>();
|
final List<K> list = new ArrayList<>();
|
||||||
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
for (final MapIterator<K, V> it = lom.mapIterator(); it.hasNext();) {
|
||||||
|
@ -484,19 +494,23 @@ public class ListOrderedMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
||||||
ListOrderedMap<K, V> lom = getMap();
|
ListOrderedMap<K, V> lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.setValue(0, (V) StringUtils.EMPTY);
|
lom.setValue(0, (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.setValue(-1, (V) StringUtils.EMPTY);
|
lom.setValue(-1, (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
resetFull();
|
resetFull();
|
||||||
lom = getMap();
|
lom = getMap();
|
||||||
try {
|
try {
|
||||||
lom.setValue(-1, (V) StringUtils.EMPTY);
|
lom.setValue(-1, (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
lom.setValue(lom.size(), (V) StringUtils.EMPTY);
|
lom.setValue(lom.size(), (V) StringUtils.EMPTY);
|
||||||
} catch (final IndexOutOfBoundsException ex) {}
|
} catch (final IndexOutOfBoundsException ex) {
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < lom.size(); i++) {
|
for (int i = 0; i < lom.size(); i++) {
|
||||||
final V value = lom.getValue(i);
|
final V value = lom.getValue(i);
|
||||||
|
|
|
@ -1346,18 +1346,11 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
||||||
map.put((K) "B", (V) "U");
|
map.put((K) "B", (V) "U");
|
||||||
map.put((K) "B", (V) "V");
|
map.put((K) "B", (V) "V");
|
||||||
map.put((K) "B", (V) "W");
|
map.put((K) "B", (V) "W");
|
||||||
assertTrue(
|
assertTrue("{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) || "{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString()));
|
||||||
"{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) ||
|
|
||||||
"{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString())
|
|
||||||
);
|
|
||||||
|
|
||||||
final MultiValuedMap<K, V> originalNull = null;
|
final MultiValuedMap<K, V> originalNull = null;
|
||||||
assertThrows(NullPointerException.class, () -> map.putAll(originalNull),
|
assertThrows(NullPointerException.class, () -> map.putAll(originalNull), "expecting NullPointerException");
|
||||||
"expecting NullPointerException");
|
assertTrue("{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) || "{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString()));
|
||||||
assertTrue(
|
|
||||||
"{A=[X, Y, Z], B=[U, V, W]}".equals(map.toString()) ||
|
|
||||||
"{B=[U, V, W], A=[X, Y, Z]}".equals(map.toString())
|
|
||||||
);
|
|
||||||
|
|
||||||
map.remove("A");
|
map.remove("A");
|
||||||
map.remove("B");
|
map.remove("B");
|
||||||
|
|
|
@ -183,15 +183,13 @@ public class SequencesComparatorTest {
|
||||||
sentenceAfter.addAll(sentenceBefore);
|
sentenceAfter.addAll(sentenceBefore);
|
||||||
for (int i = 0; i < nbCom; i++) {
|
for (int i = 0; i < nbCom; i++) {
|
||||||
if (random.nextInt(2) == 0) {
|
if (random.nextInt(2) == 0) {
|
||||||
sentenceAfter.add(random.nextInt(sentenceAfter.size() + 1),
|
sentenceAfter.add(random.nextInt(sentenceAfter.size() + 1), shadokAlph[random.nextInt(4)]);
|
||||||
shadokAlph[random.nextInt(4)]);
|
|
||||||
} else {
|
} else {
|
||||||
sentenceAfter.remove(random.nextInt(sentenceAfter.size()));
|
sentenceAfter.remove(random.nextInt(sentenceAfter.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final SequencesComparator<String> comparator =
|
final SequencesComparator<String> comparator = new SequencesComparator<>(sentenceBefore, sentenceAfter);
|
||||||
new SequencesComparator<>(sentenceBefore, sentenceAfter);
|
|
||||||
assertTrue(comparator.getScript().getModifications() <= nbCom);
|
assertTrue(comparator.getScript().getModifications() <= nbCom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,8 +57,7 @@ public class TransformedSplitMapTest extends BulkTest {
|
||||||
NOPTransformer.<String>nopTransformer(),
|
NOPTransformer.<String>nopTransformer(),
|
||||||
NOPTransformer.<String>nopTransformer() );
|
NOPTransformer.<String>nopTransformer() );
|
||||||
|
|
||||||
final ObjectInputStream in =
|
final ObjectInputStream in = new ObjectInputStream(new FileInputStream(TEST_DATA_PATH + "/TransformedSplitMap.emptyCollection.version4.obj"));
|
||||||
new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"/TransformedSplitMap.emptyCollection.version4.obj" ) );
|
|
||||||
final Object readObject = in.readObject();
|
final Object readObject = in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
|
@ -78,8 +77,7 @@ public class TransformedSplitMapTest extends BulkTest {
|
||||||
map.put( "e", "f" );
|
map.put( "e", "f" );
|
||||||
map.put( "g", "h" );
|
map.put( "g", "h" );
|
||||||
|
|
||||||
final ObjectInputStream in =
|
final ObjectInputStream in = new ObjectInputStream(new FileInputStream(TEST_DATA_PATH + "TransformedSplitMap.fullCollection.version4.obj"));
|
||||||
new ObjectInputStream( new FileInputStream( TEST_DATA_PATH+"TransformedSplitMap.fullCollection.version4.obj" ) );
|
|
||||||
final Object readObject = in.readObject();
|
final Object readObject = in.readObject();
|
||||||
in.close();
|
in.close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue