Package com.meterware.servletunit

Examples of com.meterware.servletunit.ServletUnitClient


    }
   
    @Test
    public void testPost() throws Exception {
        WebRequest req = new PostMethodWebRequest(createUrl("/test2"), createInput("input2"), getContentType());
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals("input2", response.getText());
    }
View Full Code Here


    }
   
    @Test
    public void testGet() throws Exception {
        WebRequest req = new GetMethodWebRequest(createUrl("/test1?test=input1"));
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals(200, response.getResponseCode());
        assertEquals("input1", response.getHeaderField("test"));
    }
View Full Code Here

    }
   
    @Test
    public void testPost() throws Exception {
        WebRequest req = new PostMethodWebRequest(createUrl("/test1"), createInput("input2"), getContentType());
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals("input2", response.getText());
    }
View Full Code Here

    }
   
    @Test
    public void testCustomUrl() throws Exception {
        WebRequest req = new GetMethodWebRequest(createUrl("/test2"));
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals("http://another.org:1234/abc", response.getHeaderField("testUrl"));
    }
View Full Code Here

   

    @Test
    public void testHttpClient() throws Exception {
        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/hello", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
       
        assertEquals("Get wrong content type", "text/xml", response.getContentType());
        assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
        assertEquals("Get a wrong message header", "/hello", response.getHeaderField("PATH"));
        assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
       
        req = new PostMethodWebRequest(CONTEXT_URL + "/services/helloworld", new ByteArrayInputStream(POST_DATA.getBytes()), "text/xml; charset=UTF-8");
        response = client.getResponse(req);
       
        assertEquals("Get wrong content type", "text/xml", response.getContentType());
        assertTrue("UTF-8".equalsIgnoreCase(response.getCharacterSet()));
        assertEquals("Get a wrong message header", "/helloworld", response.getHeaderField("PATH"));
        assertEquals("The response message is wrong ", "OK", response.getResponseMessage());
        client.setExceptionsThrownOnErrorStatus(false);
    }
View Full Code Here

        assertEquals("Get a wrong response", "/mycontext/services2/echo", result);
    }
   
    public String getService(String path) throws Exception {
        WebRequest req = new GetMethodWebRequest(CONTEXT_URL + path);
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
       
        return response.getText();
    }
View Full Code Here

public class ServletSetBodyTest extends ServletCamelRouterTestSupport {

    @Test
    public void testSetBody() throws Exception {
        WebRequest req = new GetMethodWebRequest(CONTEXT_URL + "/services/hello");
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);

        assertEquals("The response message is wrong ", "Bye World", response.getText());
    }
View Full Code Here

    }

    @Test
    public void testGet() throws Exception {
        WebRequest req = new GetMethodWebRequest(createUrl("/test1?test=input1"));
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals(200, response.getResponseCode());
        assertEquals("input1", response.getHeaderField("test"));
    }
View Full Code Here

    }
   
    @Test
    public void testPost() throws Exception {
        WebRequest req = new PostMethodWebRequest(createUrl("/test1"), createInput("input2"), getContentType());
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals("input2", response.getText());
    }
View Full Code Here

    }
   
    @Test
    public void testCustomUrl() throws Exception {
        WebRequest req = new GetMethodWebRequest(createUrl("/test2"));
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
        assertEquals(getBaseUri() + "/blah", response.getHeaderField("testUrl"));
    }
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.