Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebResponse


        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);
       
        assertValid("//wsdl:operation[@name='greetMe']", doc);
        assertValid("//wsdlsoap:address"
                    + "[@location='http://localhost/mycontext/services/DerivedGreeterService']",
View Full Code Here


        invokingEndpoint(req);
    }
   
    public void invokingEndpoint(WebRequest req) throws Exception {
       
        WebResponse response = newClient().getResponse(req);
        assertEquals("text/xml", response.getContentType());
        assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet()));

        Document doc = DOMUtils.readXml(response.getInputStream());
        assertNotNull(doc);

        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
        assertValid("/s:Envelope/s:Body", doc);
        assertValid("//h:sayHiResponse", doc);
View Full Code Here

       
        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

        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);
       
        assertValid("//wsdl:operation[@name='greetMe']", doc);
        assertValid("//wsdlsoap:address[@location='" + CONTEXT_URL + "/services/Greeter3']", doc);
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()) {
        //    System.out.println(">>> Header:" + headerField + " - " + response.getHeaderField(headerField));
        //}

        //for debug purposes
        System.out.println(">>>" + GET_RESPONSE);
        System.out.println(">>>" + response.getText());

        Assert.assertEquals(200, response.getResponseCode());
        Assert.assertEquals("no-cache", response.getHeaderField("Cache-Control"));
        Assert.assertEquals("tuscany", response.getHeaderField("X-Tuscany"));
        Assert.assertEquals(GET_RESPONSE, response.getText());

    }
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());

        Assert.assertEquals(200, response.getResponseCode());
        Assert.assertEquals(GET_UPDATED_RESPONSE, response.getText());
    }
View Full Code Here

        invokingEndpoint(req);
    }
   
    public void invokingEndpoint(WebRequest req) throws Exception {
       
        WebResponse response = newClient().getResponse(req);
        assertEquals("text/xml", response.getContentType());
        assertTrue("utf-8".equalsIgnoreCase(response.getCharacterSet()));

        Document doc = DOMUtils.readXml(response.getInputStream());
        assertNotNull(doc);

        addNamespace("h", "http://apache.org/hello_world_soap_http/types");
        assertValid("/s:Envelope/s:Body", doc);
        assertValid("//h:sayHiResponse", doc);
View Full Code Here

       
        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

        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());
        assertTrue("the wsdl should contain the opertion greetMe",
                   res.getText().contains("<wsdl:operation name=\"greetMe\">"));
        assertTrue("the soap address should changed",
                   res.getText().contains("<soap:address location=\"" + CONTEXT_URL + "/services/Greeter"));
       
       
       
    }
View Full Code Here

        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

TOP

Related Classes of com.meterware.httpunit.WebResponse

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.