com.vaadin.flow.component.upload.

Class UploadTester<T extends Upload>

java.lang.Object
com.vaadin.testbench.unit.ComponentTester<T>
com.vaadin.flow.component.upload.UploadTester<T>

Type Parameters:

T - the component type.

public class UploadTester<T extends Upload> extends ComponentTester<T>

Tester for Upload components.

  • Constructor Details

    • UploadTester

      public UploadTester(T component)

      Wrap given component for testing.

      Parameters:

      component - target component

  • Method Details

    • upload

      public void upload(String fileName, String contentType, InputStream contents)

      Send the file data to the Upload component as if it is uploaded in the browser.

      Parameters:

      fileName - name of the file to upload

      contentType - content type of the file to upload

      contents - file contents as an array of bytes

      Throws:

      UncheckedIOException - if the upload component fails to handle file contents

    • upload

      public void upload(String fileName, String contentType, byte[] contents)

      Send the file data to the Upload component as if it is uploaded in the browser.

      Parameters:

      fileName - name of the file to upload

      contentType - content type of the file to upload

      contents - file contents as an array of bytes

      Throws:

      UncheckedIOException - if the upload component fails to handle file contents

    • upload

      public void upload(File file)

      Send the file data to the Upload component as if it is uploaded in the browser. The content type is detected from file name.

      Parameters:

      file - the file to upload

      Throws:

      UncheckedIOException - if the upload component fails to handle file contents

    • uploadAll

      public void uploadAll(File... files)

      Simulates uploading multiple files at once.

      Parameters:

      files - files to upload

    • uploadAll

      public void uploadAll(Collection<File> files)

      Simulates uploading multiple files at once.

      Parameters:

      files - files to upload

    • uploadAborted

      public void uploadAborted(String fileName, String contentType)

      Simulates upload interruption by user on browser.

      Parameters:

      fileName - name of uploading file

      contentType - content type of the uploading file

    • uploadAborted

      public void uploadAborted(File file)

      Simulates upload interruption by user on browser.

      Parameters:

      file - uploading file

    • uploadFailed

      public void uploadFailed(File file)

      Simulates a failure during file upload.

      Parameters:

      file - uploading file

    • uploadFailed

      public void uploadFailed(String fileName, String contentType)

      Simulates a failure during file upload.

      Parameters:

      fileName - name of uploading file

      contentType - content type of the uploading file