camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/3] git commit: Using http4.3 API when running the osgi test of CXF
Date Thu, 21 Aug 2014 09:35:24 GMT
Using http4.3 API when running the osgi test of CXF


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

Branch: refs/heads/master
Commit: 7c62ca9c5c48dacd9b046e3a007f58567d649335
Parents: 56fe28a
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Thu Aug 21 17:13:30 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Thu Aug 21 17:13:30 2014 +0800

----------------------------------------------------------------------
 .../itest/osgi/cxf/CxfBeanSpringRouteTest.java  |  6 +++--
 .../blueprint/CxfBeanBlueprintRouterTest.java   | 10 +++++---
 .../cxf/blueprint/CxfRsBlueprintRouterTest.java | 26 +++++++++++---------
 3 files changed, 24 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7c62ca9c/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java
index 5b01dc4..ebf2366 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java
@@ -20,7 +20,9 @@ import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -41,7 +43,7 @@ public class CxfBeanSpringRouteTest extends OSGiIntegrationSpringTestSupport
{
     public void testGetCustomer() throws Exception {
         HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123");
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -49,7 +51,7 @@ public class CxfBeanSpringRouteTest extends OSGiIntegrationSpringTestSupport
{
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}",
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7c62ca9c/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java
index 462a98a..490eb94 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java
@@ -21,7 +21,9 @@ import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -45,7 +47,7 @@ public class CxfBeanBlueprintRouterTest extends OSGiBlueprintTestSupport
{
     public void testGetCustomer() throws Exception {
         HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123");
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -53,7 +55,7 @@ public class CxfBeanBlueprintRouterTest extends OSGiBlueprintTestSupport
{
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}",
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 
@@ -62,7 +64,7 @@ public class CxfBeanBlueprintRouterTest extends OSGiBlueprintTestSupport
{
     public void testGetCustomerWithQuery() throws Exception {
         HttpGet get = new HttpGet("http://localhost:9000/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);
@@ -70,7 +72,7 @@ public class CxfBeanBlueprintRouterTest extends OSGiBlueprintTestSupport
{
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}",
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7c62ca9c/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java
index 65eee47..f456e27 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java
@@ -28,7 +28,9 @@ 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.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.util.EntityUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -73,7 +75,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport {
     public void testGetCustomer() throws Exception {
         HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123");
         get.addHeader("Accept" , "application/json");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -85,7 +87,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport {
             boolean isMary = "{\"Customer\":{\"id\":123,\"name\":\"Mary\"}}".equals(s);
             assertTrue("Should be John or Mary", isJohn || isMary);
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -94,7 +96,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport {
     public void testGetCustomerWithQuery() throws Exception {      
         HttpGet get = new HttpGet("http://localhost:9000/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);
@@ -102,7 +104,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
             assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", 
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -110,7 +112,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
     public void testGetCustomers() throws Exception {      
         HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/");
         get.addHeader("Accept" , "application/xml");
-        HttpClient httpclient = new DefaultHttpClient();
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
 
         try {
             HttpResponse response = httpclient.execute(get);
@@ -125,7 +127,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
                 fail("Not expected body returned: " + s);
             }
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -133,7 +135,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
     public void testGetSubResource() throws Exception {
         HttpGet get = new HttpGet("http://localhost:9000/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);
@@ -141,7 +143,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
             assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", 
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
     }
     
@@ -151,14 +153,14 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
         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();
         }
     }
     
@@ -169,7 +171,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
         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);
@@ -177,7 +179,7 @@ public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport
{
             assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>124</id><name>Jack</name></Customer>",
                          EntityUtils.toString(response.getEntity()));
         } finally {
-            httpclient.getConnectionManager().shutdown();
+            httpclient.close();
         }
 
     }


Mime
View raw message