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

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


    assertTrue(file.exists());

    //
    // 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 201 (Created)
View Full Code Here


    assertTrue(file.exists());

    //
    // 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 201 (Created)
View Full Code Here

    assertTrue(file.exists());

    //
    // 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 a 400
View Full Code Here

      assertTrue(uploadFile.exists());

      //
      // 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

    // Upload widget we'll test deleting next
    //
    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);
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

    assertTrue(file.exists());

    //
    // 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

    assertTrue(file.exists());

    //
    // 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

    assertTrue(file.exists());

    //
    // 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

      assertTrue(file.exists());

      //
      // 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

TOP

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

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.