Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 385A79594 for ; Wed, 20 Jun 2012 17:20:16 +0000 (UTC) Received: (qmail 29449 invoked by uid 500); 20 Jun 2012 17:20:16 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 29404 invoked by uid 500); 20 Jun 2012 17:20:16 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 29397 invoked by uid 99); 20 Jun 2012 17:20:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jun 2012 17:20:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jun 2012 17:20:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AFDBE2388D00; Wed, 20 Jun 2012 17:19:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120620171951.AFDBE2388D00@eris.apache.org> 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