Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebConversation


    @Test
    public void testArrayString() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{\"params\":[[\"1\",\"2\"]],\"method\":\"echoArrayString\",\"id\":9}");

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

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here


    @Test
    public void testArrayInt() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{\"params\":[[1,2]],\"method\":\"echoArrayInt\",\"id\":10}");

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

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

    @Test
    public void testSet() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{ \"method\": \"echoSet\", \"params\": [[\"red\", \"blue\"]],\"id\": 11}");

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

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

    @Test
    public void testBigDecimal() throws Exception {
        JSONObject jsonRequest = new JSONObject(
                "{ \"method\": \"echoBigDecimal\", \"params\": [\"12345.67\"], \"id\": 4}");

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

        Assert.assertEquals(200, response.getResponseCode());

        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

    @Test
    /**
     * This test make sure the JSON-RPC Binding can handle special characters when generating SMD
     */
    public void testJSONRPCSmdSpecialCharacters() throws Exception {
        WebConversation wc = new WebConversation();
        WebRequest request   = new GetMethodWebRequest(SMD_URL);
        WebResponse response = wc.getResource(request);

        Assert.assertEquals(200, response.getResponseCode());
        Assert.assertNotNull(response.getText());

        //System.out.println(">>>SMD:" + response.getText());
View Full Code Here

        assertEquals("Get the wrongreply ", reply, "get Willem");
    }

    @Test
    public void testGetServiceList() throws Exception {
        WebConversation client = new WebConversation();
        WebResponse res = client.getResponse(serviceURL + "/services");
        WebLink[] links = res.getLinks();
        Set<String> s = new HashSet<String>();
        for (WebLink l : links) {
            s.add(l.getURLString());
        }
View Full Code Here

public class FunctionalTestStandAlone extends TestCase {

    private String baseUrl;

    public void testHttpGet() throws Exception {
        WebConversation conversation = new WebConversation();

        WebRequest request = new GetMethodWebRequest(baseUrl + "/get");

        WebResponse response = conversation.getResponse(request);

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

        assertEquals(200, response.getResponseCode());
        assertEquals("Hello, World.", response.getText());
    }

    public void testHttpGetWithParameter() throws Exception {
        WebConversation conversation = new WebConversation();

        WebRequest request = new GetMethodWebRequest(baseUrl + "/get_with_parameter");
        request.setParameter("name", "World");

        WebResponse response = conversation.getResponse(request);

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

        assertEquals(200, response.getResponseCode());
        assertEquals("Hello, World.", response.getText());
    }

    public void testHttpPostWithParameter() throws Exception {
        WebConversation conversation = new WebConversation();

        WebRequest request = new PostMethodWebRequest(baseUrl + "/post_with_parameter");
        request.setParameter("name", "World");

        WebResponse response = conversation.getResponse(request);

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

        assertEquals("Hello, World.", response.getText());
    }

    public void testInternalServerError() throws Exception {
        try {
            WebConversation conversation = new WebConversation();

            WebRequest request = new PostMethodWebRequest(baseUrl + "/internal_server_error");

            conversation.getResponse(request);

            fail();
        } catch (HttpInternalErrorException e) {
        }
    }
View Full Code Here

TOP

Related Classes of com.meterware.httpunit.WebConversation

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.