Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebRequest


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


    }

    @Test
    public void testGetInvocation() throws Exception {
        WebConversation wc = new WebConversation();
        WebRequest request = new GetMethodWebRequest(SERVICE_URL);
        request.setHeaderField("Content-Type", "application/xml");
        WebResponse response = wc.getResource(request);

        //for debug purposes
        //list the response headers
        //for(String headerField : response.getHeaderFieldNames()) {
View Full Code Here

    @Test
    public void testPutInvocation() throws Exception {
        //Add new item to catalog
        WebConversation wc = new WebConversation();
        WebRequest request   = new PostMethodWebRequest(SERVICE_URL, new ByteArrayInputStream(UPDATED_ITEM.getBytes("UTF-8")),"application/xml");
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(201, response.getResponseCode());
        System.out.println(response.getHeaderField("Location"));

        //read new results and expect to get new item back in the response
        request = new GetMethodWebRequest(SERVICE_URL);
        request.setHeaderField("Content-Type", "application/xml");
        response = wc.getResource(request);

        //for debug purposes
        //System.out.println(">>>" + GET_UPDATED_RESPONSE);
        //System.out.println(">>>" + response.getText());
View Full Code Here

    }

    @Test
    public void testInvokingSpringBeans() throws Exception {

        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter",
            getClass().getResourceAsStream("GreeterMessage.xml"),
            "text/xml; charset=utf-8");

        invokingEndpoint(req);
       
View Full Code Here

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

    @Test
    public void testGetServiceList() throws Exception {
        ServletUnitClient client = newClient();
        client.setExceptionsThrownOnErrorStatus(true);
       
        WebRequest req =
            new GetMethodQueryWebRequest(CONTEXT_URL + "/services/");
        WebResponse res = client.getResponse(req);
        assertEquals(200, res.getResponseCode());
        assertEquals("text/html", res.getContentType());
        assertEquals("Here should have no services links ", 0, res.getLinks().length);
View Full Code Here

        invoke("UTF-8");
        invoke("iso-8859-1");       
    }

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

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

TOP

Related Classes of com.meterware.httpunit.WebRequest

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.