From abee89fc9083f2e3dfdba4c9caddeaebf46a7d86 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Thu, 24 Nov 2022 16:29:25 -0800 Subject: [PATCH] Stop using Commons HttpClient 3.x in tests (#256) --- .../src/test/java/com/cloudbees/workflow/Util.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rest-api/src/test/java/com/cloudbees/workflow/Util.java b/rest-api/src/test/java/com/cloudbees/workflow/Util.java index ed5a4420..16ad141a 100644 --- a/rest-api/src/test/java/com/cloudbees/workflow/Util.java +++ b/rest-api/src/test/java/com/cloudbees/workflow/Util.java @@ -29,7 +29,6 @@ import hudson.model.Result; import hudson.util.RunList; import jenkins.model.Jenkins; -import org.apache.commons.httpclient.NameValuePair; import org.jenkinsci.plugins.workflow.job.WorkflowJob; import org.jenkinsci.plugins.workflow.job.WorkflowRun; import org.junit.Assert; @@ -41,7 +40,9 @@ import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; +import java.util.AbstractMap; import java.util.Iterator; +import java.util.Map; /** * @author tom.fennelly@gmail.com @@ -65,8 +66,8 @@ public static int postToJenkins(Jenkins jenkins, String url, String content, Str conn.setRequestMethod("POST"); // Set the crumb header, otherwise the POST may be rejected. - NameValuePair crumbHeader = getCrumbHeaderNVP(jenkins); - conn.setRequestProperty(crumbHeader.getName(), crumbHeader.getValue()); + Map.Entry crumbHeader = getCrumbHeaderNVP(jenkins); + conn.setRequestProperty(crumbHeader.getKey(), crumbHeader.getValue()); if (contentType != null) { conn.setRequestProperty("Content-Type", contentType); @@ -156,8 +157,8 @@ public static T getJSON(String url, Class to, JenkinsRule jenkinsRule) th return jsonReadWrite.fromString(jsonResponse, to); } - private static NameValuePair getCrumbHeaderNVP(Jenkins jenkins) { - return new NameValuePair(jenkins.getCrumbIssuer().getDescriptor().getCrumbRequestField(), + private static Map.Entry getCrumbHeaderNVP(Jenkins jenkins) { + return new AbstractMap.SimpleEntry<>(jenkins.getCrumbIssuer().getDescriptor().getCrumbRequestField(), jenkins.getCrumbIssuer().getCrumb( null )); } }