Examples of WebConversation


Examples of com.meterware.httpunit.WebConversation

    }

    @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

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testHelloWorldServlet() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/HelloWorld"));
        assertTrue(wc.getCurrentPage().getText().startsWith("Hello world on"));
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testHelloWorldJsp() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/sample.jsp"));
        assertTrue(wc.getCurrentPage().getText().indexOf("Hello world JSP on") != -1);
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testHelloWorldServlet() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/HelloWorld"));
        assertTrue(wc.getCurrentPage().getText().startsWith("Hello world on"));
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testHelloWorldJsp() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/sample.jsp"));
        assertTrue(wc.getCurrentPage().getText().startsWith("Hello world JSP on"));
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testStrutsPages() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/TestInput.do"));
        {
            WebForm form = wc.getCurrentPage().getForms()[0];
            form.setParameter("givenName", "Archie");
            form.setParameter("familyName", "Trajano");
            form.submit();
        }
        {
            WebForm form = wc.getCurrentPage().getForms()[0];
            assertEquals("Archie", form.getParameterValue("givenName"));
            assertEquals("Trajano", form.getParameterValue("familyName"));
        }
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testHelloWorldServlet() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/HelloWorld"));
        assertTrue(wc.getCurrentPage().getText().startsWith("Hello world on"));
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

     *
     * @throws Exception
     *                    thrown when there is a problem with the test
     */
    public void testHelloWorldJsp() throws Exception {
        WebConversation wc = new WebConversation();
        wc.getResponse(requestUrl("/sample.jsp"));
        assertTrue(wc.getCurrentPage().getText().indexOf("Hello world JSP on") != -1);
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

        Assert.assertEquals("BBC News", jsonResp.getJSONObject("result").getJSONObject("source").optJSONArray("list").getJSONObject(0).getString("name"));
    }   
 
    public JSONObject callService(String url, JSONObject jsonRequest) throws Exception {
        System.out.println("Request = " + jsonRequest.toString());
        WebConversation wc   = new WebConversation();
        WebRequest request   = new PostMethodWebRequest( url,
                                                         new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
        WebResponse response = wc.getResource(request);
        System.out.println("Response= " + response.getText());              
        Assert.assertEquals(200, response.getResponseCode());
        return new JSONObject(response.getText());
    }
View Full Code Here

Examples of com.meterware.httpunit.WebConversation

    }

    public void testJSONRPCBinding() throws Exception {
        JSONObject jsonRequest = new JSONObject("{ \"method\": \"echo\", \"params\": [\"Hello JSON-RPC\"], \"id\": 1}");

        WebConversation wc = new WebConversation();
        WebRequest request   = new PostMethodWebRequest( SERVICE_URL, new ByteArrayInputStream(jsonRequest.toString().getBytes("UTF-8")),"application/json");
        WebResponse response = wc.getResource(request);

        assertEquals(200, response.getResponseCode());
        JSONObject jsonResp = new JSONObject(response.getText());
        assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.