Package org.apache.commons.httpclient.methods.multipart

Examples of org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity


      //
      // Add test wgt file to POST
      //
      Part[] parts = { new FilePart(uploadFile.getName(), uploadFile) };
      post.setRequestEntity(new MultipartRequestEntity(parts, post
          .getParams()));

      //
      // POST the file to /widgets and check we get 201 (Created)
      //
      client.executeMethod(post);  
      int code = post.getStatusCode();
      assertEquals(201,code);
      post.releaseConnection();     
     
      //
      // Now, upload a new widget, with the same filename
      // We'll use the WARP widget
      //
      uploadFile = new File("src-tests/testdata/upload-policies-test.wgt");
      assertTrue(uploadFile.exists());
      File tempFolder = createTempDirectory();
      File newFile  = new File(tempFolder+File.separator+"upload-test.wgt");
      FileUtils.copyFile(uploadFile, newFile)
      assertTrue(newFile.exists());
     
      System.out.println(newFile.getPath());
     
      //
      // Add test wgt file to POST
      //
      post = new PostMethod(TEST_WIDGETS_SERVICE_URL_VALID);
      Part[] newParts = { new FilePart(newFile.getName(), newFile) };
      post.setRequestEntity(new MultipartRequestEntity(newParts, post
          .getParams()));

      //
      // POST the file to /widgets and check we get 201 (Created)
      //
View Full Code Here


    //
    File file = new File("src-tests/testdata/delete-test.wgt");
    assertTrue(file.exists());
    PostMethod post = new PostMethod(TEST_WIDGETS_SERVICE_URL_VALID);
    Part[] parts = { new FilePart(file.getName(), file) };
    post.setRequestEntity(new MultipartRequestEntity(parts, post
        .getParams()));
    client.executeMethod(post);  
    int code = post.getStatusCode();
    assertEquals(201,code);
    post.releaseConnection();  
View Full Code Here

    //
    // Add test wgt file to POST
    //
    PostMethod post = new PostMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_UPLOAD_TEST));
    Part[] parts = { new FilePart(file.getName(), file) };
    post.setRequestEntity(new MultipartRequestEntity(parts, post
        .getParams()));

    //
    // POST the file to /widgets and check we get 201 (Created)
    //
    client.executeMethod(post);  
    int code = post.getStatusCode();
    assertEquals(201,code);
    post.releaseConnection()
   
    //
    // Now lets try updating
    //
    post = new PostMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + WIDGET_ID_UPLOAD_TEST));

    //
    // Use upload test widget
    //
    file = new File("src-tests/testdata/upload-test.wgt");
    assertTrue(file.exists());

    //
    // Add test wgt file to POST
    //
    Part[] newParts = { new FilePart(file.getName(), file) };
    post.setRequestEntity(new MultipartRequestEntity(newParts, post
        .getParams()));

    //
    // POST the file to /widgets and check we get 200 (Updated)
    //
View Full Code Here

    //
    // Add test wgt file to PUT
    //
    Part[] parts = { new FilePart(file.getName(), file) };
    put.setRequestEntity(new MultipartRequestEntity(parts, put
        .getParams()));

    //
    // PUT the file to /widgets and check we get 200 (Updated)
    //
View Full Code Here

    //
    // Add test wgt file to POST
    //
    Part[] parts = { new FilePart(file.getName(), file) };
    post.setRequestEntity(new MultipartRequestEntity(parts, post
        .getParams()));

    //
    // POST the file to /widgets and check we get 200 (Updated)
    //
View Full Code Here

    //
    // Add test wgt file to POST
    //
    Part[] parts = { new FilePart(file.getName(), file) };
    post.setRequestEntity(new MultipartRequestEntity(parts, post
        .getParams()));

    //
    // POST the file to /widgets and check we get 200 (Updated)
    //
View Full Code Here

      //
      // Add test wgt file to POST
      //
      Part[] parts = { new FilePart(file.getName(), file) };
      post.setRequestEntity(new MultipartRequestEntity(parts, post
          .getParams()));

      //
      // POST the file to /widgets
      //
View Full Code Here

      //
      // Add test wgt file to POST
      //
      Part[] parts = { new FilePart(file.getName(), file) };
      post.setRequestEntity(new MultipartRequestEntity(parts, post
          .getParams()));

      //
      // POST the file to /widgets
      //
      client.executeMethod(post);  
      SAXBuilder builder = new SAXBuilder();
      Document doc = builder.build(post.getResponseBodyAsStream());
      String id = doc.getRootElement().getAttributeValue("id");
      post.releaseConnection();
     
      //
      // Now we'll update it
      //
      PutMethod put = new PutMethod(TEST_WIDGETS_SERVICE_URL_VALID + encodeString("/" + id));

      //
      // Add test wgt file to PUT
      //
      Part[] updateparts = { new FilePart(file.getName(), file) };
      put.setRequestEntity(new MultipartRequestEntity(updateparts, put
          .getParams()));

      //
      // PUT the file to /widgets and check we get 200 (Updated)
      //
View Full Code Here

         
          //
          // Add test binary file to POST
          //
          Part[] parts = { new FilePart(file.getName(), file) };
          post.setRequestEntity(new MultipartRequestEntity(parts, post
              .getParams()));

          client.executeMethod(post);  
          int code = post.getStatusCode();
          // should be 400 - bad wgt package
View Full Code Here

         
          //
          // Add test binary file to POST
          //
          Part[] parts = { new FilePart(file.getName(), file) };
          post.setRequestEntity(new MultipartRequestEntity(parts, post
              .getParams()));

          client.executeMethod(post);  
          int code = post.getStatusCode();
          // should be 400 - bad wgt package
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.multipart.MultipartRequestEntity

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.