cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1518959 - in /cxf/trunk: rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Fri, 30 Aug 2013 13:12:00 GMT
Author: sergeyb
Date: Fri Aug 30 13:11:59 2013
New Revision: 1518959

URL: http://svn.apache.org/r1518959
Log:
[CXF-5135] Updating client filter to return Client or Configuration

Modified:
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
    cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java?rev=1518959&r1=1518958&r2=1518959&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
Fri Aug 30 13:11:59 2013
@@ -217,7 +217,7 @@ public class ClientImpl implements Clien
             pf.setUserProviders(providers);
             pf.setDynamicConfiguration(getConfiguration());
             WebClient.getConfig(targetClient).getRequestContext().putAll(getConfiguration().getProperties());
-            
+            WebClient.getConfig(targetClient).getRequestContext().put(Client.class.getName(),
ClientImpl.this);
             // TLS
             TLSClientParameters tlsParams = secConfig.getTlsClientParams();
             if (tlsParams.getSSLSocketFactory() != null 

Modified: cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java?rev=1518959&r1=1518958&r2=1518959&view=diff
==============================================================================
--- cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
(original)
+++ cxf/trunk/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
Fri Aug 30 13:11:59 2013
@@ -33,6 +33,7 @@ import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.apache.cxf.jaxrs.client.ClientProviderFactory;
 import org.apache.cxf.jaxrs.impl.AbstractRequestContextImpl;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
@@ -50,14 +51,13 @@ public class ClientRequestContextImpl ex
     
     @Override
     public Client getClient() {
-        // TODO Auto-generated method stub
-        return null;
+        return (Client)m.getContextualProperty(Client.class.getName());
     }
 
     @Override
     public Configuration getConfiguration() {
-        // TODO Auto-generated method stub
-        return null;
+        ClientProviderFactory cpf = ClientProviderFactory.getInstance(m);
+        return cpf.getDynamicConfiguration();
     }
     
     private Object getMessageContent() {

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java?rev=1518959&r1=1518958&r2=1518959&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRS20ClientServerBookTest.java
Fri Aug 30 13:11:59 2013
@@ -114,8 +114,10 @@ public class JAXRS20ClientServerBookTest
     @Test
     public void testGetBookSpec() {
         String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple";
-        Book book = ClientBuilder.newClient().target(address)
-            .request("application/xml").get(Book.class);
+        Client client = ClientBuilder.newClient();
+        client.register(new ClientFilterClientAndConfigCheck());
+        client.property("clientproperty", "somevalue");
+        Book book = client.target(address).request("application/xml").get(Book.class);
         assertEquals(124L, book.getId());
     }
     
@@ -575,6 +577,19 @@ public class JAXRS20ClientServerBookTest
         }
     }
     
+    private static class ClientFilterClientAndConfigCheck implements ClientRequestFilter
{
+
+        @Override
+        public void filter(ClientRequestContext context) throws IOException {
+            String prop = context.getClient().getConfiguration().getProperty("clientproperty").toString();
+            String prop2 = context.getConfiguration().getProperty("clientproperty").toString();
+            if (!prop2.equals(prop) || !"somevalue".equals(prop2)) {
+                throw new RuntimeException();
+            }
+            
+        }
+    }
+    
     private static class ClientHeaderResponseFilter implements ClientResponseFilter {
 
         @Override



Mime
View raw message