Changeset 16618 in josm for trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandlerTest.java
- Timestamp:
- 2020-06-14T11:54:13+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandlerTest.java
r16589 r16618 3 3 4 4 import static org.hamcrest.CoreMatchers.hasItem; 5 import static org.hamcrest.MatcherAssert.assertThat; 5 6 import static org.junit.Assert.assertEquals; 6 import static org.junit.Assert.assertThat; 7 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; 8 import static org.junit.jupiter.api.Assertions.assertThrows; 7 9 8 10 import java.util.Arrays; … … 11 13 import org.junit.Rule; 12 14 import org.junit.Test; 13 import org.junit.rules.ExpectedException;14 15 import org.openstreetmap.josm.data.imagery.ImageryInfo; 15 16 import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException; … … 22 23 */ 23 24 public class ImageryHandlerTest { 24 25 /**26 * Rule used for tests throwing exceptions.27 */28 @Rule29 public ExpectedException thrown = ExpectedException.none();30 31 25 /** 32 26 * Setup test. … … 45 39 /** 46 40 * Unit test for bad request - no param. 47 * @throws Exception if any error occurs48 41 */ 49 42 @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 54 47 } 55 48 56 49 /** 57 50 * Unit test for bad request - invalid URL. 58 * @throws Exception if any error occurs59 51 */ 60 52 @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()); 65 56 } 66 57 67 58 /** 68 59 * Unit test for bad request - incomplete URL. 69 * @throws Exception if any error occurs70 60 */ 71 61 @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()); 76 65 } 77 66 78 67 /** 79 68 * Unit test for nominal request - local data file. 80 * @throws Exception if any error occurs81 69 */ 82 70 @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()); 85 73 } 86 74
Note:
See TracChangeset
for help on using the changeset viewer.