Ignore:
Timestamp:
2014-05-09T04:49:54+02:00 (7 years ago)
Author:
Don-vip
Message:

fixes for unit tests

File:
1 edited

Legend:

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

    r7040 r7081  
    1212import java.io.FileOutputStream;
    1313import java.io.IOException;
    14 import java.io.InputStream;
    1514import java.io.OutputStreamWriter;
    1615import java.io.PrintWriter;
     
    1817import java.util.ArrayList;
    1918import java.util.Properties;
    20 import java.util.logging.Level;
    2119import java.util.logging.Logger;
    2220
     
    2422import org.junit.BeforeClass;
    2523import org.junit.Test;
     24import org.openstreetmap.josm.JOSMFixture;
    2625import org.openstreetmap.josm.Main;
    2726import org.openstreetmap.josm.data.coor.LatLon;
     
    3332import org.openstreetmap.josm.data.osm.RelationMember;
    3433import org.openstreetmap.josm.data.osm.Way;
    35 import org.openstreetmap.josm.data.projection.Projections;
    3634import org.openstreetmap.josm.gui.io.UploadStrategy;
    3735import org.openstreetmap.josm.gui.io.UploadStrategySpecification;
     
    136134    public static void init() throws OsmTransferException {
    137135        logger.info("initializing ...");
    138         testProperties = new Properties();
    139 
    140         // load properties
    141         //
    142         try (InputStream is = MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties")) {
    143             if (is == null) {
    144                 throw new IOException();
    145             }
    146             testProperties.load(is);
    147         } catch(IOException e){
    148             logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
    149             fail(MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
    150         }
    151 
    152         // check josm.home
    153         //
    154         String josmHome = testProperties.getProperty("josm.home");
    155         if (josmHome == null) {
    156             fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    157         } else {
    158             File f = new File(josmHome);
    159             if (! f.exists() || ! f.canRead()) {
    160                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
    161             }
    162         }
    163 
    164         // check temp output dir
    165         //
    166         String tempOutputDir = testProperties.getProperty("test.functional.tempdir");
    167         if (tempOutputDir == null) {
    168             fail(MessageFormat.format("property ''{0}'' not set in test environment", "test.functional.tempdir"));
    169         } else {
    170             File f = new File(tempOutputDir);
    171             if (! f.exists() || ! f.isDirectory() || ! f.canWrite()) {
    172                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing, not a directory, or not writeable", "test.functional.tempdir", tempOutputDir));
    173             }
    174         }
    175 
    176 
    177         // init preferences
    178         //
    179         System.setProperty("josm.home", josmHome);
    180         Main.pref.init(false);
     136        JOSMFixture.createFunctionalTestFixture().init();
     137
    181138        // don't use atomic upload, the test API server can't cope with large diff uploads
    182139        //
    183140        Main.pref.put("osm-server.atomic-upload", false);
    184         Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    185 
    186         File dataSetCacheOutputFile = new File(tempOutputDir, MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
     141
     142        File dataSetCacheOutputFile = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    187143
    188144        // make sure we don't upload to production
Note: See TracChangeset for help on using the changeset viewer.