Ignore:
Timestamp:
2014-05-06T01:24:41+02:00 (11 years ago)
Author:
Don-vip
Message:

test cleanup

Location:
trunk/test/functional/org/openstreetmap/josm
Files:
1 deleted
1 edited

Legend:

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

    r7040 r7068  
    1010import java.io.FileOutputStream;
    1111import java.io.IOException;
    12 import java.io.InputStream;
    1312import java.io.OutputStreamWriter;
    1413import java.io.PrintWriter;
     
    1615import java.util.ArrayList;
    1716import java.util.HashSet;
    18 import java.util.Properties;
    1917import java.util.Set;
    20 import java.util.logging.Level;
    2118import java.util.logging.Logger;
    2219
     
    2421import org.junit.BeforeClass;
    2522import org.junit.Test;
     23import org.openstreetmap.josm.JOSMFixture;
    2624import org.openstreetmap.josm.Main;
    2725import org.openstreetmap.josm.data.coor.LatLon;
     
    4038import org.openstreetmap.josm.tools.Utils;
    4139
     40/**
     41 * Reads primitives referring to a particular primitive (ways including a node, relations referring to a relation)
     42 * @since 1806
     43 */
    4244public class OsmServerBackreferenceReaderTest {
    4345    static private final Logger logger = Logger.getLogger(OsmServerBackreferenceReader.class.getName());
     
    4749            if (("node-" + i).equals(n.get("name"))) return n;
    4850        }
     51        fail("Cannot find node "+i);
    4952        return null;
    5053    }
    51 
    5254
    5355    protected static Way lookupWay(DataSet ds, int i) {
     
    5557            if (("way-" + i).equals(w.get("name"))) return w;
    5658        }
     59        fail("Cannot find way "+i);
    5760        return null;
    5861    }
     
    6265            if (("relation-" + i).equals(r.get("name"))) return r;
    6366        }
     67        fail("Cannot find relation "+i);
    6468        return null;
    6569    }
     
    107111        }
    108112    }
    109 
    110113
    111114    protected static DataSet buildTestDataSet() {
     
    137140    }
    138141
    139     static Properties testProperties;
    140142    static DataSet testDataSet;
    141143
    142144    @BeforeClass
    143     public static void  init() throws OsmTransferException {
     145    public static void init() throws OsmTransferException {
    144146        logger.info("initializing ...");
    145         testProperties = new Properties();
    146 
    147         // load properties
    148         //
    149         try (InputStream is = MultiFetchServerObjectReaderTest.class.getResourceAsStream("/test-functional-env.properties")) {
    150             if (is == null) {
    151                 throw new IOException();
    152             }
    153             testProperties.load(is);
    154         } catch(IOException e){
    155             logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
    156             fail(MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties"));
    157         }
    158 
    159         // check josm.home
    160         //
    161         String josmHome = testProperties.getProperty("josm.home");
    162         if (josmHome == null) {
    163             fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    164         } else {
    165             File f = new File(josmHome);
    166             if (! f.exists() || ! f.canRead()) {
    167                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
    168             }
    169         }
    170 
    171         // check temp output dir
    172         //
    173         String tempOutputDir = testProperties.getProperty("test.functional.tempdir");
    174         if (tempOutputDir == null) {
    175             fail(MessageFormat.format("property ''{0}'' not set in test environment", "test.functional.tempdir"));
    176         } else {
    177             File f = new File(tempOutputDir);
    178             if (! f.exists() || ! f.isDirectory() || ! f.canWrite()) {
    179                 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing, not a directory, or not writeable", "test.functional.tempdir", tempOutputDir));
    180             }
    181         }
    182 
    183 
    184         // init preferences
    185         //
    186         System.setProperty("josm.home", josmHome);
    187         Main.pref.init(false);
     147
     148        JOSMFixture.createFunctionalTestFixture().init();
     149
    188150        // don't use atomic upload, the test API server can't cope with large diff uploads
    189151        //
    190152        Main.pref.put("osm-server.atomic-upload", false);
    191153        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    192 
    193         File dataSetCacheOutputFile = new File(tempOutputDir, MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    194 
    195         // make sure we don't upload to production
    196         //
    197         String url = OsmApi.getOsmApi().getBaseUrl().toLowerCase().trim();
    198         if (url.startsWith("http://www.openstreetmap.org") || url.startsWith("http://api.openstreetmap.org")
    199             || url.startsWith("https://www.openstreetmap.org") || url.startsWith("https://api.openstreetmap.org")) {
    200             fail(MessageFormat.format("configured url ''{0}'' seems to be a productive url, aborting.", url));
    201         }
    202 
    203         String p = System.getProperties().getProperty("useCachedDataset");
     154        Main.logLevel = 4;
     155
     156        File dataSetCacheOutputFile = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
     157
     158        String p = System.getProperty("useCachedDataset");
    204159        if (p != null && Boolean.parseBoolean(p.trim().toLowerCase())) {
    205160            logger.info(MessageFormat.format("property ''{0}'' set, using cached dataset", "useCachedDataset"));
     
    239194    @Before
    240195    public void setUp() throws IOException, IllegalDataException {
    241         File f = new File(testProperties.getProperty("test.functional.tempdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
     196        File f = new File(System.getProperty("java.io.tmpdir"), MultiFetchServerObjectReaderTest.class.getName() + ".dataset");
    242197        logger.info(MessageFormat.format("reading cached dataset ''{0}''", f.toString()));
    243198        ds = new DataSet();
Note: See TracChangeset for help on using the changeset viewer.