struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [2/3] struts git commit: [WW-4831] add unit tests for conversion of String arrays
Date Tue, 01 Aug 2017 13:56:45 GMT
[WW-4831] add unit tests for conversion of String arrays


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

Branch: refs/heads/master
Commit: 60d61fac0abb5993977e84f8dcc5bea6588f41d6
Parents: 8cc56b2
Author: thrawnca <shell_layer-github@yahoo.com.au>
Authored: Tue Aug 1 11:51:37 2017 +1000
Committer: thrawnca <shell_layer-github@yahoo.com.au>
Committed: Tue Aug 1 11:51:37 2017 +1000

----------------------------------------------------------------------
 .../conversion/impl/StringConverterTest.java    | 28 +++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/60d61fac/core/src/test/java/com/opensymphony/xwork2/conversion/impl/StringConverterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/StringConverterTest.java
b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/StringConverterTest.java
index c275669..27fbb6b 100644
--- a/core/src/test/java/com/opensymphony/xwork2/conversion/impl/StringConverterTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/conversion/impl/StringConverterTest.java
@@ -49,4 +49,30 @@ public class StringConverterTest extends StrutsInternalTestCase {
         assertEquals("234,12", value);
     }
 
-}
\ No newline at end of file
+    public void testStringArrayToStringConversion() {
+        // given
+        StringConverter converter = new StringConverter();
+        Map<String, Object> context = new HashMap<>();
+        context.put(ActionContext.LOCALE, new Locale("pl", "PL"));
+
+        // when
+        Object value = converter.convertValue(context, null, null, null, new String[] {"foo",
"baz"}, null);
+
+        // then
+        assertEquals("foo, baz", value);
+   }
+
+    public void testArrayOfNullToStringConversion() {
+        // given
+        StringConverter converter = new StringConverter();
+        Map<String, Object> context = new HashMap<>();
+        context.put(ActionContext.LOCALE, new Locale("pl", "PL"));
+
+        // when
+        Object value = converter.convertValue(context, null, null, null, new String[] {null},
null);
+
+        // then
+        assertEquals("", value);
+   }
+
+}


Mime
View raw message