You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2017/02/13 09:49:00 UTC

[2/3] struts git commit: [WW-4737] add unit testing for parameters being converted to string arrays

[WW-4737] add unit testing for parameters being converted to string arrays


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/26bc9cd6
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/26bc9cd6
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/26bc9cd6

Branch: refs/heads/master
Commit: 26bc9cd64bd9e69f7bf2e1076150806581c355f4
Parents: 58667e6
Author: antuarc <ca...@dsiti.qld.gov.au>
Authored: Wed Feb 1 12:27:02 2017 +1000
Committer: antuarc <ca...@dsiti.qld.gov.au>
Committed: Wed Feb 1 12:27:02 2017 +1000

----------------------------------------------------------------------
 .../struts2/dispatcher/ParameterTest.java       | 32 ++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/26bc9cd6/core/src/test/java/org/apache/struts2/dispatcher/ParameterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/struts2/dispatcher/ParameterTest.java b/core/src/test/java/org/apache/struts2/dispatcher/ParameterTest.java
new file mode 100644
index 0000000..25d9409
--- /dev/null
+++ b/core/src/test/java/org/apache/struts2/dispatcher/ParameterTest.java
@@ -0,0 +1,32 @@
+package org.apache.struts2.dispatcher;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+
+public class ParameterTest {
+
+    private static final String PARAM_NAME = "param";
+
+    @DataProvider(name = "paramValues")
+    Object[][] paramValues() {
+        return new Object[][] {
+            {null, new String[0]},
+            {"input", new String[] {"input"}},
+            {Integer.valueOf(5), new String[] {"5"}},
+            {new String[] {"foo"}, new String[] {"foo"}},
+            {new Object[] {null}, new String[] {null}},
+        };
+    }
+
+    @Test(dataProvider = "paramValues")
+    public void shouldConvertRequestValuesToStringArrays(Object input, String[] expected) {
+        Parameter.Request request = new Parameter.Request(PARAM_NAME, input);
+
+        String[] result = request.getMultipleValues();
+
+        assertEquals(result, expected);
+        assertNotSame(result, input);
+    }
+}