Changeset 16618 in josm for trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandlerTest.java
- Timestamp:
- 2020-06-14T11:54:13+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandlerTest.java
r12558 r16618 2 2 package org.openstreetmap.josm.io.remotecontrol.handler; 3 3 4 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertThrows; 7 4 8 import org.junit.Rule; 5 9 import org.junit.Test; 6 import org.junit.rules.ExpectedException;7 10 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; 8 11 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 14 17 */ 15 18 public class LoadAndZoomHandlerTest { 16 17 /**18 * Rule used for tests throwing exceptions.19 */20 @Rule21 public ExpectedException thrown = ExpectedException.none();22 23 19 /** 24 20 * Setup test. … … 41 37 @Test 42 38 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()); 46 41 } 47 42 … … 52 47 @Test 53 48 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()); 57 51 } 58 52 … … 63 57 @Test 64 58 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()); 68 61 } 69 62 … … 74 67 @Test 75 68 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()); 77 70 } 78 71 }
Note:
See TracChangeset
for help on using the changeset viewer.
