Remove trailing white spaces on all lines.
This commit is contained in:
parent
b9522976f4
commit
be6789ced6
|
@ -66,7 +66,7 @@ public class BagUtilsTest {
|
|||
} catch (final NullPointerException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
assertSame("UnmodifiableBag shall not be decorated", bag, BagUtils.unmodifiableBag(bag));
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class BagUtilsTest {
|
|||
} catch (final NullPointerException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
assertSame("UnmodifiableSortedBag shall not be decorated", bag, BagUtils.unmodifiableSortedBag(bag));
|
||||
}
|
||||
|
||||
|
|
|
@ -1183,7 +1183,7 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
input.add(2);
|
||||
input.add(3);
|
||||
input.add(4);
|
||||
|
||||
|
||||
List<Integer> output = new ArrayList<>();
|
||||
List<Integer> rejected = new ArrayList<>();
|
||||
|
||||
|
@ -1192,11 +1192,11 @@ public class CollectionUtilsTest extends MockTestCase {
|
|||
// output contains 2
|
||||
assertEquals(1, output.size());
|
||||
assertEquals(2, CollectionUtils.extractSingleton(output).intValue());
|
||||
|
||||
|
||||
// rejected contains 1, 3, and 4
|
||||
Integer[] expected = {1, 3, 4};
|
||||
Assert.assertArrayEquals(expected, rejected.toArray());
|
||||
|
||||
|
||||
output.clear();
|
||||
rejected.clear();
|
||||
CollectionUtils.select((List<Integer>) null, EQUALS_TWO, output, rejected);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ComparatorUtilsTest {
|
|||
|
||||
assertEquals(Integer.valueOf(10), ComparatorUtils.max(1, 10, null));
|
||||
assertEquals(Integer.valueOf(10), ComparatorUtils.max(10, -10, null));
|
||||
|
||||
|
||||
assertEquals(Integer.valueOf(1), ComparatorUtils.max(1, 10, reversed));
|
||||
assertEquals(Integer.valueOf(-10), ComparatorUtils.max(10, -10, reversed));
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class ComparatorUtilsTest {
|
|||
|
||||
assertEquals(Integer.valueOf(1), ComparatorUtils.min(1, 10, null));
|
||||
assertEquals(Integer.valueOf(-10), ComparatorUtils.min(10, -10, null));
|
||||
|
||||
|
||||
assertEquals(Integer.valueOf(10), ComparatorUtils.min(1, 10, reversed));
|
||||
assertEquals(Integer.valueOf(10), ComparatorUtils.min(10, -10, reversed));
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ public class FluentIterableTest {
|
|||
} catch (NullPointerException npe) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
result = FluentIterable
|
||||
.of(Arrays.asList(1, 4, 7))
|
||||
.zip(Arrays.asList(2, 5, 8), Arrays.asList(3, 6, 9))
|
||||
|
|
|
@ -331,7 +331,7 @@ public class IterableUtilsTest {
|
|||
@Test
|
||||
public void matchesAny() {
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
|
||||
|
||||
try {
|
||||
assertFalse(IterableUtils.matchesAny(null, null));
|
||||
fail("predicate must not be null");
|
||||
|
@ -414,17 +414,17 @@ public class IterableUtilsTest {
|
|||
input.add(4);
|
||||
List<List<Integer>> partitions = IterableUtils.partition(input, EQUALS_TWO);
|
||||
assertEquals(2, partitions.size());
|
||||
|
||||
|
||||
// first partition contains 2
|
||||
Collection<Integer> partition = partitions.get(0);
|
||||
assertEquals(1, partition.size());
|
||||
assertEquals(2, CollectionUtils.extractSingleton(partition).intValue());
|
||||
|
||||
|
||||
// second partition contains 1, 3, and 4
|
||||
Integer[] expected = {1, 3, 4};
|
||||
partition = partitions.get(1);
|
||||
Assert.assertArrayEquals(expected, partition.toArray());
|
||||
|
||||
|
||||
partitions = IterableUtils.partition((List<Integer>) null, EQUALS_TWO);
|
||||
assertEquals(2, partitions.size());
|
||||
assertTrue(partitions.get(0).isEmpty());
|
||||
|
@ -456,12 +456,12 @@ public class IterableUtilsTest {
|
|||
Collection<Integer> partition = partitions.get(0);
|
||||
assertEquals(1, partition.size());
|
||||
assertEquals(2, partition.iterator().next().intValue());
|
||||
|
||||
|
||||
// second partition contains 4
|
||||
partition = partitions.get(1);
|
||||
assertEquals(1, partition.size());
|
||||
assertEquals(4, partition.iterator().next().intValue());
|
||||
|
||||
|
||||
// third partition contains 1 and 3
|
||||
Integer[] expected = {1, 3};
|
||||
partition = partitions.get(2);
|
||||
|
@ -478,7 +478,7 @@ public class IterableUtilsTest {
|
|||
public void testToString() {
|
||||
String result = IterableUtils.toString(iterableA);
|
||||
assertEquals("[1, 2, 2, 3, 3, 3, 4, 4, 4, 4]", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(new ArrayList<Integer>());
|
||||
assertEquals("[]", result);
|
||||
|
||||
|
@ -514,38 +514,38 @@ public class IterableUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testToStringDelimiter() {
|
||||
|
||||
|
||||
Transformer<Integer, String> transformer = new Transformer<Integer, String>() {
|
||||
@Override
|
||||
public String transform(Integer input) {
|
||||
return new Integer(input * 2).toString();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
String result = IterableUtils.toString(iterableA, transformer, "", "", "");
|
||||
assertEquals("2446668888", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(iterableA, transformer, ",", "", "");
|
||||
assertEquals("2,4,4,6,6,6,8,8,8,8", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(iterableA, transformer, "", "[", "]");
|
||||
assertEquals("[2446668888]", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(iterableA, transformer, ",", "[", "]");
|
||||
assertEquals("[2,4,4,6,6,6,8,8,8,8]", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(iterableA, transformer, ",", "[[", "]]");
|
||||
assertEquals("[[2,4,4,6,6,6,8,8,8,8]]", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(iterableA, transformer, ",,", "[", "]");
|
||||
assertEquals("[2,,4,,4,,6,,6,,6,,8,,8,,8,,8]", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(iterableA, transformer, ",,", "((", "))");
|
||||
assertEquals("((2,,4,,4,,6,,6,,6,,8,,8,,8,,8))", result);
|
||||
|
||||
result = IterableUtils.toString(new ArrayList<Integer>(), transformer, "", "(", ")");
|
||||
assertEquals("()", result);
|
||||
|
||||
|
||||
result = IterableUtils.toString(new ArrayList<Integer>(), transformer, "", "", "");
|
||||
assertEquals("", result);
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public class IteratorUtilsTest {
|
|||
list.add(null);
|
||||
final Object[] result = IteratorUtils.toArray(list.iterator());
|
||||
assertEquals(list, Arrays.asList(result));
|
||||
|
||||
|
||||
try {
|
||||
IteratorUtils.toArray(null);
|
||||
fail("Expecting NullPointerException");
|
||||
|
@ -201,14 +201,14 @@ public class IteratorUtilsTest {
|
|||
list.add(null);
|
||||
final String[] result = IteratorUtils.toArray(list.iterator(), String.class);
|
||||
assertEquals(list, Arrays.asList(result));
|
||||
|
||||
|
||||
try {
|
||||
IteratorUtils.toArray(list.iterator(), null);
|
||||
fail("Expecting NullPointerException");
|
||||
} catch (final NullPointerException ex) {
|
||||
// success
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
IteratorUtils.toArray(null, String.class);
|
||||
fail("Expecting NullPointerException");
|
||||
|
@ -972,7 +972,7 @@ public class IteratorUtilsTest {
|
|||
}
|
||||
|
||||
// natural ordering
|
||||
Iterator<Integer> it =
|
||||
Iterator<Integer> it =
|
||||
IteratorUtils.collatedIterator(null, collectionOdd.iterator(), collectionEven.iterator());
|
||||
|
||||
List<Integer> result = IteratorUtils.toList(it);
|
||||
|
@ -1115,14 +1115,14 @@ public class IteratorUtilsTest {
|
|||
}
|
||||
assertTrue(!iterator.hasNext());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetIterator() {
|
||||
final Object[] objArray = {"a", "b", "c"};
|
||||
final Map<String, String> inMap = new HashMap<>();
|
||||
final Node[] nodes = createNodes();
|
||||
final NodeList nodeList = createNodeList(nodes);
|
||||
|
||||
final NodeList nodeList = createNodeList(nodes);
|
||||
|
||||
assertTrue("returns empty iterator when null passed", IteratorUtils.getIterator(null) instanceof EmptyIterator);
|
||||
assertTrue("returns Iterator when Iterator directly ", IteratorUtils.getIterator(iterableA.iterator()) instanceof Iterator);
|
||||
assertTrue("returns Iterator when iterable passed", IteratorUtils.getIterator(iterableA) instanceof Iterator);
|
||||
|
@ -1130,9 +1130,9 @@ public class IteratorUtilsTest {
|
|||
assertTrue("returns Iterator when Map passed", IteratorUtils.getIterator(inMap) instanceof Iterator);
|
||||
assertTrue("returns NodeListIterator when nodeList passed", IteratorUtils.getIterator(nodeList) instanceof NodeListIterator);
|
||||
assertTrue("returns EnumerationIterator when Enumeration passed", IteratorUtils.getIterator(new Vector().elements()) instanceof EnumerationIterator);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testToListIterator() {
|
||||
final List<Integer> list = new ArrayList<>();
|
||||
|
|
|
@ -248,7 +248,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(true, test.containsKey("BLUE"));
|
||||
assertEquals("#0000FF", test.get("BLUE"));
|
||||
assertEquals(3, test.size());
|
||||
|
||||
|
||||
test = MapUtils.putAll(new HashMap<String, String>(), null);
|
||||
assertEquals(0, test.size());
|
||||
|
||||
|
@ -905,24 +905,24 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertSame(iMap, MapUtils.iterableMap(iMap));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testSize0() {
|
||||
assertEquals(0, MapUtils.size(new HashMap<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testSizeNull() {
|
||||
assertEquals(0, MapUtils.size(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testSize() {
|
||||
final HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("A", "1");
|
||||
map.put("B", "2");
|
||||
assertEquals(2, MapUtils.size(map));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testToProperties() {
|
||||
final Map<String, String> in = new HashMap<>();
|
||||
|
@ -936,7 +936,7 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(in.get("key2"), out.get("key2"));
|
||||
assertEquals(in.get("key3"), out.get("key3"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testToPropertiesEmpty() {
|
||||
final Map<String, String> in = null;
|
||||
|
@ -944,12 +944,12 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
|
||||
assertEquals(out.size(), 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetDoubleValue() {
|
||||
final Map<String, Double> in = new HashMap<>();
|
||||
in.put("key", 2.0);
|
||||
|
||||
|
||||
assertEquals(2.0, MapUtils.getDoubleValue(in,"key", 0.0), 0);
|
||||
assertEquals(2.0, MapUtils.getDoubleValue(in,"key"), 0);
|
||||
assertEquals(1.0, MapUtils.getDoubleValue(in,"noKey", 1.0), 0);
|
||||
|
@ -957,14 +957,14 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(2.0, MapUtils.getDouble(in,"key", 0.0), 0);
|
||||
assertEquals(1.0, MapUtils.getDouble(in,"noKey", 1.0), 0);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
char decimalSeparator = getDecimalSeparator();
|
||||
inStr.put("str1", "2" + decimalSeparator + "0");
|
||||
|
||||
|
||||
assertEquals(MapUtils.getDoubleValue(inStr,"str1", 0.0), 2.0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetFloatValue() {
|
||||
final Map<String, Float> in = new HashMap<>();
|
||||
|
@ -976,34 +976,34 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(0, MapUtils.getFloatValue(in,"noKey"), 0);
|
||||
assertEquals(2.0, MapUtils.getFloat(in,"key", 0.0f), 0);
|
||||
assertEquals(1.0, MapUtils.getFloat(in,"noKey", 1.0f), 0);
|
||||
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
char decimalSeparator = getDecimalSeparator();
|
||||
inStr.put("str1", "2" + decimalSeparator + "0");
|
||||
|
||||
|
||||
assertEquals(MapUtils.getFloatValue(inStr,"str1", 0.0f), 2.0, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetLongValue() {
|
||||
final Map<String, Long> in = new HashMap<>();
|
||||
in.put("key", 2L);
|
||||
|
||||
|
||||
assertEquals(2.0, MapUtils.getLongValue(in,"key", 0L), 0);
|
||||
assertEquals(2.0, MapUtils.getLongValue(in,"key"), 0);
|
||||
assertEquals(1, MapUtils.getLongValue(in,"noKey", 1L), 0);
|
||||
assertEquals(0, MapUtils.getLongValue(in,"noKey"), 0);
|
||||
assertEquals(2.0, MapUtils.getLong(in,"key", 0L), 0);
|
||||
assertEquals(1, MapUtils.getLong(in,"noKey", 1L), 0);
|
||||
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "2");
|
||||
|
||||
|
||||
assertEquals(MapUtils.getLongValue(inStr,"str1", 0L), 2, 0);
|
||||
assertEquals(MapUtils.getLong(inStr, "str1", 1L), 2, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetIntValue() {
|
||||
final Map<String, Integer> in = new HashMap<>();
|
||||
|
@ -1015,13 +1015,13 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(0, MapUtils.getIntValue(in,"noKey"), 0);
|
||||
assertEquals(2, MapUtils.getInteger(in,"key", 0), 0);
|
||||
assertEquals(0, MapUtils.getInteger(in,"noKey", 0), 0);
|
||||
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "2");
|
||||
|
||||
|
||||
assertEquals(MapUtils.getIntValue(inStr,"str1", 0), 2, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetShortValue() {
|
||||
final Map<String, Short> in = new HashMap<>();
|
||||
|
@ -1040,13 +1040,13 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
|
||||
assertEquals(MapUtils.getShortValue(inStr,"str1", val), val, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetByteValue() {
|
||||
final Map<String, Byte> in = new HashMap<>();
|
||||
final byte val = 100;
|
||||
in.put("key", val);
|
||||
|
||||
|
||||
assertEquals(val, MapUtils.getByteValue(in,"key", val), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in,"key"), 0);
|
||||
assertEquals(val, MapUtils.getByteValue(in,"noKey", val), 0);
|
||||
|
@ -1054,55 +1054,55 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(val, MapUtils.getByte(in,"key", val), 0);
|
||||
assertEquals(val, MapUtils.getByte(in,"noKey", val), 0);
|
||||
|
||||
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "100");
|
||||
|
||||
|
||||
assertEquals(MapUtils.getByteValue(inStr,"str1", val), val, 0);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetNumber() {
|
||||
final Map<String, Number> in = new HashMap<>();
|
||||
final Number val = 1000;
|
||||
in.put("key", val);
|
||||
|
||||
|
||||
assertEquals(val.intValue(), MapUtils.getNumber(in,"key", val).intValue(), 0);
|
||||
assertEquals(val.intValue(), MapUtils.getNumber(in,"noKey", val).intValue(), 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetString() {
|
||||
final Map<String, String> in = new HashMap<>();
|
||||
in.put("key", "str");
|
||||
|
||||
|
||||
assertEquals("str", MapUtils.getString(in,"key", "defualt"));
|
||||
assertEquals("str", MapUtils.getString(in,"key"));
|
||||
assertEquals(null, MapUtils.getString(null,"key"));
|
||||
assertEquals("default", MapUtils.getString(in,"noKey", "default"));
|
||||
assertEquals("default", MapUtils.getString(null,"noKey", "default"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetObject() {
|
||||
final Map<String, Object> in = new HashMap<>();
|
||||
in.put("key", "str");
|
||||
|
||||
|
||||
assertEquals("str", MapUtils.getObject(in,"key", "defualt"));
|
||||
assertEquals("str", MapUtils.getObject(in,"key"));
|
||||
assertEquals(null, MapUtils.getObject(null,"key"));
|
||||
assertEquals("default", MapUtils.getObject(in,"noKey", "default"));
|
||||
assertEquals("default", MapUtils.getObject(null,"noKey", "default"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetBooleanValue() {
|
||||
final Map<String, Boolean> in = new HashMap<>();
|
||||
in.put("key", true);
|
||||
|
||||
|
||||
assertTrue(MapUtils.getBooleanValue(in,"key", true));
|
||||
assertTrue(MapUtils.getBooleanValue(in,"key"));
|
||||
assertTrue(MapUtils.getBooleanValue(in,"noKey", true));
|
||||
|
@ -1112,16 +1112,16 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
assertEquals(null, MapUtils.getBoolean(null,"noKey"));
|
||||
|
||||
|
||||
|
||||
|
||||
final Map<String, String> inStr = new HashMap<>();
|
||||
inStr.put("str1", "true");
|
||||
|
||||
|
||||
assertTrue(MapUtils.getBooleanValue(inStr,"str1", true));
|
||||
assertTrue(MapUtils.getBoolean(inStr,"str1", true));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testgetMap() {
|
||||
final Map<String, Map<String,String>> in = new HashMap<>();
|
||||
|
@ -1129,24 +1129,24 @@ public class MapUtilsTest extends AbstractAvailableLocalesTest {
|
|||
valMap.put("key1", "value1");
|
||||
in.put("key1", valMap);
|
||||
final Map<?, ?> outValue = MapUtils.getMap(in,"key1", null);
|
||||
|
||||
|
||||
assertEquals("value1", outValue.get("key1"));
|
||||
assertEquals(null, outValue.get("key2"));
|
||||
assertEquals(null, MapUtils.getMap(in,"key2", null));
|
||||
assertEquals(null, MapUtils.getMap(null,"key2", null));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSafeAddToMap() {
|
||||
|
||||
|
||||
final Map<String, Object> inMap = new HashMap<>();
|
||||
|
||||
|
||||
MapUtils.safeAddToMap(inMap,"key1", "value1");
|
||||
MapUtils.safeAddToMap(inMap,"key2", null);
|
||||
assertEquals("value1", inMap.get("key1"));
|
||||
assertEquals("", inMap.get("key2"));
|
||||
assertEquals("", inMap.get("key2"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testOrderedMap() {
|
||||
final Map<String, String> inMap = new HashMap<>();
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
|
|
@ -129,7 +129,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertEquals(false, PredicateUtils.notPredicate(TruePredicate.truePredicate()).evaluate(cInteger));
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testNotPredicateEx() {
|
||||
PredicateUtils.notPredicate(null);
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertEquals(false, PredicateUtils.andPredicate(FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAndPredicateEx() {
|
||||
PredicateUtils.andPredicate(null, null);
|
||||
}
|
||||
|
@ -195,24 +195,24 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertTrue(AllPredicate.allPredicate(coll), null);
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAllPredicateEx1() {
|
||||
AllPredicate.allPredicate((Predicate<Object>[]) null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAllPredicateEx2() {
|
||||
AllPredicate.<Object>allPredicate(new Predicate[] { null });
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAllPredicateEx3() {
|
||||
AllPredicate.allPredicate(new Predicate[] { null, null });
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAllPredicateEx4() {
|
||||
AllPredicate.allPredicate((Collection<Predicate<Object>>) null);
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
AllPredicate.allPredicate(Collections.<Predicate<Object>>emptyList());
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAllPredicateEx6() {
|
||||
final Collection<Predicate<Object>> coll = new ArrayList<>();
|
||||
coll.add(null);
|
||||
|
@ -241,7 +241,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertEquals(false, PredicateUtils.orPredicate(FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testOrPredicateEx() {
|
||||
PredicateUtils.orPredicate(null, null);
|
||||
}
|
||||
|
@ -292,24 +292,24 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertFalse(PredicateUtils.anyPredicate(coll), null);
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAnyPredicateEx1() {
|
||||
PredicateUtils.anyPredicate((Predicate<Object>[]) null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAnyPredicateEx2() {
|
||||
PredicateUtils.anyPredicate(new Predicate[] {null});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAnyPredicateEx3() {
|
||||
PredicateUtils.anyPredicate(new Predicate[] {null, null});
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAnyPredicateEx4() {
|
||||
PredicateUtils.anyPredicate((Collection<Predicate<Object>>) null);
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
PredicateUtils.anyPredicate(Collections.<Predicate<Object>>emptyList());
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testAnyPredicateEx6() {
|
||||
final Collection<Predicate<Object>> coll = new ArrayList<>();
|
||||
coll.add(null);
|
||||
|
@ -338,7 +338,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertEquals(false, PredicateUtils.eitherPredicate(FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testEitherPredicateEx() {
|
||||
PredicateUtils.eitherPredicate(null, null);
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ public class PredicateUtilsTest extends AbstractPredicateTest {
|
|||
assertFalse(PredicateUtils.onePredicate(coll), null);
|
||||
}
|
||||
|
||||
@Test(expected=NullPointerException.class)
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testOnePredicateEx1() {
|
||||
PredicateUtils.onePredicate((Predicate<Object>[]) null);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.Test;
|
|||
|
||||
/**
|
||||
* Tests for QueueUtils factory methods.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class QueueUtilsTest {
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class QueueUtilsTest {
|
|||
} catch (final NullPointerException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
assertSame("UnmodifiableQueue shall not be decorated", queue, QueueUtils.unmodifiableQueue(queue));
|
||||
}
|
||||
|
||||
|
|
|
@ -131,12 +131,12 @@ public class SetUtilsTest {
|
|||
set.add(a);
|
||||
set.add(new String("b"));
|
||||
set.add(a);
|
||||
|
||||
|
||||
assertEquals(2, set.size());
|
||||
|
||||
|
||||
set.add(new String("a"));
|
||||
assertEquals(3, set.size());
|
||||
|
||||
|
||||
set.remove(a);
|
||||
assertEquals(2, set.size());
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ public class TransformerUtilsTest {
|
|||
// if/else tests
|
||||
assertEquals("A", TransformerUtils.<Integer, String>ifTransformer(lessThanFivePredicate, a, b).transform(1));
|
||||
assertEquals("B", TransformerUtils.<Integer, String>ifTransformer(lessThanFivePredicate, a, b).transform(5));
|
||||
|
||||
|
||||
// if tests
|
||||
Predicate<String> equalsAPredicate = EqualPredicate.equalPredicate("A");
|
||||
assertEquals("C", TransformerUtils.<String>ifTransformer(equalsAPredicate, c).transform("A"));
|
||||
|
@ -279,7 +279,7 @@ public class TransformerUtilsTest {
|
|||
fail();
|
||||
} catch (final NullPointerException ex) {}
|
||||
}
|
||||
|
||||
|
||||
// switchTransformer
|
||||
//------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class TrieUtilsTest {
|
|||
} catch (final NullPointerException ex) {
|
||||
// expected
|
||||
}
|
||||
|
||||
|
||||
assertSame("UnmodifiableTrie shall not be decorated", trie, TrieUtils.unmodifiableTrie(trie));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ import org.apache.commons.collections4.set.AbstractSetTest;
|
|||
* <p>
|
||||
* In addition to the generic collection tests (prefix testCollection) inherited
|
||||
* from AbstractCollectionTest, there are test methods that test the "normal" Bag
|
||||
* interface (prefix testBag). For Bag specific tests use the {@link #makeObject()} and
|
||||
* interface (prefix testBag). For Bag specific tests use the {@link #makeObject()} and
|
||||
* {@link #makeFullCollection()} methods instead of {@link #resetEmpty()} and resetFull(),
|
||||
* otherwise the collection will be wrapped by a {@link CollectionBag} decorator.
|
||||
*
|
||||
|
@ -156,11 +156,11 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
|||
public void testBagEqualsSelf() {
|
||||
final Bag<T> bag = makeObject();
|
||||
assertTrue(bag.equals(bag));
|
||||
|
||||
|
||||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bag.add((T) "elt");
|
||||
assertTrue(bag.equals(bag));
|
||||
bag.add((T) "elt"); // again
|
||||
|
@ -198,7 +198,7 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
|||
if (!isRemoveSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Bag<T> bag = makeObject();
|
||||
bag.add((T) "A", 2);
|
||||
assertEquals("Should have count of 2", 2, bag.getCount("A"));
|
||||
|
@ -220,7 +220,7 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Bag<T> bag = makeObject();
|
||||
|
||||
assertEquals("Bag does not have at least 1 'A'", false, bag.contains("A"));
|
||||
|
@ -244,7 +244,7 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Bag<T> bag = makeObject();
|
||||
final List<String> known = new ArrayList<>();
|
||||
final List<String> known1A = new ArrayList<>();
|
||||
|
@ -298,7 +298,7 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Bag<T> bag = makeObject();
|
||||
assertEquals("Should have 0 total items", 0, bag.size());
|
||||
bag.add((T) "A");
|
||||
|
@ -323,7 +323,7 @@ public abstract class AbstractBagTest<T> extends AbstractCollectionTest<T> {
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final Bag<T> bag = makeObject();
|
||||
bag.add((T) "A");
|
||||
bag.add((T) "A");
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.commons.collections4.collection.AbstractCollectionTest;
|
|||
* Test class for {@link CollectionBag}.
|
||||
* <p>
|
||||
* Note: This test is mainly for serialization support, the CollectionBag decorator
|
||||
* is extensively used and tested in AbstractBagTest.
|
||||
* is extensively used and tested in AbstractBagTest.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ public class CollectionBagTest<T> extends AbstractCollectionTest<T> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public Bag<T> makeObject() {
|
||||
return CollectionBag.collectionBag(new HashBag<T>());
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.apache.commons.collections4.collection.AbstractCollectionTest;
|
|||
* Test class for {@link CollectionSortedBag}.
|
||||
* <p>
|
||||
* Note: This test is mainly for serialization support, the CollectionSortedBag decorator
|
||||
* is extensively used and tested in AbstractSortedBagTest.
|
||||
* is extensively used and tested in AbstractSortedBagTest.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
@ -46,7 +46,7 @@ public class CollectionSortedBagTest<T> extends AbstractCollectionTest<T> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Overridden because SortedBags don't allow null elements (normally).
|
||||
* @return false
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TreeBagTest<T> extends AbstractSortedBagTest<T> {
|
|||
} catch(final NullPointerException npe) {
|
||||
// expected;
|
||||
}
|
||||
|
||||
|
||||
final Bag<String> bag2 = new TreeBag<>(new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
|
|
|
@ -80,7 +80,7 @@ public class UnmodifiableBagTest<E> extends AbstractBagTest<E> {
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final Bag<E> queue = makeFullCollection();
|
||||
assertSame(queue, UnmodifiableBag.unmodifiableBag(queue));
|
||||
|
|
|
@ -80,7 +80,7 @@ public class UnmodifiableSortedBagTest<E> extends AbstractSortedBagTest<E> {
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final SortedBag<E> queue = makeFullCollection();
|
||||
assertSame(queue, UnmodifiableSortedBag.unmodifiableSortedBag(queue));
|
||||
|
|
|
@ -166,7 +166,7 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
|
|||
preTail + "bulkTestMapEntrySet.testCollectionIteratorRemove",
|
||||
preTail + "bulkTestMapEntrySet.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapKeySet.testCollectionIteratorRemove",
|
||||
preTail + "bulkTestMapKeySet.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapKeySet.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapValues.testCollectionClear",
|
||||
preTail + "bulkTestMapValues.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapValues.testCollectionRetainAll"
|
||||
|
|
|
@ -60,7 +60,7 @@ public class DualTreeBidiMapTest<K extends Comparable<K>, V extends Comparable<V
|
|||
preTail + "bulkTestMapEntrySet.testCollectionIteratorRemove",
|
||||
preTail + "bulkTestMapEntrySet.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapKeySet.testCollectionIteratorRemove",
|
||||
preTail + "bulkTestMapKeySet.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapKeySet.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapValues.testCollectionClear",
|
||||
preTail + "bulkTestMapValues.testCollectionRemoveAll",
|
||||
preTail + "bulkTestMapValues.testCollectionRetainAll"
|
||||
|
|
|
@ -85,7 +85,7 @@ public class UnmodifiableBidiMapTest<K, V> extends AbstractBidiMapTest<K, V> {
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullMap() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final BidiMap<K, V> map = makeFullMap();
|
||||
assertSame(map, UnmodifiableBidiMap.unmodifiableBidiMap(map));
|
||||
|
@ -95,5 +95,5 @@ public class UnmodifiableBidiMapTest<K, V> extends AbstractBidiMapTest<K, V> {
|
|||
fail();
|
||||
} catch (final NullPointerException ex) {}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class UnmodifiableOrderedBidiMapTest<K extends Comparable<K>, V extends C
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullMap() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final OrderedBidiMap<K, V> map = makeFullMap();
|
||||
assertSame(map, UnmodifiableOrderedBidiMap.unmodifiableOrderedBidiMap(map));
|
||||
|
|
|
@ -101,7 +101,7 @@ public class UnmodifiableSortedBidiMapTest<K extends Comparable<K>, V extends Co
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullMap() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final SortedBidiMap<K, V> map = makeFullMap();
|
||||
assertSame(map, UnmodifiableSortedBidiMap.unmodifiableSortedBidiMap(map));
|
||||
|
|
|
@ -90,7 +90,7 @@ import org.apache.commons.collections4.AbstractObjectTest;
|
|||
* {@link #confirmed}, the {@link #verify()} method is invoked to compare
|
||||
* the results. You may want to override {@link #verify()} to perform
|
||||
* additional verifications. For instance, when testing the collection
|
||||
* views of a map, {@link org.apache.commons.collections4.map.AbstractMapTest AbstractTestMap}
|
||||
* views of a map, {@link org.apache.commons.collections4.map.AbstractMapTest AbstractTestMap}
|
||||
* would override {@link #verify()} to make
|
||||
* sure the map is changed after the collection view is changed.
|
||||
* <p>
|
||||
|
@ -106,7 +106,7 @@ import org.apache.commons.collections4.AbstractObjectTest;
|
|||
* <p>
|
||||
* If you're extending {@link org.apache.commons.collections4.list.AbstractListTest AbstractListTest},
|
||||
* {@link org.apache.commons.collections4.set.AbstractSetTest AbstractTestSet},
|
||||
* or {@link org.apache.commons.collections4.bag.AbstractBagTest AbstractBagTest},
|
||||
* or {@link org.apache.commons.collections4.bag.AbstractBagTest AbstractBagTest},
|
||||
* you probably don't have to worry about the
|
||||
* above methods, because those three classes already override the methods
|
||||
* to provide standard JDK confirmed collections.<P>
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.junit.Test;
|
|||
|
||||
/**
|
||||
* Tests the PredicatedCollection.Builder class.
|
||||
*
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public class PredicatedCollectionBuilderTest {
|
||||
|
@ -52,7 +52,7 @@ public class PredicatedCollectionBuilderTest {
|
|||
PredicatedCollection.Builder<String> builder = PredicatedCollection.notNullBuilder();
|
||||
builder.add((String) null);
|
||||
Assert.assertTrue(builder.createPredicatedList().isEmpty());
|
||||
|
||||
|
||||
Assert.assertEquals(1, builder.rejectedElements().size());
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class PredicatedCollectionBuilderTest {
|
|||
|
||||
List<String> predicatedList = builder.createPredicatedList();
|
||||
checkPredicatedCollection1(predicatedList);
|
||||
|
||||
|
||||
Set<String> predicatedSet = builder.createPredicatedSet();
|
||||
checkPredicatedCollection1(predicatedSet);
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class PredicatedCollectionBuilderTest {
|
|||
Queue<String> predicatedQueue = builder.createPredicatedQueue();
|
||||
checkPredicatedCollection1(predicatedQueue);
|
||||
}
|
||||
|
||||
|
||||
private void checkPredicatedCollection1(final Collection<String> collection) {
|
||||
Assert.assertEquals(1, collection.size());
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class PredicatedCollectionBuilderTest {
|
|||
|
||||
List<Integer> predicatedList = builder.createPredicatedList();
|
||||
checkPredicatedCollection2(predicatedList);
|
||||
|
||||
|
||||
Set<Integer> predicatedSet = builder.createPredicatedSet();
|
||||
checkPredicatedCollection2(predicatedSet);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.collections4.Predicate;
|
|||
import org.apache.commons.collections4.functors.TruePredicate;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractCollectionTest} for exercising the
|
||||
* Extension of {@link AbstractCollectionTest} for exercising the
|
||||
* {@link PredicatedCollection} implementation.
|
||||
*
|
||||
* @since 3.0
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.collections4.list.FixedSizeList;
|
|||
/**
|
||||
* Extension of {@link AbstractCollectionTest} for exercising the
|
||||
* {@link UnmodifiableBoundedCollection} implementation.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UnmodifiableBoundedCollectionTest<E> extends AbstractCollectionTest<E> {
|
||||
|
||||
|
@ -80,14 +80,14 @@ public class UnmodifiableBoundedCollectionTest<E> extends AbstractCollectionTest
|
|||
public String getCompatibilityVersion() {
|
||||
return "4";
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
public void testUnmodifiable() {
|
||||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final BoundedCollection<E> coll = makeFullCollection();
|
||||
assertSame(coll, UnmodifiableBoundedCollection.unmodifiableBoundedCollection(coll));
|
||||
|
@ -97,5 +97,5 @@ public class UnmodifiableBoundedCollectionTest<E> extends AbstractCollectionTest
|
|||
fail();
|
||||
} catch (final NullPointerException ex) {}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -71,12 +71,12 @@ public class UnmodifiableCollectionTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
public void testUnmodifiable() {
|
||||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final Collection<E> coll = makeFullCollection();
|
||||
assertSame(coll, UnmodifiableCollection.unmodifiableCollection(coll));
|
||||
|
|
|
@ -69,7 +69,7 @@ public abstract class AbstractAnyAllOnePredicateTest<T> extends AbstractComposit
|
|||
|
||||
/**
|
||||
* Tests creating composite predicate instances with single predicates and verifies that the composite returns
|
||||
* the same value as the single predicate does.
|
||||
* the same value as the single predicate does.
|
||||
*/
|
||||
@SuppressWarnings("boxing")
|
||||
public final void singleValues() {
|
||||
|
|
|
@ -74,7 +74,7 @@ public class FilterIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
/**
|
||||
* Returns an array with elements wrapped in a pass-through
|
||||
* FilterIterator
|
||||
*
|
||||
*
|
||||
* @return a filtered iterator
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -25,16 +25,16 @@ import junit.framework.TestCase;
|
|||
|
||||
/**
|
||||
* Tests the IteratorEnumeration.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class IteratorEnumerationTest extends TestCase {
|
||||
|
||||
|
||||
public void testEnumeration() {
|
||||
Iterator<String> iterator = Arrays.asList("a", "b", "c").iterator();
|
||||
IteratorEnumeration<String> enumeration = new IteratorEnumeration<>(iterator);
|
||||
|
||||
|
||||
assertEquals(iterator, enumeration.getIterator());
|
||||
|
||||
|
||||
assertTrue(enumeration.hasMoreElements());
|
||||
assertEquals("a", enumeration.nextElement());
|
||||
assertEquals("b", enumeration.nextElement());
|
||||
|
|
|
@ -135,7 +135,7 @@ public class ListIteratorWrapper2Test<E> extends AbstractIteratorTest<E> {
|
|||
//like we never started iterating:
|
||||
assertEquals(-1, iter.previousIndex());
|
||||
assertEquals(0, iter.nextIndex());
|
||||
|
||||
|
||||
try {
|
||||
iter.remove();
|
||||
fail("ListIteratorWrapper#remove() should fail; must be repositioned first");
|
||||
|
|
|
@ -136,7 +136,7 @@ public class ListIteratorWrapperTest<E> extends AbstractIteratorTest<E> {
|
|||
//like we never started iterating:
|
||||
assertEquals(-1, iter.previousIndex());
|
||||
assertEquals(0, iter.nextIndex());
|
||||
|
||||
|
||||
try {
|
||||
iter.remove();
|
||||
fail("ListIteratorWrapper#remove() should fail; must be repositioned first");
|
||||
|
|
|
@ -36,7 +36,7 @@ public class PeekingIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
private final String[] testArray = { "a", "b", "c" };
|
||||
|
||||
private List<E> testList;
|
||||
|
||||
|
||||
public PeekingIteratorTest(final String testName) {
|
||||
super(testName);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class PeekingIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
||||
@Test
|
||||
public void testEmpty() {
|
||||
Iterator<E> it = makeEmptyIterator();
|
||||
|
@ -99,7 +99,7 @@ public class PeekingIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
assertEquals("c", it.next());
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIteratorExhausted() {
|
||||
PeekingIterator<E> it = makeObject();
|
||||
|
@ -108,7 +108,7 @@ public class PeekingIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
it.next();
|
||||
assertFalse(it.hasNext());
|
||||
assertNull(it.peek());
|
||||
|
||||
|
||||
try {
|
||||
it.element();
|
||||
fail();
|
||||
|
@ -122,10 +122,10 @@ public class PeekingIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
PeekingIterator<E> it = makeObject();
|
||||
it.next();
|
||||
it.remove(); // supported
|
||||
|
||||
|
||||
assertTrue(it.hasNext());
|
||||
assertEquals("b", it.peek());
|
||||
|
||||
|
||||
try {
|
||||
it.remove();
|
||||
fail();
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.junit.Test;
|
|||
|
||||
/**
|
||||
* Tests the PushbackIterator.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PushbackIteratorTest<E> extends AbstractIteratorTest<E> {
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class UniqueFilterIteratorTest<E> extends AbstractIteratorTest<E> {
|
|||
try {
|
||||
iter.next();
|
||||
} catch (final Exception e) {
|
||||
assertTrue("NoSuchElementException must be thrown",
|
||||
assertTrue("NoSuchElementException must be thrown",
|
||||
e.getClass().equals(new NoSuchElementException().getClass()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -253,7 +253,7 @@ public class MultiKeyTest extends TestCase {
|
|||
final MultiKey<?> mk2 = new MultiKey<Object>(ONE, sysKey);
|
||||
assertEquals(TWO, map2.get(mk2));
|
||||
}
|
||||
|
||||
|
||||
static class DerivedMultiKey<T> extends MultiKey<T> {
|
||||
|
||||
private static final long serialVersionUID = 1928896152249821416L;
|
||||
|
@ -290,5 +290,5 @@ public class MultiKeyTest extends TestCase {
|
|||
|
||||
assertEquals(mk.hashCode(), mk2.hashCode());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class GrowthListTest<E> extends AbstractListTest<E> {
|
|||
fail("List.set should throw IndexOutOfBoundsException [-1]");
|
||||
} catch(final IndexOutOfBoundsException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.collections4.Predicate;
|
|||
import org.apache.commons.collections4.functors.TruePredicate;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractListTest} for exercising the
|
||||
* Extension of {@link AbstractListTest} for exercising the
|
||||
* {@link PredicatedList} implementation.
|
||||
*
|
||||
* @since 3.0
|
||||
|
|
|
@ -120,7 +120,7 @@ public class CaseInsensitiveMapTest<K, V> extends AbstractIterableMapTest<K, V>
|
|||
|
||||
final Locale[] locales = { Locale.ENGLISH, new Locale("tr", "", ""), Locale.getDefault() };
|
||||
|
||||
final String[][] data = {
|
||||
final String[][] data = {
|
||||
{ "i", "I" },
|
||||
{ "\u03C2", "\u03C3" },
|
||||
{ "\u03A3", "\u03C2" },
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.apache.commons.collections4.Transformer;
|
|||
import org.apache.commons.collections4.functors.ConstantFactory;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractMapTest} for exercising the
|
||||
* Extension of {@link AbstractMapTest} for exercising the
|
||||
* {@link DefaultedMap} implementation.
|
||||
*
|
||||
* @since 3.2
|
||||
|
|
|
@ -412,15 +412,15 @@ public class Flat3MapTest<K, V> extends AbstractIterableMapTest<K, V> {
|
|||
final Flat3Map<Integer, Integer> m = new Flat3Map<>();
|
||||
m.put( Integer.valueOf(1), Integer.valueOf(1) );
|
||||
m.put( Integer.valueOf(0), Integer.valueOf(0) );
|
||||
assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) );
|
||||
assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) );
|
||||
assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) );
|
||||
assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) );
|
||||
|
||||
m.put( Integer.valueOf(2), Integer.valueOf(2) );
|
||||
m.put( Integer.valueOf(1), Integer.valueOf(1) );
|
||||
m.put( Integer.valueOf(0), Integer.valueOf(0) );
|
||||
assertEquals( Integer.valueOf(2), m.remove( Integer.valueOf(2) ) );
|
||||
assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) );
|
||||
assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) );
|
||||
assertEquals( Integer.valueOf(2), m.remove( Integer.valueOf(2) ) );
|
||||
assertEquals( Integer.valueOf(1), m.remove( Integer.valueOf(1) ) );
|
||||
assertEquals( Integer.valueOf(0), m.remove( Integer.valueOf(0) ) );
|
||||
}
|
||||
|
||||
public void testToString() {
|
||||
|
|
|
@ -281,7 +281,7 @@ public class LRUMapTest<K, V> extends AbstractOrderedMapTest<K, V> {
|
|||
|
||||
resetEmpty();
|
||||
LRUMap<K, V> lruMap = (LRUMap<K, V>) map;
|
||||
|
||||
|
||||
lruMap.put(keys[0], values[0]);
|
||||
lruMap.put(keys[1], values[1]);
|
||||
kit = lruMap.keySet().iterator();
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.collections4.Transformer;
|
|||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractMapTest} for exercising the
|
||||
* Extension of {@link AbstractMapTest} for exercising the
|
||||
* {@link LazyMap} implementation.
|
||||
*
|
||||
* @since 3.0
|
||||
|
|
|
@ -308,7 +308,7 @@ public class MultiKeyMapTest<K, V> extends AbstractIterableMapTest<MultiKey<? ex
|
|||
map.put("a", null, "value5");
|
||||
map.put(null, "a", "value6");
|
||||
map.put(null, null, "value7");
|
||||
|
||||
|
||||
assertEquals(6, map.size());
|
||||
assertEquals("value5", map.get("a", null));
|
||||
assertEquals("value4", map.get("a", "z"));
|
||||
|
|
|
@ -396,7 +396,7 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest {
|
|||
byte[] bytes = serialize(map1);
|
||||
Object result = deserialize(bytes);
|
||||
assertEquals(map1, result);
|
||||
|
||||
|
||||
MultiValueMap map2 = MultiValueMap.multiValueMap(new HashMap(), (Class) String.class);
|
||||
bytes = serialize(map2);
|
||||
try {
|
||||
|
@ -416,16 +416,16 @@ public class MultiValueMapTest<K, V> extends AbstractObjectTest {
|
|||
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
private Object deserialize(byte[] data) throws IOException, ClassNotFoundException {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||
ObjectInputStream iis = new ObjectInputStream(bais);
|
||||
|
||||
|
||||
return iis.readObject();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Manual serialization testing as this class cannot easily
|
||||
// Manual serialization testing as this class cannot easily
|
||||
// extend the AbstractTestMap
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> {
|
|||
m.put("a", "b");
|
||||
assertNull(m.get("a"));
|
||||
}
|
||||
|
||||
|
||||
public void testExpiration() {
|
||||
validateExpiration(new PassiveExpiringMap<String, String>(500), 500);
|
||||
validateExpiration(new PassiveExpiringMap<String, String>(1000), 1000);
|
||||
|
@ -236,9 +236,9 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> {
|
|||
|
||||
private void validateExpiration(final Map<String, String> map, long timeout) {
|
||||
map.put("a", "b");
|
||||
|
||||
|
||||
assertNotNull(map.get("a"));
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(2 * timeout);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -247,5 +247,5 @@ public class PassiveExpiringMapTest<K, V> extends AbstractMapTest<K, V> {
|
|||
|
||||
assertNull(map.get("a"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.collections4.Predicate;
|
|||
import org.apache.commons.collections4.functors.TruePredicate;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractMapTest} for exercising the
|
||||
* Extension of {@link AbstractMapTest} for exercising the
|
||||
* {@link PredicatedMap} implementation.
|
||||
*
|
||||
* @since 3.0
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TransformedSortedMapTest<K, V> extends AbstractSortedMapTest<K, V>
|
|||
preTailMap + "bulkTestMapEntrySet.testCollectionIteratorRemove",
|
||||
preTailMap + "bulkTestMapEntrySet.testCollectionRemoveAll",
|
||||
preTailMap + "bulkTestMapKeySet.testCollectionIteratorRemove",
|
||||
preTailMap + "bulkTestMapKeySet.testCollectionRemoveAll",
|
||||
preTailMap + "bulkTestMapKeySet.testCollectionRemoveAll",
|
||||
preTailMap + "bulkTestMapValues.testCollectionClear",
|
||||
preTailMap + "bulkTestMapValues.testCollectionRemoveAll",
|
||||
preTailMap + "bulkTestMapValues.testCollectionRetainAll"
|
||||
|
|
|
@ -1135,7 +1135,7 @@ public abstract class AbstractMultiValuedMapTest<K, V> extends AbstractObjectTes
|
|||
public boolean isRemoveSupported() {
|
||||
return AbstractMultiValuedMapTest.this.isRemoveSupported();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean areEqualElementsDistinguishable() {
|
||||
// work-around for a problem with the EntrySet: the entries contain
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections4.collection.TransformedCollectionTest;
|
|||
|
||||
/**
|
||||
* Tests for TransformedMultiValuedMap
|
||||
*
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public class TransformedMultiValuedMapTest<K, V> extends AbstractMultiValuedMapTest<K, V> {
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.apache.commons.collections4.Unmodifiable;
|
|||
|
||||
/**
|
||||
* Tests for UnmodifiableMultiValuedMap
|
||||
*
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public class UnmodifiableMultiValuedMapTest<K, V> extends AbstractMultiValuedMapTest<K, V> {
|
||||
|
@ -45,7 +45,7 @@ public class UnmodifiableMultiValuedMapTest<K, V> extends AbstractMultiValuedMap
|
|||
public static Test suite() {
|
||||
return BulkTest.makeSuite(UnmodifiableMultiValuedMapTest.class);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
@Override
|
||||
public boolean isAddSupported() {
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.apache.commons.collections4.set.AbstractSetTest;
|
|||
* <p>
|
||||
* In addition to the generic collection tests (prefix testCollection) inherited
|
||||
* from AbstractCollectionTest, there are test methods that test the "normal" MultiSet
|
||||
* interface (prefix testMultiSet). For MultiSet specific tests use the {@link #makeObject()} and
|
||||
* interface (prefix testMultiSet). For MultiSet specific tests use the {@link #makeObject()} and
|
||||
* {@link #makeFullCollection()} methods instead of {@link #resetEmpty()} and resetFull().
|
||||
*
|
||||
* @since 4.1
|
||||
|
@ -152,11 +152,11 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T>
|
|||
public void testMultiSetEqualsSelf() {
|
||||
final MultiSet<T> multiset = makeObject();
|
||||
assertTrue(multiset.equals(multiset));
|
||||
|
||||
|
||||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
multiset.add((T) "elt");
|
||||
assertTrue(multiset.equals(multiset));
|
||||
multiset.add((T) "elt"); // again
|
||||
|
@ -194,7 +194,7 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T>
|
|||
if (!isRemoveSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final MultiSet<T> multiset = makeObject();
|
||||
multiset.add((T) "A", 2);
|
||||
assertEquals("Should have count of 2", 2, multiset.getCount("A"));
|
||||
|
@ -216,7 +216,7 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T>
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final MultiSet<T> multiset = makeObject();
|
||||
|
||||
assertEquals("MultiSet does not have at least 1 'A'", false, multiset.contains("A"));
|
||||
|
@ -240,7 +240,7 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T>
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final MultiSet<T> multiset = makeObject();
|
||||
final List<String> known = new ArrayList<>();
|
||||
final List<String> known1A = new ArrayList<>();
|
||||
|
@ -294,7 +294,7 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T>
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final MultiSet<T> multiset = makeObject();
|
||||
assertEquals("Should have 0 total items", 0, multiset.size());
|
||||
multiset.add((T) "A");
|
||||
|
@ -319,7 +319,7 @@ public abstract class AbstractMultiSetTest<T> extends AbstractCollectionTest<T>
|
|||
if (!isAddSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final MultiSet<T> multiset = makeObject();
|
||||
multiset.add((T) "A");
|
||||
multiset.add((T) "A");
|
||||
|
|
|
@ -79,7 +79,7 @@ public class UnmodifiableMultiSetTest<E> extends AbstractMultiSetTest<E> {
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final MultiSet<E> multiset = makeFullCollection();
|
||||
assertSame(multiset, UnmodifiableMultiSet.unmodifiableMultiSet(multiset));
|
||||
|
|
|
@ -162,13 +162,13 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
assertTrue("Queue should contain added element", getCollection().contains(element));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests {@link Queue#element()}.
|
||||
*/
|
||||
public void testQueueElement() {
|
||||
resetEmpty();
|
||||
|
||||
|
||||
try {
|
||||
getCollection().element();
|
||||
fail("Queue.element should throw NoSuchElementException");
|
||||
|
@ -193,13 +193,13 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
assertTrue(getConfirmed().contains(element));
|
||||
|
||||
|
||||
getCollection().remove(element);
|
||||
getConfirmed().remove(element);
|
||||
|
||||
verify();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
getCollection().element();
|
||||
fail("Queue.element should throw NoSuchElementException");
|
||||
|
@ -217,7 +217,7 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
resetEmpty();
|
||||
|
||||
|
||||
E element = getCollection().peek();
|
||||
assertNull(element);
|
||||
|
||||
|
@ -232,13 +232,13 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
assertTrue(getConfirmed().contains(element));
|
||||
|
||||
|
||||
getCollection().remove(element);
|
||||
getConfirmed().remove(element);
|
||||
|
||||
verify();
|
||||
}
|
||||
|
||||
|
||||
element = getCollection().peek();
|
||||
assertNull(element);
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
resetEmpty();
|
||||
|
||||
|
||||
try {
|
||||
getCollection().remove();
|
||||
fail("Queue.remove should throw NoSuchElementException");
|
||||
|
@ -269,7 +269,7 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
assertTrue("remove should return correct element", success);
|
||||
verify();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
getCollection().element();
|
||||
fail("Queue.remove should throw NoSuchElementException");
|
||||
|
@ -287,7 +287,7 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
}
|
||||
|
||||
resetEmpty();
|
||||
|
||||
|
||||
E element = getCollection().poll();
|
||||
assertNull(element);
|
||||
|
||||
|
@ -300,7 +300,7 @@ public abstract class AbstractQueueTest<E> extends AbstractCollectionTest<E> {
|
|||
assertTrue("poll should return correct element", success);
|
||||
verify();
|
||||
}
|
||||
|
||||
|
||||
element = getCollection().poll();
|
||||
assertNull(element);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public class UnmodifiableQueueTest<E> extends AbstractQueueTest<E> {
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final Queue<E> queue = makeFullCollection();
|
||||
assertSame(queue, UnmodifiableQueue.unmodifiableQueue(queue));
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.collections4.IteratorUtils;
|
|||
/**
|
||||
* Extension of {@link AbstractSetTest} for exercising the
|
||||
* {@link ListOrderedSet} implementation.
|
||||
*
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class ListOrderedSetTest<E>
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.collections4.Predicate;
|
|||
import org.apache.commons.collections4.functors.TruePredicate;
|
||||
|
||||
/**
|
||||
* Extension of {@link AbstractSetTest} for exercising the
|
||||
* Extension of {@link AbstractSetTest} for exercising the
|
||||
* {@link PredicatedSet} implementation.
|
||||
*
|
||||
* @since 3.0
|
||||
|
|
|
@ -70,7 +70,7 @@ public class UnmodifiableSetTest<E> extends AbstractSetTest<E> {
|
|||
assertTrue(makeObject() instanceof Unmodifiable);
|
||||
assertTrue(makeFullCollection() instanceof Unmodifiable);
|
||||
}
|
||||
|
||||
|
||||
public void testDecorateFactory() {
|
||||
final Set<E> set = makeFullCollection();
|
||||
assertSame(set, UnmodifiableSet.unmodifiableSet(set));
|
||||
|
|
|
@ -443,5 +443,5 @@ public class PatriciaTrieTest<V> extends AbstractSortedMapTest<String, V> {
|
|||
// writeExternalFormToDisk(
|
||||
// (java.io.Serializable) map,
|
||||
// "src/test/resources/data/test/PatriciaTrie.fullCollection.version4.obj");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue