[ 
https://issues.apache.org/jira/browse/WW-4589?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Rich P Peters, II updated WW-4589:
----------------------------------
    Description: 
When creating a ActionMapper for a rest url with a method name, an incorrect 
mapping is created.  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}

  was:
when creating a mapper for a rest url with a method name, an incorrect mapping 
is created.  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}


> Struts2 REST plugin does not compute id and action name correctly
> -----------------------------------------------------------------
>
>                 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 P Peters, II
>             Fix For: 2.3.25, 2.5
>
>
> When creating a ActionMapper for a rest url with a method name, an incorrect 
> mapping is created.  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)

Reply via email to