cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [1/2] cxf git commit: Remove old commons-httpclient code
Date Wed, 07 Jun 2017 17:53:53 GMT
Repository: cxf
Updated Branches:
  refs/heads/master e0ace3dc7 -> 8e8f01a3c


http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
index 8395cbc..c246a8f 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java
@@ -27,8 +27,6 @@ import java.util.List;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.jaxrs.model.Parameter;
@@ -37,7 +35,10 @@ import org.apache.cxf.jaxrs.model.UserOperation;
 import org.apache.cxf.jaxrs.model.UserResource;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
-
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -137,13 +138,13 @@ public class JAXRSClientServerUserResourceTest extends AbstractBusClientServerTe
     private void getAndCompare(String address,
                                String acceptType,
                                int expectedStatus) throws Exception {
-        GetMethod get = new GetMethod(address);
-        get.setRequestHeader("Accept", acceptType);
-        HttpClient httpClient = new HttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet(address);
+        get.addHeader("Accept", acceptType);
         try {
-            int result = httpClient.executeMethod(get);
-            assertEquals(expectedStatus, result);
-            Book book = readBook(get.getResponseBodyAsStream());
+            CloseableHttpResponse response = client.execute(get);
+            assertEquals(expectedStatus, response.getStatusLine().getStatusCode());
+            Book book = readBook(response.getEntity().getContent());
             assertEquals(123, book.getId());
             assertEquals("CXF in Action", book.getName());
         } finally {
@@ -154,13 +155,13 @@ public class JAXRSClientServerUserResourceTest extends AbstractBusClientServerTe
     private void getAndCompareChapter(String address,
                                String acceptType,
                                int expectedStatus) throws Exception {
-        GetMethod get = new GetMethod(address);
-        get.setRequestHeader("Accept", acceptType);
-        HttpClient httpClient = new HttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet(address);
+        get.addHeader("Accept", acceptType);
         try {
-            int result = httpClient.executeMethod(get);
-            assertEquals(expectedStatus, result);
-            Chapter c = readChapter(get.getResponseBodyAsStream());
+            CloseableHttpResponse response = client.execute(get);
+            assertEquals(expectedStatus, response.getStatusLine().getStatusCode());
+            Chapter c = readChapter(response.getEntity().getContent());
             assertEquals(1, c.getId());
             assertEquals("chapter 1", c.getTitle());
         } finally {

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsServlet3Test.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsServlet3Test.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsServlet3Test.java
index e3bedd2..9cbdf04 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsServlet3Test.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsServlet3Test.java
@@ -19,10 +19,13 @@
 
 package org.apache.cxf.systest.jaxrs;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -40,15 +43,15 @@ public class JAXRSCxfContinuationsServlet3Test extends AbstractBusClientServerTe
     @Test
     public void testEncodedURL() throws Exception {
         String id = "A%20B%20C"; // "A B C"
-        GetMethod get = new GetMethod("http://localhost:" + PORT + "/bookstore/books/" +
id);
-        HttpClient httpclient = new HttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet("http://localhost:" + PORT + "/bookstore/books/" + id);
 
         try {
-            int result = httpclient.executeMethod(get);
+            CloseableHttpResponse response = client.execute(get);
             assertEquals("Encoded path '/" + id + "' is not handled successfully",
-                         200, result);
+                         200, response.getStatusLine().getStatusCode());
             assertEquals("Book description for id " + id + " is wrong",
-                         "CXF in Action A B C", get.getResponseBodyAsString());
+                         "CXF in Action A B C", EntityUtils.toString(response.getEntity()));
         } finally {
             // Release current connection to the connection pool once you are done
             get.releaseConnection();

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsTest.java
index e56e776..e6f58a1 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSCxfContinuationsTest.java
@@ -24,11 +24,13 @@ import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -74,14 +76,14 @@ public class JAXRSCxfContinuationsTest extends AbstractBusClientServerTestBase
{
     }
 
     private void checkBook(String address, String id, String expected) throws Exception {
-        GetMethod get = new GetMethod(address);
-        HttpClient httpclient = new HttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet(address);
 
         try {
-            int result = httpclient.executeMethod(get);
-            assertEquals(200, result);
+            CloseableHttpResponse response = client.execute(get);
+            assertEquals(200, response.getStatusLine().getStatusCode());
             assertEquals("Book description for id " + id + " is wrong",
-                         expected, get.getResponseBodyAsString());
+                         expected, EntityUtils.toString(response.getEntity()));
         } finally {
             // Release current connection to the connection pool once you are done
             get.releaseConnection();
@@ -128,15 +130,15 @@ public class JAXRSCxfContinuationsTest extends AbstractBusClientServerTestBase
{
     @Test
     public void testEncodedURL() throws Exception {
         String id = "A%20B%20C"; // "A B C"
-        GetMethod get = new GetMethod("http://localhost:" + PORT + "/bookstore/books/" +
id);
-        HttpClient httpclient = new HttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet("http://localhost:" + PORT + "/bookstore/books/" + id);
 
         try {
-            int result = httpclient.executeMethod(get);
+            CloseableHttpResponse response = client.execute(get);
             assertEquals("Encoded path '/" + id + "' is not handled successfully",
-                         200, result);
+                         200,  response.getStatusLine().getStatusCode());
             assertEquals("Book description for id " + id + " is wrong",
-                         "CXF in Action A B C", get.getResponseBodyAsString());
+                         "CXF in Action A B C", EntityUtils.toString(response.getEntity()));
         } finally {
             // Release current connection to the connection pool once you are done
             get.releaseConnection();

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
index 2d812e2..a4c5791 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
@@ -44,14 +44,6 @@ import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;
-import org.apache.commons.httpclient.methods.multipart.FilePart;
-import org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity;
-import org.apache.commons.httpclient.methods.multipart.Part;
 import org.apache.cxf.ext.logging.LoggingInInterceptor;
 import org.apache.cxf.ext.logging.LoggingOutInterceptor;
 import org.apache.cxf.helpers.FileUtils;
@@ -66,7 +58,14 @@ import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.provider.json.JSONProvider;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.transport.http.HTTPConduit;
-
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.ByteArrayBody;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -881,14 +880,14 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
 
     @Test
     public void testMultipartRequestNoBody() throws Exception {
-        PostMethod post = new PostMethod("http://localhost:" + PORT + "/bookstore/books/image");
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost("http://localhost:" + PORT + "/bookstore/books/image");
         String ct = "multipart/mixed";
-        post.setRequestHeader("Content-Type", ct);
-        HttpClient httpclient = new HttpClient();
+        post.setHeader("Content-Type", ct);
 
         try {
-            int result = httpclient.executeMethod(post);
-            assertEquals(400, result);
+            CloseableHttpResponse response = client.execute(post);
+            assertEquals(400, response.getStatusLine().getStatusCode());
         } finally {
             // Release current connection to the connection pool once you are done
             post.releaseConnection();
@@ -897,44 +896,41 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
 
     @Test
     public void testMultipartRequestTooLarge() throws Exception {
-        PostMethod post = new PostMethod("http://localhost:" + PORT + "/bookstore/books/image");
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost("http://localhost:" + PORT + "/bookstore/books/image");
         String ct = "multipart/mixed";
-        post.setRequestHeader("Content-Type", ct);
-        Part[] parts = new Part[1];
-        parts[0] = new FilePart("image",
-                new ByteArrayPartSource("testfile.png", new byte[1024 * 11]),
-                "image/png", null);
-        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
+        post.setHeader("Content-Type", ct);
+
+        MultipartEntity entity = new MultipartEntity();
+        entity.addPart("image", new ByteArrayBody(new byte[1024 * 11], "testfile.png"));
 
-        HttpClient httpclient = new HttpClient();
+        post.setEntity(entity);
 
         try {
-            int result = httpclient.executeMethod(post);
-            assertEquals(413, result);
+            CloseableHttpResponse response = client.execute(post);
+            assertEquals(413, response.getStatusLine().getStatusCode());
         } finally {
             // Release current connection to the connection pool once you are done
             post.releaseConnection();
         }
     }
+
     @Test
     public void testMultipartRequestTooLargeManyParts() throws Exception {
-        PostMethod post = new PostMethod("http://localhost:" + PORT + "/bookstore/books/image");
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost("http://localhost:" + PORT + "/bookstore/books/image");
         String ct = "multipart/mixed";
-        post.setRequestHeader("Content-Type", ct);
-        Part[] parts = new Part[2];
-        parts[0] = new FilePart("image",
-                new ByteArrayPartSource("testfile.png", new byte[1024 * 9]),
-                "image/png", null);
-        parts[1] = new FilePart("image",
-                new ByteArrayPartSource("testfile2.png", new byte[1024 * 11]),
-                "image/png", null);
-        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
-
-        HttpClient httpclient = new HttpClient();
+        post.setHeader("Content-Type", ct);
+
+        MultipartEntity entity = new MultipartEntity();
+        entity.addPart("image", new ByteArrayBody(new byte[1024 * 9], "testfile.png"));
+        entity.addPart("image", new ByteArrayBody(new byte[1024 * 11], "testfile2.png"));
+
+        post.setEntity(entity);
 
         try {
-            int result = httpclient.executeMethod(post);
-            assertEquals(413, result);
+            CloseableHttpResponse response = client.execute(post);
+            assertEquals(413, response.getStatusLine().getStatusCode());
         } finally {
             // Release current connection to the connection pool once you are done
             post.releaseConnection();
@@ -952,24 +948,22 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
     }
     private void doAddBook(String type, String address, InputStream is, int status) throws
Exception {
 
-        PostMethod post = new PostMethod(address);
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(address);
 
         String ct = type + "; type=\"text/xml\"; " + "start=\"rootPart\"; "
             + "boundary=\"----=_Part_4_701508.1145579811786\"";
-        post.setRequestHeader("Content-Type", ct);
-
+        post.setHeader("Content-Type", ct);
 
-        RequestEntity entity = new InputStreamRequestEntity(is);
-        post.setRequestEntity(entity);
-        HttpClient httpclient = new HttpClient();
+        post.setEntity(new InputStreamEntity(is));
 
         try {
-            int result = httpclient.executeMethod(post);
-            assertEquals(status, result);
+            CloseableHttpResponse response = client.execute(post);
+            assertEquals(status, response.getStatusLine().getStatusCode());
             if (status == 200) {
                 InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");
                 assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
-                             stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
+                             stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
             }
         } finally {
             // Release current connection to the connection pool once you are done
@@ -978,23 +972,22 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase
{
     }
 
     private void doAddFormBook(String address, String resourceName, int status) throws Exception
{
-        PostMethod post = new PostMethod(address);
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(address);
 
         String ct = "multipart/form-data; boundary=bqJky99mlBWa-ZuqjC53mG6EzbmlxB";
-        post.setRequestHeader("Content-Type", ct);
+        post.setHeader("Content-Type", ct);
         InputStream is =
             getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/" + resourceName);
-        RequestEntity entity = new InputStreamRequestEntity(is);
-        post.setRequestEntity(entity);
-        HttpClient httpclient = new HttpClient();
+        post.setEntity(new InputStreamEntity(is));
 
         try {
-            int result = httpclient.executeMethod(post);
-            assertEquals(status, result);
+            CloseableHttpResponse response = client.execute(post);
+            assertEquals(status, response.getStatusLine().getStatusCode());
             if (status == 200) {
                 InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");
                 assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
-                             stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
+                             stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
             }
         } finally {
             // Release current connection to the connection pool once you are done

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
index 63ba7b8..0e151f3 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
@@ -42,10 +42,6 @@ import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
 import javax.xml.ws.soap.SOAPBinding;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.FileRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.cxf.Bus;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.ext.logging.LoggingInInterceptor;
@@ -82,7 +78,13 @@ import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 import org.apache.http.HttpStatus;
-
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.FileEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -749,20 +751,19 @@ public class JAXRSSoapBookTest extends AbstractBusClientServerTestBase
{
             "http://localhost:" + PORT + "/test/services/rest/bookstore/books";
 
         File input = new File(getClass().getResource("resources/add_book.txt").toURI());
-        PostMethod post = new PostMethod(endpointAddress);
-        post.setRequestHeader("Content-Type", "application/xml");
-        RequestEntity entity = new FileRequestEntity(input, "text/xml; charset=ISO-8859-1");
-        post.setRequestEntity(entity);
-        HttpClient httpclient = new HttpClient();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(endpointAddress);
+        post.addHeader("Content-Type", "application/xml");
+        post.setEntity(new FileEntity(input, ContentType.TEXT_XML));
 
         try {
-            int result = httpclient.executeMethod(post);
-            assertEquals(200, result);
+            CloseableHttpResponse response = client.execute(post);
+            assertEquals(200, response.getStatusLine().getStatusCode());
 
             InputStream expected = getClass().getResourceAsStream("resources/expected_add_book.txt");
 
             assertEquals(stripXmlInstructionIfNeeded(getStringFromInputStream(expected)),
-                         stripXmlInstructionIfNeeded(post.getResponseBodyAsString()));
+                         stripXmlInstructionIfNeeded(EntityUtils.toString(response.getEntity())));
         } finally {
             // Release current connection to the connection pool once you are done
             post.releaseConnection();

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
index abdc4b1..a9478fc 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/security/AbstractSpringSecurityTest.java
@@ -21,11 +21,14 @@ package org.apache.cxf.systest.jaxrs.security;
 
 import java.io.InputStream;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 
 public abstract class AbstractSpringSecurityTest extends AbstractBusClientServerTestBase
{
 
@@ -41,16 +44,16 @@ public abstract class AbstractSpringSecurityTest extends AbstractBusClientServer
                          int expectedStatus)
         throws Exception {
 
-        GetMethod get = new GetMethod(endpointAddress);
-        get.setRequestHeader("Accept", "application/xml");
-        get.setRequestHeader("Authorization",
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet(endpointAddress);
+        get.addHeader("Accept", "application/xml");
+        get.addHeader("Authorization",
                              "Basic " + base64Encode(user + ":" + password));
-        HttpClient httpClient = new HttpClient();
         try {
-            int result = httpClient.executeMethod(get);
-            assertEquals(expectedStatus, result);
+            CloseableHttpResponse response = client.execute(get);
+            assertEquals(expectedStatus, response.getStatusLine().getStatusCode());
             if (expectedStatus == 200) {
-                String content = getStringFromInputStream(get.getResponseBodyAsStream());
+                String content = EntityUtils.toString(response.getEntity());
                 String resource = "/org/apache/cxf/systest/jaxrs/resources/expected_get_book123.txt";
                 InputStream expected = getClass().getResourceAsStream(resource);
                 assertEquals("Expected value is wrong",

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxws/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxws/pom.xml b/systests/jaxws/pom.xml
index d1d93c6..73e8be9 100644
--- a/systests/jaxws/pom.xml
+++ b/systests/jaxws/pom.xml
@@ -225,11 +225,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
         </dependency>
@@ -270,6 +265,12 @@
             <groupId>org.littleshoot</groupId>
             <artifactId>littleproxy</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
     <profiles>
         <profile>

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4130Test.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4130Test.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4130Test.java
index 7fe543b..49a2c0a 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4130Test.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4130Test.java
@@ -28,13 +28,16 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -72,12 +75,12 @@ public class CXF4130Test extends AbstractBusClientServerTestBase {
     @Test
     public void testCxf4130() throws Exception {
         InputStream body = getClass().getResourceAsStream("cxf4130data.txt");
-        HttpClient client = new HttpClient();
-        PostMethod post = new PostMethod(ADDRESS);
-        post.setRequestEntity(new InputStreamRequestEntity(body, "text/xml"));
-        client.executeMethod(post);
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(ADDRESS);
+        post.setEntity(new InputStreamEntity(body, ContentType.TEXT_XML));
+        CloseableHttpResponse response = client.execute(post);
 
-        Document doc = StaxUtils.read(post.getResponseBodyAsStream());
+        Document doc = StaxUtils.read(response.getEntity().getContent());
         Element root = doc.getDocumentElement();
         Node child = root.getFirstChild();
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4818Test.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4818Test.java
b/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4818Test.java
index b5956b4..9ddf62b 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4818Test.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/provider/CXF4818Test.java
@@ -39,13 +39,16 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
-import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -83,12 +86,12 @@ public class CXF4818Test extends AbstractBusClientServerTestBase {
     @Test
     public void testCXF4818() throws Exception {
         InputStream body = getClass().getResourceAsStream("cxf4818data.txt");
-        HttpClient client = new HttpClient();
-        PostMethod post = new PostMethod(ADDRESS);
-        post.setRequestEntity(new InputStreamRequestEntity(body, "text/xml"));
-        client.executeMethod(post);
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(ADDRESS);
+        post.setEntity(new InputStreamEntity(body, ContentType.TEXT_XML));
+        CloseableHttpResponse response = client.execute(post);
 
-        Document doc = StaxUtils.read(post.getResponseBodyAsStream());
+        Document doc = StaxUtils.read(response.getEntity().getContent());
         //System.out.println(StaxUtils.toString(doc));
         Element root = doc.getDocumentElement();
         Node child = root.getFirstChild();

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/transports-ssl3/pom.xml
----------------------------------------------------------------------
diff --git a/systests/transports-ssl3/pom.xml b/systests/transports-ssl3/pom.xml
index 7e162bc..3d2490d 100644
--- a/systests/transports-ssl3/pom.xml
+++ b/systests/transports-ssl3/pom.xml
@@ -141,10 +141,5 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/transports/pom.xml
----------------------------------------------------------------------
diff --git a/systests/transports/pom.xml b/systests/transports/pom.xml
index 8950784..1af6fde 100644
--- a/systests/transports/pom.xml
+++ b/systests/transports/pom.xml
@@ -253,11 +253,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.littleshoot</groupId>
             <artifactId>littleproxy</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/uncategorized/pom.xml
----------------------------------------------------------------------
diff --git a/systests/uncategorized/pom.xml b/systests/uncategorized/pom.xml
index d6123d6..d3e7b3a 100644
--- a/systests/uncategorized/pom.xml
+++ b/systests/uncategorized/pom.xml
@@ -381,11 +381,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>commons-httpclient</groupId>
-            <artifactId>commons-httpclient</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>net.java.dev.msv</groupId>
             <artifactId>msv-core</artifactId>
             <exclusions>
@@ -405,6 +400,11 @@
             <artifactId>jacorb</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <profiles>
         <profile>

http://git-wip-us.apache.org/repos/asf/cxf/blob/8e8f01a3/systests/uncategorized/src/test/java/org/apache/cxf/systest/simple/SimpleFrontendTest.java
----------------------------------------------------------------------
diff --git a/systests/uncategorized/src/test/java/org/apache/cxf/systest/simple/SimpleFrontendTest.java
b/systests/uncategorized/src/test/java/org/apache/cxf/systest/simple/SimpleFrontendTest.java
index e60ec7c..3805acd 100644
--- a/systests/uncategorized/src/test/java/org/apache/cxf/systest/simple/SimpleFrontendTest.java
+++ b/systests/uncategorized/src/test/java/org/apache/cxf/systest/simple/SimpleFrontendTest.java
@@ -19,13 +19,16 @@
 
 package org.apache.cxf.systest.simple;
 
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.systest.simple.impl.WSSimpleImpl;
 import org.apache.cxf.testutil.common.TestUtil;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -59,10 +62,10 @@ public class SimpleFrontendTest extends Assert {
 
     @Test
     public void testGetWSDL() throws Exception {
-        GetMethod getMethod = new GetMethod("http://localhost:" + PORT1 + "/test11?wsdl");
-        HttpClient httpClient = new HttpClient();
-        httpClient.executeMethod(getMethod);
-        String response = getMethod.getResponseBodyAsString();
+        CloseableHttpClient client = HttpClientBuilder.create().build();
+        HttpGet get = new HttpGet("http://localhost:" + PORT1 + "/test11?wsdl");
+        CloseableHttpResponse httpResponse = client.execute(get);
+        String response = EntityUtils.toString(httpResponse.getEntity());
         assertFalse(response.indexOf("import") >= 0);
         assertFalse(response.indexOf("?wsdl?wsdl") >= 0);
     }


Mime
View raw message