Search in sources :

Example 31 with ServletUnitClient

use of com.meterware.servletunit.ServletUnitClient 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)

Example 32 with ServletUnitClient

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

Example 33 with ServletUnitClient

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

Example 34 with ServletUnitClient

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

Example 35 with ServletUnitClient

use of com.meterware.servletunit.ServletUnitClient 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
    }
}
Also used : HttpNotFoundException(com.meterware.httpunit.HttpNotFoundException) WebRequest(com.meterware.httpunit.WebRequest) PostMethodWebRequest(com.meterware.httpunit.PostMethodWebRequest) ServletUnitClient(com.meterware.servletunit.ServletUnitClient) Test(org.junit.Test)

Aggregations

ServletUnitClient (com.meterware.servletunit.ServletUnitClient)58 WebResponse (com.meterware.httpunit.WebResponse)56 WebRequest (com.meterware.httpunit.WebRequest)52 Test (org.junit.Test)47 PostMethodWebRequest (com.meterware.httpunit.PostMethodWebRequest)40 GetMethodWebRequest (com.meterware.httpunit.GetMethodWebRequest)34 ByteArrayInputStream (java.io.ByteArrayInputStream)27 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)16 PutMethodWebRequest (com.meterware.httpunit.PutMethodWebRequest)12 Document (org.w3c.dom.Document)7 HttpNotFoundException (com.meterware.httpunit.HttpNotFoundException)6 HeaderOnlyWebRequest (com.meterware.httpunit.HeaderOnlyWebRequest)5 HttpException (com.meterware.httpunit.HttpException)3 WebLink (com.meterware.httpunit.WebLink)3 HashSet (java.util.HashSet)3 BasicBSONObject (org.bson.BasicBSONObject)3 ObjectId (org.bson.types.ObjectId)2 MongoContentStorage (v7db.files.mongodb.MongoContentStorage)2 ContentSHA (v7db.files.spi.ContentSHA)2 InputStream (java.io.InputStream)1