【发布时间】:2016-06-08 16:47:38
【问题描述】:
我尝试在集成测试的发布请求中传递参数,但我得到的响应是未检测到所需的参数“源”。也许你会知道是什么原因。谢谢。
public void testUploadBundleFromRepository() throws IOException, InterruptedException {
String boundary = "---------------"+ UUID.randomUUID().toString();
String uri = String.format("http://%s:%d/upload/", HOST, PORT);
HttpPost httpPost = new HttpPost(uri);
httpPost.setHeader(HTTP.CONTENT_TYPE, ContentType.MULTIPART_FORM_DATA.getMimeType()+";boundary="+boundary);
List<NameValuePair> postParameters = new ArrayList<>();
postParameters.add(new BasicNameValuePair("source","repo"));
postParameters.add(new BasicNameValuePair("id","1"));
postParameters.add(new BasicNameValuePair("start", "true"));
httpPost.setEntity(new UrlEncodedFormEntity(postParameters, "UTF-8"));
HttpResponse response = getHttpClient().execute(httpPost);
//assert in future
}
【问题讨论】:
标签: java testing junit integration