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/01/20 10:17:12 UTC

[1/2] struts git commit: WW-4589 do not overwrite explicit method name

Repository: struts
Updated Branches:
  refs/heads/support-2-3 a39879317 -> 10a612c9d


WW-4589 do not overwrite explicit method name

Conflicts:
	plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java


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

Branch: refs/heads/support-2-3
Commit: 1d160f4d5f166b4806b475562a8808ac1eeae4aa
Parents: c6750c1
Author: petersr <ri...@braxtontech.com>
Authored: Tue Jan 19 14:02:57 2016 -0800
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jan 20 10:06:46 2016 +0100

----------------------------------------------------------------------
 .../apache/struts2/rest/RestActionMapper.java   |  3 +-
 .../struts2/rest/RestActionMapperTest.java      | 68 ++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/1d160f4d/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
----------------------------------------------------------------------
diff --git a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
index c4fd827..07957de 100644
--- a/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
+++ b/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
@@ -215,7 +215,8 @@ public class RestActionMapper extends DefaultActionMapper {
 
                 // fun trickery to parse 'actionName/id/methodName' in the case of 'animals/dog/edit'
                 int prevSlashPos = fullName.lastIndexOf('/', lastSlashPos - 1);
-                if (prevSlashPos > -1) {
+                //WW-4589 do not overwrite explicit method name
+                if (prevSlashPos > -1 && mapping.getMethod() == null) {
                     mapping.setMethod(fullName.substring(lastSlashPos + 1));
                     fullName = fullName.substring(0, lastSlashPos);
                     lastSlashPos = prevSlashPos;

http://git-wip-us.apache.org/repos/asf/struts/blob/1d160f4d/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
----------------------------------------------------------------------
diff --git a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
index 8d39cc1..d2e7777 100644
--- a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
+++ b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
@@ -179,6 +179,74 @@ public class RestActionMapperTest extends TestCase {
         assertEquals("show", mapping.getMethod());
     }
 
+    public void testGetJsessionIdSemicolonMappingWithMethod() throws Exception {
+        req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g");
+        req.setServletPath("/animals/dog/fido");
+        req.setMethod("GET");
+        
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("/animals", mapping.getNamespace());
+        assertEquals("dog", mapping.getName());
+        assertEquals("fido", ((String[]) mapping.getParams().get("id"))[0]);
+        assertEquals("show", mapping.getMethod());
+    }
+
+    public void testGetJsessionIdSemicolonMappingWithMethodAllowDMI() throws Exception {
+        req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g");
+        req.setServletPath("/animals/dog/fido");
+        req.setMethod("GET");
+        
+        // allow DMI
+        mapper.setAllowDynamicMethodCalls("true");
+        
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("/animals", mapping.getNamespace());
+        assertEquals("dog", mapping.getName());
+        assertEquals("fido", ((String[]) mapping.getParams().get("id"))[0]);
+        assertEquals("update", mapping.getMethod());
+    }
+
+    public void testMappingWithMethodAndId() throws Exception {
+        req.setRequestURI("/myapp/animals/dog/fido/test/some-id!create;jsessionid=29fefpv23do1g");
+        req.setServletPath("/animals/dog/fido/test/some-id");
+        req.setMethod("GET");
+        mapper.setAllowDynamicMethodCalls("true");
+        ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("/animals", mapping.getNamespace());
+        assertEquals("dog/fido/test", mapping.getName());
+        assertEquals("some-id", ((String[]) mapping.getParams().get("id"))[0]);
+        assertEquals("create", mapping.getMethod());
+    }
+
+    public void testMappingForStaticFiles() throws Exception {
+        req.setRequestURI("/myApp/custom/menu/Yosemite/Vernal_Fall/Vernal_Fall_Image!iframe");
+        req.setServletPath("/custom/menu/Yosemite/Vernal_Fall/Vernal_Fall_Image");
+        req.setMethod("GET");
+        mapper.setAllowDynamicMethodCalls("true");
+        final ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("", mapping.getNamespace());
+        assertEquals("custom/menu/Yosemite/Vernal_Fall", mapping.getName());
+        assertEquals("Vernal_Fall_Image", ((String[]) mapping.getParams().get("id"))[0]);
+        assertEquals("iframe", mapping.getMethod());
+    }
+
+    public void testMappingForStaticFilesWithJsessionId() throws Exception {
+        req.setRequestURI("/myApp/custom/menu/Yosemite/Vernal_Fall/Vernal_Fall_Image!iframe;jsessionid=29fefpv23do1g");
+        req.setServletPath("/custom/menu/Yosemite/Vernal_Fall/Vernal_Fall_Image");
+        req.setMethod("GET");
+        mapper.setAllowDynamicMethodCalls("true");
+        final ActionMapping mapping = mapper.getMapping(req, configManager);
+
+        assertEquals("", mapping.getNamespace());
+        assertEquals("custom/menu/Yosemite/Vernal_Fall", mapping.getName());
+        assertEquals("Vernal_Fall_Image", ((String[]) mapping.getParams().get("id"))[0]);
+        assertEquals("iframe", mapping.getMethod());
+    }
+
     public void testParseNameAndNamespace() {
         tryUri("/foo/23", "", "foo/23");
         tryUri("/foo/", "", "foo/");


[2/2] struts git commit: Merge branch 'support-2-3' of https://git-wip-us.apache.org/repos/asf/struts into support-2-3

Posted by lu...@apache.org.
Merge branch 'support-2-3' of https://git-wip-us.apache.org/repos/asf/struts into support-2-3

Conflicts:
	plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java


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

Branch: refs/heads/support-2-3
Commit: 10a612c9da84a77edef7a1394fd71b4024eee268
Parents: 1d160f4 a398793
Author: Lukasz Lenart <lu...@apache.org>
Authored: Wed Jan 20 10:13:03 2016 +0100
Committer: Lukasz Lenart <lu...@apache.org>
Committed: Wed Jan 20 10:13:03 2016 +0100

----------------------------------------------------------------------
 .../dispatcher/mapper/Restful2ActionMapper.java |   6 +-
 .../dispatcher/mapper/RestfulActionMapper.java  |   6 +-
 .../org/apache/struts2/util/URLDecoderUtil.java |  22 +
 .../apache/struts2/util/tomcat/buf/Ascii.java   | 255 +++++
 .../struts2/util/tomcat/buf/B2CConverter.java   | 201 ++++
 .../struts2/util/tomcat/buf/ByteChunk.java      | 935 +++++++++++++++++++
 .../struts2/util/tomcat/buf/CharChunk.java      | 700 ++++++++++++++
 .../struts2/util/tomcat/buf/HexUtils.java       | 113 +++
 .../struts2/util/tomcat/buf/MessageBytes.java   | 546 +++++++++++
 .../struts2/util/tomcat/buf/StringCache.java    | 695 ++++++++++++++
 .../struts2/util/tomcat/buf/UDecoder.java       | 421 +++++++++
 .../struts2/util/tomcat/buf/Utf8Decoder.java    | 293 ++++++
 .../struts2/views/util/DefaultUrlHelper.java    |   8 +-
 .../apache/struts2/util/URLDecoderUtilTest.java |  71 ++
 .../apache/struts2/rest/RestActionMapper.java   |  15 +-
 .../struts2/rest/DefaultHttpHeadersTest.java    |  16 +-
 .../struts2/rest/RestActionMapperTest.java      |   6 +-
 pom.xml                                         |  19 +
 18 files changed, 4309 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/10a612c9/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/struts/blob/10a612c9/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
----------------------------------------------------------------------
diff --cc plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
index d2e7777,9903265..3de37d4
--- a/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
+++ b/plugins/rest/src/test/java/org/apache/struts2/rest/RestActionMapperTest.java
@@@ -183,7 -183,7 +183,7 @@@ public class RestActionMapperTest exten
          req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g");
          req.setServletPath("/animals/dog/fido");
          req.setMethod("GET");
--        
++
          ActionMapping mapping = mapper.getMapping(req, configManager);
  
          assertEquals("/animals", mapping.getNamespace());
@@@ -196,10 -196,10 +196,10 @@@
          req.setRequestURI("/myapp/animals/dog/fido!update;jsessionid=29fefpv23do1g");
          req.setServletPath("/animals/dog/fido");
          req.setMethod("GET");
--        
++
          // allow DMI
          mapper.setAllowDynamicMethodCalls("true");
--        
++
          ActionMapping mapping = mapper.getMapping(req, configManager);
  
          assertEquals("/animals", mapping.getNamespace());