cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1533535 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 18 Oct 2013 16:19:52 GMT
Author: sergeyb
Date: Fri Oct 18 16:19:51 2013
New Revision: 1533535

URL: http://svn.apache.org/r1533535
Log:
Merged revisions 1533457 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1533457 | sergeyb | 2013-10-18 15:07:20 +0100 (Fri, 18 Oct 2013) | 1 line
  
  [CXF-5343,CXF-5316] Updating the phase of ClientRequestFilterInterceptor, adding a test
to confirm that changing Content-Type in server filter affects the method selection
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1533457

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java?rev=1533535&r1=1533534&r2=1533535&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestFilterInterceptor.java
Fri Oct 18 16:19:51 2013
@@ -40,7 +40,7 @@ import org.apache.cxf.transport.MessageO
 public class ClientRequestFilterInterceptor extends AbstractOutDatabindingInterceptor {
 
     public ClientRequestFilterInterceptor() {
-        super(Phase.WRITE);
+        super(Phase.PRE_LOGICAL);
     }
     
     public void handleMessage(Message outMessage) throws Fault {

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java?rev=1533535&r1=1533534&r2=1533535&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
Fri Oct 18 16:19:51 2013
@@ -145,6 +145,11 @@ public class BookServer20 extends Abstra
                     context.setMethod("POST");
                 }
                 context.getHeaders().putSingle("Content-Type", "application/xml");
+            } else {
+                String newMt = context.getHeaderString("newmediatype");
+                if (newMt != null) {
+                    context.getHeaders().putSingle("Content-Type", newMt);
+                }
             }
             List<MediaType> acceptTypes = context.getAcceptableMediaTypes();
             if (acceptTypes.size() == 1 && acceptTypes.get(0).toString().equals("text/mistypedxml"))
{

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1533535&r1=1533534&r2=1533535&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Fri Oct 18 16:19:51 2013
@@ -635,12 +635,40 @@ public class BookStore {
     @Path("/bookheaders/simple/")
     @CustomHeaderAdded
     @PostMatchMode
+    @Consumes("application/xml")
     public Response echoBookByHeaderSimple(Book book,
+        @HeaderParam("Content-type") String ct,
         @HeaderParam("BOOK") String headerBook,
         @HeaderParam("Simple") String headerSimple,
         @HeaderParam("ServerReaderInterceptor") String serverInterceptorHeader,
         @HeaderParam("ClientWriterInterceptor") String clientInterceptorHeader) throws Exception
{
-        
+        if (!"application/xml".equals(ct)) {
+            throw new RuntimeException();
+        }
+        ResponseBuilder builder = getBookByHeaderSimpleBuilder(headerBook, headerSimple);
+        if (serverInterceptorHeader != null) {
+            builder.header("ServerReaderInterceptor", serverInterceptorHeader);
+        }
+        if (clientInterceptorHeader != null) {
+            builder.header("ClientWriterInterceptor", clientInterceptorHeader);
+        }
+        return builder.build();
+    }
+    
+    @POST
+    @Path("/bookheaders/simple/")
+    @CustomHeaderAdded
+    @PostMatchMode
+    @Consumes("application/v1+xml")
+    public Response echoBookByHeaderSimple2(Book book,
+        @HeaderParam("Content-type") String ct,                                    
+        @HeaderParam("BOOK") String headerBook,
+        @HeaderParam("Simple") String headerSimple,
+        @HeaderParam("ServerReaderInterceptor") String serverInterceptorHeader,
+        @HeaderParam("ClientWriterInterceptor") String clientInterceptorHeader) throws Exception
{
+        if (!"application/v1+xml".equals(ct)) {
+            throw new RuntimeException();
+        }
         ResponseBuilder builder = getBookByHeaderSimpleBuilder(headerBook, headerSimple);
         if (serverInterceptorHeader != null) {
             builder.header("ServerReaderInterceptor", serverInterceptorHeader);
@@ -648,6 +676,7 @@ public class BookStore {
         if (clientInterceptorHeader != null) {
             builder.header("ClientWriterInterceptor", clientInterceptorHeader);
         }
+        builder.header("newmediatypeused", ct);
         return builder.build();
     }
     

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java?rev=1533535&r1=1533534&r2=1533535&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
Fri Oct 18 16:19:51 2013
@@ -20,6 +20,7 @@
 package org.apache.cxf.systest.jaxrs;
 
 import java.io.IOException;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -252,12 +253,12 @@ public class JAXRS20ClientServerBookTest
     @Test
     public void testReplaceBookMistypedCTAndHttpVerb() throws Exception {
         
-        String endpointAddress = "http://localhost:" + PORT + "/bookstore/books2"; 
+        String endpointAddress = "http://localhost:" + PORT + "/bookstore/books2/mistyped";

         WebClient wc = WebClient.create(endpointAddress,
                                         Collections.singletonList(new ReplaceBodyFilter()));
         WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(1000000L);
         wc.accept("text/mistypedxml").type("text/xml").header("THEMETHOD", "PUT");
-        Book book = wc.put(new Book("book", 555L), Book.class);
+        Book book = wc.invoke("DELETE", new Book("book", 555L), Book.class);
         assertEquals(561L, book.getId());
     }
     
@@ -493,6 +494,17 @@ public class JAXRS20ClientServerBookTest
     }
     
     @Test
+    public void testPostBookNewMediaType() {
+        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
+        WebClient wc = createWebClientPost(address);
+        wc.header("newmediatype", "application/v1+xml");
+        Book book = wc.post(new Book("Book", 126L), Book.class);
+        assertEquals(124L, book.getId());
+        validatePostResponse(wc);
+        assertEquals("application/v1+xml", wc.getResponse().getHeaderString("newmediatypeused"));
+    }
+    
+    @Test
     public void testBookExistsServerStreamReplace() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/books/check2";
         WebClient wc = WebClient.create(address);
@@ -531,7 +543,9 @@ public class JAXRS20ClientServerBookTest
             String expectedMethod = null; 
             if (rc.getAcceptableMediaTypes().contains(MediaType.valueOf("text/mistypedxml"))
                 && rc.getHeaders().getFirst("THEMETHOD") != null) {
-                expectedMethod = "PUT";
+                expectedMethod = "DELETE";
+                rc.setUri(URI.create("http://localhost:" + PORT + "/bookstore/books2"));
+                rc.setMethod(rc.getHeaders().getFirst("THEMETHOD").toString());
             } else {
                 expectedMethod = "POST";
             }



Mime
View raw message