Examples of PutMethod


Examples of org.apache.commons.httpclient.methods.PutMethod

      GetMethod get = createGetMethod("/array");
      int status = client.executeMethod(get);
      Assert.assertEquals(200, status);
      String str = get.getResponseBodyAsString();
      System.out.println(str);
      PutMethod put = createPutMethod("/array");
      put.setRequestEntity(new StringRequestEntity(str, "application/xml", null));
      status = client.executeMethod(put);
      Assert.assertEquals(204, status);

   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

      GetMethod get = createGetMethod("/list");
      int status = client.executeMethod(get);
      Assert.assertEquals(200, status);
      String str = get.getResponseBodyAsString();
      System.out.println(str);
      PutMethod put = createPutMethod("/list");
      put.setRequestEntity(new StringRequestEntity(str, "application/xml", null));
      status = client.executeMethod(put);
      Assert.assertEquals(204, status);

   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

      GetMethod get = createGetMethod("/namespaced/array");
      int status = client.executeMethod(get);
      Assert.assertEquals(200, status);
      String str = get.getResponseBodyAsString();
      System.out.println(str);
      PutMethod put = createPutMethod("/namespaced/array");
      put.setRequestEntity(new StringRequestEntity(str, "application/xml", null));
      status = client.executeMethod(put);
      Assert.assertEquals(204, status);

   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

      GetMethod get = createGetMethod("/namespaced/list");
      int status = client.executeMethod(get);
      Assert.assertEquals(200, status);
      String str = get.getResponseBodyAsString();
      System.out.println(str);
      PutMethod put = createPutMethod("/namespaced/list");
      put.setRequestEntity(new StringRequestEntity(str, "application/xml", null));
      status = client.executeMethod(put);
      Assert.assertEquals(204, status);

   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

      int status = client.executeMethod(get);
      junit.framework.Assert.assertEquals(200, status);
      String str = get.getResponseBodyAsString();
      System.out.println(str);

      PutMethod put = createPutMethod("/intf");
      put.setRequestEntity(new StringRequestEntity(str, "application/json", null));
      status = client.executeMethod(put);
      junit.framework.Assert.assertEquals(204, status);
   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

   public void testOneway() throws Exception
   {
      HttpClient client = new HttpClient();
      {
         latch = new CountDownLatch(1);
         PutMethod method = createPutMethod("?oneway=true");
         method.setRequestEntity(new StringRequestEntity("content", "text/plain", null));
         long start = System.currentTimeMillis();
         int status = client.executeMethod(method);
         long end = System.currentTimeMillis() - start;
         Assert.assertEquals(HttpServletResponse.SC_ACCEPTED, status);
         Assert.assertTrue(end < 1000);
         Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));

         method.releaseConnection();
      }
      client.getHttpConnectionManager().closeIdleConnections(0);
   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

        // 2) Add attachment to the page on XWiki 1
        switchXWiki(1);
        String attachmentUri = getUriBuilder(AttachmentResource.class).build(getWiki(), "Test",
            "AttachementCacheSync", "file.ext").toString();
        PutMethod putMethod = executePut(attachmentUri, "content", MediaType.TEXT_PLAIN, "Admin", "admin");
        Assert.assertEquals(getHttpMethodInfo(putMethod), HttpStatus.SC_CREATED, putMethod.getStatusCode());

        // ASSERT) The content in XWiki 0 should be the one set than in XWiki 1
        // Since it can take time for the Cluster to propagate the change, we need to wait and set up a timeout.
        switchXWiki(0);
        String attachmentsUri = getUriBuilder(AttachmentsResource.class).build(getWiki(), "Test",
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("basic", method.getResponseBodyAsString());
         method.releaseConnection();
      }
      {
         PutMethod method = new PutMethod("http://localhost:8080/test-war/basic");
         method.setRequestEntity(new StringRequestEntity("basic", "text/plain", null));
         int status = client.executeMethod(method);
         Assert.assertEquals(204, status);
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/test-war/queryParam");
         NameValuePair[] params = {new NameValuePair("param", "hello world")};
         method.setQueryString(params);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("hello world", method.getResponseBodyAsString());
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/test-war/uriParam/1234");
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("1234", method.getResponseBodyAsString());
         method.releaseConnection();
      }
   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("basic", method.getResponseBodyAsString());
         method.releaseConnection();
      }
      {
         PutMethod method = new PutMethod("http://localhost:8080/test-war/locating/basic");
         method.setRequestEntity(new StringRequestEntity("basic", "text/plain", null));
         int status = client.executeMethod(method);
         Assert.assertEquals(204, status);
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/test-war/locating/queryParam");
         NameValuePair[] params = {new NameValuePair("param", "hello world")};
         method.setQueryString(params);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("hello world", method.getResponseBodyAsString());
         method.releaseConnection();
      }
      {
         GetMethod method = new GetMethod("http://localhost:8080/test-war/locating/uriParam/1234");
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
         Assert.assertEquals("1234", method.getResponseBodyAsString());
         method.releaseConnection();
      }
   }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.PutMethod

      partsList.add(new StringPart("part1", "This is Value 1"));
      partsList.add(new StringPart("part2", "This is Value 2"));
      partsList.add(new FilePart("data.txt", LocateTestData
              .getTestData("data.txt")));
      Part[] parts = partsList.toArray(new Part[partsList.size()]);
      PutMethod method = new PutMethod(TEST_URI);
      RequestEntity entity = new MultipartRequestEntity(parts, method
              .getParams());
      method.setRequestEntity(entity);
      int status = client.executeMethod(method);
      Assert.assertEquals(200, status);
      String responseBody = method.getResponseBodyAsString();
      Assert.assertEquals(responseBody, "Count: 3");
      method.releaseConnection();
   }
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.