You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2011/09/15 22:27:43 UTC
svn commit: r1171255 [3/5] - in /commons/sandbox/functor/trunk: ./
src/test/java/org/apache/commons/functor/
src/test/java/org/apache/commons/functor/adapter/
src/test/java/org/apache/commons/functor/core/
src/test/java/org/apache/commons/functor/core/...
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestNoOp.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestNoOp.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestNoOp.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestNoOp.java Thu Sep 15 20:27:39 2011
@@ -16,13 +16,14 @@
*/
package org.apache.commons.functor.core;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryProcedure;
import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.UnaryProcedure;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -30,17 +31,6 @@ import org.apache.commons.functor.UnaryP
*/
public class TestNoOp extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestNoOp(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestNoOp.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -48,20 +38,10 @@ public class TestNoOp extends BaseFuncto
return new NoOp();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testRun() throws Exception {
NoOp p = new NoOp();
p.run();
@@ -73,6 +53,7 @@ public class TestNoOp extends BaseFuncto
p.run("foo","bar");
}
+ @Test
public void testEquals() throws Exception {
NoOp p = new NoOp();
assertEquals(p,p);
@@ -83,6 +64,7 @@ public class TestNoOp extends BaseFuncto
assertObjectsAreNotEqual(p,new BinaryProcedure<Object, Object>() { public void run(Object a, Object b) { } });
}
+ @Test
public void testConstant() throws Exception {
assertEquals(NoOp.instance(),NoOp.instance());
assertSame(NoOp.instance(),NoOp.instance());
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestOffset.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestOffset.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestOffset.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestOffset.java Thu Sep 15 20:27:39 2011
@@ -16,13 +16,14 @@
*/
package org.apache.commons.functor.core;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.UnaryPredicate;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -30,17 +31,6 @@ import org.apache.commons.functor.UnaryP
*/
public class TestOffset extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestOffset(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestOffset.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -54,6 +44,7 @@ public class TestOffset extends BaseFunc
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testZero() throws Exception {
Predicate p = new Offset(0);
assertTrue( p.test());
@@ -61,6 +52,7 @@ public class TestOffset extends BaseFunc
assertTrue( p.test());
}
+ @Test
public void testBadArgs() throws Exception {
try {
new Offset(-1);
@@ -70,6 +62,7 @@ public class TestOffset extends BaseFunc
}
}
+ @Test
public void testTestNullary() throws Exception {
Predicate p = new Offset(3);
assertTrue(!p.test());
@@ -78,6 +71,7 @@ public class TestOffset extends BaseFunc
assertTrue(p.test());
}
+ @Test
public void testTestUnary() throws Exception {
UnaryPredicate<Object> p = new Offset(3);
assertTrue(!p.test(null));
@@ -86,6 +80,7 @@ public class TestOffset extends BaseFunc
assertTrue(p.test(null));
}
+ @Test
public void testTestBinary() throws Exception {
BinaryPredicate<Object, Object> p = new Offset(3);
assertTrue(!p.test(null,null));
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/TestRightIdentity.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,16 @@
*/
package org.apache.commons.functor.core;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+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 org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryFunction;
import org.apache.commons.functor.BinaryPredicate;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +33,6 @@ import org.apache.commons.functor.Binary
*/
public class TestRightIdentity extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestRightIdentity(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestRightIdentity.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -47,20 +40,10 @@ public class TestRightIdentity extends B
return RightIdentity.FUNCTION;
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testEvaluate() throws Exception {
BinaryFunction<Object, Object, Object> f = RightIdentity.FUNCTION;
assertNull(f.evaluate(null,null));
@@ -73,6 +56,7 @@ public class TestRightIdentity extends B
assertSame(obj,f.evaluate(obj,obj));
}
+ @Test
public void testTest() throws Exception {
BinaryPredicate<Object, Boolean> p = RightIdentity.PREDICATE;
assertTrue(p.test(null,Boolean.TRUE));
@@ -85,6 +69,7 @@ public class TestRightIdentity extends B
}
}
+ @Test
public void testEquals() throws Exception {
BinaryFunction<Object, Object, Object> f = RightIdentity.FUNCTION;
assertEquals(f,f);
@@ -95,6 +80,7 @@ public class TestRightIdentity extends B
assertObjectsAreNotEqual(f,Constant.of("abcde"));
}
+ @Test
public void testConstant() throws Exception {
assertEquals(RightIdentity.function(),RightIdentity.function());
}
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterable.java Thu Sep 15 20:27:39 2011
@@ -16,6 +16,12 @@
*/
package org.apache.commons.functor.core.collection;
+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.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
@@ -24,13 +30,13 @@ import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
import org.apache.commons.functor.core.Constant;
import org.apache.commons.functor.core.IsEqual;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -49,17 +55,6 @@ public class TestFilteredIterable extend
}
};
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestFilteredIterable(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestFilteredIterable.class);
- }
-
public Object makeFunctor() {
List<String> list = new ArrayList<String>();
list.add("xyzzy");
@@ -69,8 +64,8 @@ public class TestFilteredIterable extend
// Lifecycle
// ------------------------------------------------------------------------
+ @Before
public void setUp() throws Exception {
- super.setUp();
list = new ArrayList<Integer>();
evens = new ArrayList<Integer>();
for (int i = 0; i < 10; i++) {
@@ -81,8 +76,8 @@ public class TestFilteredIterable extend
}
}
+ @After
public void tearDown() throws Exception {
- super.tearDown();
list = null;
evens = null;
}
@@ -90,6 +85,7 @@ public class TestFilteredIterable extend
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testSomePass() {
Iterator<Integer> expected = evens.iterator();
@@ -100,6 +96,7 @@ public class TestFilteredIterable extend
assertFalse(expected.hasNext());
}
+ @Test
public void testAllPass() {
Iterator<Integer> expected = evens.iterator();
@@ -110,6 +107,7 @@ public class TestFilteredIterable extend
assertFalse(expected.hasNext());
}
+ @Test
public void testAllPass2() {
Iterator<Integer> expected = list.iterator();
for (Integer i : FilteredIterable.of(list)) {
@@ -119,18 +117,22 @@ public class TestFilteredIterable extend
assertFalse(expected.hasNext());
}
+ @Test
public void testEmptyFilteredIterable() {
assertFalse(FilteredIterable.empty().iterator().hasNext());
}
+ @Test
public void testEmptyList() {
assertFalse(FilteredIterable.of(Collections.EMPTY_LIST).iterator().hasNext());
}
+ @Test
public void testNonePass() {
assertFalse(FilteredIterable.of(list).retain(Constant.falsePredicate()).iterator().hasNext());
}
+ @Test
public void testNextWithoutHasNext() {
Iterator<Integer> testing = FilteredIterable.of(list).retain(isEven).iterator();
Iterator<Integer> expected = evens.iterator();
@@ -140,6 +142,7 @@ public class TestFilteredIterable extend
assertFalse(testing.hasNext());
}
+ @Test
public void testNextAfterEndOfList() {
Iterator<Integer> testing = FilteredIterable.of(list).retain(isEven).iterator();
Iterator<Integer> expected = evens.iterator();
@@ -154,6 +157,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testNextOnEmptyList() {
try {
FilteredIterable.empty().iterator().next();
@@ -163,6 +167,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testRemoveBeforeNext() {
Iterator<Integer> testing = FilteredIterable.of(list).retain(isEven).iterator();
try {
@@ -173,6 +178,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testRemoveAfterNext() {
Iterator<Integer> testing = FilteredIterable.of(list).retain(isEven).iterator();
testing.next();
@@ -185,6 +191,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testRemoveSome() {
Iterator<Integer> testing = FilteredIterable.of(list).retain(isEven).iterator();
while (testing.hasNext()) {
@@ -194,6 +201,7 @@ public class TestFilteredIterable extend
assertTrue(Collections.disjoint(list, evens));
}
+ @Test
public void testRemoveAll() {
Iterator<Integer> testing = FilteredIterable.of(list).iterator();
while (testing.hasNext()) {
@@ -203,6 +211,7 @@ public class TestFilteredIterable extend
assertTrue(list.isEmpty());
}
+ @Test
public void testRemoveWithoutHasNext() {
Iterator<Integer> testing = FilteredIterable.of(list).iterator();
for (int i = 0, m = list.size(); i < m; i++) {
@@ -212,10 +221,12 @@ public class TestFilteredIterable extend
assertTrue(list.isEmpty());
}
+ @Test
public void testFilterWithNullIteratorReturnsNull() {
assertNull(FilteredIterable.of(null));
}
+ @Test
public void testRetainOneType() {
Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L, BigInteger.ZERO);
Iterable<String> strings = FilteredIterable.of(objects).retain(String.class);
@@ -224,6 +235,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testRetainOneType2() {
Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L, BigInteger.ZERO);
Iterator<Number> iterator = FilteredIterable.of(objects).retain(Number.class).iterator();
@@ -232,6 +244,7 @@ public class TestFilteredIterable extend
assertFalse(iterator.hasNext());
}
+ @Test
public void testRetainMultipleTypes() {
Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L, BigInteger.ZERO);
Iterator<Object> iterator = FilteredIterable.of(objects).retain(Long.class, BigInteger.class).iterator();
@@ -240,6 +253,7 @@ public class TestFilteredIterable extend
assertFalse(iterator.hasNext());
}
+ @Test
public void testMultipleLevels() {
Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L, BigInteger.ZERO);
Iterator<String> iterator = FilteredIterable.of(objects).retain(String.class).retain(IsEqual.to("foo"))
@@ -248,6 +262,7 @@ public class TestFilteredIterable extend
assertFalse(iterator.hasNext());
}
+ @Test
public void testMultipleLevels2() {
Iterable<Object> objects = Arrays.asList((Object) "foo", "bar", "baz", 2L, BigInteger.ZERO);
Iterator<Long> iterator = FilteredIterable.of(objects).retain(Number.class).retain(Long.class).iterator();
@@ -255,6 +270,7 @@ public class TestFilteredIterable extend
assertFalse(iterator.hasNext());
}
+ @Test
public void testRetainNullType() {
try {
FilteredIterable.of(Collections.singleton("foo")).retain((Class<?>) null);
@@ -264,6 +280,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testRetainNullTypes() {
try {
FilteredIterable.of(Collections.singleton("foo")).retain((Class<?>[]) null);
@@ -273,6 +290,7 @@ public class TestFilteredIterable extend
}
}
+ @Test
public void testRetainNullPredicate() {
try {
FilteredIterable.of(Collections.singleton("foo")).retain((UnaryPredicate<String>) null);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java Thu Sep 15 20:27:39 2011
@@ -16,18 +16,24 @@
*/
package org.apache.commons.functor.core.collection;
+import static org.junit.Assert.assertEquals;
+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.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -36,28 +42,14 @@ import org.apache.commons.functor.core.C
@SuppressWarnings("unchecked")
public class TestFilteredIterator extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestFilteredIterator(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestFilteredIterator.class);
- }
-
public Object makeFunctor() {
List list = new ArrayList();
list.add("xyzzy");
return FilteredIterator.filter(list.iterator(),Constant.truePredicate());
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
+ @Before
public void setUp() throws Exception {
- super.setUp();
list = new ArrayList();
evens = new ArrayList();
for (int i=0;i<10;i++) {
@@ -68,8 +60,8 @@ public class TestFilteredIterator extend
}
}
+ @After
public void tearDown() throws Exception {
- super.tearDown();
list = null;
evens = null;
}
@@ -77,6 +69,7 @@ public class TestFilteredIterator extend
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testSomePass() {
Iterator expected = evens.iterator();
Iterator testing = new FilteredIterator(list.iterator(),isEven);
@@ -87,6 +80,7 @@ public class TestFilteredIterator extend
assertTrue(!testing.hasNext());
}
+ @Test
public void testAllPass() {
Iterator expected = evens.iterator();
Iterator testing = new FilteredIterator(evens.iterator(),isEven);
@@ -97,6 +91,7 @@ public class TestFilteredIterator extend
assertTrue(!testing.hasNext());
}
+ @Test
public void testAllPass2() {
Iterator expected = list.iterator();
Iterator testing = new FilteredIterator(list.iterator(),Constant.truePredicate());
@@ -107,16 +102,19 @@ public class TestFilteredIterator extend
assertTrue(!testing.hasNext());
}
+ @Test
public void testEmptyList() {
Iterator testing = new FilteredIterator(Collections.EMPTY_LIST.iterator(),isEven);
assertTrue(!testing.hasNext());
}
+ @Test
public void testNonePass() {
Iterator testing = new FilteredIterator(Collections.EMPTY_LIST.iterator(),Constant.falsePredicate());
assertTrue(!testing.hasNext());
}
+ @Test
public void testNextWithoutHasNext() {
Iterator testing = new FilteredIterator(list.iterator(),isEven);
Iterator expected = evens.iterator();
@@ -126,6 +124,7 @@ public class TestFilteredIterator extend
assertTrue(!(testing.hasNext()));
}
+ @Test
public void testNextAfterEndOfList() {
Iterator testing = new FilteredIterator(list.iterator(),isEven);
Iterator expected = evens.iterator();
@@ -140,6 +139,7 @@ public class TestFilteredIterator extend
}
}
+ @Test
public void testNextOnEmptyList() {
Iterator testing = new FilteredIterator(Collections.EMPTY_LIST.iterator(),isEven);
try {
@@ -150,6 +150,7 @@ public class TestFilteredIterator extend
}
}
+ @Test
public void testRemoveBeforeNext() {
Iterator testing = new FilteredIterator(list.iterator(),isEven);
try {
@@ -160,6 +161,7 @@ public class TestFilteredIterator extend
}
}
+ @Test
public void testRemoveAfterNext() {
Iterator testing = new FilteredIterator(list.iterator(),isEven);
testing.next();
@@ -172,6 +174,7 @@ public class TestFilteredIterator extend
}
}
+ @Test
public void testRemoveSome() {
Iterator testing = new FilteredIterator(list.iterator(),isEven);
while(testing.hasNext()) {
@@ -183,6 +186,7 @@ public class TestFilteredIterator extend
}
}
+ @Test
public void testRemoveAll() {
Iterator testing = new FilteredIterator(list.iterator(),Constant.truePredicate());
while(testing.hasNext()) {
@@ -192,6 +196,7 @@ public class TestFilteredIterator extend
assertTrue(list.isEmpty());
}
+ @Test
public void testRemoveWithoutHasNext() {
Iterator testing = new FilteredIterator(list.iterator(),Constant.truePredicate());
for (int i=0,m = list.size();i<m;i++) {
@@ -201,15 +206,18 @@ public class TestFilteredIterator extend
assertTrue(list.isEmpty());
}
+ @Test
public void testFilterWithNullIteratorReturnsNull() {
assertNull(FilteredIterator.filter(null,Constant.truePredicate()));
}
+ @Test
public void testFilterWithNullPredicateReturnsIdentity() {
Iterator iter = list.iterator();
assertSame(iter,FilteredIterator.filter(iter,null));
}
+ @Test
public void testConstructorProhibitsNull() {
try {
new FilteredIterator(null,null);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsElementOf.java Thu Sep 15 20:27:39 2011
@@ -16,14 +16,16 @@
*/
package org.apache.commons.functor.core.collection;
-import java.util.ArrayList;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.util.ArrayList;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -33,17 +35,6 @@ import org.apache.commons.functor.core.C
@SuppressWarnings("unchecked")
public class TestIsElementOf extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsElementOf(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsElementOf.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -51,12 +42,10 @@ public class TestIsElementOf extends Bas
return new IsElementOf();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTestCollection() throws Exception {
ArrayList list = new ArrayList();
list.add(new Integer(5));
@@ -73,6 +62,7 @@ public class TestIsElementOf extends Bas
}
+ @Test
public void testTestArray() throws Exception {
int[] list = new int[] { 5, 10, 15 };
@@ -85,12 +75,14 @@ public class TestIsElementOf extends Bas
assertTrue(!p.test(new Integer(11)));
}
+ @Test
public void testTestArrayWithNull() throws Exception {
assertTrue(! IsElementOf.instance().test(null,new int[] { 5, 10, 15 }));
assertTrue(IsElementOf.instance().test(null,new Integer[] { new Integer(5), null, new Integer(15) }));
assertTrue(IsElementOf.instance().test(new Integer(15),new Integer[] { new Integer(5), null, new Integer(15) }));
}
+ @Test
public void testWrapNull() {
try {
IsElementOf.instance(null);
@@ -100,6 +92,7 @@ public class TestIsElementOf extends Bas
}
}
+ @Test
public void testWrapNonCollection() {
try {
IsElementOf.instance(new Integer(3));
@@ -109,6 +102,7 @@ public class TestIsElementOf extends Bas
}
}
+ @Test
public void testTestNull() {
try {
IsElementOf.instance().test(new Integer(5),null);
@@ -118,6 +112,7 @@ public class TestIsElementOf extends Bas
}
}
+ @Test
public void testTestNonCollection() {
try {
IsElementOf.instance().test(new Integer(5),new Long(5));
@@ -127,6 +122,7 @@ public class TestIsElementOf extends Bas
}
}
+ @Test
public void testEquals() throws Exception {
IsElementOf p1 = new IsElementOf();
assertObjectsAreEqual(p1, p1);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestIsEmpty.java Thu Sep 15 20:27:39 2011
@@ -16,6 +16,10 @@
*/
package org.apache.commons.functor.core.collection;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -24,12 +28,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryPredicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -38,17 +40,6 @@ import org.apache.commons.functor.core.C
@SuppressWarnings("unchecked")
public class TestIsEmpty extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsEmpty(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsEmpty.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -56,20 +47,10 @@ public class TestIsEmpty extends BaseFun
return new IsEmpty();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
assertTrue(IsEmpty.instance().test(Collections.EMPTY_LIST));
assertTrue(IsEmpty.instance().test(Collections.EMPTY_SET));
@@ -87,6 +68,7 @@ public class TestIsEmpty extends BaseFun
}
}
+ @Test
public void testTestNull() throws Exception {
try {
IsEmpty.instance().test(null);
@@ -96,6 +78,7 @@ public class TestIsEmpty extends BaseFun
}
}
+ @Test
public void testTestNonCollection() throws Exception {
try {
IsEmpty.instance().test(new Integer(3));
@@ -105,6 +88,7 @@ public class TestIsEmpty extends BaseFun
}
}
+ @Test
public void testTestArray() throws Exception {
assertTrue(! IsEmpty.instance().test(new int[10]));
assertTrue(! IsEmpty.instance().test(new Object[10]));
@@ -112,11 +96,13 @@ public class TestIsEmpty extends BaseFun
assertTrue(IsEmpty.instance().test(new Object[0]));
}
+ @Test
public void testTestString() throws Exception {
assertTrue(! IsEmpty.instance().test("xyzzy"));
assertTrue(IsEmpty.instance().test(""));
}
+ @Test
public void testTestMap() throws Exception {
Map map = new HashMap();
assertTrue(IsEmpty.instance().test(map));
@@ -124,6 +110,7 @@ public class TestIsEmpty extends BaseFun
assertTrue(! IsEmpty.instance().test(map));
}
+ @Test
public void testEquals() throws Exception {
UnaryPredicate p = new IsEmpty();
assertEquals(p,p);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestSize.java Thu Sep 15 20:27:39 2011
@@ -16,18 +16,21 @@
*/
package org.apache.commons.functor.core.collection;
+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.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryFunction;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -36,17 +39,6 @@ import org.apache.commons.functor.core.C
@SuppressWarnings("unchecked")
public class TestSize extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestSize(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestSize.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -54,20 +46,10 @@ public class TestSize extends BaseFuncto
return new Size();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testEvaluate() throws Exception {
assertEquals(new Integer(0),Size.instance().evaluate(Collections.EMPTY_LIST));
assertEquals(new Integer(0),Size.instance().evaluate(Collections.EMPTY_SET));
@@ -91,6 +73,7 @@ public class TestSize extends BaseFuncto
}
}
+ @Test
public void testEvaluateNull() throws Exception {
try {
Size.instance().evaluate(null);
@@ -100,6 +83,7 @@ public class TestSize extends BaseFuncto
}
}
+ @Test
public void testEvaluateNonCollection() throws Exception {
try {
Size.instance().evaluate(new Integer(3));
@@ -109,15 +93,18 @@ public class TestSize extends BaseFuncto
}
}
+ @Test
public void testEvaluateArray() throws Exception {
assertEquals(new Integer(10),Size.instance().evaluate(new int[10]));
assertEquals(new Integer(7),Size.instance().evaluate(new String[7]));
}
+ @Test
public void testEvaluateString() throws Exception {
assertEquals(new Integer("xyzzy".length()),Size.instance().evaluate("xyzzy"));
}
+ @Test
public void testEquals() throws Exception {
UnaryFunction f = new Size();
assertEquals(f,f);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestTransformedIterator.java Thu Sep 15 20:27:39 2011
@@ -16,18 +16,24 @@
*/
package org.apache.commons.functor.core.collection;
+import static org.junit.Assert.assertEquals;
+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.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.UnaryFunction;
import org.apache.commons.functor.core.Identity;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -36,17 +42,6 @@ import org.apache.commons.functor.core.I
@SuppressWarnings("unchecked")
public class TestTransformedIterator extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestTransformedIterator(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestTransformedIterator.class);
- }
-
public Object makeFunctor() {
List list = new ArrayList();
list.add("xyzzy");
@@ -56,8 +51,8 @@ public class TestTransformedIterator ext
// Lifecycle
// ------------------------------------------------------------------------
+ @Before
public void setUp() throws Exception {
- super.setUp();
list = new ArrayList();
negatives = new ArrayList();
for (int i=0;i<10;i++) {
@@ -66,8 +61,8 @@ public class TestTransformedIterator ext
}
}
+ @After
public void tearDown() throws Exception {
- super.tearDown();
list = null;
negatives = null;
}
@@ -75,6 +70,7 @@ public class TestTransformedIterator ext
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testBasicTransform() {
Iterator expected = negatives.iterator();
Iterator testing = new TransformedIterator(list.iterator(),negate);
@@ -85,11 +81,13 @@ public class TestTransformedIterator ext
assertTrue(!testing.hasNext());
}
+ @Test
public void testEmptyList() {
Iterator testing = new TransformedIterator(Collections.EMPTY_LIST.iterator(),negate);
assertTrue(!testing.hasNext());
}
+ @Test
public void testNextWithoutHasNext() {
Iterator testing = new TransformedIterator(list.iterator(),negate);
Iterator expected = negatives.iterator();
@@ -99,6 +97,7 @@ public class TestTransformedIterator ext
assertTrue(!(testing.hasNext()));
}
+ @Test
public void testNextAfterEndOfList() {
Iterator testing = new TransformedIterator(list.iterator(),negate);
Iterator expected = negatives.iterator();
@@ -113,6 +112,7 @@ public class TestTransformedIterator ext
}
}
+ @Test
public void testNextOnEmptyList() {
Iterator testing = new TransformedIterator(Collections.EMPTY_LIST.iterator(),negate);
try {
@@ -123,6 +123,7 @@ public class TestTransformedIterator ext
}
}
+ @Test
public void testRemoveBeforeNext() {
Iterator testing = new TransformedIterator(list.iterator(),negate);
try {
@@ -133,6 +134,7 @@ public class TestTransformedIterator ext
}
}
+ @Test
public void testRemoveAfterNext() {
Iterator testing = new TransformedIterator(list.iterator(),negate);
testing.next();
@@ -145,6 +147,7 @@ public class TestTransformedIterator ext
}
}
+ @Test
public void testRemoveAll() {
Iterator testing = new TransformedIterator(list.iterator(),negate);
while(testing.hasNext()) {
@@ -154,6 +157,7 @@ public class TestTransformedIterator ext
assertTrue(list.isEmpty());
}
+ @Test
public void testRemoveWithoutHasNext() {
Iterator testing = new TransformedIterator(list.iterator(),negate);
for (int i=0,m = list.size();i<m;i++) {
@@ -163,15 +167,18 @@ public class TestTransformedIterator ext
assertTrue(list.isEmpty());
}
+ @Test
public void testTransformWithNullIteratorReturnsNull() {
assertNull(TransformedIterator.transform(null,negate));
}
+ @Test
public void testTransformWithNullPredicateReturnsIdentity() {
Iterator iter = list.iterator();
assertSame(iter,TransformedIterator.maybeTransform(iter,null));
}
+ @Test
public void testConstructorProhibitsNull() {
try {
new TransformedIterator(null,null);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/BaseComparisonPredicateTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/BaseComparisonPredicateTest.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/BaseComparisonPredicateTest.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/BaseComparisonPredicateTest.java Thu Sep 15 20:27:39 2011
@@ -16,8 +16,11 @@
*/
package org.apache.commons.functor.core.comparator;
+import static org.junit.Assert.fail;
+
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -25,27 +28,10 @@ import org.apache.commons.functor.Binary
*/
public abstract class BaseComparisonPredicateTest extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public BaseComparisonPredicateTest(String testName) {
- super(testName);
- }
-
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public final void testTestNull() throws Exception {
@SuppressWarnings("unchecked")
BinaryPredicate<Object, Object> p = (BinaryPredicate<Object, Object>)(makeFunctor());
@@ -69,6 +55,7 @@ public abstract class BaseComparisonPred
}
}
+ @Test
public final void testTestNonComparable() throws Exception {
@SuppressWarnings("unchecked")
BinaryPredicate<Object, Object> p = (BinaryPredicate<Object, Object>)(makeFunctor());
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparableComparator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparableComparator.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparableComparator.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparableComparator.java Thu Sep 15 20:27:39 2011
@@ -16,41 +16,22 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
/**
* @version $Revision$ $Date$
* @author Rodney Waldhoff
*/
-public class TestComparableComparator extends TestCase {
-
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestComparableComparator(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestComparableComparator.class);
- }
-
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
+public class TestComparableComparator {
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testCompareIntegers() {
assertTrue(ComparableComparator.instance().compare(new Integer(Integer.MIN_VALUE),new Integer(Integer.MIN_VALUE)) == 0);
assertTrue(ComparableComparator.instance().compare(new Integer(-1),new Integer(-1)) == 0);
@@ -59,6 +40,7 @@ public class TestComparableComparator ex
assertTrue(ComparableComparator.instance().compare(new Integer(1),new Integer(1)) == 0);
}
+ @Test
public void testCompareIncomparable() {
try {
ComparableComparator.instance().compare(new Object(),new Integer(2));
@@ -68,6 +50,7 @@ public class TestComparableComparator ex
}
}
+ @Test
public void testCompareNull() {
try {
ComparableComparator.instance().compare(null,new Integer(2));
@@ -77,6 +60,7 @@ public class TestComparableComparator ex
}
}
+ @Test
public void testEqualsAndHashCode() {
assertEquals(new ComparableComparator(),new ComparableComparator());
assertEquals(new ComparableComparator().hashCode(),new ComparableComparator().hashCode());
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestComparatorFunction.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import java.util.Collections;
+import static org.junit.Assert.assertTrue;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.util.Collections;
import org.apache.commons.functor.BaseFunctorTest;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +29,6 @@ import org.apache.commons.functor.BaseFu
*/
public class TestComparatorFunction extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestComparatorFunction(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestComparatorFunction.class);
- }
-
// Framework
// ------------------------------------------------------------------------
@@ -50,6 +39,7 @@ public class TestComparatorFunction exte
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testEvaluate() {
ComparatorFunction<Integer> f = ComparatorFunction.<Integer>instance();
@@ -84,6 +74,7 @@ public class TestComparatorFunction exte
assertTrue(((Integer)(f.evaluate(new Integer(Integer.MIN_VALUE),new Integer(Integer.MIN_VALUE)))).intValue() == 0);
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() {
ComparatorFunction<Comparable<?>> f = ComparatorFunction.instance();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsEquivalent.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,11 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -27,17 +28,6 @@ import org.apache.commons.functor.core.C
*/
public class TestIsEquivalent extends BaseComparisonPredicateTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsEquivalent(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsEquivalent.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -45,20 +35,10 @@ public class TestIsEquivalent extends Ba
return IsEquivalent.INSTANCE;
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsEquivalent<Integer> p = IsEquivalent.<Integer>instance();
assertTrue(!p.test(new Integer(2),new Integer(4)));
@@ -68,11 +48,13 @@ public class TestIsEquivalent extends Ba
assertTrue(!p.test(new Integer(6),new Integer(4)));
}
+ @Test
public void testInstance() {
assertTrue(IsEquivalent.instance("Xyzzy").test("Xyzzy"));
assertTrue(!IsEquivalent.instance("Xyzzy").test("z"));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() throws Exception {
IsEquivalent<Comparable<?>> p = IsEquivalent.INSTANCE;
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThan.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -27,17 +29,6 @@ import org.apache.commons.functor.core.C
*/
public class TestIsGreaterThan extends BaseComparisonPredicateTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsGreaterThan(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsGreaterThan.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -45,20 +36,10 @@ public class TestIsGreaterThan extends B
return new IsGreaterThan<Comparable<?>>();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsGreaterThan<Integer> p = new IsGreaterThan<Integer>();
assertFalse(p.test(new Integer(2),new Integer(4)));
@@ -68,11 +49,13 @@ public class TestIsGreaterThan extends B
assertTrue(p.test(new Integer(6),new Integer(4)));
}
+ @Test
public void testInstance() {
assertTrue(IsGreaterThan.instance(new Integer(7)).test(new Integer(8)));
assertTrue(! IsGreaterThan.instance(new Integer(7)).test(new Integer(6)));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() throws Exception {
IsGreaterThan<Comparable<?>> p = new IsGreaterThan<Comparable<?>>();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsGreaterThanOrEqual.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -27,17 +29,6 @@ import org.apache.commons.functor.core.C
*/
public class TestIsGreaterThanOrEqual extends BaseComparisonPredicateTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsGreaterThanOrEqual(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsGreaterThanOrEqual.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -45,20 +36,10 @@ public class TestIsGreaterThanOrEqual ex
return new IsGreaterThanOrEqual<Comparable<?>>();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsGreaterThanOrEqual<Integer> p = new IsGreaterThanOrEqual<Integer>();
assertFalse(p.test(new Integer(2),new Integer(4)));
@@ -68,11 +49,13 @@ public class TestIsGreaterThanOrEqual ex
assertTrue(p.test(new Integer(6),new Integer(4)));
}
+ @Test
public void testInstance() {
assertTrue(IsGreaterThanOrEqual.instance(new Integer(7)).test(new Integer(8)));
assertTrue(! IsGreaterThanOrEqual.instance(new Integer(7)).test(new Integer(6)));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() throws Exception {
IsGreaterThanOrEqual<Comparable<?>> p = new IsGreaterThanOrEqual<Comparable<?>>();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThan.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -27,17 +29,6 @@ import org.apache.commons.functor.core.C
*/
public class TestIsLessThan extends BaseComparisonPredicateTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsLessThan(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsLessThan.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -45,20 +36,10 @@ public class TestIsLessThan extends Base
return new IsLessThan<Comparable<?>>();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsLessThan<Integer> p = new IsLessThan<Integer>();
assertTrue(p.test(new Integer(2),new Integer(4)));
@@ -68,11 +49,13 @@ public class TestIsLessThan extends Base
assertFalse(p.test(new Integer(6),new Integer(4)));
}
+ @Test
public void testInstance() {
assertFalse(IsLessThan.instance(new Integer(7)).test(new Integer(8)));
assertTrue(IsLessThan.instance(new Integer(7)).test(new Integer(6)));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() throws Exception {
IsLessThan<Comparable<?>> p = new IsLessThan<Comparable<?>>();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsLessThanOrEqual.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -27,17 +29,6 @@ import org.apache.commons.functor.core.C
*/
public class TestIsLessThanOrEqual extends BaseComparisonPredicateTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsLessThanOrEqual(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsLessThanOrEqual.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -45,20 +36,10 @@ public class TestIsLessThanOrEqual exten
return new IsLessThanOrEqual<Comparable<?>>();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsLessThanOrEqual<Integer> p = new IsLessThanOrEqual<Integer>();
assertTrue(p.test(new Integer(2),new Integer(4)));
@@ -68,11 +49,13 @@ public class TestIsLessThanOrEqual exten
assertFalse(p.test(new Integer(6),new Integer(4)));
}
+ @Test
public void testInstance() {
assertFalse(IsLessThanOrEqual.instance(new Integer(7)).test(new Integer(8)));
assertTrue(IsLessThanOrEqual.instance(new Integer(7)).test(new Integer(6)));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() throws Exception {
IsLessThanOrEqual<Comparable<?>> p = new IsLessThanOrEqual<Comparable<?>>();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsNotEquivalent.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,11 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -27,17 +28,6 @@ import org.apache.commons.functor.core.C
*/
public class TestIsNotEquivalent extends BaseComparisonPredicateTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsNotEquivalent(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsNotEquivalent.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -45,20 +35,10 @@ public class TestIsNotEquivalent extends
return IsNotEquivalent.instance();
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsNotEquivalent<Integer> p = new IsNotEquivalent<Integer>();
assertTrue(p.test(new Integer(2),new Integer(4)));
@@ -68,11 +48,13 @@ public class TestIsNotEquivalent extends
assertTrue(p.test(new Integer(6),new Integer(4)));
}
+ @Test
public void testInstance() {
assertTrue(! IsNotEquivalent.instance(new Integer(7)).test(new Integer(7)));
assertTrue(IsNotEquivalent.instance(new Integer(7)).test(new Integer(8)));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() throws Exception {
IsNotEquivalent<Comparable<?>> p = new IsNotEquivalent<Comparable<?>>();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestIsWithinRange.java Thu Sep 15 20:27:39 2011
@@ -16,10 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import org.apache.commons.functor.BaseFunctorTest;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -28,17 +30,6 @@ import org.apache.commons.functor.BaseFu
*/
public class TestIsWithinRange extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestIsWithinRange(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestIsWithinRange.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -46,20 +37,10 @@ public class TestIsWithinRange extends B
return new IsWithinRange<Integer>(new Integer(5), new Integer(10));
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
IsWithinRange<Integer> p = new IsWithinRange<Integer>(new Integer(5), new Integer(10));
assertTrue(p.test(new Integer(5)));
@@ -74,6 +55,7 @@ public class TestIsWithinRange extends B
}
+ @Test
public void testInvalidRange() {
try {
new IsWithinRange<Integer>(new Integer(5), new Integer(4));
@@ -94,6 +76,7 @@ public class TestIsWithinRange extends B
}
}
+ @Test
public void testEquals() throws Exception {
IsWithinRange<Integer> p1 = new IsWithinRange<Integer>(new Integer(5), new Integer(10));
IsWithinRange<Integer> p2 = new IsWithinRange<Integer>(new Integer(5), new Integer(10));
@@ -104,6 +87,7 @@ public class TestIsWithinRange extends B
assertTrue(!p1.equals(p2));
}
+ @Test
public void testFactory() throws Exception {
IsWithinRange<Integer> p = IsWithinRange.instance(new Integer(5), new Integer(10));
assertTrue(p.test(new Integer(5)));
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMax.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import java.util.Collections;
+import static org.junit.Assert.assertEquals;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.util.Collections;
import org.apache.commons.functor.BaseFunctorTest;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +29,6 @@ import org.apache.commons.functor.BaseFu
*/
public class TestMax extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestMax(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestMax.class);
- }
-
// Framework
// ------------------------------------------------------------------------
@@ -55,6 +44,7 @@ public class TestMax extends BaseFunctor
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testEvaluate() {
Max<Integer> f = Max.instance();
assertEquals(ONE,f.evaluate(ONE,ONE));
@@ -65,6 +55,7 @@ public class TestMax extends BaseFunctor
assertEquals(MINUS_TWO,f.evaluate(MIN,MINUS_TWO));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() {
Max<Comparable<?>> f = Max.instance();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/comparator/TestMin.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,12 @@
*/
package org.apache.commons.functor.core.comparator;
-import java.util.Collections;
+import static org.junit.Assert.assertEquals;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import java.util.Collections;
import org.apache.commons.functor.BaseFunctorTest;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +29,6 @@ import org.apache.commons.functor.BaseFu
*/
public class TestMin extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestMin(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestMin.class);
- }
-
// Framework
// ------------------------------------------------------------------------
@@ -55,6 +44,7 @@ public class TestMin extends BaseFunctor
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testEvaluate() {
Min<Integer> f = Min.instance();
assertEquals(ONE,f.evaluate(ONE,ONE));
@@ -65,6 +55,7 @@ public class TestMin extends BaseFunctor
assertEquals(MIN,f.evaluate(MIN,MINUS_TWO));
}
+ @Test
@SuppressWarnings("unchecked")
public void testEquals() {
Min<Comparable<?>> f = Min.instance();
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAbstractLoopProcedure.java Thu Sep 15 20:27:39 2011
@@ -16,14 +16,17 @@
*/
package org.apache.commons.functor.core.composite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.Procedure;
import org.apache.commons.functor.core.Constant;
import org.apache.commons.functor.core.NoOp;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -31,17 +34,6 @@ import org.apache.commons.functor.core.N
*/
public class TestAbstractLoopProcedure extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestAbstractLoopProcedure(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestAbstractLoopProcedure.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -51,7 +43,8 @@ public class TestAbstractLoopProcedure e
// tests
// ------------------------------------------------------------------------
- public void testEqualsAndHashCodeWithNullArgs() {
+ @Test
+ public void testEqualsAndHashCodeWithNullArgs() {
Procedure p = new MockLoopProcedure(null,null);
assertNotNull(p.toString());
assertFalse(p.equals(null));
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAnd.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAnd.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAnd.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestAnd.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,13 @@
*/
package org.apache.commons.functor.core.composite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.Predicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +30,6 @@ import org.apache.commons.functor.core.C
*/
public class TestAnd extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestAnd(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestAnd.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -47,20 +37,10 @@ public class TestAnd extends BaseFunctor
return new And(Constant.TRUE, Constant.TRUE);
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTrue() throws Exception {
assertTrue((new And()).test());
assertTrue((new And(Constant.TRUE)).test());
@@ -85,6 +65,7 @@ public class TestAnd extends BaseFunctor
assertTrue(r.test());
}
+ @Test
public void testFalse() throws Exception {
assertTrue(!(new And(Constant.FALSE)).test());
assertTrue(!(new And(Constant.TRUE,Constant.FALSE)).test());
@@ -108,6 +89,7 @@ public class TestAnd extends BaseFunctor
assertTrue(!r.test());
}
+ @Test
public void testDuplicateAdd() throws Exception {
Predicate p = Constant.TRUE;
And q = new And(p,p);
@@ -118,6 +100,7 @@ public class TestAnd extends BaseFunctor
}
}
+ @Test
public void testEquals() throws Exception {
And p = new And();
assertEquals(p,p);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryAnd.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,13 @@
*/
package org.apache.commons.functor.core.composite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +30,6 @@ import org.apache.commons.functor.core.C
*/
public class TestBinaryAnd extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestBinaryAnd(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestBinaryAnd.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -47,20 +37,10 @@ public class TestBinaryAnd extends BaseF
return new BinaryAnd<Object, Object>(Constant.TRUE, Constant.TRUE);
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTrue() throws Exception {
assertTrue((new BinaryAnd<String, Integer>()).test("xyzzy",3));
assertTrue((new BinaryAnd<String, Integer>(Constant.TRUE)).test("xyzzy",3));
@@ -85,6 +65,7 @@ public class TestBinaryAnd extends BaseF
assertTrue(r.test("xyzzy",3));
}
+ @Test
public void testFalse() throws Exception {
assertTrue(!(new BinaryAnd<String, Integer>(Constant.FALSE)).test("xyzzy",3));
assertTrue(!(new BinaryAnd<String, Integer>(Constant.TRUE,Constant.FALSE)).test("xyzzy",3));
@@ -108,6 +89,7 @@ public class TestBinaryAnd extends BaseF
assertTrue(!r.test("xyzzy",3));
}
+ @Test
public void testDuplicateAdd() throws Exception {
BinaryPredicate<Object, Object> p = Constant.TRUE;
BinaryAnd<String, Integer> q = new BinaryAnd<String, Integer>(p,p);
@@ -118,6 +100,7 @@ public class TestBinaryAnd extends BaseF
}
}
+ @Test
public void testEquals() throws Exception {
BinaryAnd<Object, Object> p = new BinaryAnd<Object, Object>();
assertEquals(p,p);
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryCompositeBinaryFunction.java Thu Sep 15 20:27:39 2011
@@ -16,14 +16,15 @@
*/
package org.apache.commons.functor.core.composite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryFunction;
import org.apache.commons.functor.core.Constant;
import org.apache.commons.functor.core.LeftIdentity;
import org.apache.commons.functor.core.RightIdentity;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -31,17 +32,6 @@ import org.apache.commons.functor.core.R
*/
public class TestBinaryCompositeBinaryFunction extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestBinaryCompositeBinaryFunction(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestBinaryCompositeBinaryFunction.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -52,20 +42,10 @@ public class TestBinaryCompositeBinaryFu
RightIdentity.FUNCTION);
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
@SuppressWarnings("unchecked")
public void testEvaluateRaw() throws Exception {
BinaryFunction f = new BinaryCompositeBinaryFunction(
@@ -77,6 +57,7 @@ public class TestBinaryCompositeBinaryFu
assertEquals("right",f.evaluate(null,"right"));
}
+ @Test
public void testEvaluate() throws Exception {
BinaryFunction<String, String, String> f = new BinaryCompositeBinaryFunction<String, String, String>(
RightIdentity.<String, String>function(),
@@ -87,6 +68,7 @@ public class TestBinaryCompositeBinaryFu
assertEquals("right",f.evaluate(null,"right"));
}
+ @Test
public void testEvaluateObject() throws Exception {
BinaryFunction<Object, Object, Object> f = new BinaryCompositeBinaryFunction<Object, Object, Object>(
RightIdentity.FUNCTION,
@@ -97,6 +79,7 @@ public class TestBinaryCompositeBinaryFu
assertEquals("right",f.evaluate(null,"right"));
}
+ @Test
public void testEquals() throws Exception {
BinaryFunction<Object, Object, Object> f = new BinaryCompositeBinaryFunction<Object, Object, Object>(
LeftIdentity.FUNCTION,
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryNot.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,15 @@
*/
package org.apache.commons.functor.core.composite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +32,6 @@ import org.apache.commons.functor.core.C
*/
public class TestBinaryNot extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestBinaryNot(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestBinaryNot.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -47,20 +39,10 @@ public class TestBinaryNot extends BaseF
return new BinaryNot<Object, Object>(Constant.TRUE);
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTest() throws Exception {
BinaryPredicate<Object, Object> truePred = new BinaryNot<Object, Object>(Constant.FALSE);
assertTrue(truePred.test(null,null));
@@ -68,6 +50,7 @@ public class TestBinaryNot extends BaseF
assertTrue(truePred.test("xyzzy",new Integer(3)));
}
+ @Test
public void testEquals() throws Exception {
BinaryNot<Object, Object> p = new BinaryNot<Object, Object>(Constant.TRUE);
assertEquals(p,p);
@@ -77,10 +60,12 @@ public class TestBinaryNot extends BaseF
assertObjectsAreNotEqual(p,Constant.TRUE);
}
+ @Test
public void testNotNull() throws Exception {
assertNull(BinaryNot.not(null));
}
+ @Test
public void testNotNotNull() throws Exception {
assertNotNull(BinaryNot.not(Constant.truePredicate()));
}
Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryOr.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryOr.java?rev=1171255&r1=1171254&r2=1171255&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryOr.java (original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestBinaryOr.java Thu Sep 15 20:27:39 2011
@@ -16,12 +16,13 @@
*/
package org.apache.commons.functor.core.composite;
-import junit.framework.Test;
-import junit.framework.TestSuite;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import org.apache.commons.functor.BaseFunctorTest;
import org.apache.commons.functor.BinaryPredicate;
import org.apache.commons.functor.core.Constant;
+import org.junit.Test;
/**
* @version $Revision$ $Date$
@@ -29,17 +30,6 @@ import org.apache.commons.functor.core.C
*/
public class TestBinaryOr extends BaseFunctorTest {
- // Conventional
- // ------------------------------------------------------------------------
-
- public TestBinaryOr(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestBinaryOr.class);
- }
-
// Functor Testing Framework
// ------------------------------------------------------------------------
@@ -47,20 +37,10 @@ public class TestBinaryOr extends BaseFu
return new BinaryOr<Object, Object>(Constant.FALSE, Constant.TRUE);
}
- // Lifecycle
- // ------------------------------------------------------------------------
-
- public void setUp() throws Exception {
- super.setUp();
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
// Tests
// ------------------------------------------------------------------------
+ @Test
public void testTrue() throws Exception {
assertTrue((new BinaryOr<Object, Object>(Constant.TRUE)).test("xyzzy",new Integer(3)));
assertTrue((new BinaryOr<Object, Object>(Constant.FALSE,Constant.TRUE)).test("xyzzy",new Integer(3)));
@@ -84,6 +64,7 @@ public class TestBinaryOr extends BaseFu
assertTrue(r.test("xyzzy",new Integer(3)));
}
+ @Test
public void testFalse() throws Exception {
assertTrue(!(new BinaryOr<Object, Object>()).test("xyzzy",new Integer(3)));
assertTrue(!(new BinaryOr<Object, Object>(Constant.FALSE)).test("xyzzy",new Integer(3)));
@@ -108,6 +89,7 @@ public class TestBinaryOr extends BaseFu
assertTrue(!r.test("xyzzy",new Integer(3)));
}
+ @Test
public void testDuplicateAdd() throws Exception {
BinaryPredicate<Object, Object> p = Constant.TRUE;
BinaryOr<Object, Object> q = new BinaryOr<Object, Object>(p,p);
@@ -118,6 +100,7 @@ public class TestBinaryOr extends BaseFu
}
}
+ @Test
public void testEquals() throws Exception {
BinaryOr<Object, Object> p = new BinaryOr<Object, Object>();
assertEquals(p,p);