Ignore:
Timestamp:
2023-11-06T16:17:31+01:00 (14 months ago)
Author:
taylor.smock
Message:

See #16567: Upgrade to JUnit 5

This updates plugins to use the JUnit 5 annotations

Location:
applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java

    r36065 r36193  
    2525@Main
    2626class StreetsideDataTest {
    27 
    28   /*@Rule
    29   public JOSMTestRules rules = new StreetsideTestRules().platform();*/
    3027
    3128  private StreetsideData data;
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java

    r36065 r36193  
    33
    44import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    56import static org.junit.jupiter.api.Assertions.assertNotNull;
    67import static org.junit.jupiter.api.Assertions.assertThrows;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
    8 
    9 import java.awt.GraphicsEnvironment;
    109
    1110import org.junit.jupiter.api.Test;
     
    6968  void testGetInfoComponent() {
    7069    Object comp = StreetsideLayer.getInstance().getInfoComponent();
    71     assertTrue(comp instanceof String);
     70    assertInstanceOf(String.class, comp);
    7271    assertTrue(((String) comp).length() >= 9);
    7372  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/TestUtil.java

    r36065 r36193  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertTrue;
    6 import static org.junit.jupiter.api.Assertions.fail;
    76
    8 import java.awt.GraphicsEnvironment;
    97import java.lang.reflect.Constructor;
    108import java.lang.reflect.Field;
     
    1210import java.lang.reflect.Method;
    1311import java.lang.reflect.Modifier;
    14 import java.util.logging.Level;
    1512
    16 import org.junit.runners.model.InitializationError;
    17 import org.openstreetmap.josm.testutils.JOSMTestRules;
    18 import org.openstreetmap.josm.tools.Logging;
    19 import org.openstreetmap.josm.tools.Utils;
     13import org.openstreetmap.josm.tools.JosmRuntimeException;
    2014
    2115/**
     
    3731      return result;
    3832    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
    39       fail(e.getLocalizedMessage());
     33      throw new JosmRuntimeException(e);
    4034    }
    41     return null;
    4235  }
    4336
     
    5245      return getAccessibleField(object.getClass(), name).get(object);
    5346    } catch (IllegalAccessException | SecurityException e) {
    54       fail(e.getLocalizedMessage());
     47      throw new JosmRuntimeException(e);
    5548    }
    56     return null;
    5749  }
    5850
     
    8072      }
    8173    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    82       fail(e.getLocalizedMessage());
    83     }
    84   }
    85 
    86   public static class StreetsideTestRules extends JOSMTestRules {
    87     @Override
    88     protected void before() throws InitializationError, ReflectiveOperationException {
    89       Logging.getLogger().setFilter(record -> record.getLevel().intValue() >= Level.WARNING.intValue() || record.getSourceClassName().startsWith("org.openstreetmap.josm.plugins.streetside"));
    90       Utils.updateSystemProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT.%1$tL %2$s %4$s: %5$s%6$s%n");
    91       final String isHeadless = Boolean.toString(GraphicsEnvironment.isHeadless());
    92       super.before();
    93       System.setProperty("java.awt.headless", isHeadless);
     74      throw new JosmRuntimeException(e);
    9475    }
    9576  }
Note: See TracChangeset for help on using the changeset viewer.