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 2016/05/22 06:30:58 UTC
[1/7] struts git commit: fix patch WW-4558
Repository: struts
Updated Branches:
refs/heads/master 104bd92b8 -> 880c1d54a
fix patch WW-4558
contentType override ignored for JSONInterceptor
>From now on:
The "accept" request header parameter must be "application/json" or
"application/json-rpc"
Also the default encoding is "UTF-8"
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/fab687a0
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/fab687a0
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/fab687a0
Branch: refs/heads/master
Commit: fab687a07e8d873c82465b29188100debf61097f
Parents: a2c5bc8
Author: victorsosa <vi...@peopleware.do>
Authored: Mon Feb 15 08:28:01 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Mon Feb 15 08:28:01 2016 -0400
----------------------------------------------------------------------
.../apache/struts2/json/JSONInterceptor.java | 6 ++--
.../struts2/json/JSONInterceptorTest.java | 37 +++++++++++---------
2 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/fab687a0/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
index 6731871..11488fe 100644
--- a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
+++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
@@ -58,7 +58,7 @@ public class JSONInterceptor extends AbstractInterceptor {
private boolean enableGZIP = false;
private boolean wrapWithComments;
private boolean prefix;
- private String defaultEncoding = "ISO-8859-1";
+ private String defaultEncoding = "UTF-8";
private boolean ignoreHierarchy = true;
private String root;
private List<Pattern> excludeProperties;
@@ -76,7 +76,7 @@ public class JSONInterceptor extends AbstractInterceptor {
public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
- String contentType = request.getHeader("content-type");
+ contentType = request.getHeader("accept");
if (contentType != null) {
int iSemicolonIdx;
if ((iSemicolonIdx = contentType.indexOf(";")) != -1)
@@ -181,7 +181,7 @@ public class JSONInterceptor extends AbstractInterceptor {
return Action.NONE;
} else {
- LOG.debug("Content type must be 'application/json' or 'application/json-rpc'. Ignoring request with content type ", contentType);
+ LOG.debug("Accept header parameter must be 'application/json' or 'application/json-rpc'. Ignoring request with accept ", contentType);
}
return invocation.invoke();
http://git-wip-us.apache.org/repos/asf/struts/blob/fab687a0/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java b/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
index 7bf53d3..ddae716 100644
--- a/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
+++ b/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
@@ -71,7 +71,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
private void tryBadJSON(String fileName) throws Exception {
// request
setRequestContent(fileName);
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -92,7 +92,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDDisabledSMD() throws Exception {
// request
setRequestContent("smd-3.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
SMDActionTest1 action = new SMDActionTest1();
@@ -111,7 +111,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDAliasedMethodCall1() throws Exception {
// request
setRequestContent("smd-14.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -129,7 +129,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDAliasedMethodCall2() throws Exception {
// request
setRequestContent("smd-15.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -147,7 +147,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDNoMethod() throws Exception {
// request
setRequestContent("smd-4.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -171,7 +171,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDMethodWithoutAnnotations() throws Exception {
// request
setRequestContent("smd-9.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -192,7 +192,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDPrimitivesNoResult() throws Exception {
// request
setRequestContent("smd-6.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -221,13 +221,13 @@ public class JSONInterceptorTest extends StrutsTestCase {
String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
assertEquals(normalizedExpected, normalizedActual);
- assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+ assertEquals("application/json;charset=UTF-8", response.getContentType());
}
public void testSMDReturnObject() throws Exception {
// request
setRequestContent("smd-10.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -245,14 +245,14 @@ public class JSONInterceptorTest extends StrutsTestCase {
String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-12.txt"));
assertEquals(normalizedExpected, normalizedActual);
- assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+ assertEquals("application/json;charset=UTF-8", response.getContentType());
}
@SuppressWarnings("unchecked")
public void testSMDObjectsNoResult() throws Exception {
// request
setRequestContent("smd-7.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -293,14 +293,14 @@ public class JSONInterceptorTest extends StrutsTestCase {
String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
assertEquals(normalizedExpected, normalizedActual);
- assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+ assertEquals("application/json;charset=UTF-8", response.getContentType());
}
@SuppressWarnings( { "unchecked", "unchecked" })
public void testReadEmpty() throws Exception {
// request
setRequestContent("json-6.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -315,7 +315,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void test() throws Exception {
// request
setRequestContent("json-1.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -437,7 +437,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testRoot() throws Exception {
setRequestContent("json-5.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -462,7 +462,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testJSONArray() throws Exception {
setRequestContent("json-12.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -488,7 +488,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testJSONArray2() throws Exception {
setRequestContent("json-12.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -536,6 +536,9 @@ public class JSONInterceptorTest extends StrutsTestCase {
}
class MockActionInvocationEx extends MockActionInvocation {
+
+ private static final long serialVersionUID = 3057703805130170757L;
+
private boolean invoked;
@Override
[5/7] struts git commit: Merge branch 'ww-4558' of
github.com:victorsosa/struts into ww-4558
Posted by lu...@apache.org.
Merge branch 'ww-4558' of github.com:victorsosa/struts into ww-4558
# Conflicts:
# plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/8b8135af
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/8b8135af
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/8b8135af
Branch: refs/heads/master
Commit: 8b8135af79550bf732d5aaa98ee7d3d5116e4b4b
Parents: 2fada1e bab451c
Author: victorsosa <vi...@peopleware.do>
Authored: Mon Feb 15 10:37:26 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Mon Feb 15 10:37:26 2016 -0400
----------------------------------------------------------------------
.../json/src/main/java/org/apache/struts2/json/JSONInterceptor.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/8b8135af/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
----------------------------------------------------------------------
diff --cc plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
index 207d014,0b4cf37..5beb8df
--- a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
+++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
@@@ -186,7 -186,11 +186,8 @@@ public class JSONInterceptor extends Ab
return Action.NONE;
} else {
-<<<<<<< HEAD
++
LOG.debug("Accept header parameter must be 'application/json' or 'application/json-rpc'. Ignoring request with accept ", accept);
-=======
- LOG.debug("Accept header parameter must be 'application/json' or 'application/json-rpc'. Ignoring request with accept ", contentType);
->>>>>>> fab687a07e8d873c82465b29188100debf61097f
}
return invocation.invoke();
[7/7] struts git commit: WW-4558 contentType override ignored for
JSONInterceptor
Posted by lu...@apache.org.
WW-4558 contentType override ignored for JSONInterceptor
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/880c1d54
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/880c1d54
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/880c1d54
Branch: refs/heads/master
Commit: 880c1d54a41964d998a8b5b08e7954a7a7c48ab1
Parents: 104bd92 d16aa65
Author: Lukasz Lenart <lu...@apache.org>
Authored: Sun May 22 08:30:27 2016 +0200
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Sun May 22 08:30:27 2016 +0200
----------------------------------------------------------------------
.../apache/struts2/json/JSONInterceptor.java | 26 +++++++-------
.../struts2/json/JSONInterceptorTest.java | 37 +++++++++++---------
2 files changed, 33 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
[3/7] struts git commit: Merge branch 'ww-4558' of
github.com:victorsosa/struts into ww-4558
Posted by lu...@apache.org.
Merge branch 'ww-4558' of github.com:victorsosa/struts into ww-4558
# Conflicts:
# plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/bab451c6
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/bab451c6
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/bab451c6
Branch: refs/heads/master
Commit: bab451c6d80ee9b2685570d797e505768ff8bbe4
Parents: 0d49050 fab687a
Author: victorsosa <vi...@peopleware.do>
Authored: Mon Feb 15 10:34:15 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Mon Feb 15 10:34:15 2016 -0400
----------------------------------------------------------------------
.../src/main/java/org/apache/struts2/json/JSONInterceptor.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/bab451c6/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
----------------------------------------------------------------------
diff --cc plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
index 207d014,11488fe..0b4cf37
--- a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
+++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
@@@ -186,7 -181,7 +186,11 @@@ public class JSONInterceptor extends Ab
return Action.NONE;
} else {
++<<<<<<< HEAD
+ LOG.debug("Accept header parameter must be 'application/json' or 'application/json-rpc'. Ignoring request with accept ", accept);
++=======
+ LOG.debug("Accept header parameter must be 'application/json' or 'application/json-rpc'. Ignoring request with accept ", contentType);
++>>>>>>> fab687a07e8d873c82465b29188100debf61097f
}
return invocation.invoke();
[2/7] struts git commit: fix patch WW-4558
Posted by lu...@apache.org.
fix patch WW-4558
contentType override ignored for JSONInterceptor
use of accept parameter st by the interceptor params
Signed-off-by: victorsosa <vi...@peopleware.do>
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/0d490503
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/0d490503
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/0d490503
Branch: refs/heads/master
Commit: 0d4905038119f614f021af5738154079b30bca24
Parents: a2c5bc8
Author: victorsosa <vi...@peopleware.do>
Authored: Mon Feb 15 08:28:01 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Mon Feb 15 10:31:36 2016 -0400
----------------------------------------------------------------------
.../apache/struts2/json/JSONInterceptor.java | 27 ++++++++------
.../struts2/json/JSONInterceptorTest.java | 37 +++++++++++---------
2 files changed, 36 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/0d490503/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
index 6731871..207d014 100644
--- a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
+++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
@@ -58,7 +58,7 @@ public class JSONInterceptor extends AbstractInterceptor {
private boolean enableGZIP = false;
private boolean wrapWithComments;
private boolean prefix;
- private String defaultEncoding = "ISO-8859-1";
+ private String defaultEncoding = "UTF-8";
private boolean ignoreHierarchy = true;
private String root;
private List<Pattern> excludeProperties;
@@ -70,17 +70,22 @@ public class JSONInterceptor extends AbstractInterceptor {
private boolean noCache = false;
private boolean excludeNullProperties;
private String callbackParameter;
- private String contentType;
+ private String accept;
@SuppressWarnings("unchecked")
public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
- String contentType = request.getHeader("content-type");
- if (contentType != null) {
+
+ //parameter wasn't set by the interceptor
+ if (accept == null) {
+ accept = request.getHeader("accept");
+ }
+
+ if (accept != null) {
int iSemicolonIdx;
- if ((iSemicolonIdx = contentType.indexOf(";")) != -1)
- contentType = contentType.substring(0, iSemicolonIdx);
+ if ((iSemicolonIdx = accept.indexOf(";")) != -1)
+ accept = accept.substring(0, iSemicolonIdx);
}
Object rootObject = null;
@@ -93,7 +98,7 @@ public class JSONInterceptor extends AbstractInterceptor {
}
}
- if ((contentType != null) && contentType.equalsIgnoreCase("application/json")) {
+ if ((accept != null) && accept.equalsIgnoreCase("application/json")) {
// load JSON object
Object obj = JSONUtil.deserialize(request.getReader());
@@ -133,7 +138,7 @@ public class JSONInterceptor extends AbstractInterceptor {
LOG.error("Unable to deserialize JSON object from request");
throw new JSONException("Unable to deserialize JSON object from request");
}
- } else if ((contentType != null) && contentType.equalsIgnoreCase("application/json-rpc")) {
+ } else if ((accept != null) && accept.equalsIgnoreCase("application/json-rpc")) {
Object result;
if (this.enableSMD) {
// load JSON object
@@ -181,7 +186,7 @@ public class JSONInterceptor extends AbstractInterceptor {
return Action.NONE;
} else {
- LOG.debug("Content type must be 'application/json' or 'application/json-rpc'. Ignoring request with content type ", contentType);
+ LOG.debug("Accept header parameter must be 'application/json' or 'application/json-rpc'. Ignoring request with accept ", accept);
}
return invocation.invoke();
@@ -535,7 +540,7 @@ public class JSONInterceptor extends AbstractInterceptor {
this.prefix = prefix;
}
- public void setContentType(String contentType) {
- this.contentType = contentType;
+ public void setAccept(String accept) {
+ this.accept = accept;
}
}
http://git-wip-us.apache.org/repos/asf/struts/blob/0d490503/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java b/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
index 7bf53d3..ddae716 100644
--- a/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
+++ b/plugins/json/src/test/java/org/apache/struts2/json/JSONInterceptorTest.java
@@ -71,7 +71,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
private void tryBadJSON(String fileName) throws Exception {
// request
setRequestContent(fileName);
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -92,7 +92,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDDisabledSMD() throws Exception {
// request
setRequestContent("smd-3.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
SMDActionTest1 action = new SMDActionTest1();
@@ -111,7 +111,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDAliasedMethodCall1() throws Exception {
// request
setRequestContent("smd-14.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -129,7 +129,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDAliasedMethodCall2() throws Exception {
// request
setRequestContent("smd-15.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -147,7 +147,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDNoMethod() throws Exception {
// request
setRequestContent("smd-4.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -171,7 +171,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDMethodWithoutAnnotations() throws Exception {
// request
setRequestContent("smd-9.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -192,7 +192,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testSMDPrimitivesNoResult() throws Exception {
// request
setRequestContent("smd-6.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -221,13 +221,13 @@ public class JSONInterceptorTest extends StrutsTestCase {
String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
assertEquals(normalizedExpected, normalizedActual);
- assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+ assertEquals("application/json;charset=UTF-8", response.getContentType());
}
public void testSMDReturnObject() throws Exception {
// request
setRequestContent("smd-10.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -245,14 +245,14 @@ public class JSONInterceptorTest extends StrutsTestCase {
String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-12.txt"));
assertEquals(normalizedExpected, normalizedActual);
- assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+ assertEquals("application/json;charset=UTF-8", response.getContentType());
}
@SuppressWarnings("unchecked")
public void testSMDObjectsNoResult() throws Exception {
// request
setRequestContent("smd-7.txt");
- this.request.addHeader("content-type", "application/json-rpc");
+ this.request.addHeader("accept", "application/json-rpc");
JSONInterceptor interceptor = new JSONInterceptor();
interceptor.setEnableSMD(true);
@@ -293,14 +293,14 @@ public class JSONInterceptorTest extends StrutsTestCase {
String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-11.txt"));
assertEquals(normalizedExpected, normalizedActual);
- assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+ assertEquals("application/json;charset=UTF-8", response.getContentType());
}
@SuppressWarnings( { "unchecked", "unchecked" })
public void testReadEmpty() throws Exception {
// request
setRequestContent("json-6.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -315,7 +315,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void test() throws Exception {
// request
setRequestContent("json-1.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -437,7 +437,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testRoot() throws Exception {
setRequestContent("json-5.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -462,7 +462,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testJSONArray() throws Exception {
setRequestContent("json-12.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -488,7 +488,7 @@ public class JSONInterceptorTest extends StrutsTestCase {
public void testJSONArray2() throws Exception {
setRequestContent("json-12.txt");
- this.request.addHeader("content-type", "application/json");
+ this.request.addHeader("accept", "application/json");
// interceptor
JSONInterceptor interceptor = new JSONInterceptor();
@@ -536,6 +536,9 @@ public class JSONInterceptorTest extends StrutsTestCase {
}
class MockActionInvocationEx extends MockActionInvocation {
+
+ private static final long serialVersionUID = 3057703805130170757L;
+
private boolean invoked;
@Override
[6/7] struts git commit: remove old second contentType parameter
Posted by lu...@apache.org.
remove old second contentType parameter
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/d16aa650
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/d16aa650
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/d16aa650
Branch: refs/heads/master
Commit: d16aa65098b5c830d26eb32c00006f793f485036
Parents: 8b8135a
Author: victorsosa <vi...@peopleware.do>
Authored: Fri May 6 18:04:04 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Fri May 6 18:04:04 2016 -0400
----------------------------------------------------------------------
.../src/main/java/org/apache/struts2/json/JSONInterceptor.java | 6 ------
1 file changed, 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/d16aa650/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
----------------------------------------------------------------------
diff --git a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
index 5beb8df..ba775d3 100644
--- a/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
+++ b/plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
@@ -82,12 +82,6 @@ public class JSONInterceptor extends AbstractInterceptor {
accept = request.getHeader("accept");
}
- if (accept != null) {
- int iSemicolonIdx;
- if ((iSemicolonIdx = accept.indexOf(";")) != -1)
- accept = accept.substring(0, iSemicolonIdx);
- }
-
Object rootObject = null;
final ValueStack stack = invocation.getStack();
if (this.root != null) {
[4/7] struts git commit: Merge branch 'ww-4558' of
github.com:victorsosa/struts into ww-4558
Posted by lu...@apache.org.
Merge branch 'ww-4558' of github.com:victorsosa/struts into ww-4558
# Conflicts:
# plugins/json/src/main/java/org/apache/struts2/json/JSONInterceptor.java
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/2fada1ec
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/2fada1ec
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/2fada1ec
Branch: refs/heads/master
Commit: 2fada1ec05e61dfb0b3e43ab447a7673d689c684
Parents: 0d49050 fab687a
Author: victorsosa <vi...@peopleware.do>
Authored: Mon Feb 15 10:34:15 2016 -0400
Committer: victorsosa <vi...@peopleware.do>
Committed: Mon Feb 15 10:35:29 2016 -0400
----------------------------------------------------------------------
----------------------------------------------------------------------