svn commit: r1421740 - in /struts/struts2/trunk/plugins/json/src: main/java/org/apache/struts2/json/JSONResult.java test/java/org/apache/struts2/json/JSONResultTest.java

2012-12-14 Thread lukaszlenart
Author: lukaszlenart
Date: Fri Dec 14 08:53:49 2012
New Revision: 1421740

URL: http://svn.apache.org/viewvc?rev=1421740&view=rev
Log:
WW-3863 Allows to define encoding per result

Modified:

struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java

struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONResultTest.java

Modified: 
struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java?rev=1421740&r1=1421739&r2=1421740&view=diff
==
--- 
struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java
 (original)
+++ 
struts/struts2/trunk/plugins/json/src/main/java/org/apache/struts2/json/JSONResult.java
 Fri Dec 14 08:53:49 2012
@@ -65,6 +65,7 @@ public class JSONResult implements Resul
 
 private static final Logger LOG = 
LoggerFactory.getLogger(JSONResult.class);
 
+private String encoding;
 private String defaultEncoding = "ISO-8859-1";
 private List includeProperties;
 private List excludeProperties;
@@ -217,10 +218,14 @@ public class JSONResult implements Resul
  * Retrieve the encoding 
  *
  * @return The encoding associated with this template (defaults to the 
value
- * of 'struts.i18n.encoding' property)
+ * of param 'encoding', if empty default to 'struts.i18n.encoding' 
property)
  */
 protected String getEncoding() {
-String encoding = this.defaultEncoding;
+String encoding = this.encoding;
+
+if (encoding == null) {
+encoding = this.defaultEncoding;
+}
 
 if (encoding == null) {
 encoding = System.getProperty("file.encoding");
@@ -421,4 +426,16 @@ public class JSONResult implements Resul
 public void setWrapSuffix(String wrapSuffix) {
 this.wrapSuffix = wrapSuffix;
 }
+
+/**
+ * If defined will be used instead of {@link #defaultEncoding}, you can 
define it with result
+ * 
+ * UTF-8
+ * 
+ *
+ * @param encoding valid encoding string
+ */
+public void setEncoding(String encoding) {
+this.encoding = encoding;
+}
 }

Modified: 
struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONResultTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONResultTest.java?rev=1421740&r1=1421739&r2=1421740&view=diff
==
--- 
struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONResultTest.java
 (original)
+++ 
struts/struts2/trunk/plugins/json/src/test/java/org/apache/struts2/json/JSONResultTest.java
 Fri Dec 14 08:53:49 2012
@@ -20,6 +20,16 @@
  */
 package org.apache.struts2.json;
 
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.mock.MockActionInvocation;
+import com.opensymphony.xwork2.util.ValueStack;
+import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.StrutsTestCase;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletContext;
+
+import javax.servlet.http.HttpServletResponse;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
@@ -34,18 +44,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.StrutsTestCase;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.mock.web.MockServletContext;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.mock.MockActionInvocation;
-import com.opensymphony.xwork2.util.ValueStack;
-
 /**
  * JSONResultTest
  */
@@ -573,6 +571,31 @@ public class JSONResultTest extends Stru
 assertEquals("application/json;charset=ISO-8859-1", 
response.getContentType());
 }
 
+public void testDefaultEncoding() throws Exception {
+// given
+JSONResult json = new JSONResult();
+json.setDefaultEncoding("UTF-16");
+
+// when
+String encoding = json.getEncoding();
+
+// thn
+assertEquals("UTF-16", encoding);
+}
+
+public void testEncoding() throws Exception {
+// given
+JSONResult json = new JSONResult();
+json.setEncoding("UTF-8");
+json.setDefaultEncoding("UTF-8");
+
+// when
+String encoding = json.getEncoding();
+
+// thn
+   

[CONF] Confluence Changes in the last 24 hours

2012-12-14 Thread confluence
This is a daily summary of all recent changes in Confluence.

-
Updated Spaces:
-


Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL)

Pages
-
Crypto edited by  njiang  (07:34 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Crypto

File2 edited by  njiang  (06:40 AM)
https://cwiki.apache.org/confluence/display/CAMEL/File2

Zookeeper edited by  b...@habegger.fr  (03:51 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Zookeeper

Camel 2.11.0 Release edited by  davsclaus  (03:40 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Camel+2.11.0+Release



Apache Cloudstack (https://cwiki.apache.org/confluence/display/CLOUDSTACK)

Pages
-
Index edited by  animeshc  (04:53 PM)
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Index

CloudStack 4.1 Release edited by  chip.child...@gmail.com  (02:34 PM)
https://cwiki.apache.org/confluence/display/CLOUDSTACK/CloudStack+4.1+Release

Multiple IP address per NIC created by jayapal (08:02 AM)
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IP+address+per+NIC

VM Snapshots edited by  mice_xia  (07:00 AM)
https://cwiki.apache.org/confluence/display/CLOUDSTACK/VM+Snapshots

ASF CS 4.0.1 Test Execution Plan edited by  abhinavr  (05:49 AM)
https://cwiki.apache.org/confluence/display/CLOUDSTACK/ASF+CS+4.0.1+Test+Execution+Plan



Apache cTAKES (https://cwiki.apache.org/confluence/display/CTAKES)

Pages
-
cTAKES 3.0 - Assertion edited by  bleeker  (06:00 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Assertion

cTAKES 3.0 - Chunk Adjuster edited by  bleeker  (06:00 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Chunk+Adjuster

cTAKES 3.0 - Chunker edited by  bleeker  (06:00 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Chunker

cTAKES 3.0 - Clinical Documents Pipeline edited by  bleeker  (06:00 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Clinical+Documents+Pipeline

cTAKES 3.0 - Constituency Parser edited by  bleeker  (05:59 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Constituency+Parser

cTAKES 3.0 - Context Dependent Tokenizer edited by  bleeker  (05:59 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Context+Dependent+Tokenizer

cTAKES 3.0 - Core edited by  bleeker  (05:59 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Core

cTAKES 3.0 - Dependency Parser and Semantic Role Labeler edited by  bleeker  
(05:59 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Dependency+Parser+and+Semantic+Role+Labeler

cTAKES 3.0 - Dictionary Lookup edited by  bleeker  (05:53 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Dictionary+Lookup

cTAKES 3.0 - Document Preprocessor edited by  bleeker  (05:53 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Document+Preprocessor

cTAKES 3.0 - Drug Named Entity Recognition edited by  bleeker  (05:53 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Drug+Named+Entity+Recognition

cTAKES 3.0 - LVG edited by  bleeker  (05:52 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+LVG

cTAKES 3.0 - NE Contexts edited by  bleeker  (05:52 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+NE+Contexts

cTAKES 3.0 - PAD Term Spotter edited by  bleeker  (05:52 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+PAD+Term+Spotter

cTAKES 3.0 - POS Tagger edited by  bleeker  (05:52 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+POS+Tagger

cTAKES 3.0 - Side Effect edited by  bleeker  (05:52 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Side+Effect

cTAKES 3.0 - Smoking status edited by  bleeker  (05:51 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+-+Smoking+status

cTAKES 3.0 Developer Guide edited by  bleeker  (05:50 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+Developer+Guide

cTAKES 3.0 edited by  bleeker  (05:44 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0

cTAKES 3.0 Component Use Guide edited by  bleeker  (05:41 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+Component+Use+Guide

cTAKES 3.0 User Guide edited by  bleeker  (05:40 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES+3.0+User+Guide

cTAKES edited by  bleeker  (05:32 PM)
https://cwiki.apache.org/confluence/display/CTAKES/cTAKES

Menu cTAKES 3.0 to Include edited by  bleeker  (05:31 PM)
https://cwiki.apache.org/confluence/display/CTAKES/Menu+cTAKES+3.0+to+Include



Apache CXF (https://cwiki.apache.org/confluence/dis