camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: CAMEL-7010 updated the camel-cxf unit test to use httpclient 4.3.x API
Date Thu, 12 Dec 2013 12:14:08 GMT
CAMEL-7010 updated the camel-cxf unit test to use httpclient 4.3.x API


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2170352c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2170352c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2170352c

Branch: refs/heads/master
Commit: 2170352c37744985b4a70c7c7bf5d65558149057
Parents: fffd139
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Dec 12 20:10:50 2013 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Dec 12 20:10:50 2013 +0800

----------------------------------------------------------------------
 .../cxf/CxfConsumerPayloadXPathTest.java        |  9 +++--
 .../cxf/CxfConusmerNamespacePayLoadTest.java    |  8 ++---
 .../component/cxf/FailOverFeatureTest.java      |  1 -
 .../component/cxf/cxfbean/CxfBeanTest.java      | 29 ++++++++-------
 ...CxfBeanWithWsdlLocationInBeanAndIoCTest.java | 12 +++----
 .../CxfBeanWithWsdlLocationInBeanTest.java      |  9 +++--
 .../component/cxf/jaxrs/CxfRsConsumerTest.java  | 12 +++----
 .../cxf/jaxrs/CxfRsConvertBodyToTest.java       |  8 ++---
 .../cxf/jaxrs/CxfRsEndpointWithProperties.java  | 13 ++++---
 .../component/cxf/jaxrs/CxfRsRouterTest.java    | 32 ++++++++---------
 .../CxfRsConsumerSimpleBindingTest.java         | 37 ++++++++++----------
 11 files changed, 86 insertions(+), 84 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadXPathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadXPathTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadXPathTest.java
index b2063c9..00206d6 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadXPathTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadXPathTest.java
@@ -75,13 +75,16 @@ public class CxfConsumerPayloadXPathTest extends CamelTestSupport {
         simpleTest(10000, new TestRouteWithXPathBuilder());
     }  
     
-   
-    
     //the textnode appears to have siblings!
     @Test
     public void size10000DomTest() throws Exception {
         simpleTest(10000, new TestRouteWithDomBuilder());
     }
