use of testutil.HTTPResponseInfo in project metro-jax-ws by eclipse-ee4j.
the class SOAPActionTest method testUnquotedSOAPAction1.
public void testUnquotedSOAPAction1() throws Exception {
TestEndpoint port = new TestEndpointService().getTestEndpointPort1();
String address = (String) ((BindingProvider) port).getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
HTTPResponseInfo rInfo = ClientServerTestUtil.sendPOSTRequest(address, s11_request, "text/xml", "http://example.com/action/echo");
String resp = rInfo.getResponseBody();
SOAPMessage respMesg = getSOAPMessage(makeStreamSource(resp));
SOAPBody body = respMesg.getSOAPPart().getEnvelope().getBody();
Element e = (Element) body.getElementsByTagName("return").item(0);
// make sure it is dispatched to echo() using SoapAction
assertEquals("Hello Duke", e.getTextContent());
}
use of testutil.HTTPResponseInfo in project metro-jax-ws by eclipse-ee4j.
the class NegativeTest method testMalformedMessageWithoutHeaders.
/*
* Sends a malformed message
*/
public void testMalformedMessageWithoutHeaders() throws Exception {
String message = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://example.com/types'><soapenv:Body><ns1:echo><ns1:reqInfo>foo<ns1:reqInfo></ns1:echo></soapenv:Body></soapenv:Envelope>";
HTTPResponseInfo rInfo = ClientServerTestUtil.sendPOSTRequest(getStub(), message);
assertEquals(500, rInfo.getResponseCode());
}
use of testutil.HTTPResponseInfo in project metro-jax-ws by eclipse-ee4j.
the class NegativeTest method testMalformedMessage.
/*
* Sends a malformed message
*/
public void testMalformedMessage() throws Exception {
String message = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://example.com/types'><soapenv:Header><ns1:echo><ns1:reqInfo>foo</ns1:reqInfo></ns1:echo></ns1:echo><ns1:echo2><ns1:reqInfo>foo</ns1:reqInfo></ns1:echo2></soapenv:Header><soapenv:Body><ns1:echo><ns1:reqInfo>foo</ns1:reqInfo></ns1:echo></soapenv:Body><soapenv:Envelope>";
HTTPResponseInfo rInfo = ClientServerTestUtil.sendPOSTRequest(getStub(), message);
assertEquals(500, rInfo.getResponseCode());
}
use of testutil.HTTPResponseInfo in project metro-jax-ws by eclipse-ee4j.
the class NegativeTest method testMediaType.
/*
* Sends a message with wrong Content-Type
*/
public void testMediaType() throws Exception {
String message = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns1='http://example.com/types'><soapenv:Header><ns1:echo><ns1:reqInfo>foo</ns1:reqInfo></ns1:echo><ns1:echo2><ns1:reqInfo>foo</ns1:reqInfo></ns1:echo2></soapenv:Header><soapenv:Body><ns1:echo><ns1:reqInfo>foo</ns1:reqInfo></ns1:echo></soapenv:Body></soapenv:Envelope>";
HTTPResponseInfo rInfo = ClientServerTestUtil.sendPOSTRequest(getStub(), message, "a/b");
assertEquals(415, rInfo.getResponseCode());
}
use of testutil.HTTPResponseInfo in project metro-jax-ws by eclipse-ee4j.
the class NegativeTest method testEnvelopeNS.
/*
* Sends a message with wrong envelope namespace
*/
public void testEnvelopeNS() throws Exception {
String message = "<?xml version='1.0' encoding='UTF-8'?><env:Envelope xmlns:env='http://wrongname.org' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><env:Body><wrongname xmlns='http://example.com/types'><reqInfo>foo</reqInfo></echo></env:Body></env:Envelope>";
HTTPResponseInfo rInfo = ClientServerTestUtil.sendPOSTRequest(getStub(), message);
assertEquals(500, rInfo.getResponseCode());
String resp = rInfo.getResponseBody();
MessageFactory messageFactory = MessageFactory.newInstance();
MimeHeaders headers = new MimeHeaders();
headers.addHeader("Content-Type", "text/xml");
SOAPMessage soapMsg = messageFactory.createMessage(headers, new ByteArrayInputStream(resp.getBytes()));
SOAPBody body = soapMsg.getSOAPPart().getEnvelope().getBody();
if (!body.hasFault()) {
fail("Wrong operation QName doesn't generate a fault on server");
}
QName got = body.getFault().getFaultCodeAsQName();
QName exp = new QName("http://schemas.xmlsoap.org/soap/envelope/", "VersionMismatch");
assertEquals(exp, got);
}
Aggregations