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/LoadObjectHandlerTest.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 LoadObjectHandlerTest {
    16 
    17     /**
    18      * Rule used for tests throwing exceptions.
    19      */
    20     @Rule
    21     public ExpectedException thrown = ExpectedException.none();
    22 
    2319    /**
    2420     * Setup test.
     
    3733    /**
    3834     * Unit test for bad request - no param.
    39      * @throws Exception if any error occurs
    4035     */
    4136    @Test
    42     public void testBadRequestNoParam() throws Exception {
    43         newHandler(null).handle();
     37    public void testBadRequestNoParam() {
     38        assertDoesNotThrow(() -> newHandler(null).handle());
    4439    }
    4540
    4641    /**
    4742     * Unit test for bad request - invalid URL.
    48      * @throws Exception if any error occurs
    4943     */
    5044    @Test
    51     public void testBadRequestInvalidUrl() throws Exception {
    52         thrown.expect(RequestHandlerBadRequestException.class);
    53         thrown.expectMessage("The following keys are mandatory, but have not been provided: objects");
    54         newHandler("invalid_url").handle();
     45    public void testBadRequestInvalidUrl() {
     46        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler("invalid_url").handle());
     47        assertEquals("The following keys are mandatory, but have not been provided: objects", e.getMessage());
    5548    }
    5649
    5750    /**
    5851     * Unit test for bad request - incomplete URL.
    59      * @throws Exception if any error occurs
    6052     */
    6153    @Test
    62     public void testBadRequestIncompleteUrl() throws Exception {
    63         thrown.expect(RequestHandlerBadRequestException.class);
    64         thrown.expectMessage("The following keys are mandatory, but have not been provided: objects");
    65         newHandler("https://localhost").handle();
     54    public void testBadRequestIncompleteUrl() {
     55        Exception e = assertThrows(RequestHandlerBadRequestException.class, () -> newHandler("https://localhost").handle());
     56        assertEquals("The following keys are mandatory, but have not been provided: objects", e.getMessage());
    6657    }
    6758
    6859    /**
    6960     * Unit test for nominal request - local data file.
    70      * @throws Exception if any error occurs
    7161     */
    7262    @Test
    73     public void testNominalRequest() throws Exception {
    74         newHandler("https://localhost?objects=foo,bar").handle();
     63    public void testNominalRequest() {
     64        assertDoesNotThrow(() -> newHandler("https://localhost?objects=foo,bar").handle());
    7565    }
    7666}
Note: See TracChangeset for help on using the changeset viewer.