cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5592] RequestDispatcherProvider should not override HttpServletRequest getRequestURI
Date Wed, 05 Mar 2014 18:03:15 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes a3d5ad37d -> 4faeb62fd


[CXF-5592] RequestDispatcherProvider should not override HttpServletRequest getRequestURI


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4faeb62f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4faeb62f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4faeb62f

Branch: refs/heads/2.7.x-fixes
Commit: 4faeb62fdcf7f0d9fd7f03af2c427d1ba6632d16
Parents: a3d5ad3
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Mar 5 18:00:10 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Mar 5 18:02:49 2014 +0000

----------------------------------------------------------------------
 .../provider/RequestDispatcherProvider.java     |  5 --
 .../cxf/systest/jaxrs/BookStoreSpring.java      | 15 ++++++
 .../jaxrs/JAXRSSimpleRequestDispatcherTest.java | 10 ++++
 .../jaxrs_dispatch_simple/WEB-INF/beans.xml     | 52 ++++++++++++++++++++
 .../jaxrs_dispatch_simple/WEB-INF/web.xml       | 26 +++++-----
 5 files changed, 91 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4faeb62f/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
index 72f9bcf..0b362d1 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/RequestDispatcherProvider.java
@@ -406,11 +406,6 @@ public class RequestDispatcherProvider extends AbstractConfigurableProvider
             return path;
         }
         
-        @Override
-        public String getRequestURI() {
-            return path;
-        }
-        
         public void setParameter(String name, String value) {
             doSetParameters(name, new String[]{value});
         }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4faeb62f/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
index 6d062b3..ecd701a 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
@@ -28,6 +28,7 @@ import java.util.Map;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.InternalServerErrorException;
@@ -85,6 +86,20 @@ public class BookStoreSpring {
     }
     
     @GET
+    @Path("/books/redirectStart")
+    public Book getBookRedirectStart() {
+        return new Book("Redirect start", 123L); 
+    }
+    
+    @GET
+    @Path("/books/redirectComplete")
+    public Book getBookRedirectComplete(@Context HttpServletRequest request) {
+        Book book = (Book)request.getAttribute(Book.class.getSimpleName().toLowerCase());
+        book.setName("Redirect complete");
+        return book; 
+    }
+    
+    @GET
     @Path("/books/webex2")
     public Books getBookWebEx2() {
         throw new InternalServerErrorException(new RuntimeException("Book web exception"));


http://git-wip-us.apache.org/repos/asf/cxf/blob/4faeb62f/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSimpleRequestDispatcherTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSimpleRequestDispatcherTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSimpleRequestDispatcherTest.java
index 7c6d7c4..936a864 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSimpleRequestDispatcherTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSimpleRequestDispatcherTest.java
@@ -55,5 +55,15 @@ public class JAXRSSimpleRequestDispatcherTest extends AbstractBusClientServerTes
         assertEquals("Welcome", welcome);
     }
     
+    @Test
+    public void testGetRedirectedBook() throws Exception {
+        String address = "http://localhost:" + PORT + "/dispatch/bookstore2/books/redirectStart";
+        WebClient client = WebClient.create(address);
+        WebClient.getConfig(client).getHttpConduit().getClient().setReceiveTimeout(10000000L);
+        client.accept("application/json");
+        Book book = client.get(Book.class);
+        assertEquals("Redirect complete", book.getName());
+    }
+    
     
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4faeb62f/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/beans.xml
new file mode 100644
index 0000000..f43aacf
--- /dev/null
+++ b/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/beans.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<!-- START SNIPPET: beans -->
+<!--beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:simple="http://cxf.apache.org/simple"
+  xsi:schemaLocation="
+  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"-->
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util
 http://www.springframework.org/schema/util/spring-util.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+    <import resource="classpath:META-INF/cxf/cxf.xml"/>
+    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+    <bean class="org.apache.cxf.systest.jaxrs.BookStoreSpring" id="serviceBean"/>
+    <jaxrs:server id="bookservice" address="/bookstore">
+        <jaxrs:serviceBeans>
+            <ref bean="serviceBean"/>
+        </jaxrs:serviceBeans>
+    </jaxrs:server>
+    <jaxrs:server id="bookservice2" address="/bookstore2">
+        <jaxrs:serviceBeans>
+            <ref bean="serviceBean"/>
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <bean class="org.apache.cxf.jaxrs.provider.RequestDispatcherProvider">
+                <property name="produceMediaTypes">
+                    <list>
+                      <value>application/json</value>
+                    </list>
+                </property>
+                <property name="resourcePath" value="/bookstore/books/redirectComplete"/>
+            </bean>
+        </jaxrs:providers>
+    </jaxrs:server>
+</beans>
+<!-- END SNIPPET: beans -->

http://git-wip-us.apache.org/repos/asf/cxf/blob/4faeb62f/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/web.xml
index c7203ac..ac100a1 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/web.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_dispatch_simple/WEB-INF/web.xml
@@ -20,15 +20,21 @@
 -->
 <!-- START SNIPPET: webxml -->
 <web-app>
+    <context-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>WEB-INF/beans.xml</param-value>
+    </context-param>
+    <listener>
+        <listener-class>
+                        org.springframework.web.context.ContextLoaderListener
+                </listener-class>
+    </listener>
     <servlet>
-    <servlet-name>CXFServlet</servlet-name>
-    <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
-    <init-param>
-      <param-name>jaxrs.serviceClasses</param-name>
-      <param-value>
-           org.apache.cxf.systest.jaxrs.BookStore
-      </param-value>
-    </init-param>  
+        <servlet-name>CXFServlet</servlet-name>
+        <display-name>CXF Servlet</display-name>
+        <servlet-class>
+                        org.apache.cxf.transport.servlet.CXFServlet
+                </servlet-class>  
     <init-param>
         <param-name>redirects-list</param-name>
         <param-value>/welcome.txt</param-value>
@@ -37,10 +43,6 @@
         <param-name>redirect-servlet-name</param-name>
         <param-value>default</param-value>
     </init-param>
-    <init-param>
-        <param-name>redirect-attributes</param-name>
-        <param-value>javax.servlet.include.request_uri</param-value>
-    </init-param>
     <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>


Mime
View raw message