Assert.assertEquals(HttpResponseCodes.SC_OK, status);
Assert.assertEquals("basic", method.getResponseBodyAsString());
method.releaseConnection();
}
{
PutMethod method = new PutMethod("http://localhost:8080/basic-integration-test/basic");
method.setRequestEntity(new StringRequestEntity("basic", "text/plain", null));
int status = client.executeMethod(method);
Assert.assertEquals(204, status);
method.releaseConnection();
}
{
GetMethod method = new GetMethod("http://localhost:8080/basic-integration-test/queryParam");
NameValuePair[] params = {new NameValuePair("param", "hello world")};
method.setQueryString(params);
int status = client.executeMethod(method);
Assert.assertEquals(HttpResponseCodes.SC_OK, status);
Assert.assertEquals("hello world", method.getResponseBodyAsString());
method.releaseConnection();
}
{
GetMethod method = new GetMethod("http://localhost:8080/basic-integration-test/uriParam/1234");
int status = client.executeMethod(method);
Assert.assertEquals(HttpResponseCodes.SC_OK, status);
Assert.assertEquals("1234", method.getResponseBodyAsString());
method.releaseConnection();
}
{
// I'm testing unknown content-length here
GetMethod method = new GetMethod("http://localhost:8080/basic-integration-test/xml");
int status = client.executeMethod(method);
Assert.assertEquals(HttpResponseCodes.SC_OK, status);
String result = method.getResponseBodyAsString();
JAXBContext ctx = JAXBContext.newInstance(Customer.class);
Customer cust = (Customer)ctx.createUnmarshaller().unmarshal(new StringReader(result));
Assert.assertEquals("Bill Burke", cust.getName());
method.releaseConnection();
}
}