Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletUnitClient


    }
   
    public void testInvalidServiceUrl()
        throws Exception
    {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);
       
        WebResponse res = client.getResponse("http://localhost/services/NoSuchService");
        assertEquals(404, res.getResponseCode());
        assertTrue(res.isHTML());
    }
View Full Code Here


    }
   
    public void testServiceUrlNoSOAPMessage()
        throws Exception
    {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);
       
        WebResponse res = client.getResponse("http://localhost/services/EchoImpl");

        assertTrue(res.isHTML());
        assertEquals("<html><body>Invalid SOAP request.</body></html>", res.getText());
    }
View Full Code Here

        assertValid("/wsdl:definitions/wsdl:message[@name='getVersionResponse']", doc );
  }

    public void testExposeService() throws Exception
    {
        ServletUnitClient client = newClient();

    WebResponse response = client.getResponse("http://localhost/services/SparePartInfo?method=getPartInfo&PartSKU=test");

    //assertIsXml( response.getText() );
    //assertStringInBody( response, "<getPartInfoReturn" );
    //assertStringInBody( response, "test - Part Info" );
    }
View Full Code Here

    //assertStringInBody( response, "test - Part Info" );
    }
   
    public void testComplexSerialization() throws Exception
    {
        ServletUnitClient client = newClient();

    WebResponse response = client.getResponse("http://localhost/services/SparePartInfo?method=getSparePart");
   
    //assertIsXml( response.getText() );
        //assertStringInBody( response, "<SKU" );
    }
View Full Code Here

        headers.join();
    }


    private void doTestGet(String context, String expectedReponsePattern) throws Exception {
        ServletUnitClient client = runner.newClient();
        WebRequest request = new GetMethodWebRequest(BASE_URL + CONTEXT_PATH + context);
        request.setHeaderField("Accept", "text/plain");

        verify(client.getResponse(request), 200, expectedReponsePattern);
    }
View Full Code Here

    }

    @Test
    public void testServletProducerGet() throws Exception {
        WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/123/basic");
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        WebResponse response = client.getResponse(req);

        assertEquals(200, response.getResponseCode());

        assertEquals("123;Donald Duck", response.getText());
    }
View Full Code Here

    @Test
    public void testServletPojoInOut() throws Exception {
        String body = "{\"id\": 123, \"name\": \"Donald Duck\"}";
        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/users/lives", new ByteArrayInputStream(body.getBytes()), "application/json");
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        WebResponse response = client.getResponse(req);

        assertEquals(200, response.getResponseCode());

        String out = response.getText();
View Full Code Here

   
    @Test
    public void testServletPojoGet() throws Exception {
       
        WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/users/lives");
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(false);
        WebResponse response = client.getResponse(req);

        assertEquals(200, response.getResponseCode());

        String out = response.getText();
View Full Code Here

    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 = DOMUtils.readXml(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("There should get two links for the service", 3, 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"));
        assertEquals("text/html", res.getContentType());
       
        res = client.getResponse(CONTEXT_URL + "/services/");
      
       
        links = res.getLinks();
        links2.clear();
        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.