Ticket #16705: v1-0002-tests-AddNodeHandlerTest-add-main-assertionsInEDT.patch

File v1-0002-tests-AddNodeHandlerTest-add-main-assertionsInEDT.patch, 2.5 KB (added by ris, 7 years ago)
  • test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java

    From d81eea4ec03d854e13f48e91a712045595c8ebdc Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Sun, 26 Aug 2018 16:03:08 +0100
    Subject: [PATCH v1 2/3] tests: AddNodeHandlerTest: add main, assertionsInEDT &
     projection to JOSMTestRules
    
    we can also omit the attempt to clean up our added layer as that will be
    handled by JOSMTestRules
    ---
     .../remotecontrol/handler/AddNodeHandlerTest.java   | 21 ++++++++-------------
     1 file changed, 8 insertions(+), 13 deletions(-)
    
    diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java
    index 1db909812..2a80c5711 100644
    a b public class AddNodeHandlerTest {  
    2828     */
    2929    @Rule
    3030    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    31     public JOSMTestRules test = new JOSMTestRules();
     31    public JOSMTestRules test = new JOSMTestRules().main().assertionsInEDT().projection();
    3232
    3333    private static AddNodeHandler newHandler(String url) throws RequestHandlerBadRequestException {
    3434        AddNodeHandler req = new AddNodeHandler();
    public class AddNodeHandlerTest {  
    5656    public void testBadRequestNoParam() throws Exception {
    5757        thrown.expect(RequestHandlerBadRequestException.class);
    5858        thrown.expectMessage("NumberFormatException (empty String)");
     59
    5960        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    60         try {
    61             MainApplication.getLayerManager().addLayer(layer);
    62             newHandler(null).handle();
    63         } finally {
    64             MainApplication.getLayerManager().removeLayer(layer);
    65         }
     61        MainApplication.getLayerManager().addLayer(layer);
     62
     63        newHandler(null).handle();
    6664    }
    6765
    6866    /**
    public class AddNodeHandlerTest {  
    9492    @Test
    9593    public void testNominalRequest() throws Exception {
    9694        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    97         try {
    98             MainApplication.getLayerManager().addLayer(layer);
    99             newHandler("https://localhost?lat=0&lon=0").handle();
    100         } finally {
    101             MainApplication.getLayerManager().removeLayer(layer);
    102         }
     95        MainApplication.getLayerManager().addLayer(layer);
     96
     97        newHandler("https://localhost?lat=0&lon=0").handle();
    10398    }
    10499}