Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebRequest


    @Test
    public void testDivide() throws Exception {
        String queryString = "/divide/3/2";

        WebConversation wc = new WebConversation();
        WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
        request.setHeaderField("Content-Type", MediaType.TEXT_PLAIN);
        WebResponse response = wc.getResource(request);

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


    @Test
    public void testFormula() throws Exception {
        String queryString = "/calculate/3+2";

        WebConversation wc = new WebConversation();
        WebRequest request = new GetMethodWebRequest(SERVICE_URL + queryString);
        request.setHeaderField("Content-Type", MediaType.TEXT_PLAIN);
        WebResponse response = wc.getResource(request);

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

    /******* Tests **********/

    public @Test void testBrowserSnifferTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"browser.vm");
        WebResponse resp = conv.getResponse(req);

        /* check we are identified as a Java (HttpUnit) client */
        checkText(resp,"Java","true");
    }
View Full Code Here

        checkText(resp,"Java","true");
    }

    public @Test void testContextTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"context.vm");
        WebResponse resp = conv.getResponse(req);

        /* check that getThis() is a ChainedContext instance */
        checkTextStart(resp,"this","org.apache.velocity.tools.view.context.ChainedContext");

View Full Code Here

        checkTextRegex(resp,"values","^\\[.*\\]$");
    }

    public @Test void testCookiesTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"cookies.vm");
        WebResponse resp = conv.getResponse(req);

        /* check all */
        checkTextStart(resp,"all","[Ljavax.servlet.http.Cookie;");

View Full Code Here

        checkTextStart(resp,"get","javax.servlet.http.Cookie");
    }

    public @Test void testLinkTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"link.vm");
        WebResponse resp = conv.getResponse(req);

        /* check anchor(foo) and anchor */
        resp = submitWithParam(resp,"anchor","anchor","foo");
        checkText(resp,"anchor","#foo");
View Full Code Here

        checkText(resp,"encodeURL","%3A+%2F");
    }

    public @Test void testParameterParserTool() throws Exception {
        WebConversation conv = new WebConversation();
        WebRequest req = new GetMethodWebRequest(ROOT_URL+"params.vm?foo=bar&b=false&n=55&d=1.2");
        WebResponse resp = conv.getResponse(req);

        /* check exists(foo) */
        resp = submitWithParam(resp,"exists","exists","foo");
        checkText(resp,"exists","true");
View Full Code Here

    public JwsTest(String name) {
        super(name);
    }

    public void testStockQuote() throws Exception {
        WebRequest request = new GetMethodWebRequest(url+"/StockQuoteService.jws?wsdl");
        assertStringInBody(request,"<wsdl:definitions");
    }
View Full Code Here

    /**
     * verify the /servlet url is there
     * @throws Exception
     */
    public void testServlet() throws Exception {
        WebRequest request = new GetMethodWebRequest(url+"/servlet/AxisServlet");
        assertStringInBody(request,services_text);
    }
View Full Code Here

    /**
     * verify the services url works
     */
    public void testServices() throws Exception {
        WebRequest request = new GetMethodWebRequest(services);
        expectErrorCode(request,404);
    }
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.