use of com.meterware.httpunit.WebResponse in project camel by apache.
the class MultiServletConsumerTest method getService.
public String getService(String path) throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + path);
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
return response.getText();
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class ServletNoSlashNeededTest method testNoSlashNeeded.
@Test
public void testNoSlashNeeded() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
assertEquals("The response message is wrong ", "Bye World", response.getText());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class ServletRootPathTest method testRootPath.
@Test
public void testRootPath() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/");
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
assertEquals("The response message is wrong ", "Bye World", response.getText());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class ServletSetBodyTest method testSetBody.
@Test
public void testSetBody() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
assertEquals("The response message is wrong ", "Bye World", response.getText());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class ServletTransferExceptionTest method testTransferException.
@Test
public void testTransferException() throws Exception {
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/hello", new ByteArrayInputStream("".getBytes()), "text/plain");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(500, response.getResponseCode());
assertEquals(HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT, response.getContentType());
Object object = HttpHelper.deserializeJavaObjectFromStream(response.getInputStream());
assertNotNull(object);
IllegalArgumentException cause = assertIsInstanceOf(IllegalArgumentException.class, object);
assertEquals("Damn", cause.getMessage());
}
Aggregations