Added:
/trunk/jjson-struts2/src/test/java/de/grobmeier/json/plugins/struts2/MultilineTestAction.java
Modified:
/trunk/jjson-struts2/src/test/java/de/grobmeier/json/plugins/struts2/JsonResultTest.java
/trunk/jjson-struts2/src/test/resources/struts.xml
=======================================
--- /dev/null
+++
/trunk/jjson-struts2/src/test/java/de/grobmeier/json/plugins/struts2/MultilineTestAction.java
Mon Aug 1 08:32:52 2011
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2011 Christian Grobmeier
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+package de.grobmeier.json.plugins.struts2;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import de.grobmeier.jjson.convert.JSON;
+
+@JSON
+public class MultilineTestAction extends ActionSupport {
+ /** Serial */
+ private static final long serialVersionUID = -6707682090128966810L;
+
+ @JSON(encodeLinebreaks = true)
+ private String test = "mytest\nagain";
+
+ public String execute(){
+ return SUCCESS;
+ }
+
+ public String getTest() {
+ return test;
+ }
+ public void setTest(String test) {
+ this.test = test;
+ }
+
+
+}
=======================================
---
/trunk/jjson-struts2/src/test/java/de/grobmeier/json/plugins/struts2/JsonResultTest.java
Tue Jul 12 02:54:21 2011
+++
/trunk/jjson-struts2/src/test/java/de/grobmeier/json/plugins/struts2/JsonResultTest.java
Mon Aug 1 08:32:52 2011
@@ -29,7 +29,7 @@
}
@Test
- public void testSomething() throws Exception {
+ public void testSimple() throws Exception {
String executeAction = this.executeAction("/test");
Assert.assertEquals("{\"test\":\"mytest\"}", executeAction);
}
@@ -39,4 +39,10 @@
String executeAction = this.executeAction("/test2");
Assert.assertEquals("/* {\"test\":\"mytest\"} */", executeAction);
}
-}
+
+ @Test
+ public void testMultiline() throws Exception {
+ String executeAction = this.executeAction("/multilinetest");
+ Assert.assertEquals("{\"test\":\"mytest\\nagain\"}", executeAction);
+ }
+}
=======================================
--- /trunk/jjson-struts2/src/test/resources/struts.xml Tue Jul 12 02:54:21
2011
+++ /trunk/jjson-struts2/src/test/resources/struts.xml Mon Aug 1 08:32:52
2011
@@ -31,6 +31,10 @@
<action name="test" class="de.grobmeier.json.plugins.struts2.TestAction">
<result type="json" />
</action>
+
+ <action name="multilinetest"
class="de.grobmeier.json.plugins.struts2.MultilineTestAction">
+ <result type="json" />
+ </action>
</package>
<package name="commentJjson" extends="struts-default">