You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2013/06/11 21:51:22 UTC

svn commit: r1491925 - /commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/ChainBaseTestCase.java

Author: britter
Date: Tue Jun 11 19:51:22 2013
New Revision: 1491925

URL: http://svn.apache.org/r1491925
Log:
Add some tests to verify input parameter validation of constrcutors

Modified:
    commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/ChainBaseTestCase.java

Modified: commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/ChainBaseTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/ChainBaseTestCase.java?rev=1491925&r1=1491924&r2=1491925&view=diff
==============================================================================
--- commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/ChainBaseTestCase.java (original)
+++ commons/proper/chain/trunk/core/src/test/java/org/apache/commons/chain2/impl/ChainBaseTestCase.java Tue Jun 11 19:51:22 2013
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.commons.chain2.Chain;
@@ -28,6 +30,7 @@ import org.apache.commons.chain2.Command
 import org.apache.commons.chain2.Context;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -340,6 +343,39 @@ public class ChainBaseTestCase {
         checkCommandCount(0);
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testConstructorCommandNull() throws Exception {
+        new ChainBase<String, Object, Context<String, Object>>((Command<String, Object, Context<String, Object>>) null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testConstructorVarArgsNull() throws Exception {
+        new ChainBase<String, Object, Context<String, Object>>((Command<String, Object, Context<String, Object>>[]) null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testConstructorVarArgsWithNullElements() throws Exception {
+        new ChainBase<String, Object, Context<String, Object>>(
+                new DelegatingFilter("1", "a"),
+                null,
+                new ExceptionFilter("2", "b"));
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testConstructorCollectionNull() throws Exception {
+        new ChainBase<String, Object, Context<String, Object>>((Collection<Command<String, Object, Context<String, Object>>>) null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    @Ignore // FIXME this one fails although javadoc says it shouldn't
+    public void testConstructorCollectionWithNullElements() throws Exception {
+        List<Command<String, Object, Context<String, Object>>> commands = new ArrayList<Command<String, Object, Context<String, Object>>>();
+        commands.add(new DelegatingFilter("1", "a"));
+        commands.add(null);
+        commands.add(new ExceptionFilter("2", "b"));
+        new ChainBase<String, Object, Context<String, Object>>(commands);
+    }
+
 
     // -------------------------------------------------------- Support Methods