Return-Path: X-Original-To: apmail-struts-issues-archive@minotaur.apache.org Delivered-To: apmail-struts-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2090218D85 for ; Fri, 15 Jan 2016 15:58:41 +0000 (UTC) Received: (qmail 59341 invoked by uid 500); 15 Jan 2016 15:58:40 -0000 Delivered-To: apmail-struts-issues-archive@struts.apache.org Received: (qmail 59212 invoked by uid 500); 15 Jan 2016 15:58:40 -0000 Mailing-List: contact issues-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list issues@struts.apache.org Received: (qmail 59182 invoked by uid 99); 15 Jan 2016 15:58:40 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Jan 2016 15:58:40 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id D4BB52C1F60 for ; Fri, 15 Jan 2016 15:58:39 +0000 (UTC) Date: Fri, 15 Jan 2016 15:58:39 +0000 (UTC) From: "Rich P Peters, II (JIRA)" To: issues@struts.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (WW-4589) Struts2 REST plugin does not compute id and action name correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Rich P Peters, II created WW-4589: ------------------------------------- Summary: 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 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 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 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)