Package rife.test

Class MockFileUpload

java.lang.Object
rife.test.MockFileUpload

public class MockFileUpload extends Object
An instance of this class provides all the data that is needed to simulate a file upload.
Since:
1.0
  • Constructor Details

    • MockFileUpload

      public MockFileUpload(File file)
      Creates a new file upload simulation based on a File object.

      The content type will be guessed from the file extension. The extension to mime-type mapping is retrieved from RifeConfig.Mime.

      Parameters:
      file - the file that will be uploaded
      Since:
      1.0
    • MockFileUpload

      public MockFileUpload(File file, String contentType)
      Creates a new file upload simulation based on a File object.
      Parameters:
      file - the file that will be uploaded
      contentType - the content type of the file
      Since:
      1.0
    • MockFileUpload

      public MockFileUpload(String fileName, InputStream inputStream, String contentType)
      Creates a new file upload simulation based on an InputStream.
      Parameters:
      fileName - the name of file that will be uploaded
      inputStream - the input stream that will be read to provide the content of the uploaded file
      contentType - the content type of the uploaded file
      Since:
      1.0
  • Method Details

    • getContentType

      public String getContentType()
      Returns the content type associated with this file upload simulation.

      If no content type has been provided, and it could not be detected automatically, then it defaults to text/plain.

      Returns:
      the content type
      Since:
      1.0