cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1383110 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org...
Date Mon, 10 Sep 2012 21:06:49 GMT
Author: sergeyb
Date: Mon Sep 10 21:06:48 2012
New Revision: 1383110

URL: http://svn.apache.org/viewvc?rev=1383110&view=rev
Log:
[CXF-4455] Minor updates to the filter tests

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java?rev=1383110&r1=1383109&r2=1383110&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
Mon Sep 10 21:06:48 2012
@@ -39,6 +39,7 @@ import javax.ws.rs.core.SecurityContext;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.message.Message;
 
 public class ContainerRequestContextImpl implements ContainerRequestContext {
@@ -201,7 +202,7 @@ public class ContainerRequestContextImpl
         if (!preMatch) {
             throw new IllegalStateException();
         }
-        m.put(Message.REQUEST_URI, requestUri.toString());
+        HttpUtils.resetRequestURI(m, requestUri.toString());
     }
 
     @Override

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1383110&r1=1383109&r2=1383110&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Mon Sep 10 21:06:48 2012
@@ -987,13 +987,12 @@ public final class ProviderFactory {
     public void setSchemaLocations(List<String> schemas) {
         boolean schemasMethodAvailable = false;
         for (ProviderInfo<MessageBodyReader<?>> r : messageReaders) {
-            schemasMethodAvailable = injectProviderProperty(r.getProvider(), "setSchemas",

-                                                            List.class, schemas);
+            schemasMethodAvailable = 
+                injectProviderProperty(r.getProvider(), "setSchemas", List.class, schemas);
         }
         if (!schemasMethodAvailable) {
             for (ProviderInfo<MessageBodyReader<?>> r : jaxbReaders) {
-                schemasMethodAvailable = injectProviderProperty(r.getProvider(), "setSchemas",

-                                                                List.class, schemas);
+                injectProviderProperty(r.getProvider(), "setSchemas", List.class, schemas);
             }
         }
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1383110&r1=1383109&r2=1383110&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Mon
Sep 10 21:06:48 2012
@@ -288,6 +288,13 @@ public final class HttpUtils {
         return u;
     }
     
+    public static void resetRequestURI(Message m, String requestURI) {
+        m.remove(REQUEST_PATH_TO_MATCH_SLASH);
+        m.remove(REQUEST_PATH_TO_MATCH);
+        m.put(Message.REQUEST_URI, requestURI);
+    }
+    
+    
     public static String getPathToMatch(Message m, boolean addSlash) {
         String var = addSlash ? REQUEST_PATH_TO_MATCH_SLASH : REQUEST_PATH_TO_MATCH;
         String pathToMatch = (String)m.get(var);

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java?rev=1383110&r1=1383109&r2=1383110&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
Mon Sep 10 21:06:48 2012
@@ -24,6 +24,7 @@ import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -32,6 +33,8 @@ import javax.ws.rs.container.ContainerRe
 import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.container.ContainerResponseContext;
 import javax.ws.rs.container.ContainerResponseFilter;
+import javax.ws.rs.container.PreMatching;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -83,11 +86,18 @@ public class BookServer20 extends Abstra
         }
     }
     
+    @PreMatching
     private static class PreMatchContainerRequestFilter implements ContainerRequestFilter
{
 
         @Override
         public void filter(ContainerRequestContext context) throws IOException {
             context.getHeaders().add("BOOK", "123");
+            
+            UriInfo ui = context.getUriInfo();
+            String path = ui.getPath(false);
+            if ("wrongpath".equals(path)) {
+                context.setRequestUri(URI.create("/bookstore/bookheaders/simple"));
+            }
         }
         
     }
@@ -109,6 +119,8 @@ public class BookServer20 extends Abstra
         public void filter(ContainerRequestContext requestContext,
                            ContainerResponseContext responseContext) throws IOException {
             responseContext.getHeaders().add("Custom", "custom");
+            Book book = (Book)responseContext.getEntity();
+            responseContext.setEntity(new Book(book.getName(), 1 + book.getId()), null, null);
         }
         
     }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java?rev=1383110&r1=1383109&r2=1383110&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
Mon Sep 10 21:06:48 2012
@@ -39,9 +39,19 @@ public class JAXRS20ClientServerBookTest
     @Test
     public void testGetBook() {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
+        doTestBook(address);
+    }
+    
+    @Test
+    public void testGetBookWrongPath() {
+        String address = "http://localhost:" + PORT + "/wrongpath";
+        doTestBook(address);
+    }
+    
+    private void doTestBook(String address) {
         WebClient wc = WebClient.create(address);
         Book book = wc.get(Book.class);
-        assertEquals(123L, book.getId());
+        assertEquals(124L, book.getId());
         Response response = wc.getResponse();
         assertEquals("OK", response.getHeaderString("Response"));
         assertEquals("custom", response.getHeaderString("Custom"));



Mime
View raw message