cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1477580 - in /cxf/branches/2.6.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/...
Date Tue, 30 Apr 2013 12:01:57 GMT
Author: sergeyb
Date: Tue Apr 30 12:01:56 2013
New Revision: 1477580

URL: http://svn.apache.org/r1477580
Log:
Merged revisions 1477566 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

................
  r1477566 | sergeyb | 2013-04-30 12:32:21 +0100 (Tue, 30 Apr 2013) | 17 lines
  
  Merged revisions 1477528,1477532,1477553 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1477528 | sergeyb | 2013-04-30 11:13:43 +0100 (Tue, 30 Apr 2013) | 1 line
    
    [CXF-4992] Fixing subresource proxies invoking on non-HTTP endpoints
  ........
    r1477532 | sergeyb | 2013-04-30 11:17:45 +0100 (Tue, 30 Apr 2013) | 1 line
    
    [CXF-4992] Test server flag update
  ........
    r1477553 | sergeyb | 2013-04-30 12:06:05 +0100 (Tue, 30 Apr 2013) | 1 line
    
    [CXF-4992] Minor cleanup
  ........
................

Modified:
    cxf/branches/2.6.x-fixes/   (props changed)
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
    cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java

Propchange: cxf/branches/2.6.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/branches/2.7.x-fixes:r1477566
  Merged /cxf/trunk:r1477528-1477553

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

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/LocalClientState.java
Tue Apr 30 12:01:56 2013
@@ -46,14 +46,18 @@ public class LocalClientState implements
     
     public LocalClientState(URI baseURI) {
         this.baseURI = baseURI;
-        String scheme = baseURI.getScheme();
-        if (!StringUtils.isEmpty(scheme) && scheme.startsWith(HTTP_SCHEME)) {
+        if (isHttpScheme(baseURI)) {
             this.currentBuilder = UriBuilder.fromUri(baseURI);
         } else {
             this.currentBuilder = UriBuilder.fromUri("/");
         }
     }
     
+    public LocalClientState(URI baseURI, URI currentURI) {
+        this.baseURI = baseURI;
+        this.currentBuilder = UriBuilder.fromUri(currentURI);
+    }
+    
     public LocalClientState(LocalClientState cs) {
         this.requestHeaders = new MetadataMap<String, String>(cs.requestHeaders);
         this.templates = cs.templates == null ? null : new MetadataMap<String, String>(cs.templates);
@@ -117,10 +121,15 @@ public class LocalClientState implements
         templates = null;
     }
     
-    public ClientState newState(URI newBaseURI, 
+    public ClientState newState(URI currentURI, 
                                 MultivaluedMap<String, String> headers,
                                 MultivaluedMap<String, String> templatesMap) {
-        ClientState state = new LocalClientState(newBaseURI);
+        ClientState state = null;
+        if (isHttpScheme(currentURI)) {
+            state = new LocalClientState(currentURI);
+        } else {
+            state = new LocalClientState(baseURI, currentURI);
+        }
         if (headers != null) {
             state.setRequestHeaders(headers);
         }
@@ -134,4 +143,8 @@ public class LocalClientState implements
         state.setTemplates(newTemplateParams);
         return state;
     }
+
+    private static boolean isHttpScheme(URI uri) {
+        return !StringUtils.isEmpty(uri.getScheme()) && uri.getScheme().startsWith(HTTP_SCHEME);
+    }
 }

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ThreadLocalClientState.java
Tue Apr 30 12:01:56 2013
@@ -101,12 +101,10 @@ public class ThreadLocalClientState impl
         removeThreadLocalState(Thread.currentThread());
     }
     
-    public ClientState newState(URI baseURI, 
+    public ClientState newState(URI currentURI, 
                                 MultivaluedMap<String, String> headers,
                                 MultivaluedMap<String, String> templates) {
-        LocalClientState ls = new LocalClientState(baseURI);
-        ls.setRequestHeaders(headers);
-        ls.setTemplates(templates);
+        LocalClientState ls = (LocalClientState)getState().newState(currentURI, headers,
templates);
         return new ThreadLocalClientState(ls, timeToKeepState);
     }
     

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Tue Apr 30 12:01:56 2013
@@ -25,6 +25,7 @@ import java.util.ResourceBundle;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -117,6 +118,9 @@ public class JAXRSInInterceptor extends 
             }
         }
         
