Package com.meterware.httpunit

Examples of com.meterware.httpunit.WebConversation


    @Test
    public void testList() throws Exception {
        JSONObject jsonRequest = new JSONObject(
            "{ \"method\": \"echoList\", \"params\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [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());

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


    @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\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"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
    /**
     * 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

   
    @Test
    public void testRuntimeException() throws Exception{
      JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoRuntimeException\", \"params\": [], \"id\": 2}");
     
      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 jsonErr = new JSONObject(response.getText()).getJSONObject("error");
       
View Full Code Here

   
    @Test
    public void testBusinessException() throws Exception{
      JSONObject jsonRequest = new JSONObject("{ \"method\": \"echoBusinessException\", \"params\": [], \"id\": 3}");
     
      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 jsonErr = new JSONObject(response.getText()).getJSONObject("error");
       
View Full Code Here

    @Test
    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);

        Assert.assertEquals(200, response.getResponseCode());
       
        JSONObject jsonResp = new JSONObject(response.getText());
        Assert.assertEquals("echo: Hello JSON-RPC", jsonResp.getString("result"));
View Full Code Here

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

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

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

    JSONObject jsonResp = new JSONObject(response.getText());
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.