cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1352214 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ rt/transports/local/src/main/java/org/apache/cxf/transport/local/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Wed, 20 Jun 2012 17:19:51 GMT
Author: sergeyb
Date: Wed Jun 20 17:19:51 2012
New Revision: 1352214

URL: http://svn.apache.org/viewvc?rev=1352214&view=rev
Log:
[CXF-4390] Initial support for Local transport in the JAX-RS client runtime

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=1352214&r1=1352213&r2=1352214&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Wed Jun 20 17:19:51 2012
@@ -320,7 +320,10 @@ public abstract class AbstractClient imp
     protected ResponseBuilder setResponseBuilder(Message outMessage, Exchange exchange) throws
Exception {
         checkClientException(exchange.getOutMessage(), exchange.getOutMessage().getContent(Exception.class));
         
-        int status = (Integer)exchange.get(Message.RESPONSE_CODE);
+        Integer status = (Integer)exchange.get(Message.RESPONSE_CODE);
+        if (status == null) {
+            status = (Integer)exchange.getInMessage().get(Message.RESPONSE_CODE);
+        }
         ResponseBuilder currentResponseBuilder = Response.status(status);
         
         Message responseMessage = exchange.getInMessage() != null 
@@ -493,8 +496,12 @@ public abstract class AbstractClient imp
         return result != null ? result.toArray() : null;
     }
     
-    protected void checkClientException(Message message, Exception ex) throws Exception {
-        if (message.getExchange().get(Message.RESPONSE_CODE) == null) {
+    protected void checkClientException(Message outMessage, Exception ex) throws Exception
{
+        if (outMessage.getExchange().get(Message.RESPONSE_CODE) == null) {
+            Message inMessage = outMessage.getExchange().getInMessage();
+            if (inMessage != null && inMessage.get(Message.RESPONSE_CODE) != null)
{
+                return;
+            }
             if (ex instanceof ClientWebApplicationException) {
                 throw ex;
             } else if (ex != null) {
@@ -750,7 +757,7 @@ public abstract class AbstractClient imp
         
         m.put(Message.HTTP_REQUEST_METHOD, httpMethod);
         m.put(Message.PROTOCOL_HEADERS, headers);
-        if (currentURI.isAbsolute()) {
+        if (currentURI.isAbsolute() && currentURI.getScheme().startsWith(HTTP_SCHEME))
{
             m.put(Message.ENDPOINT_ADDRESS, currentURI.toString());
         } else {
             m.put(Message.ENDPOINT_ADDRESS, state.getBaseURI().toString());

Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java?rev=1352214&r1=1352213&r2=1352214&view=diff
==============================================================================
--- cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
(original)
+++ cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalTransportFactory.java
Wed Jun 20 17:19:51 2012
@@ -94,6 +94,8 @@ public class LocalTransportFactory exten
         messageIncludeProperties.add(Message.CONTENT_TYPE);
         messageIncludeProperties.add(Message.ACCEPT_CONTENT_TYPE);
         messageIncludeProperties.add(Message.RESPONSE_CODE);
+        messageIncludeProperties.add(Message.REQUEST_URI);
+        messageIncludeProperties.add(Message.HTTP_REQUEST_METHOD);
         
         bus = b;
         register();

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1352214&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Wed Jun 20 17:19:51 2012
@@ -0,0 +1,67 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.local.LocalConduit;
+import org.apache.cxf.transport.local.LocalTransportFactory;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class JAXRSLocalTransportTest extends AbstractBusClientServerTestBase {
+ 
+    private Server localServer;
+    
+    @Before
+    public void setUp() {
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        sf.setResourceClasses(BookStore.class);
+        sf.setResourceProvider(BookStore.class,
+                               new SingletonResourceProvider(new BookStore(), true));
+        sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
+        sf.setAddress("local://books");
+        localServer = sf.create();
+    }
+    
+    @After
+    public void tearDown() {
+        if (localServer != null) {
+            localServer.stop();
+        }
+    }
+    
+    @Test
+    public void testProxy() throws Exception {
+        BookStore localProxy = 
+            JAXRSClientFactory.create("local://books", BookStore.class);
+        
+        WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,
Boolean.TRUE);
+        
+        Book book = localProxy.getBook("123");
+        assertEquals(123L, book.getId());
+    }
+}

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message