Examples of PostMethodWebRequest


Examples of com.meterware.httpunit.PostMethodWebRequest

        invoke("UTF-8");
        invoke("iso-8859-1");       
    }

    private void invoke(String encoding) throws Exception {       
        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/greeter",
            getClass().getResourceAsStream("GreeterMessage.xml"),
            "text/xml; charset=" + encoding);
       
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

    }

    @Test
    public void testInvokingSpringBeans() throws Exception {

        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/SOAPService",
            getClass().getResourceAsStream("GreeterMessage.xml"),
            "text/xml; charset=utf-8");

        invokingEndpoint(req);
       
        req = new PostMethodWebRequest(CONTEXT_URL + "/services/DerivedGreeterService",
            getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=utf-8");
       
        invokingEndpoint(req);
    }
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

    }

    @Test
    public void testInvokingSpringBeans() throws Exception {

        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter",
            getClass().getResourceAsStream("GreeterMessage.xml"),
            "text/xml; charset=utf-8");

        invokingEndpoint(req);
       
        req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter1",
            getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=utf-8");
       
        invokingEndpoint(req);
    }
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

    @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.PostMethodWebRequest

    }

    @Test
    public void testInvokingSpringBeans() throws Exception {

        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter",
            getClass().getResourceAsStream("GreeterMessage.xml"),
            "text/xml; charset=utf-8");

        invokingEndpoint(req);
       
        req = new PostMethodWebRequest(CONTEXT_URL + "/services/Greeter1",
            getClass().getResourceAsStream("GreeterMessage.xml"), "text/xml; charset=utf-8");
       
        invokingEndpoint(req);
    }
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

  }

  @Test
  public void testSendFile() throws Exception {
    //TODO test with url parameters (i.e. a=b); but HttpUnit is faulty so we can't
    final PostMethodWebRequest request = new PostMethodWebRequest(
            rewriteMakeMethodUrl("http://localhost/proxyMe"), true);//true: mime encoded
    InputStream data = new ByteArrayInputStream("testFileData".getBytes("UTF-8"));
    request.selectFile("fileNameParam", "fileName", data, "text/plain");
    WebResponse rsp = execAndAssert(request);
    assertTrue(rsp.getText().contains("Content-Type: multipart/form-data; boundary="));
  }
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

      queryString = url.substring(qIdx + 1);

    }
    //WARNING: Ugly! Groovy could do this better.
    if (clazz == PostMethodWebRequest.class) {
      return (M) new PostMethodWebRequest(urlNoQuery) {
        @Override
        public String getQueryString() {
          return queryString;
        }
        @Override
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

        invoke("UTF-8");
        invoke("iso-8859-1");       
    }

    private void invoke(String encoding) throws Exception {       
        WebRequest req = new PostMethodWebRequest(CONTEXT_URL + "/services/greeter",
            getClass().getResourceAsStream("GreeterMessage.xml"),
            "text/xml; charset=" + encoding);
       
        ServletUnitClient client = newClient();
        WebResponse response = client.getResponse(req);
View Full Code Here

Examples of com.meterware.httpunit.PostMethodWebRequest

    }   
 
    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.PostMethodWebRequest

    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.