From 3794779291bade20d4026da66ba76f353989e94f Mon Sep 17 00:00:00 2001 From: Jiameng Yu Date: Mon, 6 Mar 2017 11:22:43 -0500 Subject: [PATCH] Fix proxy issue #102 * Use CloseableHttpClient to replace HttpClient implementation * Updated test cases with CloseableHttpClientStub * Optimize CloseableHttpClient Response manipulation. * Rebased #156 on latest master --- pom.xml | 6 ++-- .../jenkins/plugins/slack/HttpClientStub.java | 34 ------------------- 2 files changed, 3 insertions(+), 37 deletions(-) delete mode 100644 src/test/java/jenkins/plugins/slack/HttpClientStub.java diff --git a/pom.xml b/pom.xml index ee69c41e..3e857f4c 100644 --- a/pom.xml +++ b/pom.xml @@ -70,9 +70,9 @@ 2.4.4 - commons-httpclient - commons-httpclient - 3.1 + org.apache.httpcomponents + httpclient + 4.3.2 org.json diff --git a/src/test/java/jenkins/plugins/slack/HttpClientStub.java b/src/test/java/jenkins/plugins/slack/HttpClientStub.java deleted file mode 100644 index f6de0935..00000000 --- a/src/test/java/jenkins/plugins/slack/HttpClientStub.java +++ /dev/null @@ -1,34 +0,0 @@ -package jenkins.plugins.slack; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.HttpStatus; - -public class HttpClientStub extends HttpClient { - - private int numberOfCallsToExecuteMethod; - private int httpStatus; - private boolean failAlternateResponses = false; - - @Override - public int executeMethod(HttpMethod httpMethod) { - numberOfCallsToExecuteMethod++; - if (failAlternateResponses && (numberOfCallsToExecuteMethod % 2 == 0)) { - return HttpStatus.SC_NOT_FOUND; - } else { - return httpStatus; - } - } - - public int getNumberOfCallsToExecuteMethod() { - return numberOfCallsToExecuteMethod; - } - - public void setHttpStatus(int httpStatus) { - this.httpStatus = httpStatus; - } - - public void setFailAlternateResponses(boolean failAlternateResponses) { - this.failAlternateResponses = failAlternateResponses; - } -}