Changeset 7081 in josm for trunk/test/functional/org/openstreetmap
- Timestamp:
- 2014-05-09T04:49:54+02:00 (11 years ago)
- Location:
- trunk/test/functional/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/functional/org/openstreetmap/josm/gui/history/HistoryBrowserTest.java
r7030 r7081 2 2 package org.openstreetmap.josm.gui.history; 3 3 4 import static org.junit.Assert.fail;5 6 4 import java.awt.BorderLayout; 7 import java.io.File;8 import java.io.IOException;9 import java.io.InputStream;10 import java.text.MessageFormat;11 import java.util.Properties;12 import java.util.logging.Level;13 5 import java.util.logging.Logger; 14 6 … … 16 8 17 9 import org.junit.BeforeClass; 10 import org.openstreetmap.josm.JOSMFixture; 18 11 import org.openstreetmap.josm.Main; 19 12 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 21 14 import org.openstreetmap.josm.data.osm.history.History; 22 15 import org.openstreetmap.josm.data.osm.history.HistoryDataSet; 23 import org.openstreetmap.josm.data.projection.Projections;24 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 25 17 import org.openstreetmap.josm.io.OsmServerHistoryReader; … … 30 22 static private Logger logger = Logger.getLogger(HistoryBrowserTest.class.getName()); 31 23 32 static Properties testProperties;33 34 24 @BeforeClass 35 25 static public void init() { 36 testProperties = new Properties(); 37 38 // load properties 39 // 40 try (InputStream is = HistoryBrowserTest.class.getResourceAsStream("/test-functional-env.properties");) { 41 testProperties.load(is); 42 } catch(IOException e){ 43 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties")); 44 fail(MessageFormat.format("failed to load property file ''{0}''", "test-functional-env.properties")); 45 } 46 47 // check josm.home 48 // 49 String josmHome = testProperties.getProperty("josm.home"); 50 if (josmHome == null) { 51 fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home")); 52 } else { 53 File f = new File(josmHome); 54 if (! f.exists() || ! f.canRead()) { 55 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome)); 56 } 57 } 58 System.setProperty("josm.home", josmHome); 59 Main.pref.init(false); 60 61 // init projection 62 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 26 JOSMFixture.createFunctionalTestFixture().init(); 63 27 } 64 28 -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r7040 r7081 12 12 import java.io.FileOutputStream; 13 13 import java.io.IOException; 14 import java.io.InputStream;15 14 import java.io.OutputStreamWriter; 16 15 import java.io.PrintWriter; … … 18 17 import java.util.ArrayList; 19 18 import java.util.Properties; 20 import java.util.logging.Level;21 19 import java.util.logging.Logger; 22 20 … … 24 22 import org.junit.BeforeClass; 25 23 import org.junit.Test; 24 import org.openstreetmap.josm.JOSMFixture; 26 25 import org.openstreetmap.josm.Main; 27 26 import org.openstreetmap.josm.data.coor.LatLon; … … 33 32 import org.openstreetmap.josm.data.osm.RelationMember; 34 33 import org.openstreetmap.josm.data.osm.Way; 35 import org.openstreetmap.josm.data.projection.Projections;36 34 import org.openstreetmap.josm.gui.io.UploadStrategy; 37 35 import org.openstreetmap.josm.gui.io.UploadStrategySpecification; … … 136 134 public static void init() throws OsmTransferException { 137 135 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 181 138 // don't use atomic upload, the test API server can't cope with large diff uploads 182 139 // 183 140 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"); 187 143 188 144 // make sure we don't upload to production
Note:
See TracChangeset
for help on using the changeset viewer.