Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletUnitClient


        assertValid("//xsd:complexType[@name='ErrorCode']", doc);
    }
   
    @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 = DOMUtils.readXml(res.getInputStream());
        assertNotNull(doc);
View Full Code Here


        assertValid("//http:address[@location='" + CONTEXT_URL + "/services/greeter2']", doc);
    }

    @Test
    public void testInvalidServiceUrl() throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);

        WebResponse res = client.getResponse(CONTEXT_URL + "/services/NoSuchService");
        assertEquals(404, res.getResponseCode());
        assertEquals("text/html", res.getContentType());
    }
View Full Code Here

        expectErrorCode(req, 404, "Response code 404 required for invalid WSDL url.");
    }
   
    @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",
View Full Code Here

        assertValid("//h:sayHiResponse", doc);
    }
   
    @Test
    public void testGreetMeGetRequest() throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(true);
       
        WebRequest req =
            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/SOAPService/greetMe?"
                                         + "requestType=hello");
       
        WebResponse response = client.getResponse(req);       
        Document doc = DOMUtils.readXml(response.getInputStream());
        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
        assertValid("/s:Envelope/s:Body", doc);
        assertValid("//h:greetMeResponse", doc);
       
        req =
            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/DerivedGreeterService/greetMe?"
                                         + "requestType=hello");
       
        response = client.getResponse(req);       
        doc = DOMUtils.readXml(response.getInputStream());
        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
        assertValid("/s:Envelope/s:Body", doc);
        assertValid("//h:greetMeResponse", doc);
    }
View Full Code Here

    }
   
       
    @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 = DOMUtils.readXml(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 = DOMUtils.readXml(res.getInputStream());
        assertNotNull(doc);
View Full Code Here

    public void testGetThatBook123() throws Exception {
        testInvokingBookService("/jaxrs/bookstorestorage/thosebooks/123");
    }  
   
    private void testInvokingBookService(String serviceAddress) throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);
       
        WebRequest req =
            new GetMethodQueryWebRequest(CONTEXT_URL + serviceAddress);
       
        WebResponse response = client.getResponse(req);
        InputStream in = response.getInputStream();       
        InputStream expected = JaxRsServletTest.class
            .getResourceAsStream("resources/expected_get_book123.txt");
       
        assertEquals(" Can't get the expected result ",
View Full Code Here

        assertValid("//h:sayHiResponse", doc);
    }
   
    @Test
    public void testGreetMeGetRequest() throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(true);
       
        WebRequest req =
            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter/greetMe?"
                                         + "requestType=hello");
       
        WebResponse response = client.getResponse(req);       
        Document doc = DOMUtils.readXml(response.getInputStream());
        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
        assertValid("/s:Envelope/s:Body", doc);
        assertValid("//h:greetMeResponse", doc);
       
        req =
            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/Greeter1/greetMe?"
                                         + "requestType=hello");
       
        response = client.getResponse(req);       
        doc = DOMUtils.readXml(response.getInputStream());
        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
        assertValid("/s:Envelope/s:Body", doc);
        assertValid("//h:greetMeResponse", doc);
    }
View Full Code Here

    }
   
       
    @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 = DOMUtils.readXml(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 = DOMUtils.readXml(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 = DOMUtils.readXml(res.getInputStream());
        assertNotNull(doc);
View Full Code Here

    }
   
    @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
        }
    }
View Full Code Here

    }
   
    @Test
    public void testGetServiceList() throws Exception {
       
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);

        //test the '/' context get service list
        WebResponse  res = client.getResponse(CONTEXT_URL + "/");
        WebLink[] links = res.getLinks();
        assertEquals("Wrong number of service links", 4, links.length);
       
        Set<String> links2 = new HashSet<String>();
        for (WebLink l : links) {
View Full Code Here

TOP

Related Classes of com.meterware.servletunit.ServletUnitClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.