Changeset 16618 in josm for trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/LoadObjectHandlerTest.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/LoadObjectHandlerTest.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 LoadObjectHandlerTest { 16 17 /**18 * Rule used for tests throwing exceptions.19 */20 @Rule21 public ExpectedException thrown = ExpectedException.none();22 23 19 /** 24 20 * Setup test. … … 37 33 /** 38 34 * Unit test for bad request - no param. 39 * @throws Exception if any error occurs40 35 */ 41 36 @Test 42 public void testBadRequestNoParam() throws Exception{43 newHandler(null).handle(); 37 public void testBadRequestNoParam() { 38 assertDoesNotThrow(() -> newHandler(null).handle()); 44 39 } 45 40 46 41 /** 47 42 * Unit test for bad request - invalid URL. 48 * @throws Exception if any error occurs49 43 */ 50 44 @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()); 55 48 } 56 49 57 50 /** 58 51 * Unit test for bad request - incomplete URL. 59 * @throws Exception if any error occurs60 52 */ 61 53 @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()); 66 57 } 67 58 68 59 /** 69 60 * Unit test for nominal request - local data file. 70 * @throws Exception if any error occurs71 61 */ 72 62 @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()); 75 65 } 76 66 }
Note:
See TracChangeset
for help on using the changeset viewer.
