use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletGetWildcardsTest method testServletProducerGet.
@Test
public void testServletProducerGet() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
assertEquals("123;Donald Duck", response.getText());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletGetWildcardsTest method testServletProducerGetWildcards.
@Test
public void testServletProducerGetWildcards() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/456/name=g*");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
assertEquals("456;Goofy", response.getText());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletPojoInOutTest method testServletPojoGet.
@Test
public void testServletPojoGet() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/lives");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
String out = response.getText();
assertNotNull(out);
assertEquals("{\"iso\":\"EN\",\"country\":\"England\"}", out);
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletPojoInOutTest method testServletPojoInOut.
@Test
public void testServletPojoInOut() throws Exception {
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/lives", new ByteArrayInputStream(body.getBytes()), "application/json");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
String out = response.getText();
assertNotNull(out);
assertEquals("{\"iso\":\"EN\",\"country\":\"England\"}", out);
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletPostJsonJaxbPojoTest method testPostJaxbPojo.
@Test
public void testPostJaxbPojo() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:input");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(UserJaxbPojo.class);
String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/new", new ByteArrayInputStream(body.getBytes()), "application/json");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
assertMockEndpointsSatisfied();
UserJaxbPojo user = mock.getReceivedExchanges().get(0).getIn().getBody(UserJaxbPojo.class);
assertNotNull(user);
assertEquals(123, user.getId());
assertEquals("Donald Duck", user.getName());
}
Aggregations