struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4627 Adds unit test to confirm the issue
Date Fri, 13 May 2016 06:28:35 GMT
Repository: struts
Updated Branches:
  refs/heads/master a44c7bc13 -> 104bd92b8


WW-4627 Adds unit test to confirm the issue


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

Branch: refs/heads/master
Commit: 104bd92b88361978d3b8014db44e8a9a9b63077f
Parents: a44c7bc
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Fri May 13 08:00:04 2016 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Fri May 13 08:07:59 2016 +0200

----------------------------------------------------------------------
 .../org/apache/struts2/json/JSONWriterTest.java | 37 ++++++++++++++++++++
 .../struts2/json/jsonwriter-write-bean-04.txt   | 16 +++++++++
 2 files changed, 53 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/104bd92b/plugins/json/src/test/java/org/apache/struts2/json/JSONWriterTest.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/test/java/org/apache/struts2/json/JSONWriterTest.java b/plugins/json/src/test/java/org/apache/struts2/json/JSONWriterTest.java
index 88c888c..2a9d733 100644
--- a/plugins/json/src/test/java/org/apache/struts2/json/JSONWriterTest.java
+++ b/plugins/json/src/test/java/org/apache/struts2/json/JSONWriterTest.java
@@ -7,7 +7,9 @@ import org.junit.Test;
 
 import java.net.URL;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.TimeZone;
 
@@ -90,6 +92,41 @@ public class JSONWriterTest extends StrutsTestCase{
         TestUtils.assertEquals(JSONWriter.class.getResource("jsonwriter-write-bean-02.txt"),
json);
     }
 
+    @Test
+    public void testWriteBeanWithList() throws Exception {
+        BeanWithList bean1 = new BeanWithList();
+        bean1.setStringField("str");
+        bean1.setBooleanField(true);
+        bean1.setCharField('s');
+        bean1.setDoubleField(10.1);
+        bean1.setFloatField(1.5f);
+        bean1.setIntField(10);
+        bean1.setLongField(100);
+        bean1.setEnumField(AnEnum.ValueA);
+        bean1.setEnumBean(AnEnumBean.Two);
+        List<String> errors = new ArrayList<String>();
+        errors.add("Field is required");
+        bean1.setErrors(errors);
+
+        JSONWriter jsonWriter = new JSONWriter();
+        jsonWriter.setEnumAsBean(false);
+        jsonWriter.setIgnoreHierarchy(false);
+        String json = jsonWriter.write(bean1);
+        TestUtils.assertEquals(JSONWriter.class.getResource("jsonwriter-write-bean-04.txt"),
json);
+    }
+
+    private class BeanWithList extends Bean {
+        private List<String> errors;
+
+        public List<String> getErrors() {
+            return errors;
+        }
+
+        public void setErrors(List<String> errors) {
+            this.errors = errors;
+        }
+    }
+
     private class AnnotatedBean extends Bean{
         private URL url;
 

http://git-wip-us.apache.org/repos/asf/struts/blob/104bd92b/plugins/json/src/test/resources/org/apache/struts2/json/jsonwriter-write-bean-04.txt
----------------------------------------------------------------------
diff --git a/plugins/json/src/test/resources/org/apache/struts2/json/jsonwriter-write-bean-04.txt
b/plugins/json/src/test/resources/org/apache/struts2/json/jsonwriter-write-bean-04.txt
new file mode 100644
index 0000000..41f0b81
--- /dev/null
+++ b/plugins/json/src/test/resources/org/apache/struts2/json/jsonwriter-write-bean-04.txt
@@ -0,0 +1,16 @@
+{
+    "bigDecimal":null,
+    "bigInteger":null,
+    "booleanField":true,
+    "byteField":0,
+    "charField":"s",
+    "doubleField":10.1,
+    "enumBean":"Two",
+    "enumField":"ValueA",
+    "errors":["Field is required"],
+    "floatField":1.5,
+    "intField":10,
+    "longField":100,
+    "objectField":null,
+    "stringField":"str"
+}


Mime
View raw message