+  
+    @Test
+    public void size1000DomFirstTest() throws Exception {
+        simpleTest(1000, new TestRouteWithDomFirstOneOnlyBuilder());
+    }
     
     private class TestRouteWithXPathBuilder extends BaseRouteBuilder {
         @Override
@@ -153,6 +156,7 @@ public class CxfConsumerPayloadXPathTest extends CamelTestSupport {
         @Override
         public void process(Exchange exchange) throws Exception {
             Object obj =  exchange.getIn().getBody();
+            @SuppressWarnings("unchecked")
             CxfPayload<SoapHeader> payload = (CxfPayload<SoapHeader>) obj;
             Element el = (Element) payload.getBody().get(0);
             Text textnode = (Text) el.getFirstChild();
@@ -165,6 +169,7 @@ public class CxfConsumerPayloadXPathTest extends CamelTestSupport {
         @Override
         public void process(Exchange exchange) throws Exception {
             Object obj =  exchange.getIn().getBody();
+            @SuppressWarnings("unchecked")
             CxfPayload<SoapHeader> payload = (CxfPayload<SoapHeader>) obj;
             Element el = (Element) payload.getBody().get(0);
             Text textnode = (Text) el.getFirstChild();

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConusmerNamespacePayLoadTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConusmerNamespacePayLoadTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConusmerNamespacePayLoadTest.java
index 787e0ec..535f739 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConusmerNamespacePayLoadTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConusmerNamespacePayLoadTest.java
@@ -17,11 +17,11 @@
 package org.apache.camel.component.cxf;
 
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 
@@ -51,7 +51,7 @@ public class CxfConusmerNamespacePayLoadTest extends CxfConsumerPayloadTest
{
         
         StringEntity entity = new StringEntity(ECHO_REQUEST, ContentType.create("text/xml",
"ISO-8859-1"));
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -60,7 +60,7 @@ public class CxfConusmerNamespacePayLoadTest extends CxfConsumerPayloadTest
{
             
             assertEquals("Get a wrong response", ECHO_RESPONSE, responseBody);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
 
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/FailOverFeatureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/FailOverFeatureTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/FailOverFeatureTest.java
index f6c73a9..6c9b1be 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/FailOverFeatureTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/FailOverFeatureTest.java
@@ -48,7 +48,6 @@ public class FailOverFeatureTest {
     public static void init() {
 
         // publish a web-service
-        String addr1 = "http://localhost:9001/hello";
         ServerFactoryBean factory = new ServerFactoryBean();
         factory.setAddress(SERVICE_ADDRESS);
         factory.setServiceBean(new HelloServiceImpl());

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
index 1d47e20..a3eed4d 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.component.cxf.cxfbean;
 
-
 import java.net.URL;
 
 import javax.xml.namespace.QName;
@@ -31,12 +30,12 @@ import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.wsdl_first.Person;
 import org.apache.camel.wsdl_first.PersonService;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -101,7 +100,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
         HttpGet get = new HttpGet(getUrl);
         get.addHeader("Accept" , "application/json");
         get.addHeader("key", "customer");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -109,7 +108,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
             assertEquals(expected,
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -158,14 +157,14 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
         StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         put.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(put);
             assertEquals(200, response.getStatusLine().getStatusCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -176,7 +175,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
         StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -185,7 +184,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
             assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>"
+ id + "</id><name>Jack</name></Customer>",
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -196,7 +195,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
         StringEntity entity = new StringEntity(POST2_REQUEST, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -205,14 +204,14 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
             assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>"
+ id + "</id><name>James</name></Customer>",
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 
     private String getCustomerId(String name) throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + PORT1 + "/customerservice/customers/");
         get.addHeader("Accept", "application/xml");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -222,7 +221,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
             String answer = before.substring(before.lastIndexOf(">") + 1, before.length());
             return answer;
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 
@@ -237,7 +236,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
         StringEntity entity = new StringEntity(body, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -249,7 +248,7 @@ public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
             
             assertEquals("Get a wrong response", correct, responseBody);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanAndIoCTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanAndIoCTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanAndIoCTest.java
index 64d2b4f..80e27dc 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanAndIoCTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanAndIoCTest.java
@@ -18,11 +18,11 @@ package org.apache.camel.component.cxf.cxfbean;
 
 import org.apache.camel.component.cxf.CXFTestSupport;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.springframework.test.context.ContextConfiguration;
@@ -30,10 +30,6 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
 import static org.junit.Assert.assertEquals;
 
-/**
- *
- * @version 
- */
 @ContextConfiguration
 public class CxfBeanWithWsdlLocationInBeanAndIoCTest extends AbstractJUnit4SpringContextTests
{
     static int port = CXFTestSupport.getPort("CxfBeanWithWsdlLocationInBeanAndIoCTest.1");
@@ -48,7 +44,7 @@ public class CxfBeanWithWsdlLocationInBeanAndIoCTest extends AbstractJUnit4Sprin
         
         StringEntity entity = new StringEntity(body, ContentType.create("text/xml", "ISO-8859-1"));
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -60,7 +56,7 @@ public class CxfBeanWithWsdlLocationInBeanAndIoCTest extends AbstractJUnit4Sprin
             
             assertEquals("Get a wrong response", correct, responseBody);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java
index 174a1d2..c7235a2 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanWithWsdlLocationInBeanTest.java
@@ -18,18 +18,17 @@ package org.apache.camel.component.cxf.cxfbean;
 
 import org.apache.camel.component.cxf.CXFTestSupport;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
 
 import static org.junit.Assert.assertEquals;
-
 /**
  *
  * @version 
@@ -47,7 +46,7 @@ public class CxfBeanWithWsdlLocationInBeanTest extends AbstractJUnit4SpringConte
         
         StringEntity entity = new StringEntity(body, ContentType.create("text/xml", "ISO-8859-1"));
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -59,7 +58,7 @@ public class CxfBeanWithWsdlLocationInBeanTest extends AbstractJUnit4SpringConte
             
             assertEquals("Get a wrong response", correct, responseBody);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
index 51c10a0..3ad6170 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConsumerTest.java
@@ -35,11 +35,11 @@ import org.apache.camel.component.cxf.common.message.CxfConstants;
 import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 
@@ -119,7 +119,7 @@ public class CxfRsConsumerTest extends CamelTestSupport {
     private void invokeGetCustomer(String uri, String expect) throws Exception {
         HttpGet get = new HttpGet(uri);
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -127,7 +127,7 @@ public class CxfRsConsumerTest extends CamelTestSupport {
             assertEquals(expect,
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -170,14 +170,14 @@ public class CxfRsConsumerTest extends CamelTestSupport {
         entity.setContentType("text/xml; charset=ISO-8859-1");
         put.addHeader("test", "header1;header2");
         put.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(put);
             assertEquals(200, response.getStatusLine().getStatusCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
         

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
index fdd4bfd..bbc8e73 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsConvertBodyToTest.java
@@ -24,10 +24,10 @@ import org.apache.camel.component.cxf.jaxrs.testbean.Customer;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 
@@ -62,14 +62,14 @@ public class CxfRsConvertBodyToTest extends CamelTestSupport {
         entity.setContentType("text/xml; charset=ISO-8859-1");
         put.addHeader("test", "header1;header2");
         put.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(put);
             assertEquals(200, response.getStatusLine().getStatusCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
index 9396e05..e51de63 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsEndpointWithProperties.java
@@ -20,7 +20,8 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.component.cxf.spring.AbstractSpringBeanTestSupport;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.Test;
 
 public class CxfRsEndpointWithProperties extends AbstractSpringBeanTestSupport {
@@ -37,9 +38,13 @@ public class CxfRsEndpointWithProperties extends AbstractSpringBeanTestSupport
{
         CxfRsEndpoint testEndpoint = camelContext.getEndpoint("cxfrs:bean:testEndpoint",
CxfRsEndpoint.class);
         assertEquals("Got a wrong address", "http://localhost:9900/testEndpoint", testEndpoint.getAddress());
         HttpGet get = new HttpGet(testEndpoint.getAddress());
-        DefaultHttpClient httpclient = new DefaultHttpClient();
-        HttpResponse response = httpclient.execute(get);
-        assertEquals(404, response.getStatusLine().getStatusCode());
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+        try {
+            HttpResponse response = httpclient.execute(get);
+            assertEquals(404, response.getStatusLine().getStatusCode());
+        } finally {
+            httpclient.close();
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
index ddb3ecb..48be39c 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/CxfRsRouterTest.java
@@ -20,13 +20,13 @@ package org.apache.camel.component.cxf.jaxrs;
 import org.apache.camel.component.cxf.CXFTestSupport;
 import org.apache.camel.test.spring.CamelSpringTestSupport;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
 import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.springframework.context.support.AbstractXmlApplicationContext;
@@ -61,7 +61,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetCustomer() throws Exception {      
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/123");
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -69,7 +69,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", 
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -78,7 +78,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetCustomerWithQuery() throws Exception {      
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers?id=123");
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -86,7 +86,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", 
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -94,7 +94,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetCustomers() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/");
         get.addHeader("Accept" , "application/xml");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -109,7 +109,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
                 fail("Not expected body returned: " + s);
             }
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -117,7 +117,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
     public void testGetSubResource() throws Exception {
         HttpGet get = new HttpGet("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/orders/223/products/323");
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -125,7 +125,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
             assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", 
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -135,14 +135,14 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
         StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         put.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(put);
             assertEquals(200, response.getStatusLine().getStatusCode());
             assertEquals("", EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -153,7 +153,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
         StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -164,7 +164,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
             HttpDelete del = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/");
             httpclient.execute(del);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
 
     }
@@ -176,7 +176,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
         StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1");
         entity.setContentType("text/xml; charset=ISO-8859-1");
         post.setEntity(entity);
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(post);
@@ -187,7 +187,7 @@ public class CxfRsRouterTest extends CamelSpringTestSupport {
             HttpDelete del = new HttpDelete("http://localhost:" + getPort() + "/CxfRsRouterTest/route/customerservice/customers/124/");
             httpclient.execute(del);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2170352c/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
index 951f6dc..8cfe283 100644
--- a/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
+++ b/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/jaxrs/simplebinding/CxfRsConsumerSimpleBindingTest.java
@@ -20,7 +20,6 @@ import java.io.File;
 import java.io.InputStream;
 import java.io.StringReader;
 import java.io.StringWriter;
-import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -37,19 +36,19 @@ import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Order;
 import org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.Product;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.cxf.message.MessageContentsList;
+import org.apache.http.Consts;
 import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ContentType;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.entity.mime.HttpMultipartMode;
-import org.apache.http.entity.mime.MultipartEntity;
-import org.apache.http.entity.mime.content.FileBody;
-import org.apache.http.entity.mime.content.StringBody;
-import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 
@@ -62,17 +61,17 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport {
         + "/rest?resourceClasses=org.apache.camel.component.cxf.jaxrs.simplebinding.testbean.CustomerServiceResource&bindingStyle=SimpleConsumer";
     
     private JAXBContext jaxb;
-    private HttpClient httpclient;
+    private CloseableHttpClient httpclient;
     
     public void setUp() throws Exception {
         super.setUp();
-        httpclient = new DefaultHttpClient();
+        httpclient = HttpClientBuilder.create().build();
         jaxb = JAXBContext.newInstance(CustomerList.class, Customer.class, Order.class, Product.class);
     }
     
     public void tearDown() throws Exception {
         super.tearDown();
-        httpclient.getConnectionManager().shutdown();
+        httpclient.close();
     }
     
     protected RouteBuilder createRouteBuilder() throws Exception {
@@ -295,13 +294,13 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport
{
     @Test
     public void testMultipartPostWithParametersAndPayload() throws Exception {
         HttpPost post = new HttpPost("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/multipart/123?query=abcd");
-        MultipartEntity multipart = new MultipartEntity(HttpMultipartMode.STRICT);
-        multipart.addPart("part1", new FileBody(new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
"java.jpg"));
-        multipart.addPart("part2", new FileBody(new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
"java.jpg"));
+        MultipartEntityBuilder builder = MultipartEntityBuilder.create().setMode(HttpMultipartMode.STRICT);
+        builder.addBinaryBody("part1", new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
ContentType.create("image/jpeg"), "java.jpg");
+        builder.addBinaryBody("part2", new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
ContentType.create("image/jpeg"), "java.jpg");
         StringWriter sw = new StringWriter();
         jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
-        multipart.addPart("body", new StringBody(sw.toString(), "text/xml", Charset.forName("UTF-8")));
-        post.setEntity(multipart);
+        builder.addTextBody("body", sw.toString(), ContentType.create("text/xml", Consts.UTF_8));
+        post.setEntity(builder.build());
         HttpResponse response = httpclient.execute(post);
         assertEquals(200, response.getStatusLine().getStatusCode());
     }
@@ -309,13 +308,13 @@ public class CxfRsConsumerSimpleBindingTest extends CamelTestSupport
{
     @Test
     public void testMultipartPostWithoutParameters() throws Exception {
         HttpPost post = new HttpPost("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/multipart");
-        MultipartEntity multipart = new MultipartEntity(HttpMultipartMode.STRICT);
-        multipart.addPart("part1", new FileBody(new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
"java.jpg"));
-        multipart.addPart("part2", new FileBody(new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
"java.jpg"));
+        MultipartEntityBuilder builder = MultipartEntityBuilder.create().setMode(HttpMultipartMode.STRICT);
+        builder.addBinaryBody("part1", new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
ContentType.create("image/jpeg"), "java.jpg");
+        builder.addBinaryBody("part2", new File(this.getClass().getClassLoader().getResource("java.jpg").toURI()),
ContentType.create("image/jpeg"), "java.jpg");
         StringWriter sw = new StringWriter();
         jaxb.createMarshaller().marshal(new Customer(123, "Raul"), sw);
-        multipart.addPart("body", new StringBody(sw.toString(), "text/xml", Charset.forName("UTF-8")));
-        post.setEntity(multipart);
+        builder.addTextBody("body", sw.toString(), ContentType.create("text/xml", Consts.UTF_8));
+        post.setEntity(builder.build());
         HttpResponse response = httpclient.execute(post);
         assertEquals(200, response.getStatusLine().getStatusCode());
     }


Mime
View raw message