Ignore:
Timestamp:
2020-06-14T11:54:13+02:00 (6 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/LoadAndZoomHandlerTest.java

    r12558 r16618  
    22package org.openstreetmap.josm.io.remotecontrol.handler;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
     7
    48import org.junit.Rule;
    59import org.junit.Test;
    6 import org.junit.rules.ExpectedException;
    710import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
    811import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1417 */
    1518public class LoadAndZoomHandlerTest {
    16 
    17     /**
    18      * Rule used for tests throwing exceptions.
    19      */
    20     @Rule
    21     public ExpectedException thrown = ExpectedException.none();
    22 
    2319    /**
    2420     * Setup test.
     
    4137    @Test
    4238    public void testBadRequestNoParam() throws Exception {
    43         thrown.expect(RequestHandlerBadRequestException.class);
    44         thrown.expectMessage("NumberFormatException (empty String)");
    45         newHandler(null).handle();
     39        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler(null).handle());
     40        assertEquals("NumberFormatException (empty String)", e.getMessage());
    4641    }
    4742
     
    5247    @Test
    5348    public void testBadRequestInvalidUrl() throws Exception {
    54         thrown.expect(RequestHandlerBadRequestException.class);
    55         thrown.expectMessage("The following keys are mandatory, but have not been provided: bottom, top, left, right");
    56         newHandler("invalid_url").handle();
     49        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler("invalid_url").handle());
     50        assertEquals("The following keys are mandatory, but have not been provided: bottom, top, left, right", e.getMessage());
    5751    }
    5852
     
    6357    @Test
    6458    public void testBadRequestIncompleteUrl() throws Exception {
    65         thrown.expect(RequestHandlerBadRequestException.class);
    66         thrown.expectMessage("The following keys are mandatory, but have not been provided: bottom, top, left, right");
    67         newHandler("https://localhost").handle();
     59        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler("https://localhost").handle());
     60        assertEquals("The following keys are mandatory, but have not been provided: bottom, top, left, right", e.getMessage());
    6861    }
    6962
     
    7467    @Test
    7568    public void testNominalRequest() throws Exception {
    76         newHandler("https://localhost?bottom=0&top=0&left=1&right=1").handle();
     69        assertDoesNotThrow(() -> newHandler("https://localhost?bottom=0&top=0&left=1&right=1").handle());
    7770    }
    7871}
Note: See TracChangeset for help on using the changeset viewer.