Examples of PostMethodWebRequest


Examples of com.meterware.httpunit.PostMethodWebRequest

    @Test
    public void testEchoWithJSONRPCBinding() 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);

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

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

Examples of com.meterware.httpunit.PostMethodWebRequest

    @Test
    public void testEchoVoidWithJSONRPCBinding() throws Exception {
        JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoVoid\", \"params\": [], \"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);

        Assert.assertEquals(200, response.getResponseCode());
       
        JSONObject jsonResp = new JSONObject(response.getText());
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

    public void testInt() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{ \"method\": \"echoInt\", \"params\": [12345], \"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());
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

    public void testBoolean() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{ \"method\": \"echoBoolean\", \"params\": [true], \"id\": 5}");

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

Examples of com.meterware.httpunit.PostMethodWebRequest

    public void testMap() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{ \"method\": \"echoMap\", \"params\": [ {\"javaClass\": \"java.util.HashMap\", \"map\": { \"Binding\": \"JSON-RPC\"}}], \"id\": 6}");

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

Examples of com.meterware.httpunit.PostMethodWebRequest

    public void testBean() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{ \"method\": \"echoBean\", \"params\": [ {\"javaClass\": \"bean.TestBean\", \"testString\": \"JSON-RPC\", \"testInt\":1234}], \"id\": 7}");

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

Examples of com.meterware.httpunit.PostMethodWebRequest

    public void testList() throws Exception {
        JSONObject jsonRequest = new JSONObject(
        "{ \"method\": \"echoList\", \"params\": [[0,1,2,3,4]], \"id\": 8}");

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

Examples of com.meterware.httpunit.PostMethodWebRequest

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

Examples of com.meterware.httpunit.PostMethodWebRequest

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

Examples of com.meterware.httpunit.PostMethodWebRequest

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