You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/01/19 23:08:39 UTC
[jira] [Commented] (WW-4589) Struts2 REST plugin do not overwrite
method name
[ https://issues.apache.org/jira/browse/WW-4589?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15107554#comment-15107554 ]
ASF GitHub Bot commented on WW-4589:
------------------------------------
GitHub user rpii opened a pull request:
https://github.com/apache/struts/pull/81
WW-4589 do not overwrite explicit method name
Lukasz,
here is a proposed fix for WW-4589. This makes sure a url specified method name is not overwritten by an implied method name. It passes the unit tests that I have added
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rpii/struts WW-4589
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/struts/pull/81.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #81
----
commit 1fb695a82b589cdd6e7b5bc2501dfec6b95c906e
Author: petersr <ri...@braxtontech.com>
Date: 2016-01-19T22:02:57Z
WW-4589 do not overwrite explicit method name
----
> Struts2 REST plugin do not overwrite method name
> ------------------------------------------------
>
> Key: WW-4589
> URL: https://issues.apache.org/jira/browse/WW-4589
> Project: Struts 2
> Issue Type: Bug
> Components: Plugin - REST
> Environment: tomcat
> Reporter: Rich Peters
> Fix For: 2.3.25, 2.5
>
>
> When creating a ActionMapper for a rest url with a method name, an incorrect mapping is created. I haven't been able to determine a fix for this with the new code, but it works in my code provided for WW-4545. A unit test shows the issue:
> {code:java}
> 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());
> }
> {code}
> here is the unit test result:
> {code:java}
> junit.framework.ComparisonFailure: null
> Expected :dog/fido/test
> Actual :dog/fido
> <Click to see difference>
> at junit.framework.Assert.assertEquals(Assert.java:81)
> at junit.framework.Assert.assertEquals(Assert.java:87)
> at org.apache.struts2.rest.RestActionMapperTest.testMappingWithMethodAndId(RestActionMapperTest.java:203)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:243)
> at junit.framework.TestSuite.run(TestSuite.java:238)
> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
> at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
> {code}
> Another test that fails in a different way:
> {code:java}
> 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");
> 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());
> }
> {code}
> Unit test results:
> {code:java}
> junit.framework.ComparisonFailure: null
> Expected :custom/menu/Yosemite/Vernal_Fall
> Actual :custom/menu/Yosemite
> <Click to see difference>
> at junit.framework.Assert.assertEquals(Assert.java:81)
> at junit.framework.Assert.assertEquals(Assert.java:87)
> at org.apache.struts2.rest.RestActionMapperTest.testMappingForStaticFiles(RestActionMapperTest.java:216)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:497)
> at junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:243)
> at junit.framework.TestSuite.run(TestSuite.java:238)
> at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
> at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
> at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)