Changeset 7068 in josm for trunk/test/functional/org/openstreetmap
- Timestamp:
- 2014-05-06T01:24:41+02:00 (11 years ago)
- 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 10 10 import java.io.FileOutputStream; 11 11 import java.io.IOException; 12 import java.io.InputStream;13 12 import java.io.OutputStreamWriter; 14 13 import java.io.PrintWriter; … … 16 15 import java.util.ArrayList; 17 16 import java.util.HashSet; 18 import java.util.Properties;19 17 import java.util.Set; 20 import java.util.logging.Level;21 18 import java.util.logging.Logger; 22 19 … … 24 21 import org.junit.BeforeClass; 25 22 import org.junit.Test; 23 import org.openstreetmap.josm.JOSMFixture; 26 24 import org.openstreetmap.josm.Main; 27 25 import org.openstreetmap.josm.data.coor.LatLon; … … 40 38 import org.openstreetmap.josm.tools.Utils; 41 39 40 /** 41 * Reads primitives referring to a particular primitive (ways including a node, relations referring to a relation) 42 * @since 1806 43 */ 42 44 public class OsmServerBackreferenceReaderTest { 43 45 static private final Logger logger = Logger.getLogger(OsmServerBackreferenceReader.class.getName()); … … 47 49 if (("node-" + i).equals(n.get("name"))) return n; 48 50 } 51 fail("Cannot find node "+i); 49 52 return null; 50 53 } 51 52 54 53 55 protected static Way lookupWay(DataSet ds, int i) { … … 55 57 if (("way-" + i).equals(w.get("name"))) return w; 56 58 } 59 fail("Cannot find way "+i); 57 60 return null; 58 61 } … … 62 65 if (("relation-" + i).equals(r.get("name"))) return r; 63 66 } 67 fail("Cannot find relation "+i); 64 68 return null; 65 69 } … … 107 111 } 108 112 } 109 110 113 111 114 protected static DataSet buildTestDataSet() { … … 137 140 } 138 141 139 static Properties testProperties;140 142 static DataSet testDataSet; 141 143 142 144 @BeforeClass 143 public static void 145 public static void init() throws OsmTransferException { 144 146 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 188 150 // don't use atomic upload, the test API server can't cope with large diff uploads 189 151 // 190 152 Main.pref.put("osm-server.atomic-upload", false); 191 153 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"); 204 159 if (p != null && Boolean.parseBoolean(p.trim().toLowerCase())) { 205 160 logger.info(MessageFormat.format("property ''{0}'' set, using cached dataset", "useCachedDataset")); … … 239 194 @Before 240 195 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"); 242 197 logger.info(MessageFormat.format("reading cached dataset ''{0}''", f.toString())); 243 198 ds = new DataSet();
Note:
See TracChangeset
for help on using the changeset viewer.