use of com.meterware.httpunit.PostMethodWebRequest in project cxf by apache.
the class CXFFilterTest method testPostInvokeServices.
@Test
public void testPostInvokeServices() throws Exception {
newClient();
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=UTF-8");
WebResponse response = newClient().getResponse(req);
assertEquals("text/xml", response.getContentType());
assertEquals(StandardCharsets.UTF_8.name(), 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.PostMethodWebRequest in project cxf by apache.
the class JsFrontEndServletTest method testPostInvokeServices.
@Test
public void testPostInvokeServices() throws Exception {
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=UTF-8");
WebResponse response = newClient().getResponse(req);
assertEquals("text/xml", response.getContentType());
// assertEquals(StandardCharsets.UTF_8, 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);
assertValid("//h:responseType", doc);
}
use of com.meterware.httpunit.PostMethodWebRequest in project cxf by apache.
the class ExternalServicesServletTest method testPostInvokeServices.
@Test
public void testPostInvokeServices() throws Exception {
newClient();
WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/greeter", getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=UTF-8");
WebResponse response = newClient().getResponse(req);
assertEquals("text/xml", response.getContentType());
assertEquals(StandardCharsets.UTF_8.name(), 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.PostMethodWebRequest in project teammates by TEAMMATES.
the class GaeSimulation method createWebRequest.
private HttpServletRequest createWebRequest(String uri, String... parameters) {
WebRequest request = new PostMethodWebRequest("http://localhost" + uri);
if (Const.SystemParams.PAGES_REQUIRING_ORIGIN_VALIDATION.contains(uri)) {
request.setHeaderField("referer", "http://localhost");
String sessionId = sc.getSession(true).getId();
String token = CryptoHelper.computeSessionToken(sessionId);
request.setParameter(Const.ParamsNames.SESSION_TOKEN, token);
}
Map<String, List<String>> paramMultiMap = new HashMap<>();
for (int i = 0; i < parameters.length; i = i + 2) {
String key = parameters[i];
if (paramMultiMap.get(key) == null) {
paramMultiMap.put(key, new ArrayList<String>());
}
paramMultiMap.get(key).add(parameters[i + 1]);
}
paramMultiMap.forEach((key, values) -> request.setParameter(key, values.toArray(new String[0])));
try {
InvocationContext ic = sc.newInvocation(request);
return ic.getRequest();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations