-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop using Commons HttpClient 3.x in tests (#256)
- Loading branch information
Showing
1 changed file
with
6 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <a href="mailto:[email protected]">[email protected]</a> | ||
|
@@ -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<String, String> crumbHeader = getCrumbHeaderNVP(jenkins); | ||
conn.setRequestProperty(crumbHeader.getKey(), crumbHeader.getValue()); | ||
|
||
if (contentType != null) { | ||
conn.setRequestProperty("Content-Type", contentType); | ||
|
@@ -156,8 +157,8 @@ public static <T> T getJSON(String url, Class<T> 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<String, String> getCrumbHeaderNVP(Jenkins jenkins) { | ||
return new AbstractMap.SimpleEntry<>(jenkins.getCrumbIssuer().getDescriptor().getCrumbRequestField(), | ||
jenkins.getCrumbIssuer().getCrumb( null )); | ||
} | ||
} |