Search in sources :

Example 56 with WebRequest

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\">"));
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Test(org.junit.Test)

Example 57 with WebRequest

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);
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 58 with WebRequest

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);
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) NodeList(org.w3c.dom.NodeList) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Document(org.w3c.dom.Document) Endpoint(javax.xml.ws.Endpoint) Test(org.junit.Test)

Example 59 with WebRequest

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);
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 60 with WebRequest

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);
}
Also used : WebResponse(com.meterware.httpunit.WebResponse) WebRequest(com.meterware.httpunit.WebRequest) GetMethodWebRequest(com.meterware.httpunit.GetMethodWebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Document(org.w3c.dom.Document) WSDLReader(javax.wsdl.xml.WSDLReader) Test(org.junit.Test)

Aggregations

WebRequest (com.meterware.httpunit.WebRequest)113 WebResponse (com.meterware.httpunit.WebResponse)108 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)90 Test (org.junit.Test)87 ServletUnitClient (com.meterware.servletunit.ServletUnitClient)52 PostMethodWebRequest (com.meterware.httpunit.PostMethodWebRequest)45 WebConversation (com.meterware.httpunit.WebConversation)39 ByteArrayInputStream (java.io.ByteArrayInputStream)27 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)16 PutMethodWebRequest (com.meterware.httpunit.PutMethodWebRequest)14 TextBlock (com.meterware.httpunit.TextBlock)14 URL (java.net.URL)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)14 HttpServletResponse (javax.servlet.http.HttpServletResponse)14 Document (org.w3c.dom.Document)10 HttpSession (javax.servlet.http.HttpSession)9 WebForm (com.meterware.httpunit.WebForm)7 HeaderOnlyWebRequest (com.meterware.httpunit.HeaderOnlyWebRequest)5 HttpNotFoundException (com.meterware.httpunit.HttpNotFoundException)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5