Changeset 14190 in josm


Ignore:
Timestamp:
2018-08-28T21:29:03+02:00 (11 months ago)
Author:
Don-vip
Message:

see #16688 - skip some unit tests if preconditions are not met

Location:
trunk/test
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java

    r12850 r14190  
    2222import java.util.logging.Logger;
    2323
     24import org.junit.Assume;
    2425import org.junit.Before;
    2526import org.junit.BeforeClass;
     
    2829import org.junit.rules.Timeout;
    2930import org.openstreetmap.josm.JOSMFixture;
     31import org.openstreetmap.josm.TestUtils;
    3032import org.openstreetmap.josm.data.coor.LatLon;
    3133import org.openstreetmap.josm.data.osm.Changeset;
     
    150152    @BeforeClass
    151153    public static void init() throws Exception {
     154        if (!TestUtils.areCredentialsProvided()) {
     155            logger.severe("OSM DEV API credentials not provided. Please define them with -Dosm.username and -Dosm.password");
     156            return;
     157        }
    152158        logger.info("initializing ...");
    153159        JOSMFixture.createFunctionalTestFixture().init();
     
    200206    @Before
    201207    public void setUp() throws IOException, IllegalDataException, FileNotFoundException {
     208        if (!TestUtils.areCredentialsProvided()) {
     209            return;
     210        }
    202211        File f = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    203212        logger.info(MessageFormat.format("reading cached dataset ''{0}''", f.toString()));
     
    214223    @Test
    215224    public void testMultiGet10Nodes() throws OsmTransferException {
     225        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    216226        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    217227        ArrayList<Node> nodes = new ArrayList<>(ds.getNodes());
     
    235245    @Test
    236246    public void testMultiGet10Ways() throws OsmTransferException {
     247        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    237248        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    238249        ArrayList<Way> ways = new ArrayList<>(ds.getWays());
     
    257268    @Test
    258269    public void testMultiGet10Relations() throws OsmTransferException {
     270        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    259271        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    260272        ArrayList<Relation> relations = new ArrayList<>(ds.getRelations());
     
    279291    @Test
    280292    public void testMultiGet800Nodes() throws OsmTransferException {
     293        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    281294        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    282295        ArrayList<Node> nodes = new ArrayList<>(ds.getNodes());
     
    300313    @Test
    301314    public void testMultiGetWithNonExistingNode() throws OsmTransferException {
     315        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    302316        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    303317        ArrayList<Node> nodes = new ArrayList<>(ds.getNodes());
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r14120 r14190  
    2222import java.util.logging.Logger;
    2323
     24import org.junit.Assume;
    2425import org.junit.Before;
    2526import org.junit.BeforeClass;
    2627import org.junit.Test;
    2728import org.openstreetmap.josm.JOSMFixture;
     29import org.openstreetmap.josm.TestUtils;
    2830import org.openstreetmap.josm.data.APIDataSet;
    2931import org.openstreetmap.josm.data.coor.LatLon;
     
    158160    @BeforeClass
    159161    public static void setUpBeforeClass() throws OsmTransferException, CyclicUploadDependencyException, IOException {
     162        if (!TestUtils.areCredentialsProvided()) {
     163            logger.severe("OSM DEV API credentials not provided. Please define them with -Dosm.username and -Dosm.password");
     164            return;
     165        }
    160166        logger.info("initializing ...");
    161167
     
    213219    @Before
    214220    public void setUp() throws IOException, IllegalDataException, FileNotFoundException {
     221        if (!TestUtils.areCredentialsProvided()) {
     222            return;
     223        }
    215224        File f = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    216225        logger.info(MessageFormat.format("reading cached dataset ''{0}''", f.toString()));
     
    227236    @Test
    228237    public void testBackreferenceForNode() throws OsmTransferException {
     238        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    229239        Node n = lookupNode(ds, 0);
    230240        assertNotNull(n);
     
    284294    @Test
    285295    public void testBackreferenceForNodeFull() throws OsmTransferException {
     296        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    286297        Node n = lookupNode(ds, 0);
    287298        assertNotNull(n);
     
    332343    @Test
    333344    public void testBackreferenceForWay() throws OsmTransferException {
     345        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    334346        Way w = lookupWay(ds, 1);
    335347        assertNotNull(w);
     
    376388    @Test
    377389    public void testBackreferenceForWayFull() throws OsmTransferException {
     390        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    378391        Way w = lookupWay(ds, 1);
    379392        assertNotNull(w);
     
    414427    @Test
    415428    public void testBackreferenceForRelation() throws OsmTransferException {
     429        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    416430        Relation r = lookupRelation(ds, 1);
    417431        assertNotNull(r);
     
    533547    @Test
    534548    public void testBackreferenceForRelationFull() throws OsmTransferException {
     549        Assume.assumeTrue(TestUtils.areCredentialsProvided());
    535550        Relation r = lookupRelation(ds, 1);
    536551        assertNotNull(r);
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r14158 r14190  
    533533        return new Reflections("org.openstreetmap.josm").getSubTypesOf(superClass);
    534534    }
     535
     536    /**
     537     * Determines if OSM DEV_API credential have been provided. Required for functional tests.
     538     * @return {@code true} if {@code osm.username} and {@code osm.password} have been defined on the command line
     539     */
     540    public static boolean areCredentialsProvided() {
     541        return Utils.getSystemProperty("osm.username") != null && Utils.getSystemProperty("osm.password") != null;
     542    }
    535543}
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java

    r14138 r14190  
    66import static org.junit.Assert.assertNotNull;
    77import static org.junit.Assert.assertTrue;
    8 import static org.junit.Assert.fail;
    98
    109import java.io.File;
    1110import java.io.IOException;
    1211
     12import org.junit.Assume;
    1313import org.junit.BeforeClass;
    1414import org.junit.Test;
     
    6363    @Test
    6464    public void testOpenUrl() throws IOException {
    65         if (!PlatformManager.isPlatformWindows()) {
    66             hook.openUrl(Config.getUrls().getJOSMWebsite());
    67         } else {
    68             try {
    69                 hook.openUrl(Config.getUrls().getJOSMWebsite());
    70                 fail("Expected IOException");
    71             } catch (IOException e) {
    72                 Logging.info(e.getMessage());
    73             }
    74         }
     65        Assume.assumeTrue(PlatformManager.isPlatformOsx());
     66        hook.openUrl(Config.getUrls().getJOSMWebsite());
    7567    }
    7668
Note: See TracChangeset for help on using the changeset viewer.