use of com.meterware.httpunit.WebResponse in project cxf by apache.
the class SpringAutoPublishServletTest method testGetWSDL.
@Test
public void testGetWSDL() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/SOAPService?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
Document doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//wsdl:operation[@name='greetMe']", doc);
assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/SOAPService']", doc);
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/DerivedGreeterService?wsdl");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//wsdl:operation[@name='greetMe']", doc);
assertValid("//wsdlsoap:address" + "[@location='http://localhost/mycontext/services/DerivedGreeterService']", doc);
}
use of com.meterware.httpunit.WebResponse in project cxf by apache.
the class SpringServletTest method testGetWSDL.
@Test
public void testGetWSDL() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
Document doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//wsdl:operation[@name='greetMe']", doc);
assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter']", doc);
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter2?wsdl");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//wsdl:operation[@name='greetMe']", doc);
assertValid("//wsdlsoap:address[@location='http://cxf.apache.org/Greeter']", doc);
Endpoint.publish("/services/Greeter3", new org.apache.hello_world_soap_http.GreeterImpl());
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter3?wsdl");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//wsdl:operation[@name='greetMe']", doc);
assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter3']", doc);
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletPostXmlJaxbPojoTest 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());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletVerbTest method testGetAll.
@Test
public void testGetAll() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
assertEquals("[{ \"id\":\"1\", \"name\":\"Scott\" },{ \"id\":\"2\", \"name\":\"Claus\" }]", response.getText());
}
use of com.meterware.httpunit.WebResponse in project camel by apache.
the class RestServletVerbTest method testGetOne.
@Test
public void testGetOne() throws Exception {
WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/1");
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(false);
WebResponse response = client.getResponse(req);
assertEquals(200, response.getResponseCode());
assertEquals("{ \"id\":\"1\", \"name\":\"Scott\" }", response.getText());
}
Aggregations