Ignore:
Timestamp:
2023-03-13T21:59:27+01:00 (13 months ago)
Author:
taylor.smock
Message:

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java

    r18437 r18690  
    240240    void testTooMuchRedirects() throws IOException {
    241241        mockRedirects(false, 3);
    242         assertThrows(IOException.class, () -> HttpClient.create(url("/relative-redirect/3")).setMaxRedirects(2).connect(progress));
     242        final HttpClient client = HttpClient.create(url("/relative-redirect/3")).setMaxRedirects(2);
     243        try {
     244            assertThrows(IOException.class, () -> client.connect(progress));
     245        } finally {
     246            client.disconnect();
     247        }
    243248    }
    244249
     
    370375    void testTakesTooLong() throws IOException {
    371376        mockDelay(1);
    372         assertThrows(IOException.class, () -> HttpClient.create(url("/delay/1")).setReadTimeout(500).connect(progress));
     377        final HttpClient client = HttpClient.create(url("/delay/1")).setReadTimeout(500);
     378        try {
     379            assertThrows(IOException.class, () -> client.connect(progress));
     380        } finally {
     381            client.disconnect();
     382        }
    373383    }
    374384
     
    387397
    388398    /**
    389      * Test of {@link Response#uncompress} method with Gzip compression.
     399     * Test of {@link Response#uncompress(boolean)} method with Gzip compression.
    390400     * @throws IOException if any I/O error occurs
    391401     */
     
    407417
    408418    /**
    409      * Test of {@link Response#uncompress} method with Bzip compression.
     419     * Test of {@link Response#uncompress(boolean)} method with Bzip compression.
    410420     * @throws IOException if any I/O error occurs
    411421     */
     
    427437
    428438    /**
    429      * Test of {@link Response#uncompress} method with Bzip compression.
     439     * Test of {@link Response#uncompress(boolean)} method with Bzip compression.
    430440     * @throws IOException if any I/O error occurs
    431441     */
Note: See TracChangeset for help on using the changeset viewer.