You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2015/06/01 23:54:52 UTC
svn commit: r1683010 -
/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/
Author: tn
Date: Mon Jun 1 21:54:51 2015
New Revision: 1683010
URL: http://svn.apache.org/r1683010
Log:
Convert to Junit 4 tests.
Modified:
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BagUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java
commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BagUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BagUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BagUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/BagUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,7 +16,9 @@
*/
package org.apache.commons.collections4;
-import junit.framework.Test;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.commons.collections4.bag.HashBag;
import org.apache.commons.collections4.bag.PredicatedBag;
@@ -29,31 +31,21 @@ import org.apache.commons.collections4.b
import org.apache.commons.collections4.bag.UnmodifiableBag;
import org.apache.commons.collections4.bag.UnmodifiableSortedBag;
import org.apache.commons.collections4.functors.TruePredicate;
+import org.junit.Test;
/**
* Tests for BagUtils factory methods.
*
* @version $Id$
*/
-public class BagUtilsTest extends BulkTest {
+public class BagUtilsTest {
- public BagUtilsTest(final String name) {
- super(name);
- }
-
-
- public static Test suite() {
- return BulkTest.makeSuite(BagUtilsTest.class);
- }
-
- //----------------------------------------------------------------------
-
- protected Class<?> stringClass = this.getName().getClass();
protected Predicate<Object> truePredicate = TruePredicate.truePredicate();
protected Transformer<Object, Object> nopTransformer = TransformerUtils.nopTransformer();
//----------------------------------------------------------------------
+ @Test
public void testSynchronizedBag() {
Bag<Object> bag = BagUtils.synchronizedBag(new HashBag<Object>());
assertTrue("Returned object should be a SynchronizedBag.",
@@ -66,6 +58,7 @@ public class BagUtilsTest extends BulkTe
}
}
+ @Test
public void testUnmodifiableBag() {
Bag<Object> bag = BagUtils.unmodifiableBag(new HashBag<Object>());
assertTrue("Returned object should be an UnmodifiableBag.",
@@ -80,6 +73,7 @@ public class BagUtilsTest extends BulkTe
assertSame("UnmodifiableBag shall not be decorated", bag, BagUtils.unmodifiableBag(bag));
}
+ @Test
public void testPredicatedBag() {
Bag<Object> bag = BagUtils.predicatedBag(new HashBag<Object>(), truePredicate);
assertTrue("Returned object should be a PredicatedBag.",
@@ -98,7 +92,8 @@ public class BagUtilsTest extends BulkTe
}
}
- public void testTransformedBag() {
+ @Test
+ public void testTransformedBag() {
Bag<Object> bag = BagUtils.transformingBag(new HashBag<Object>(), nopTransformer);
assertTrue("Returned object should be an TransformedBag.",
bag instanceof TransformedBag);
@@ -116,6 +111,7 @@ public class BagUtilsTest extends BulkTe
}
}
+ @Test
public void testSynchronizedSortedBag() {
Bag<Object> bag = BagUtils.synchronizedSortedBag(new TreeBag<Object>());
assertTrue("Returned object should be a SynchronizedSortedBag.",
@@ -128,6 +124,7 @@ public class BagUtilsTest extends BulkTe
}
}
+ @Test
public void testUnmodifiableSortedBag() {
SortedBag<Object> bag = BagUtils.unmodifiableSortedBag(new TreeBag<Object>());
assertTrue("Returned object should be an UnmodifiableSortedBag.",
@@ -142,6 +139,7 @@ public class BagUtilsTest extends BulkTe
assertSame("UnmodifiableSortedBag shall not be decorated", bag, BagUtils.unmodifiableSortedBag(bag));
}
+ @Test
public void testPredicatedSortedBag() {
Bag<Object> bag = BagUtils.predicatedSortedBag(new TreeBag<Object>(), truePredicate);
assertTrue("Returned object should be a PredicatedSortedBag.",
@@ -160,6 +158,7 @@ public class BagUtilsTest extends BulkTe
}
}
+ @Test
public void testTransformedSortedBag() {
Bag<Object> bag = BagUtils.transformingSortedBag(new TreeBag<Object>(), nopTransformer);
assertTrue("Returned object should be an TransformedSortedBag",
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ClosureUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,19 +16,23 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.commons.collections4.functors.EqualPredicate;
import org.apache.commons.collections4.functors.ExceptionClosure;
import org.apache.commons.collections4.functors.FalsePredicate;
import org.apache.commons.collections4.functors.NOPClosure;
import org.apache.commons.collections4.functors.TruePredicate;
+import org.junit.Test;
/**
* Tests the ClosureUtils class.
@@ -36,7 +40,7 @@ import org.apache.commons.collections4.f
* @since 3.0
* @version $Id$
*/
-public class ClosureUtilsTest extends TestCase {
+public class ClosureUtilsTest {
private static final Object cString = "Hello";
@@ -64,6 +68,7 @@ public class ClosureUtilsTest extends Te
// exceptionClosure
//------------------------------------------------------------------
+ @Test
public void testExceptionClosure() {
assertNotNull(ClosureUtils.exceptionClosure());
assertSame(ClosureUtils.exceptionClosure(), ClosureUtils.exceptionClosure());
@@ -82,6 +87,7 @@ public class ClosureUtilsTest extends Te
// nopClosure
//------------------------------------------------------------------
+ @Test
public void testNopClosure() {
final StringBuilder buf = new StringBuilder("Hello");
ClosureUtils.nopClosure().execute(null);
@@ -93,6 +99,7 @@ public class ClosureUtilsTest extends Te
// invokeClosure
//------------------------------------------------------------------
+ @Test
public void testInvokeClosure() {
StringBuffer buf = new StringBuffer("Hello"); // Only StringBuffer has setLength() method
ClosureUtils.invokerClosure("reverse").execute(buf);
@@ -105,6 +112,7 @@ public class ClosureUtilsTest extends Te
// forClosure
//------------------------------------------------------------------
+ @Test
public void testForClosure() {
final MockClosure<Object> cmd = new MockClosure<Object>();
ClosureUtils.forClosure(5, cmd).execute(null);
@@ -119,6 +127,7 @@ public class ClosureUtilsTest extends Te
// whileClosure
//------------------------------------------------------------------
+ @Test
public void testWhileClosure() {
MockClosure<Object> cmd = new MockClosure<Object>();
ClosureUtils.whileClosure(FalsePredicate.falsePredicate(), cmd).execute(null);
@@ -145,6 +154,7 @@ public class ClosureUtilsTest extends Te
// doWhileClosure
//------------------------------------------------------------------
+ @Test
public void testDoWhileClosure() {
MockClosure<Object> cmd = new MockClosure<Object>();
ClosureUtils.doWhileClosure(cmd, FalsePredicate.falsePredicate()).execute(null);
@@ -163,6 +173,7 @@ public class ClosureUtilsTest extends Te
// chainedClosure
//------------------------------------------------------------------
+ @Test
@SuppressWarnings("unchecked")
public void testChainedClosure() {
MockClosure<Object> a = new MockClosure<Object>();
@@ -218,6 +229,7 @@ public class ClosureUtilsTest extends Te
// ifClosure
//------------------------------------------------------------------
+ @Test
public void testIfClosure() {
MockClosure<Object> a = new MockClosure<Object>();
MockClosure<Object> b = null;
@@ -244,6 +256,7 @@ public class ClosureUtilsTest extends Te
// switchClosure
//------------------------------------------------------------------
+ @Test
@SuppressWarnings("unchecked")
public void testSwitchClosure() {
final MockClosure<String> a = new MockClosure<String>();
@@ -335,6 +348,7 @@ public class ClosureUtilsTest extends Te
// switchMapClosure
//------------------------------------------------------------------
+ @Test
public void testSwitchMapClosure() {
final MockClosure<String> a = new MockClosure<String>();
final MockClosure<String> b = new MockClosure<String>();
@@ -377,6 +391,7 @@ public class ClosureUtilsTest extends Te
// asClosure
//------------------------------------------------------------------
+ @Test
public void testTransformerClosure() {
final MockTransformer<Object> mock = new MockTransformer<Object>();
final Closure<Object> closure = ClosureUtils.asClosure(mock);
@@ -392,9 +407,10 @@ public class ClosureUtilsTest extends Te
//------------------------------------------------------------------
/**
- * Test that all Closure singletones hold singleton pattern in
+ * Test that all Closure singletons hold singleton pattern in
* serialization/deserialization process.
*/
+ @Test
public void testSingletonPatternInSerialization() {
final Object[] singletones = new Object[] {
ExceptionClosure.INSTANCE,
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/FactoryUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,6 +16,13 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -36,25 +43,12 @@ import org.junit.Test;
* @since 3.0
* @version $Id$
*/
-public class FactoryUtilsTest extends junit.framework.TestCase {
-
- /**
- * Set up instance variables required by this test case.
- */
- @Override
- public void setUp() {
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @Override
- public void tearDown() {
- }
+public class FactoryUtilsTest {
// exceptionFactory
//------------------------------------------------------------------
+ @Test
public void testExceptionFactory() {
assertNotNull(FactoryUtils.exceptionFactory());
assertSame(FactoryUtils.exceptionFactory(), FactoryUtils.exceptionFactory());
@@ -73,6 +67,7 @@ public class FactoryUtilsTest extends ju
// nullFactory
//------------------------------------------------------------------
+ @Test
public void testNullFactory() {
final Factory<Object> factory = FactoryUtils.nullFactory();
assertNotNull(factory);
@@ -83,6 +78,7 @@ public class FactoryUtilsTest extends ju
// constantFactory
//------------------------------------------------------------------
+ @Test
public void testConstantFactoryNull() {
final Factory<Object> factory = FactoryUtils.constantFactory(null);
assertNotNull(factory);
@@ -90,6 +86,7 @@ public class FactoryUtilsTest extends ju
assertNull(created);
}
+ @Test
public void testConstantFactoryConstant() {
final Integer constant = Integer.valueOf(9);
final Factory<Integer> factory = FactoryUtils.constantFactory(constant);
@@ -101,10 +98,12 @@ public class FactoryUtilsTest extends ju
// prototypeFactory
//------------------------------------------------------------------
+ @Test
public void testPrototypeFactoryNull() {
assertSame(ConstantFactory.NULL_INSTANCE, FactoryUtils.prototypeFactory(null));
}
+ @Test
public void testPrototypeFactoryPublicCloneMethod() throws Exception {
final Date proto = new Date();
final Factory<Date> factory = FactoryUtils.prototypeFactory(proto);
@@ -123,6 +122,7 @@ public class FactoryUtilsTest extends ju
in.close();
}
+ @Test
public void testPrototypeFactoryPublicCopyConstructor() throws Exception {
final Mock1 proto = new Mock1(6);
Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
@@ -149,6 +149,7 @@ public class FactoryUtilsTest extends ju
in.close();
}
+ @Test
public void testPrototypeFactoryPublicSerialization() throws Exception {
final Integer proto = Integer.valueOf(9);
final Factory<Integer> factory = FactoryUtils.prototypeFactory(proto);
@@ -167,6 +168,7 @@ public class FactoryUtilsTest extends ju
in.close();
}
+ @Test
public void testPrototypeFactoryPublicSerializationError() {
final Mock2 proto = new Mock2(new Object());
final Factory<Object> factory = FactoryUtils.<Object>prototypeFactory(proto);
@@ -180,6 +182,7 @@ public class FactoryUtilsTest extends ju
fail();
}
+ @Test
public void testPrototypeFactoryPublicBad() {
final Object proto = new Object();
try {
@@ -296,6 +299,7 @@ public class FactoryUtilsTest extends ju
* Test that all Factory singletones hold singleton pattern in
* serialization/deserialization process.
*/
+ @Test
public void testSingletonPatternInSerialization() {
final Object[] singletones = new Object[] {
ExceptionFactory.INSTANCE,
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/ListUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,6 +16,12 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -23,17 +29,17 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import junit.framework.Test;
-
import org.apache.commons.collections4.functors.EqualPredicate;
import org.apache.commons.collections4.list.PredicatedList;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for ListUtils.
*
* @version $Id$
*/
-public class ListUtilsTest extends BulkTest {
+public class ListUtilsTest {
private static final String a = "a";
private static final String b = "b";
@@ -45,26 +51,16 @@ public class ListUtilsTest extends BulkT
private String[] fullArray;
private List<String> fullList;
- public ListUtilsTest(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return BulkTest.makeSuite(ListUtilsTest.class);
- }
-
- @Override
+ @Before
public void setUp() {
fullArray = new String[]{a, b, c, d, e};
fullList = new ArrayList<String>(Arrays.asList(fullArray));
}
- public void testNothing() {
- }
-
/**
* Tests intersecting a non-empty list with an empty list.
*/
+ @Test
public void testIntersectNonEmptyWithEmptyList() {
final List<String> empty = Collections.<String>emptyList();
assertTrue("result not empty", ListUtils.intersection(empty, fullList).isEmpty());
@@ -73,14 +69,16 @@ public class ListUtilsTest extends BulkT
/**
* Tests intersecting a non-empty list with an empty list.
*/
+ @Test
public void testIntersectEmptyWithEmptyList() {
final List<?> empty = Collections.EMPTY_LIST;
assertTrue("result not empty", ListUtils.intersection(empty, empty).isEmpty());
}
/**
- * Tests intersecting a non-empty list with an subset of iteself.
+ * Tests intersecting a non-empty list with an subset of itself.
*/
+ @Test
public void testIntersectNonEmptySubset() {
// create a copy
final List<String> other = new ArrayList<String>(fullList);
@@ -94,8 +92,9 @@ public class ListUtilsTest extends BulkT
}
/**
- * Tests intersecting a non-empty list with an subset of iteself.
+ * Tests intersecting a non-empty list with an subset of itself.
*/
+ @Test
public void testIntersectListWithNoOverlapAndDifferentTypes() {
@SuppressWarnings("boxing")
final List<Integer> other = Arrays.asList(1, 23);
@@ -103,8 +102,9 @@ public class ListUtilsTest extends BulkT
}
/**
- * Tests intersecting a non-empty list with iteself.
+ * Tests intersecting a non-empty list with itself.
*/
+ @Test
public void testIntersectListWithSelf() {
assertEquals(fullList, ListUtils.intersection(fullList, fullList));
}
@@ -112,6 +112,7 @@ public class ListUtilsTest extends BulkT
/**
* Tests intersecting two lists in different orders.
*/
+ @Test
public void testIntersectionOrderInsensitivity() {
final List<String> one = new ArrayList<String>();
final List<String> two = new ArrayList<String>();
@@ -124,6 +125,7 @@ public class ListUtilsTest extends BulkT
assertEquals(ListUtils.intersection(one,two),ListUtils.intersection(two, one));
}
+ @Test
public void testPredicatedList() {
final Predicate<Object> predicate = new Predicate<Object>() {
public boolean evaluate(final Object o) {
@@ -146,6 +148,7 @@ public class ListUtilsTest extends BulkT
}
}
+ @Test
public void testLazyList() {
final List<Integer> list = ListUtils.lazyList(new ArrayList<Integer>(), new Factory<Integer>() {
@@ -164,6 +167,7 @@ public class ListUtilsTest extends BulkT
assertEquals(6, list.size());
}
+ @Test
public void testEmptyIfNull() {
assertTrue(ListUtils.emptyIfNull(null).isEmpty());
@@ -171,6 +175,7 @@ public class ListUtilsTest extends BulkT
assertSame(list, ListUtils.emptyIfNull(list));
}
+ @Test
public void testDefaultIfNull() {
assertTrue(ListUtils.defaultIfNull(null, Collections.emptyList()).isEmpty());
@@ -178,6 +183,7 @@ public class ListUtilsTest extends BulkT
assertSame(list, ListUtils.defaultIfNull(list, Collections.<Long>emptyList()));
}
+ @Test
public void testEquals() {
final Collection<String> data = Arrays.asList("a", "b", "c");
@@ -193,6 +199,7 @@ public class ListUtilsTest extends BulkT
assertEquals(true, ListUtils.isEqualList(null, null));
}
+ @Test
public void testHashCode() {
final Collection<String> data = Arrays.asList("a", "b", "c");
@@ -208,6 +215,7 @@ public class ListUtilsTest extends BulkT
assertEquals(0, ListUtils.hashCodeForList(null));
}
+ @Test
public void testRetainAll() {
final List<String> sub = new ArrayList<String>();
sub.add(a);
@@ -227,6 +235,7 @@ public class ListUtilsTest extends BulkT
} catch(final NullPointerException npe){} // this is what we want
}
+ @Test
public void testRemoveAll() {
final List<String> sub = new ArrayList<String>();
sub.add(a);
@@ -244,6 +253,7 @@ public class ListUtilsTest extends BulkT
} catch(final NullPointerException npe) {} // this is what we want
}
+ @Test
public void testSubtract() {
final List<String> list = new ArrayList<String>();
list.add(a);
@@ -270,6 +280,7 @@ public class ListUtilsTest extends BulkT
} catch(final NullPointerException npe) {} // this is what we want
}
+ @Test
public void testSubtractNullElement() {
final List<String> list = new ArrayList<String>();
list.add(a);
@@ -294,6 +305,7 @@ public class ListUtilsTest extends BulkT
/**
* Tests the <code>indexOf</code> method in <code>ListUtils</code> class..
*/
+ @Test
public void testIndexOf() {
Predicate<String> testPredicate = EqualPredicate.equalPredicate("d");
int index = ListUtils.indexOf(fullList, testPredicate);
@@ -307,6 +319,7 @@ public class ListUtilsTest extends BulkT
assertEquals(ListUtils.indexOf(fullList, null), -1);
}
+ @Test
@SuppressWarnings("boxing") // OK in test code
public void testLongestCommonSubsequence() {
@@ -348,6 +361,7 @@ public class ListUtilsTest extends BulkT
assertTrue(lcs.isEmpty());
}
+ @Test
public void testLongestCommonSubsequenceWithString() {
try {
@@ -383,8 +397,9 @@ public class ListUtilsTest extends BulkT
lcs = ListUtils.longestCommonSubsequence(banana, zorro);
assertEquals(0, lcs.length());
- }
+ }
+ @Test
@SuppressWarnings("boxing") // OK in test code
public void testPartition() {
final List<Integer> strings = new ArrayList<Integer>();
@@ -421,6 +436,7 @@ public class ListUtilsTest extends BulkT
}
};
+ @Test
@SuppressWarnings("boxing") // OK in test code
public void testSelect() {
final List<Integer> list = new ArrayList<Integer>();
@@ -438,6 +454,7 @@ public class ListUtilsTest extends BulkT
assertEquals(2, output2.iterator().next());
}
+ @Test
@SuppressWarnings("boxing") // OK in test code
public void testSelectRejected() {
final List<Long> list = new ArrayList<Long>();
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MapUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MapUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MapUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MapUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,6 +16,12 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.Collection;
@@ -30,8 +36,6 @@ import java.util.TreeMap;
import java.util.List;
import java.util.ArrayList;
-import junit.framework.Test;
-
import org.apache.commons.collections4.collection.TransformedCollectionTest;
import org.apache.commons.collections4.keyvalue.DefaultKeyValue;
import org.apache.commons.collections4.keyvalue.DefaultMapEntry;
@@ -39,6 +43,7 @@ import org.apache.commons.collections4.m
import org.apache.commons.collections4.map.LazyMap;
import org.apache.commons.collections4.map.MultiValueMap;
import org.apache.commons.collections4.map.PredicatedMap;
+import org.junit.Test;
/**
* Tests for MapUtils.
@@ -46,15 +51,7 @@ import org.apache.commons.collections4.m
* @version $Id$
*/
@SuppressWarnings("boxing")
-public class MapUtilsTest extends BulkTest {
-
- public MapUtilsTest(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return BulkTest.makeSuite(MapUtilsTest.class);
- }
+public class MapUtilsTest {
public Predicate<Object> getPredicate() {
return new Predicate<Object>() {
@@ -64,6 +61,7 @@ public class MapUtilsTest extends BulkTe
};
}
+ @Test
public void testPredicatedMap() {
final Predicate<Object> p = getPredicate();
Map<Object, Object> map = MapUtils.predicatedMap(new HashMap<Object, Object>(), p, p);
@@ -76,6 +74,7 @@ public class MapUtilsTest extends BulkTe
}
}
+ @Test
public void testLazyMapFactory() {
final Factory<Integer> factory = FactoryUtils.constantFactory(Integer.valueOf(5));
Map<Object, Object> map = MapUtils.lazyMap(new HashMap<Object, Object>(), factory);
@@ -109,6 +108,7 @@ public class MapUtilsTest extends BulkTe
}
}
+ @Test
public void testLazyMapTransformer() {
final Map<Object, Object> map = MapUtils.lazyMap(new HashMap<Object, Object>(), new Transformer<Object, Object>() {
public Object transform(final Object mapKey) {
@@ -129,6 +129,7 @@ public class MapUtilsTest extends BulkTe
assertSame(i1, i2);
}
+ @Test
public void testInvertMap() {
final Map<String, String> in = new HashMap<String, String>(5, 1);
in.put("1", "A");
@@ -155,6 +156,7 @@ public class MapUtilsTest extends BulkTe
assertEquals( "5", out.get("E"));
}
+ @Test
public void testPutAll_Map_array() {
try {
MapUtils.putAll(null, null);
@@ -266,6 +268,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(3, test.size());
}
+ @Test
public void testConvertResourceBundle() {
final Map<String, String> in = new HashMap<String, String>( 5 , 1 );
in.put("1", "A");
@@ -296,6 +299,7 @@ public class MapUtilsTest extends BulkTe
assertTrue( in.equals(out));
}
+ @Test
public void testDebugAndVerbosePrintCasting() {
final Map<Integer, String> inner = new HashMap<Integer, String>(2, 1);
inner.put(2, "B");
@@ -315,6 +319,7 @@ public class MapUtilsTest extends BulkTe
}
}
+ @Test
public void testDebugAndVerbosePrintNullMap() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -334,6 +339,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintNullLabel() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -357,6 +363,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testDebugPrintNullLabel() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -380,6 +387,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintNullLabelAndMap() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -392,6 +400,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testDebugPrintNullLabelAndMap() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -404,6 +413,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintNullStream() {
try {
MapUtils.verbosePrint(null, "Map", new HashMap<Object, Object>());
@@ -412,6 +422,7 @@ public class MapUtilsTest extends BulkTe
}
}
+ @Test
public void testDebugPrintNullStream() {
try {
MapUtils.debugPrint(null, "Map", new HashMap<Object, Object>());
@@ -420,6 +431,7 @@ public class MapUtilsTest extends BulkTe
}
}
+ @Test
public void testDebugPrintNullKey() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -439,6 +451,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintNullKey() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -458,6 +471,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testDebugPrintNullKeyToMap1() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -477,6 +491,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintNullKeyToMap1() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -496,6 +511,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testDebugPrintNullKeyToMap2() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -520,6 +536,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintNullKeyToMap2() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -544,6 +561,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrint() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -579,6 +597,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testDebugPrint() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -614,6 +633,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testVerbosePrintSelfReference() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -660,6 +680,7 @@ public class MapUtilsTest extends BulkTe
assertEquals(EXPECTED_OUT, out.toString());
}
+ @Test
public void testDebugPrintSelfReference() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
@@ -708,6 +729,7 @@ public class MapUtilsTest extends BulkTe
//-----------------------------------------------------------------------
+ @Test
public void testEmptyIfNull() {
assertTrue(MapUtils.emptyIfNull(null).isEmpty());
@@ -715,38 +737,45 @@ public class MapUtilsTest extends BulkTe
assertSame(map, MapUtils.emptyIfNull(map));
}
+ @Test
public void testIsEmptyWithEmptyMap() {
final Map<Object, Object> map = new HashMap<Object, Object>();
assertEquals(true, MapUtils.isEmpty(map));
}
+ @Test
public void testIsEmptyWithNonEmptyMap() {
final Map<String, String> map = new HashMap<String, String>();
map.put("item", "value");
assertEquals(false, MapUtils.isEmpty(map));
}
+ @Test
public void testIsEmptyWithNull() {
final Map<Object, Object> map = null;
assertEquals(true, MapUtils.isEmpty(map));
}
+ @Test
public void testIsNotEmptyWithEmptyMap() {
final Map<Object, Object> map = new HashMap<Object, Object>();
assertEquals(false, MapUtils.isNotEmpty(map));
}
+ @Test
public void testIsNotEmptyWithNonEmptyMap() {
final Map<String, String> map = new HashMap<String, String>();
map.put("item", "value");
assertEquals(true, MapUtils.isNotEmpty(map));
}
+ @Test
public void testIsNotEmptyWithNull() {
final Map<Object, Object> map = null;
assertEquals(false, MapUtils.isNotEmpty(map));
}
+ @Test
public void testPopulateMap() {
// Setup Test Data
final List<String> list = new ArrayList<String>();
@@ -801,6 +830,7 @@ public class MapUtilsTest extends BulkTe
}
+ @Test
public void testPopulateMultiMap() {
// Setup Test Data
final List<X> list = new ArrayList<X>();
@@ -825,6 +855,7 @@ public class MapUtilsTest extends BulkTe
}
}
+ @Test
public void testIterableMap() {
try {
MapUtils.iterableMap(null);
@@ -842,6 +873,7 @@ public class MapUtilsTest extends BulkTe
assertSame(hMap, MapUtils.iterableMap(hMap));
}
+ @Test
public void testIterableSortedMap() {
try {
MapUtils.iterableSortedMap(null);
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/MultiMapUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,13 +16,18 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.multimap.MultiValuedHashMap;
-
-import junit.framework.Test;
+import org.junit.Test;
/**
* Tests for MultiMapUtils
@@ -30,16 +35,9 @@ import junit.framework.Test;
* @since 4.1
* @version $Id$
*/
-public class MultiMapUtilsTest extends BulkTest {
-
- public static Test suite() {
- return BulkTest.makeSuite(MultiMapUtilsTest.class);
- }
-
- public MultiMapUtilsTest(String name) {
- super(name);
- }
+public class MultiMapUtilsTest {
+ @Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testEmptyUnmodifiableMultiValuedMap() {
final MultiValuedMap map = MultiMapUtils.EMPTY_MULTI_VALUED_MAP;
@@ -51,6 +49,7 @@ public class MultiMapUtilsTest extends B
}
}
+ @Test
public void testTypeSafeEmptyMultiValuedMap() {
final MultiValuedMap<String, String> map = MultiMapUtils.<String, String>emptyMultiValuedMap();
assertTrue(map.isEmpty());
@@ -61,6 +60,7 @@ public class MultiMapUtilsTest extends B
}
}
+ @Test
public void testEmptyIfNull() {
assertTrue(MultiMapUtils.emptyIfNull(null).isEmpty());
@@ -69,22 +69,26 @@ public class MultiMapUtilsTest extends B
assertFalse(MultiMapUtils.emptyIfNull(map).isEmpty());
}
+ @Test
public void testIsEmptyWithEmptyMap() {
final MultiValuedMap<Object, Object> map = new MultiValuedHashMap<Object, Object>();
assertEquals(true, MultiMapUtils.isEmpty(map));
}
+ @Test
public void testIsEmptyWithNonEmptyMap() {
final MultiValuedMap<String, String> map = new MultiValuedHashMap<String, String>();
map.put("item", "value");
assertEquals(false, MultiMapUtils.isEmpty(map));
}
+ @Test
public void testIsEmptyWithNull() {
final MultiValuedMap<Object, Object> map = null;
assertEquals(true, MultiMapUtils.isEmpty(map));
}
+ @Test
public void testGetCollection() {
assertNull(MultiMapUtils.getCollection(null, "key1"));
@@ -100,6 +104,7 @@ public class MultiMapUtilsTest extends B
}
}
+ @Test
public void testGetList() {
assertNull(MultiMapUtils.getList(null, "key1"));
@@ -116,6 +121,7 @@ public class MultiMapUtilsTest extends B
}
}
+ @Test
public void testGetSet() {
assertNull(MultiMapUtils.getList(null, "key1"));
@@ -133,6 +139,7 @@ public class MultiMapUtilsTest extends B
}
}
+ @Test
public void testGetBag() {
assertNull(MultiMapUtils.getBag(null, "key1"));
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/PredicateUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -48,22 +48,12 @@ import org.junit.Test;
*/
@SuppressWarnings("boxing")
public class PredicateUtilsTest extends AbstractPredicateTest {
- /**
- * Set up instance variables required by this test case.
- */
- public void setUp() {
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- public void tearDown() {
- }
// exceptionPredicate
//------------------------------------------------------------------
- @Test public void testExceptionPredicate() {
+ @Test
+ public void testExceptionPredicate() {
assertNotNull(PredicateUtils.exceptionPredicate());
assertSame(PredicateUtils.exceptionPredicate(), PredicateUtils.exceptionPredicate());
try {
@@ -81,7 +71,8 @@ public class PredicateUtilsTest extends
// notNullPredicate
//------------------------------------------------------------------
- @Test public void testIsNotNullPredicate() {
+ @Test
+ public void testIsNotNullPredicate() {
assertNotNull(PredicateUtils.notNullPredicate());
assertSame(PredicateUtils.notNullPredicate(), PredicateUtils.notNullPredicate());
assertEquals(false, PredicateUtils.notNullPredicate().evaluate(null));
@@ -93,7 +84,8 @@ public class PredicateUtilsTest extends
// identityPredicate
//------------------------------------------------------------------
- @Test public void testIdentityPredicate() {
+ @Test
+ public void testIdentityPredicate() {
assertSame(nullPredicate(), PredicateUtils.identityPredicate(null));
assertNotNull(PredicateUtils.identityPredicate(Integer.valueOf(6)));
assertEquals(false, PredicateUtils.identityPredicate(Integer.valueOf(6)).evaluate(null));
@@ -106,7 +98,8 @@ public class PredicateUtilsTest extends
// truePredicate
//------------------------------------------------------------------
- @Test public void testTruePredicate() {
+ @Test
+ public void testTruePredicate() {
assertNotNull(TruePredicate.truePredicate());
assertSame(TruePredicate.truePredicate(), TruePredicate.truePredicate());
assertEquals(true, TruePredicate.truePredicate().evaluate(null));
@@ -118,7 +111,8 @@ public class PredicateUtilsTest extends
// falsePredicate
//------------------------------------------------------------------
- @Test public void testFalsePredicate() {
+ @Test
+ public void testFalsePredicate() {
assertNotNull(FalsePredicate.falsePredicate());
assertSame(FalsePredicate.falsePredicate(), FalsePredicate.falsePredicate());
assertEquals(false, FalsePredicate.falsePredicate().evaluate(null));
@@ -130,7 +124,8 @@ public class PredicateUtilsTest extends
// notPredicate
//------------------------------------------------------------------
- @Test public void testNotPredicate() {
+ @Test
+ public void testNotPredicate() {
assertNotNull(PredicateUtils.notPredicate(TruePredicate.truePredicate()));
assertEquals(false, PredicateUtils.notPredicate(TruePredicate.truePredicate()).evaluate(null));
assertEquals(false, PredicateUtils.notPredicate(TruePredicate.truePredicate()).evaluate(cObject));
@@ -146,7 +141,8 @@ public class PredicateUtilsTest extends
// andPredicate
//------------------------------------------------------------------
- @Test public void testAndPredicate() {
+ @Test
+ public void testAndPredicate() {
assertEquals(true, PredicateUtils.andPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null));
assertEquals(false, PredicateUtils.andPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
assertEquals(false, PredicateUtils.andPredicate(FalsePredicate.falsePredicate(), TruePredicate.truePredicate()).evaluate(null));
@@ -162,7 +158,8 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@SuppressWarnings("unchecked")
- @Test public void testAllPredicate() {
+ @Test
+ public void testAllPredicate() {
assertTrue(AllPredicate.allPredicate(new Predicate[] {}), null);
assertEquals(true, AllPredicate.allPredicate(new Predicate[] {
TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate()}).evaluate(null));
@@ -224,7 +221,8 @@ public class PredicateUtilsTest extends
AllPredicate.allPredicate((Collection<Predicate<Object>>) null);
}
- @Test public void testAllPredicateEx5() {
+ @Test
+ public void testAllPredicateEx5() {
AllPredicate.allPredicate(Collections.<Predicate<Object>>emptyList());
}
@@ -239,7 +237,8 @@ public class PredicateUtilsTest extends
// orPredicate
//------------------------------------------------------------------
- @Test public void testOrPredicate() {
+ @Test
+ public void testOrPredicate() {
assertEquals(true, PredicateUtils.orPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null));
assertEquals(true, PredicateUtils.orPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
assertEquals(true, PredicateUtils.orPredicate(FalsePredicate.falsePredicate(), TruePredicate.truePredicate()).evaluate(null));
@@ -255,7 +254,8 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@SuppressWarnings("unchecked")
- @Test public void testAnyPredicate() {
+ @Test
+ public void testAnyPredicate() {
assertFalse(PredicateUtils.anyPredicate(new Predicate[] {}), null);
assertEquals(true, PredicateUtils.anyPredicate(new Predicate[] {
@@ -318,7 +318,8 @@ public class PredicateUtilsTest extends
PredicateUtils.anyPredicate((Collection<Predicate<Object>>) null);
}
- @Test public void testAnyPredicateEx5() {
+ @Test
+ public void testAnyPredicateEx5() {
PredicateUtils.anyPredicate(Collections.<Predicate<Object>>emptyList());
}
@@ -333,7 +334,8 @@ public class PredicateUtilsTest extends
// eitherPredicate
//------------------------------------------------------------------
- @Test public void testEitherPredicate() {
+ @Test
+ public void testEitherPredicate() {
assertEquals(false, PredicateUtils.eitherPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null));
assertEquals(true, PredicateUtils.eitherPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
assertEquals(true, PredicateUtils.eitherPredicate(FalsePredicate.falsePredicate(), TruePredicate.truePredicate()).evaluate(null));
@@ -349,7 +351,8 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@SuppressWarnings("unchecked")
- @Test public void testOnePredicate() {
+ @Test
+ public void testOnePredicate() {
assertFalse(PredicateUtils.onePredicate((Predicate<Object>[]) new Predicate[] {}), null);
assertEquals(false, PredicateUtils.onePredicate(new Predicate[] {
TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate()}).evaluate(null));
@@ -416,7 +419,8 @@ public class PredicateUtilsTest extends
}
@SuppressWarnings("unchecked")
- @Test public void testOnePredicateEx5() {
+ @Test
+ public void testOnePredicateEx5() {
PredicateUtils.onePredicate(Collections.EMPTY_LIST);
}
@@ -431,7 +435,8 @@ public class PredicateUtilsTest extends
// neitherPredicate
//------------------------------------------------------------------
- @Test public void testNeitherPredicate() {
+ @Test
+ public void testNeitherPredicate() {
assertEquals(false, PredicateUtils.neitherPredicate(TruePredicate.truePredicate(), TruePredicate.truePredicate()).evaluate(null));
assertEquals(false, PredicateUtils.neitherPredicate(TruePredicate.truePredicate(), FalsePredicate.falsePredicate()).evaluate(null));
assertEquals(false, PredicateUtils.neitherPredicate(FalsePredicate.falsePredicate(), TruePredicate.truePredicate()).evaluate(null));
@@ -447,7 +452,8 @@ public class PredicateUtilsTest extends
//------------------------------------------------------------------
@SuppressWarnings("unchecked")
- @Test public void testNonePredicate() {
+ @Test
+ public void testNonePredicate() {
assertTrue(PredicateUtils.nonePredicate(new Predicate[] {}), null);
assertEquals(false, PredicateUtils.nonePredicate(new Predicate[] {
TruePredicate.truePredicate(), TruePredicate.truePredicate(), TruePredicate.truePredicate() }).evaluate(null));
@@ -509,7 +515,8 @@ public class PredicateUtilsTest extends
PredicateUtils.nonePredicate((Collection<Predicate<Object>>) null);
}
- @Test public void testNonePredicateEx5() {
+ @Test
+ public void testNonePredicateEx5() {
PredicateUtils.nonePredicate(Collections.<Predicate<Object>>emptyList());
}
@@ -524,7 +531,8 @@ public class PredicateUtilsTest extends
// instanceofPredicate
//------------------------------------------------------------------
- @Test public void testInstanceOfPredicate() {
+ @Test
+ public void testInstanceOfPredicate() {
assertNotNull(PredicateUtils.instanceofPredicate(String.class));
assertEquals(false, PredicateUtils.instanceofPredicate(String.class).evaluate(null));
assertEquals(false, PredicateUtils.instanceofPredicate(String.class).evaluate(cObject));
@@ -535,7 +543,8 @@ public class PredicateUtilsTest extends
// uniquePredicate
//------------------------------------------------------------------
- @Test public void testUniquePredicate() {
+ @Test
+ public void testUniquePredicate() {
final Predicate<Object> p = PredicateUtils.uniquePredicate();
assertEquals(true, p.evaluate(new Object()));
assertEquals(true, p.evaluate(new Object()));
@@ -548,7 +557,8 @@ public class PredicateUtilsTest extends
// asPredicate(Transformer)
//------------------------------------------------------------------
- @Test public void testAsPredicateTransformer() {
+ @Test
+ public void testAsPredicateTransformer() {
assertEquals(false, PredicateUtils.asPredicate(TransformerUtils.<Boolean>nopTransformer()).evaluate(false));
assertEquals(true, PredicateUtils.asPredicate(TransformerUtils.<Boolean>nopTransformer()).evaluate(true));
}
@@ -566,7 +576,8 @@ public class PredicateUtilsTest extends
// invokerPredicate
//------------------------------------------------------------------
- @Test public void testInvokerPredicate() {
+ @Test
+ public void testInvokerPredicate() {
final List<Object> list = new ArrayList<Object>();
assertEquals(true, PredicateUtils.invokerPredicate("isEmpty").evaluate(list));
list.add(new Object());
@@ -591,7 +602,8 @@ public class PredicateUtilsTest extends
// invokerPredicate2
//------------------------------------------------------------------
- @Test public void testInvokerPredicate2() {
+ @Test
+ public void testInvokerPredicate2() {
final List<String> list = new ArrayList<String>();
assertEquals(false, PredicateUtils.invokerPredicate(
"contains", new Class[] {Object.class}, new Object[] {cString}).evaluate(list));
@@ -633,7 +645,8 @@ public class PredicateUtilsTest extends
// nullIsTrue
//------------------------------------------------------------------
- @Test public void testNullIsTruePredicate() {
+ @Test
+ public void testNullIsTruePredicate() {
assertEquals(true, PredicateUtils.nullIsTruePredicate(TruePredicate.truePredicate()).evaluate(null));
assertEquals(true, PredicateUtils.nullIsTruePredicate(TruePredicate.truePredicate()).evaluate(new Object()));
assertEquals(false, PredicateUtils.nullIsTruePredicate(FalsePredicate.falsePredicate()).evaluate(new Object()));
@@ -647,7 +660,8 @@ public class PredicateUtilsTest extends
// nullIsFalse
//------------------------------------------------------------------
- @Test public void testNullIsFalsePredicate() {
+ @Test
+ public void testNullIsFalsePredicate() {
assertEquals(false, PredicateUtils.nullIsFalsePredicate(TruePredicate.truePredicate()).evaluate(null));
assertEquals(true, PredicateUtils.nullIsFalsePredicate(TruePredicate.truePredicate()).evaluate(new Object()));
assertEquals(false, PredicateUtils.nullIsFalsePredicate(FalsePredicate.falsePredicate()).evaluate(new Object()));
@@ -661,7 +675,8 @@ public class PredicateUtilsTest extends
// transformed
//------------------------------------------------------------------
- @Test public void testTransformedPredicate() {
+ @Test
+ public void testTransformedPredicate() {
assertEquals(true, PredicateUtils.transformedPredicate(
TransformerUtils.nopTransformer(),
TruePredicate.truePredicate()).evaluate(new Object()));
@@ -685,7 +700,8 @@ public class PredicateUtilsTest extends
* Test that all Predicate singletones hold singleton pattern in
* serialization/deserialization process.
*/
- @Test public void testSingletonPatternInSerialization() {
+ @Test
+ public void testSingletonPatternInSerialization() {
final Object[] singletones = new Object[] {
ExceptionPredicate.INSTANCE,
FalsePredicate.INSTANCE,
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/QueueUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,39 +16,32 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.LinkedList;
import java.util.Queue;
-import junit.framework.Test;
-
import org.apache.commons.collections4.functors.TruePredicate;
import org.apache.commons.collections4.queue.PredicatedQueue;
import org.apache.commons.collections4.queue.TransformedQueue;
import org.apache.commons.collections4.queue.UnmodifiableQueue;
+import org.junit.Test;
/**
* Tests for QueueUtils factory methods.
*
* @version $Id$
*/
-public class QueueUtilsTest extends BulkTest {
-
- public QueueUtilsTest(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return BulkTest.makeSuite(QueueUtilsTest.class);
- }
-
- // ----------------------------------------------------------------------
+public class QueueUtilsTest {
- protected Class<?> stringClass = this.getName().getClass();
protected Predicate<Object> truePredicate = TruePredicate.truePredicate();
protected Transformer<Object, Object> nopTransformer = TransformerUtils.nopTransformer();
// ----------------------------------------------------------------------
+ @Test
public void testUnmodifiableQueue() {
Queue<Object> queue = QueueUtils.unmodifiableQueue(new LinkedList<Object>());
assertTrue("Returned object should be an UnmodifiableQueue.", queue instanceof UnmodifiableQueue);
@@ -62,6 +55,7 @@ public class QueueUtilsTest extends Bulk
assertSame("UnmodifiableQueue shall not be decorated", queue, QueueUtils.unmodifiableQueue(queue));
}
+ @Test
public void testPredicatedQueue() {
Queue<Object> queue = QueueUtils.predicatedQueue(new LinkedList<Object>(), truePredicate);
assertTrue("Returned object should be a PredicatedQueue.", queue instanceof PredicatedQueue);
@@ -79,6 +73,7 @@ public class QueueUtilsTest extends Bulk
}
}
+ @Test
public void testTransformedQueue() {
Queue<Object> queue = QueueUtils.transformingQueue(new LinkedList<Object>(), nopTransformer);
assertTrue("Returned object should be an TransformedQueue.", queue instanceof TransformedQueue);
@@ -96,6 +91,7 @@ public class QueueUtilsTest extends Bulk
}
}
+ @Test
public void testEmptyQueue() {
Queue<Object> queue = QueueUtils.emptyQueue();
assertTrue("Returned object should be an UnmodifiableQueue.", queue instanceof UnmodifiableQueue);
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SetUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,33 +16,27 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.Test;
-
import org.apache.commons.collections4.set.PredicatedSet;
+import org.junit.Test;
/**
* Tests for SetUtils.
*
* @version $Id$
*/
-public class SetUtilsTest extends BulkTest {
-
- public SetUtilsTest(final String name) {
- super(name);
- }
-
- public static Test suite() {
- return BulkTest.makeSuite(SetUtilsTest.class);
- }
-
- public void testNothing() {
- }
+public class SetUtilsTest {
+ @Test
public void testpredicatedSet() {
final Predicate<Object> predicate = new Predicate<Object>() {
public boolean evaluate(final Object o) {
@@ -65,6 +59,7 @@ public class SetUtilsTest extends BulkTe
}
}
+ @Test
public void testEmptyIfNull() {
assertTrue(SetUtils.emptyIfNull(null).isEmpty());
@@ -72,6 +67,7 @@ public class SetUtilsTest extends BulkTe
assertSame(set, SetUtils.emptyIfNull(set));
}
+ @Test
public void testEquals() {
final Collection<String> data = Arrays.asList("a", "b", "c");
@@ -87,6 +83,7 @@ public class SetUtilsTest extends BulkTe
assertEquals(true, SetUtils.isEqualSet(null, null));
}
+ @Test
public void testHashCode() {
final Collection<String> data = Arrays.asList("a", "b", "c");
@@ -102,6 +99,7 @@ public class SetUtilsTest extends BulkTe
assertEquals(0, SetUtils.hashCodeForSet(null));
}
+ @Test
public void testNewIdentityHashSet() {
Set<String> set = SetUtils.newIdentityHashSet();
String a = new String("a");
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/SplitMapUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,12 +16,20 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.collections4.functors.NOPTransformer;
import org.apache.commons.collections4.map.HashedMap;
import org.apache.commons.collections4.splitmap.TransformedSplitMap;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests for {@link TransformedSplitMap}
@@ -30,7 +38,7 @@ import org.apache.commons.collections4.s
* @version $Id$
*/
@SuppressWarnings("boxing")
-public class SplitMapUtilsTest extends BulkTest {
+public class SplitMapUtilsTest {
private Map<String, Integer> backingMap;
private TransformedSplitMap<String, String, String, Integer> transformedMap;
@@ -40,13 +48,8 @@ public class SplitMapUtilsTest extends B
}
};
- public SplitMapUtilsTest(final String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
backingMap = new HashMap<String, Integer>();
transformedMap = TransformedSplitMap.transformingMap(backingMap, NOPTransformer.<String> nopTransformer(),
stringToInt);
@@ -57,6 +60,7 @@ public class SplitMapUtilsTest extends B
// -----------------------------------------------------------------------
+ @Test
public void testReadableMap() {
final IterableMap<String, Integer> map = SplitMapUtils.readableMap(transformedMap);
@@ -118,11 +122,13 @@ public class SplitMapUtilsTest extends B
assertSame(map, SplitMapUtils.readableMap(map));
}
+ @Test
public void testAlreadyReadableMap() {
final HashedMap<String, Integer> hashedMap = new HashedMap<String, Integer>();
assertSame(hashedMap, SplitMapUtils.readableMap(hashedMap));
}
+ @Test
@SuppressWarnings("unchecked")
public void testWritableMap() {
final Map<String, String> map = SplitMapUtils.writableMap(transformedMap);
@@ -197,6 +203,7 @@ public class SplitMapUtilsTest extends B
assertSame(map, SplitMapUtils.writableMap((Put<String, String>) map));
}
+ @Test
public void testAlreadyWritableMap() {
final HashedMap<String, String> hashedMap = new HashedMap<String, String>();
assertSame(hashedMap, SplitMapUtils.writableMap(hashedMap));
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TransformerUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,6 +16,11 @@
*/
package org.apache.commons.collections4;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -32,6 +37,7 @@ import org.apache.commons.collections4.f
import org.apache.commons.collections4.functors.NOPTransformer;
import org.apache.commons.collections4.functors.StringValueTransformer;
import org.apache.commons.collections4.functors.TruePredicate;
+import org.junit.Test;
/**
* Tests the TransformerUtils class.
@@ -39,29 +45,16 @@ import org.apache.commons.collections4.f
* @since 3.0
* @version $Id$
*/
-public class TransformerUtilsTest extends junit.framework.TestCase {
+public class TransformerUtilsTest {
private static final Object cObject = new Object();
private static final Object cString = "Hello";
private static final Object cInteger = Integer.valueOf(6);
- /**
- * Set up instance variables required by this test case.
- */
- @Override
- public void setUp() {
- }
-
- /**
- * Tear down instance variables required by this test case.
- */
- @Override
- public void tearDown() {
- }
-
// exceptionTransformer
//------------------------------------------------------------------
+ @Test
public void testExceptionTransformer() {
assertNotNull(TransformerUtils.exceptionTransformer());
assertSame(TransformerUtils.exceptionTransformer(), TransformerUtils.exceptionTransformer());
@@ -80,6 +73,7 @@ public class TransformerUtilsTest extend
// nullTransformer
//------------------------------------------------------------------
+ @Test
public void testNullTransformer() {
assertNotNull(TransformerUtils.nullTransformer());
assertSame(TransformerUtils.nullTransformer(), TransformerUtils.nullTransformer());
@@ -92,6 +86,7 @@ public class TransformerUtilsTest extend
// nopTransformer
//------------------------------------------------------------------
+ @Test
public void testNopTransformer() {
assertNotNull(TransformerUtils.nullTransformer());
assertSame(TransformerUtils.nullTransformer(), TransformerUtils.nullTransformer());
@@ -104,6 +99,7 @@ public class TransformerUtilsTest extend
// constantTransformer
//------------------------------------------------------------------
+ @Test
public void testConstantTransformer() {
assertEquals(cObject, TransformerUtils.constantTransformer(cObject).transform(null));
assertEquals(cObject, TransformerUtils.constantTransformer(cObject).transform(cObject));
@@ -115,6 +111,7 @@ public class TransformerUtilsTest extend
// cloneTransformer
//------------------------------------------------------------------
+ @Test
public void testCloneTransformer() {
assertEquals(null, TransformerUtils.cloneTransformer().transform(null));
assertEquals(cString, TransformerUtils.cloneTransformer().transform(cString));
@@ -130,6 +127,7 @@ public class TransformerUtilsTest extend
// mapTransformer
//------------------------------------------------------------------
+ @Test
@SuppressWarnings("boxing") // OK in test code
public void testMapTransformer() {
final Map<Object, Integer> map = new HashMap<Object, Integer>();
@@ -146,6 +144,7 @@ public class TransformerUtilsTest extend
// commandTransformer
//------------------------------------------------------------------
+ @Test
public void testExecutorTransformer() {
assertEquals(null, TransformerUtils.asTransformer(ClosureUtils.nopClosure()).transform(null));
assertEquals(cObject, TransformerUtils.asTransformer(ClosureUtils.nopClosure()).transform(cObject));
@@ -162,6 +161,7 @@ public class TransformerUtilsTest extend
// predicateTransformer
//------------------------------------------------------------------
+ @Test
public void testPredicateTransformer() {
assertEquals(Boolean.TRUE, TransformerUtils.asTransformer(TruePredicate.truePredicate()).transform(null));
assertEquals(Boolean.TRUE, TransformerUtils.asTransformer(TruePredicate.truePredicate()).transform(cObject));
@@ -178,6 +178,7 @@ public class TransformerUtilsTest extend
// factoryTransformer
//------------------------------------------------------------------
+ @Test
public void testFactoryTransformer() {
assertEquals(null, TransformerUtils.asTransformer(FactoryUtils.nullFactory()).transform(null));
assertEquals(null, TransformerUtils.asTransformer(FactoryUtils.nullFactory()).transform(cObject));
@@ -194,6 +195,7 @@ public class TransformerUtilsTest extend
// chainedTransformer
//------------------------------------------------------------------
+ @Test
@SuppressWarnings("unchecked")
public void testChainedTransformer() {
final Transformer<Object, Object> a = TransformerUtils.<Object, Object>constantTransformer("A");
@@ -238,6 +240,7 @@ public class TransformerUtilsTest extend
// ifTransformer
//------------------------------------------------------------------
+ @Test
public void testIfTransformer() {
final Transformer<Object, String> a = TransformerUtils.constantTransformer("A");
final Transformer<Object, String> b = TransformerUtils.constantTransformer("B");
@@ -281,6 +284,7 @@ public class TransformerUtilsTest extend
// switchTransformer
//------------------------------------------------------------------
+ @Test
@SuppressWarnings("unchecked")
public void testSwitchTransformer() {
final Transformer<String, String> a = TransformerUtils.constantTransformer("A");
@@ -346,6 +350,7 @@ public class TransformerUtilsTest extend
// switchMapTransformer
//------------------------------------------------------------------
+ @Test
public void testSwitchMapTransformer() {
final Transformer<String, String> a = TransformerUtils.constantTransformer("A");
final Transformer<String, String> b = TransformerUtils.constantTransformer("B");
@@ -374,6 +379,7 @@ public class TransformerUtilsTest extend
// invokerTransformer
//------------------------------------------------------------------
+ @Test
public void testInvokerTransformer() {
final List<Object> list = new ArrayList<Object>();
assertEquals(Integer.valueOf(0), TransformerUtils.invokerTransformer("size").transform(list));
@@ -394,6 +400,7 @@ public class TransformerUtilsTest extend
// invokerTransformer2
//------------------------------------------------------------------
+ @Test
public void testInvokerTransformer2() {
final List<Object> list = new ArrayList<Object>();
assertEquals(Boolean.FALSE, TransformerUtils.invokerTransformer("contains",
@@ -430,6 +437,7 @@ public class TransformerUtilsTest extend
// stringValueTransformer
//------------------------------------------------------------------
+ @Test
public void testStringValueTransformer() {
assertNotNull( "StringValueTransformer should NEVER return a null value.",
TransformerUtils.stringValueTransformer().transform(null));
@@ -442,6 +450,7 @@ public class TransformerUtilsTest extend
// instantiateFactory
//------------------------------------------------------------------
+ @Test
public void testInstantiateTransformerNull() {
try {
TransformerUtils.instantiateTransformer(null, new Object[] { "str" });
@@ -472,6 +481,7 @@ public class TransformerUtilsTest extend
* Test that all Transformer singletons hold singleton pattern in
* serialization/deserialization process.
*/
+ @Test
public void testSingletonPatternInSerialization() {
final Object[] singletones = new Object[] {
CloneTransformer.INSTANCE,
Modified: commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java?rev=1683010&r1=1683009&r2=1683010&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java (original)
+++ commons/proper/collections/trunk/src/test/java/org/apache/commons/collections4/TrieUtilsTest.java Mon Jun 1 21:54:51 2015
@@ -16,29 +16,24 @@
*/
package org.apache.commons.collections4;
-import junit.framework.Test;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.commons.collections4.trie.PatriciaTrie;
import org.apache.commons.collections4.trie.UnmodifiableTrie;
+import org.junit.Test;
/**
* Tests for TrieUtils factory methods.
*
* @version $Id$
*/
-public class TrieUtilsTest extends BulkTest {
-
- public TrieUtilsTest(final String name) {
- super(name);
- }
-
-
- public static Test suite() {
- return BulkTest.makeSuite(TrieUtilsTest.class);
- }
+public class TrieUtilsTest {
//----------------------------------------------------------------------
+ @Test
public void testUnmodifiableTrie() {
Trie<String, Object> trie = TrieUtils.unmodifiableTrie(new PatriciaTrie<Object>());
assertTrue("Returned object should be an UnmodifiableTrie.",