Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletUnitClient


    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());
View Full Code Here


        assertValid("//h:sayHiResponse", doc);   
    }
   
    @Test
    public void testGetServiceList() throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);

        WebResponse res = client.getResponse(CONTEXT_URL + "/services");
       
       
        WebLink[] links = res.getLinks();
        assertEquals("Wrong number of service links", 6, links.length);
       
        Set<String> links2 = new HashSet<String>();
        for (WebLink l : links) {
            links2.add(l.getURLString());
        }
       
        assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl"));      
        assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl"));
        assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl"));
        assertEquals("text/html", res.getContentType());
       
        res = client.getResponse(CONTEXT_URL + "/services/");
      
       
        links = res.getLinks();
        links2.clear();
        for (WebLink l : links) {
View Full Code Here

        assertNotNull(BusFactory.getDefaultBus(false));
    }
   
    @Test
    public void testGetUnformatServiceList() throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);

        WebResponse res = client.getResponse(CONTEXT_URL + "/services?formatted=false");
       
        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter3"));
        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter2"));
        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter"));
       
View Full Code Here

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

        WebResponse res = client.getResponse(CONTEXT_URL + "/services");
       
        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter3"));
        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter2"));
        assertTrue(res.getText().contains("http://localhost/mycontext/services/greeter"));
        WebRequest req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter?wsdl");
        res = client.getResponse(req);
        req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter2?wsdl");
        res = client.getResponse(req);
        req = new GetMethodQueryWebRequest(CONTEXT_URL + "/services/greeter3?wsdl");
        res = client.getResponse(req);
        String loopAddr = "http://127.0.0.1/mycontext";
        res = client.getResponse(loopAddr + "/services");
        assertFalse(res.getText().contains(
             "http://127.0.0.1/mycontext/serviceshttp://localhost/mycontext/services/greeter"));
               
    }
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 = StaxUtils.read(res.getInputStream());
        assertNotNull(doc);
       
View Full Code Here

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

            + "http://cxf.apache.org/publishedEndpointUrl2']", doc);
       
    }
    @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);
View Full Code Here

        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 = StaxUtils.read(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

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.