嗨我有一个json请求,我必须在我的junit测试用例中传递,但是请求被删除,因为删除不支持setEntity方法。我如何在我的测试用例中传递请求。 JSON请求我要通过如何在junit中传递删除方法的请求
{
"userId":"AJudd",
"siteId":"131",
"alternateSiteId":"186"
}
mytest的情况下对本
@Test
public void testdeleteAltSite() throws ClientProtocolException, IOException {
String resultCode = "001";
String resultText = "Success";
String url = "http://localhost:8080/adminrest1/alternatesite";
HttpClient client = HttpClientBuilder.create().build();
HttpDelete delete = new HttpDelete(url);
// add header
delete.addHeader("Transaction-Id", "11");
delete.addHeader("content-type", "application/json");
LOG.info(url);
HttpResponse response = client.execute(delete);
byte[] buf = new byte[512];
InputStream is = response.getEntity().getContent();
int count = 0;
StringBuilder builder = new StringBuilder(1024);
while ((count = is.read(buf, 0, 512)) > 0) {
builder.append(new String(buf, 0, count));
}
String output = builder.toString();
System.out.println(output);
}`
如何传递JSON值,使得传递的值的数据可以是删除吗?