FILEUPLOAD-302: JUnit Jupiter migration (#23)

* FILEUPLOAD-302 Remove junit.framework.TestCase dependency

junit.framework.TestCase was introduced in JUnit 3, and while it
isn't technically deprecated, it's outdated, and should not be used
in JUnit 4.

This patch removes its usage in the project, and replaces it with
static imports from org.junit.Assert, as per JUnit 4's best
practices.

In addition, `@Test` annotations were added to the test methods, so
they are recognized as tests by JUnit 4.

* FILEUPLOAD-302 JUnit Jupiter migration

This patch upgrades the project's testing framework from JUnit 4.12
to the modern JUnit Jupiter 5.5.2.

Since JUnit 5 Jupiter is not backwards compatible to JUnit 4.x (or
even JUnit Vintage), this patch is a bit large, even though a lot of
the changes are merely cosmetic (such as changing the argument order,
see details below). In order to make the reviewer's task as easy as
possible, this PR does not presume to use JUnit Jupiter's best
practices and all its new functionality, but only to migrate the
existing tests with as little change as possible. Following patches
may want to improve the tests by using some of JUnit Jupiter's new
features.

This patch includes the following changes:

1. Maven dependency changes:
 a. junit:junit was replaced with org.junit.jupiter:junit-jupiter.

2. Annotations:
 a. org.junit.jupiter.api.Test was used as a drop in replacement for
    org.juit.Test without arguments. See 3.ii. for handling of @Test
    annotations with an "expected" argument.
 b. org.junit.jupiter.api.BeforeEach was used as an drop in
    replacement for org.junit.Before.
 c. org.junit.jupiter.api.AfterEach was used as an drop in
    replacement for org.junit.After.

3. Assertions:
 a. org.junit.jupiter.api.Assertions' methods were used as drop in
    replacements for org.junit.Assert's methods with the same name in
    the simple case of an assertion without a message. In the case of
    an assertion with a message, org.junit.jupiter.api.Assertions'
    methods were used, but the argument order was changed - Assert's
    methods take the message as the first argument, while Assertions'
    methods take the message as the last argument.
 b. org.junit.jupiter.api.Assertions#assertThrows was used to assert
    that a specific exception was throws instead of an org.junit.Test
    annotation with an expected argument. As a side bonus, this
    change makes the tests slightly stricter, as now they can assert
    the exception was thrown from a specific line and prevent false
    positives where the test's "set-up" code accidentally threw that
    exception.

4. Parameterized tests:
 a. FileUploadTest was rewritten with @ParameterizedTests and
    @MethodSource in order to gain an equivalent functionality of
    JUnit 4's Parameterized runner.
16 files changed
tree: 5ed7c51e2f7bd42542b62b149efa88cd50cbf790
  1. src/
  2. .gitignore
  3. .travis.yml
  4. CONTRIBUTING.md
  5. LICENSE.txt
  6. NOTICE.txt
  7. pom.xml
  8. README.md
  9. RELEASE-NOTES.txt
README.md

Apache Commons FileUpload

Build Status Maven Central

The Apache Commons FileUpload component provides a simple yet flexible means of adding support for multipart file upload functionality to servlets and web applications.

Documentation

More information can be found on the Apache Commons FileUpload homepage. The Javadoc can be browsed. Questions related to the usage of Apache Commons FileUpload should be posted to the user mailing list.

Where can I get the latest release?

You can download source and binaries from our download page.

Alternatively you can pull it from the central Maven repositories:

<dependency>
  <groupId>commons-fileupload</groupId>
  <artifactId>commons-fileupload</artifactId>
  <version>1.4</version>
</dependency>

Contributing

We accept Pull Requests via GitHub. The developer mailing list is the main channel of communication for contributors. There are some guidelines which will make applying PRs easier for us:

  • No tabs! Please use spaces for indentation.
  • Respect the code style.
  • Create minimal diffs - disable on save actions like reformat source code or organize imports. If you feel the source code should be reformatted create a separate PR for this change.
  • Provide JUnit tests for your changes and make sure your changes don't break any existing tests by running mvn clean test.

If you plan to contribute on a regular basis, please consider filing a contributor license agreement. You can learn more about contributing via GitHub in our contribution guidelines.

License

This code is under the Apache Licence v2.

See the NOTICE.txt file for required notices and attributions.

Donations

You like Apache Commons FileUpload? Then donate back to the ASF to support the development.

Additional Resources