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/08/01 13:56:45 UTC
[2/3] struts git commit: [WW-4831] add unit tests for conversion of
String arrays
[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 <sh...@yahoo.com.au>
Authored: Tue Aug 1 11:51:37 2017 +1000
Committer: thrawnca <sh...@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);
+ }
+
+}