+        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,

+                                                        HttpMethod.POST, true);
+        
         String requestContentType = (String)message.get(Message.CONTENT_TYPE);
         if (requestContentType == null) {
             requestContentType = "*/*";
@@ -160,7 +164,6 @@ public class JAXRSInInterceptor extends 
 
         message.getExchange().put(JAXRSUtils.ROOT_RESOURCE_CLASS, resource);
 
-        String httpMethod = HttpUtils.getProtocolHeader(message, Message.HTTP_REQUEST_METHOD,
"POST");
         OperationResourceInfo ori = null;     
         
         boolean operChecked = false;

Modified: cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
Tue Apr 30 12:01:56 2013
@@ -253,9 +253,16 @@ public final class HttpUtils {
     }
     
     public static String getProtocolHeader(Message m, String name, String defaultValue) {
+        return getProtocolHeader(m, name, defaultValue, false);
+    }
+    
+    public static String getProtocolHeader(Message m, String name, String defaultValue, boolean
setOnMessage) {
         String value = (String)m.get(name);
         if (value == null) {
             value = new HttpHeadersImpl(m).getRequestHeaders().getFirst(name);
+            if (value != null && setOnMessage) {
+                m.put(name, value);
+            }
         }
         return value == null ? defaultValue : value;
     }

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
Tue Apr 30 12:01:56 2013
@@ -68,6 +68,7 @@ public class Book {
     }
     
     @GET
+    @Produces("application/xml")
     public Book retrieveState() {
         return this;
     }

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java
Tue Apr 30 12:01:56 2013
@@ -125,6 +125,22 @@ public class JAXRSJmsTest extends Abstra
     }
     
     @Test
+    public void testGetBookFromSubresourceProxyClient() throws Exception {
+        // setup the the client
+        String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"
+             + "?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
+             + "&replyToName=dynamicQueues/test.jmstransport.response"
+             + "&jndiURL=tcp://localhost:" + JMS_PORT
+             + "&jndiConnectionFactoryName=ConnectionFactory";
+               
+        JMSBookStore client = JAXRSClientFactory.create(endpointAddressUrlEncoded, JMSBookStore.class);
+        Book bookProxy = client.getBookSubResource("123");
+        Book book = bookProxy.retrieveState();
+        assertEquals("Get a wrong response code.", 200, WebClient.client(bookProxy).getResponse().getStatus());
+        assertEquals("Get a wrong book id.", 123, book.getId());
+    }
+    
+    @Test
     public void testGetBookFromProxyClientWithQuery() throws Exception {
         // setup the the client
         String endpointAddressUrlEncoded = "jms:jndi:dynamicQueues/test.jmstransport.text"

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Tue Apr 30 12:01:56 2013
@@ -70,6 +70,18 @@ public class JAXRSLocalTransportTest ext
     }
     
     @Test
+    public void testSubresourceProxyDirectDispatchGet() throws Exception {
+        BookStore localProxy = 
+            JAXRSClientFactory.create("local://books", BookStore.class);
+        
+        WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,
Boolean.TRUE);
+        
+        Book bookSubProxy = localProxy.getBookSubResource("123");
+        Book book = bookSubProxy.retrieveState();
+        assertEquals(123L, book.getId());
+    }
+    
+    @Test
     public void testProxyDirectDispatchPostWithGzip() throws Exception {
         BookStore localProxy = 
             JAXRSClientFactory.create("local://books", BookStore.class);

Modified: cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java?rev=1477580&r1=1477579&r2=1477580&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JMSBookStore.java
Tue Apr 30 12:01:56 2013
@@ -84,6 +84,11 @@ public class JMSBookStore {
         return doGetBook(id);
     }
     
+    @Path("/booksubresource/{bookId}/")
+    public Book getBookSubResource(@PathParam("bookId") String id) throws BookNotFoundFault
{
+        return doGetBook(id);
+    }
+    
     private Book doGetBook(String id) throws BookNotFoundFault {
         Book book = books.get(Long.parseLong(id));
         if (book != null) {



Mime
View raw message