use of com.meterware.httpunit.WebRequest in project cxf by apache.
the class CXFServletTest method invoke.
private void invoke(String encoding) throws Exception {
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=" + encoding);
ServletUnitClient client = newClient();
WebResponse response = client.getResponse(req);
client.setExceptionsThrownOnErrorStatus(false);
assertEquals("text/xml", response.getContentType());
assertTrue(encoding.equalsIgnoreCase(response.getCharacterSet()));
Document doc = StaxUtils.read(response.getInputStream());
assertNotNull(doc);
addNamespace("h", "http://apache.org/hello_world_soap_http/types");
assertValid("/s:Envelope/s:Body", doc);
assertValid("//h:sayHiResponse", doc);
}
use of com.meterware.httpunit.WebRequest 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.WebRequest 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.WebRequest in project cxf by apache.
the class SpringServletTest method testIgnoreServiceList.
@Test
public void testIgnoreServiceList() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/");
try {
client.getResponse(req);
fail();
} catch (HttpNotFoundException ex) {
// expected
}
}
use of com.meterware.httpunit.WebRequest 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());
}
Aggregations