use of com.meterware.httpunit.WebRequest in project cxf by apache.
the class CXFServletTest method testGetImportedXSD.
@Test
public void testGetImportedXSD() 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());
String text = res.getText();
assertEquals("text/xml", res.getContentType());
assertTrue(text.contains(CONTEXT_URL + "/services/greeter?wsdl=test_import.xsd"));
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl=test_import.xsd");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
text = res.getText();
assertEquals("text/xml", res.getContentType());
assertTrue("the xsd should contain the completType SimpleStruct", text.contains("<complexType name=\"SimpleStruct\">"));
}
use of com.meterware.httpunit.WebRequest in project cxf by apache.
the class CXFServletTest method testGetWSDLWithIncludes.
@Test
public void testGetWSDLWithIncludes() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
Document doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertXPathEquals("//xsd:include/@schemaLocation", "http://localhost/mycontext/services/greeter3?xsd=hello_world_includes2.xsd", doc.getDocumentElement());
req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?xsd=hello_world_includes2.xsd");
res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
assertValid("//xsd:complexType[@name='ErrorCode']", doc);
}
use of com.meterware.httpunit.WebRequest in project cxf by apache.
the class CXFServletTest method testGetWSDLWithXMLBinding.
@Test
public void testGetWSDLWithXMLBinding() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter2?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
Document doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
addNamespace("http", "http://schemas.xmlsoap.org/wsdl/http/");
assertValid("//wsdl:operation[@name='greetMe']", doc);
NodeList addresses = assertValid("//http:address/@location", doc);
boolean found = true;
for (int i = 0; i < addresses.getLength(); i++) {
String address = addresses.item(i).getLocalName();
if (address.startsWith("http://localhost") && address.endsWith("/services/greeter2")) {
found = true;
break;
}
}
assertTrue(found);
}
use of com.meterware.httpunit.WebRequest in project cxf by apache.
the class CXFServletTest 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);
}
use of com.meterware.httpunit.WebRequest in project cxf by apache.
the class CXFServletTest method testGetWSDLWithMultiplePublishedEndpointUrl.
@Test
public void testGetWSDLWithMultiplePublishedEndpointUrl() throws Exception {
ServletUnitClient client = newClient();
client.setExceptionsThrownOnErrorStatus(true);
WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter5?wsdl");
WebResponse res = client.getResponse(req);
assertEquals(200, res.getResponseCode());
assertEquals("text/xml", res.getContentType());
Document doc = StaxUtils.read(res.getInputStream());
assertNotNull(doc);
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
assertValid("//wsdl:service[@name='SOAPService']/wsdl:port[@name='SoapPort']/wsdlsoap:address[@location='" + "http://cxf.apache.org/publishedEndpointUrl1']", doc);
assertValid("//wsdl:service[@name='SOAPService']/wsdl:port[@name='SoapPort1']/wsdlsoap:address[@location='" + "http://cxf.apache.org/publishedEndpointUrl2']", doc);
}
Aggregations