Ignore:
Timestamp:
2020-06-14T11:54:13+02:00 (4 years ago)
Author:
simon04
Message:

see #16567 - Fix deprecations related to JUnit 5 (patch by taylor.smock)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandlerTest.java

    r16589 r16618  
    33
    44import static org.hamcrest.CoreMatchers.hasItem;
     5import static org.hamcrest.MatcherAssert.assertThat;
    56import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertThat;
     7import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
    79
    810import java.util.Arrays;
     
    1113import org.junit.Rule;
    1214import org.junit.Test;
    13 import org.junit.rules.ExpectedException;
    1415import org.openstreetmap.josm.data.imagery.ImageryInfo;
    1516import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
     
    2223 */
    2324public class ImageryHandlerTest {
    24 
    25     /**
    26      * Rule used for tests throwing exceptions.
    27      */
    28     @Rule
    29     public ExpectedException thrown = ExpectedException.none();
    30 
    3125    /**
    3226     * Setup test.
     
    4539    /**
    4640     * Unit test for bad request - no param.
    47      * @throws Exception if any error occurs
    4841     */
    4942    @Test
    50     public void testBadRequestNoParam() throws Exception {
    51         thrown.expect(RequestHandlerBadRequestException.class);
    52         thrown.expectMessage("Parameter must not be null");
    53         newHandler(null).handle();
     43    public void testBadRequestNoParam() {
     44        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler(null).handle());
     45        assertEquals("Parameter must not be null", e.getMessage());
     46
    5447    }
    5548
    5649    /**
    5750     * Unit test for bad request - invalid URL.
    58      * @throws Exception if any error occurs
    5951     */
    6052    @Test
    61     public void testBadRequestInvalidUrl() throws Exception {
    62         thrown.expect(RequestHandlerBadRequestException.class);
    63         thrown.expectMessage("The following keys are mandatory, but have not been provided: url");
    64         newHandler("invalid_url").handle();
     53    public void testBadRequestInvalidUrl() {
     54        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler("invalid_url").handle());
     55        assertEquals("The following keys are mandatory, but have not been provided: url", e.getMessage());
    6556    }
    6657
    6758    /**
    6859     * Unit test for bad request - incomplete URL.
    69      * @throws Exception if any error occurs
    7060     */
    7161    @Test
    72     public void testBadRequestIncompleteUrl() throws Exception {
    73         thrown.expect(RequestHandlerBadRequestException.class);
    74         thrown.expectMessage("The following keys are mandatory, but have not been provided: url");
    75         newHandler("https://localhost").handle();
     62    public void testBadRequestIncompleteUrl() {
     63        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler("https://localhost").handle());
     64        assertEquals("The following keys are mandatory, but have not been provided: url", e.getMessage());
    7665    }
    7766
    7867    /**
    7968     * Unit test for nominal request - local data file.
    80      * @throws Exception if any error occurs
    8169     */
    8270    @Test
    83     public void testNominalRequest() throws Exception {
    84         newHandler("https://localhost?url=foo").handle();
     71    public void testNominalRequest() {
     72        assertDoesNotThrow(() -> newHandler("https://localhost?url=foo").handle());
    8573    }
    8674
Note: See TracChangeset for help on using the changeset viewer.