cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1479982 - in /cxf/trunk: rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/
Date Tue, 07 May 2013 17:03:12 GMT
Author: sergeyb
Date: Tue May  7 17:03:11 2013
New Revision: 1479982

URL: http://svn.apache.org/r1479982
Log:
[CXF-4953] Updating FrontendClientAdapter and ClientConfiguration to return Endpoint

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientConfiguration.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientConfiguration.java?rev=1479982&r1=1479981&r2=1479982&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientConfiguration.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/ClientConfiguration.java
Tue May  7 17:03:11 2013
@@ -232,4 +232,8 @@ public class ClientConfiguration impleme
     public Map<String, Object> getRequestContext() {
         return requestContext;
     }
+    
+    public Endpoint getEndpoint() {
+        return conduitSelector == null ? null : conduitSelector.getEndpoint();
+    }
 }

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java?rev=1479982&r1=1479981&r2=1479982&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/FrontendClientAdapter.java
Tue May  7 17:03:11 2013
@@ -88,11 +88,36 @@ class FrontendClientAdapter implements o
     
     @Override
     public Endpoint getEndpoint() {
-        throw new UnsupportedOperationException();
+        return config.getEndpoint();
     }
     
     @Override
     public void destroy() {
+        //complete, the actual JAX-RS Client will be closed via a different path 
+    }
+    
+    @Override
+    public Map<String, Object> getRequestContext() {
+        return config.getRequestContext();
+    }
+
+    @Override
+    public Map<String, Object> getResponseContext() {
+        return config.getResponseContext();
+    }
+    
+    @Override
+    public void setThreadLocalRequestContext(boolean b) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public boolean isThreadLocalRequestContext() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void setExecutor(Executor executor) {
         throw new UnsupportedOperationException();
     }
     
@@ -184,28 +209,5 @@ class FrontendClientAdapter implements o
         throw new UnsupportedOperationException();
     }
 
-    @Override
-    public Map<String, Object> getRequestContext() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public Map<String, Object> getResponseContext() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void setThreadLocalRequestContext(boolean b) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public boolean isThreadLocalRequestContext() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void setExecutor(Executor executor) {
-        throw new UnsupportedOperationException();
-    }
+    
 }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java?rev=1479982&r1=1479981&r2=1479982&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
Tue May  7 17:03:11 2013
@@ -22,6 +22,11 @@ package org.apache.cxf.systest.jaxrs.sec
 import javax.ws.rs.core.MediaType;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.ClientLifeCycleListener;
+import org.apache.cxf.endpoint.ClientLifeCycleManager;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
@@ -34,7 +39,6 @@ import org.junit.Test;
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-
 public class JAXRSHttpsBookTest extends AbstractBusClientServerTestBase {
     public static final String PORT = BookHttpsServer.PORT;
 
@@ -128,8 +132,14 @@ public class JAXRSHttpsBookTest extends 
         Object bean = ctx.getBean("bookService.proxyFactory");
         assertNotNull(bean);
         JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
-        
+        Bus bus = cfb.getBus();
+        ClientLifeCycleManager manager = bus.getExtension(ClientLifeCycleManager.class);
+        TestClientLifeCycleListener listener = new TestClientLifeCycleListener();
+        manager.registerListener(listener);
         BookStore bs = cfb.create(BookStore.class);
+        assertNotNull(listener.getEp());
+        assertEquals("{http://service.rs}BookService", 
+                     listener.getEp().getEndpointInfo().getName().toString());
         assertEquals("https://localhost:" + PORT, WebClient.client(bs).getBaseURI().toString());
         Book b = bs.getSecureBook("123");
         assertEquals(b.getId(), 123);
@@ -204,4 +214,25 @@ public class JAXRSHttpsBookTest extends 
             this.id = id;
         }
     }
+    
+    public static class TestClientLifeCycleListener implements ClientLifeCycleListener {
+
+        private Endpoint ep;
+        
+        @Override
+        public void clientCreated(Client client) {
+            this.ep = client.getEndpoint();
+        }
+
+        @Override
+        public void clientDestroyed(Client client) {
+            ep = null;
+            
+        }
+
+        public Endpoint getEp() {
+            return ep;
+        }
+        
+    }
 }



Mime
View raw message