Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.PostMethod.addParameter()


   public void testFormResource() throws Exception
   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(TEST_URI);
      method.addRequestHeader("custom-header", "42");
      method.addParameter(BOOLEAN_VALUE_FIELD, "true");
      method.addParameter(NAME_FIELD, "This is My Name");
      method.addParameter(DOUBLE_VALUE_FIELD, "123.45");
      method.addParameter(LONG_VALUE_FIELD, "566780");
      method.addParameter(INTEGER_VALUE_FIELD, "3");
      method.addParameter(SHORT_VALUE_FIELD, "12345");
View Full Code Here


   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(TEST_URI);
      method.addRequestHeader("custom-header", "42");
      method.addParameter(BOOLEAN_VALUE_FIELD, "true");
      method.addParameter(NAME_FIELD, "This is My Name");
      method.addParameter(DOUBLE_VALUE_FIELD, "123.45");
      method.addParameter(LONG_VALUE_FIELD, "566780");
      method.addParameter(INTEGER_VALUE_FIELD, "3");
      method.addParameter(SHORT_VALUE_FIELD, "12345");
      int status = client.executeMethod(method);
View Full Code Here

      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(TEST_URI);
      method.addRequestHeader("custom-header", "42");
      method.addParameter(BOOLEAN_VALUE_FIELD, "true");
      method.addParameter(NAME_FIELD, "This is My Name");
      method.addParameter(DOUBLE_VALUE_FIELD, "123.45");
      method.addParameter(LONG_VALUE_FIELD, "566780");
      method.addParameter(INTEGER_VALUE_FIELD, "3");
      method.addParameter(SHORT_VALUE_FIELD, "12345");
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpServletResponse.SC_OK, status);
View Full Code Here

      PostMethod method = new PostMethod(TEST_URI);
      method.addRequestHeader("custom-header", "42");
      method.addParameter(BOOLEAN_VALUE_FIELD, "true");
      method.addParameter(NAME_FIELD, "This is My Name");
      method.addParameter(DOUBLE_VALUE_FIELD, "123.45");
      method.addParameter(LONG_VALUE_FIELD, "566780");
      method.addParameter(INTEGER_VALUE_FIELD, "3");
      method.addParameter(SHORT_VALUE_FIELD, "12345");
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpServletResponse.SC_OK, status);
      InputStream response = method.getResponseBodyAsStream();
View Full Code Here

      method.addRequestHeader("custom-header", "42");
      method.addParameter(BOOLEAN_VALUE_FIELD, "true");
      method.addParameter(NAME_FIELD, "This is My Name");
      method.addParameter(DOUBLE_VALUE_FIELD, "123.45");
      method.addParameter(LONG_VALUE_FIELD, "566780");
      method.addParameter(INTEGER_VALUE_FIELD, "3");
      method.addParameter(SHORT_VALUE_FIELD, "12345");
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpServletResponse.SC_OK, status);
      InputStream response = method.getResponseBodyAsStream();
      BufferedInputStream in = new BufferedInputStream(response);
View Full Code Here

      method.addParameter(BOOLEAN_VALUE_FIELD, "true");
      method.addParameter(NAME_FIELD, "This is My Name");
      method.addParameter(DOUBLE_VALUE_FIELD, "123.45");
      method.addParameter(LONG_VALUE_FIELD, "566780");
      method.addParameter(INTEGER_VALUE_FIELD, "3");
      method.addParameter(SHORT_VALUE_FIELD, "12345");
      int status = client.executeMethod(method);
      Assert.assertEquals(HttpServletResponse.SC_OK, status);
      InputStream response = method.getResponseBodyAsStream();
      BufferedInputStream in = new BufferedInputStream(response);
      String contentType = method.getResponseHeader("content-type").getValue();
View Full Code Here

  public void testApacheClient() throws Exception {

    org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
   
    PostMethod postMethod = new PostMethod(url);
    postMethod.addParameter(new org.apache.commons.httpclient.NameValuePair("file", new String(HttpUtils.encodeBase64(data), "US-ASCII")));

    httpClient.executeMethod(postMethod);
     
      Assert.assertEquals(200, postMethod.getStatusCode());
      Assert.assertTrue(QAUtil.isEquals(file, postMethod.getResponseBody()));
View Full Code Here

                                                                             userNameAndPassword[1]));
        }

        if (parameters != null) {
            for (Map.Entry<String, String> e : parameters.entrySet()) {
                method.addParameter(e.getKey(), e.getValue());
            }
        }
        client.executeMethod(method);
        return method;
    }
View Full Code Here

  public void testApacheClient() throws Exception {

    org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
   
    PostMethod postMethod = new PostMethod(url);
    postMethod.addParameter(new org.apache.commons.httpclient.NameValuePair("file", new String(HttpUtils.encodeBase64(data), "US-ASCII")));

    httpClient.executeMethod(postMethod);
     
      Assert.assertEquals(200, postMethod.getStatusCode());
      Assert.assertTrue(QAUtil.isEquals(file, postMethod.getResponseBody()));
View Full Code Here

          HttpClient client = new HttpClient();
          PostMethod method = new PostMethod(MessagingServiceCallbackRegistrationURL);
          Base64 base64 = new Base64();
          String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
          method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
          method.addParameter("consumer_id", consumerKey);
          method.addParameter("callback_uri", callback);
          int status = client.executeMethod(method);
          if (HttpResponseCodes.SC_OK != status) {
              throw new RuntimeException("Callback Registration failed");
          }
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.