Changeset 7068 in josm
- Timestamp:
- 2014-05-06T01:24:41+02:00 (11 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 5 deleted
- 18 edited
- 2 copied
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/.classpath
r6133 r7068 4 4 <classpathentry kind="src" path="test/unit"/> 5 5 <classpathentry kind="src" path="test/functional"/> 6 <classpathentry kind="src" path="test/performance"/> 6 7 <classpathentry excluding="build/|data_nodist/|dist/|doc/|lib/|macosx/|nb/|src/|test/|test/build/|test/functional/|test/performance/|test/unit/|tools/|utils/" kind="src" path=""/> 7 <classpathentry kind="src" path="test/performance"/>8 8 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 9 9 <classpathentry kind="lib" path="test/lib/fest/fest-assert-1.0.jar"/> -
trunk/build.xml
r7063 r7068 199 199 </target> 200 200 <target name="compile" depends="init,javacc"> 201 201 <!-- COTS --> 202 202 <javac srcdir="src" includes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**" nowarn="on" 203 203 destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="iso-8859-1"> 204 204 <!-- get rid of "internal proprietary API" warning --> 205 205 <compilerarg value="-XDignore.symbol.file"/> 206 206 </javac> 207 207 <!-- JMapViewer/JOSM --> 208 208 <javac srcdir="src" excludes="com/**,oauth/**,org/apache/commons/codec/**,org/glassfish/**,org/openstreetmap/gui/jmapviewer/Demo.java" 209 209 destdir="build" target="1.7" source="1.7" debug="on" includeantruntime="false" createMissingPackageInfoClass="false" encoding="UTF-8"> 210 210 <compilerarg value="-Xlint:cast"/> 211 211 <compilerarg value="-Xlint:deprecation"/> … … 261 261 <pathelement path="tools/groovy-all-2.2.2.jar"/> 262 262 </path> 263 <macrodef name="init-test-preferences"> 264 <attribute name="testfamily"/> 265 <sequential> 266 <copy file="${test.dir}/config/preferences.template.xml" tofile="${test.dir}/config/@{testfamily}-josm.home/preferences.xml"/> 267 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_USERNAME@" value="${osm.username}"/> 268 <replace file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" encoding="UTF-8" token="@OSM_PASSWORD@" value="${osm.password}"/> 269 <!-- Works only on Windows, does nothing on Unix --> 270 <attrib file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" readonly="true"/> 271 <!-- Works only on Unix, does nothing on Windows --> 272 <chmod file="${test.dir}/config/@{testfamily}-josm.home/preferences.xml" perm="a-w"/> 273 </sequential> 274 </macrodef> 263 275 <target name="test-init"> 264 276 <mkdir dir="${test.dir}/build"/> 277 <mkdir dir="${test.dir}/build/unit"/> 278 <mkdir dir="${test.dir}/build/functional"/> 279 <mkdir dir="${test.dir}/build/performance"/> 265 280 <mkdir dir="${test.dir}/report"/> 281 <init-test-preferences testfamily="unit"/> 282 <init-test-preferences testfamily="functional"/> 283 <init-test-preferences testfamily="performance"/> 266 284 </target> 267 285 <target name="test-clean"> … … 269 287 <delete dir="${test.dir}/report"/> 270 288 <delete file="${test.dir}/jacoco.exec" /> 271 </target> 289 <delete file="${test.dir}/config/unit-josm.home/preferences.xml" /> 290 <delete file="${test.dir}/config/functional-josm.home/preferences.xml" /> 291 <delete file="${test.dir}/config/performance-josm.home/preferences.xml" /> 292 <delete dir="${test.dir}/config/unit-josm.home/cache" failonerror="false"/> 293 <delete dir="${test.dir}/config/functional-josm.home/cache" failonerror="false"/> 294 <delete dir="${test.dir}/config/performance-josm.home/cache" failonerror="false"/> 295 </target> 296 <macrodef name="call-groovyc"> 297 <attribute name="testfamily"/> 298 <element name="cp-elements"/> 299 <sequential> 300 <groovyc srcdir="${test.dir}/@{testfamily}" destdir="${test.dir}/build/@{testfamily}" encoding="UTF-8"> 301 <classpath> 302 <cp-elements/> 303 </classpath> 304 <javac target="1.7" source="1.7" debug="on"> 305 <compilerarg value="-Xlint:all"/> 306 <compilerarg value="-Xlint:-serial"/> 307 </javac> 308 </groovyc> 309 </sequential> 310 </macrodef> 272 311 <target name="test-compile" depends="test-init,dist"> 273 312 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="tools/groovy-all-2.2.2.jar"/> 274 <groovyc classpathref="test.classpath" destdir="${test.dir}/build" encoding="UTF-8"> 275 <src path="${test.dir}/unit"/> 276 <src path="${test.dir}/functional"/> 277 <src path="${test.dir}/performance"/> 278 <javac target="1.7" source="1.7" debug="on"> 279 <compilerarg value="-Xlint:all"/> 280 <compilerarg value="-Xlint:-serial"/> 281 </javac> 282 </groovyc> 283 </target> 284 <target name="test" depends="test-compile"> 313 <call-groovyc testfamily="unit"> 314 <cp-elements> 315 <path refid="test.classpath"/> 316 </cp-elements> 317 </call-groovyc> 318 <call-groovyc testfamily="functional"> 319 <cp-elements> 320 <path refid="test.classpath"/> 321 <pathelement path="${test.dir}/build/unit"/> 322 </cp-elements> 323 </call-groovyc> 324 <call-groovyc testfamily="performance"> 325 <cp-elements> 326 <path refid="test.classpath"/> 327 <pathelement path="${test.dir}/build/unit"/> 328 </cp-elements> 329 </call-groovyc> 330 </target> 331 <macrodef name="call-junit"> 332 <attribute name="testfamily"/> 333 <sequential> 334 <echo message="Running @{testfamily} tests with JUnit"/> 335 <jacoco:coverage destfile="${test.dir}/jacoco.exec"> 336 <junit printsummary="yes" fork="true" forkmode="once"> 337 <sysproperty key="josm.home" value="${test.dir}/config/@{testfamily}-josm.home"/> 338 <sysproperty key="josm.test.data" value="${test.dir}/data"/> 339 <sysproperty key="java.awt.headless" value="true"/> 340 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/> 341 <classpath> 342 <path refid="test.classpath"/> 343 <pathelement path="${test.dir}/build/unit"/> 344 <pathelement path="${test.dir}/build/@{testfamily}"/> 345 <pathelement path="${test.dir}/config"/> 346 </classpath> 347 <formatter type="plain"/> 348 <formatter type="xml"/> 349 <batchtest fork="yes" todir="${test.dir}/report"> 350 <fileset dir="${test.dir}/build/@{testfamily}" includes="**/*Test.class"/> 351 </batchtest> 352 </junit> 353 </jacoco:coverage> 354 </sequential> 355 </macrodef> 356 <target name="test" depends="test-compile" 357 description="Run unit, functional and performance tests. OSM API (TEST) account shall be set with -Dosm.username and -Dosm.password"> 285 358 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" classpath="tools/jacocoant.jar" /> 286 <jacoco:coverage destfile="${test.dir}/jacoco.exec"> 287 <junit printsummary="yes" fork="true" forkmode="once"> 288 <sysproperty key="josm.home" value="${test.dir}/config/unit-josm.home"/> 289 <sysproperty key="josm.test.data" value="${test.dir}/data"/> 290 <sysproperty key="java.awt.headless" value="true"/> 291 <sysproperty key="suppressPermanentFailure" value="${suppressPermanentFailure}"/> 292 <classpath> 293 <path refid="test.classpath"/> 294 <pathelement path="${test.dir}/build"/> 295 <pathelement path="${test.dir}/config"/> 296 </classpath> 297 <formatter type="plain"/> 298 <formatter type="xml"/> 299 <batchtest fork="yes" todir="${test.dir}/report"> 300 <fileset dir="${test.dir}/build" includes="**/*Test.class"/> 301 </batchtest> 302 </junit> 303 </jacoco:coverage> 359 <call-junit testfamily="unit"/> 360 <call-junit testfamily="functional"/> 361 <call-junit testfamily="performance"/> 304 362 </target> 305 363 <target name="test-html" depends="test" description="Generate HTML test reports"> -
trunk/test/config/unit-josm.home
- Property svn:ignore
-
old new 1 1 cache 2 preferences.xml_backup 3 preferences.xml_tmp 4 preferences.xml
-
- Property svn:ignore
-
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(); -
trunk/test/performance/org/openstreetmap/josm/data/osm/RoundingPerformanceTest.java
r4573 r7068 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.data.osm; 3 4 import static org.junit.Assert.assertTrue; 2 5 3 6 import org.junit.Test; … … 5 8 import org.openstreetmap.josm.data.coor.LatLonTest; 6 9 7 import static org.junit.Assert.assertTrue; 10 public class RoundingPerformanceTest { 8 11 9 public class RoundingPerformanceTest extends LatLonTest {10 11 12 private static double oldRoundToOsmPrecision(double value) { 12 13 return Math.round(value / LatLon.MAX_SERVER_PRECISION) * LatLon.MAX_SERVER_PRECISION; // Old method, causes rounding errors, but efficient … … 18 19 long start = System.nanoTime(); 19 20 for (int i = 0; i < n; i++) { 20 for (double value : sampleValues) {21 for (double value : LatLonTest.SAMPLE_VALUES) { 21 22 oldRoundToOsmPrecision(value); 22 23 } … … 25 26 long oldTime = end-start; 26 27 System.out.println("Old time: "+oldTime/1000000.0 + " ms"); 27 28 28 29 start = System.nanoTime(); 29 30 for (int i = 0; i < n; i++) { 30 for (double value : sampleValues) {31 for (double value : LatLonTest.SAMPLE_VALUES) { 31 32 LatLon.roundToOsmPrecision(value); 32 33 } … … 35 36 long newTime = end-start; 36 37 System.out.println("New time: "+newTime/1000000.0 + " ms"); 37 38 38 39 assertTrue(newTime <= oldTime*10); 39 40 } -
trunk/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java
r7065 r7068 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.data.osm; 2 package org.openstreetmap.josm.data.osm.visitor.paint; 3 3 4 4 import java.awt.Graphics2D; … … 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.data.Bounds; 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.visitor.paint.Rendering; 14 15 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; … … 19 20 import org.openstreetmap.josm.io.OsmReader; 20 21 21 public class MapPaintVisitorPerformanceTest {22 public class StyledMapRendererPerformanceTest { 22 23 23 24 private static final int IMG_WIDTH = 1400; … … 54 55 55 56 // Warm up 56 new MapPaintVisitorPerformanceTest().testRestrictionSmall();57 new MapPaintVisitorPerformanceTest().testCity();57 new StyledMapRendererPerformanceTest().testRestrictionSmall(); 58 new StyledMapRendererPerformanceTest().testCity(); 58 59 } 59 60 -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.groovy
r7065 r7068 1 2 1 // License: GPL. For details, see LICENSE file. 3 package mapcss.performance;2 package org.openstreetmap.josm.gui.mappaint.mapcss; 4 3 5 4 import static org.junit.Assert.* … … 16 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer 17 16 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles 18 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource19 17 import org.openstreetmap.josm.gui.preferences.SourceEntry 20 18 import org.openstreetmap.josm.io.OsmReader 21 19 22 20 /** 23 * This performance test smeasures the time for a full run of MapPaintVisitor.visitAll()21 * This performance test measures the time for a full run of MapPaintVisitor.visitAll() 24 22 * against a test data set using a test style. 25 * 23 * 26 24 */ 27 class PerformanceTest { 25 class MapCSSPerformanceTest { 28 26 29 27 /* ------------------------ configuration section ---------------------------- */ 30 28 /** 31 * The path to the JOSM home environment 32 */ 33 def static JOSM_HOME="/my/josm/home/dir" 34 35 /** 36 * The path to the style file used for rendering. 37 */ 38 def static STYLE_FILE="/my/test-style.mapcss" 29 * The path to the JOSM home environment 30 */ 31 def static JOSM_HOME="test/config/performance-josm.home" 39 32 40 /** 41 * The data file to be rendered 42 */ 43 def static DATA_FILE = "/my/test-data.osm" 44 /* ------------------------ / configuration section ---------------------------- */ 45 33 /** 34 * The path to the style file used for rendering. 35 */ 36 def static STYLE_FILE="styles/standard/elemstyles.mapcss" 37 38 /** 39 * The data file to be rendered 40 */ 41 def static DATA_FILE = "/my/test-data.osm" 42 /* ------------------------ / configuration section ---------------------------- */ 43 46 44 def DataSet ds 47 45 48 46 def static boolean checkTestEnvironment() { 49 47 File f = new File(JOSM_HOME) 50 48 if (!f.isDirectory() || !f.exists()) { 51 fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.") 49 fail("JOSM_HOME refers to '${JOSM_HOME}. This is either not a directory or doesn't exist.\nPlease update configuration settings in the unit test file.") 52 50 } 53 51 54 52 f = new File(STYLE_FILE); 55 53 if ( !f.isFile() || ! f.exists()) { 56 54 fail("STYLE_FILE refers to '${STYLE_FILE}. This is either not a file or doesn't exist.\nPlease update configuration settings in the unit test file.") 57 55 } 58 56 59 57 f = new File(DATA_FILE); 60 58 if ( !f.isFile() || ! f.exists()) { … … 62 60 } 63 61 } 64 62 65 63 @BeforeClass 66 64 public static void createJOSMFixture(){ … … 69 67 MainApplication.main(new String[0]) 70 68 } 71 69 72 70 def timed(Closure c){ 73 71 long before = System.currentTimeMillis() … … 76 74 return after - before 77 75 } 78 76 79 77 def loadStyle() { 80 78 print "Loading style '$STYLE_FILE' ..." … … 95 93 println "DONE" 96 94 } 97 95 98 96 def loadData() { 99 97 print "Loading data file '$DATA_FILE' ..." … … 105 103 println "DONE" 106 104 } 107 105 108 106 @Test 109 107 public void measureTimeForStylePreparation() { 110 108 loadStyle() 111 109 loadData() 112 110 113 111 def mv = Main.map.mapView 114 112 115 113 BufferedImage img = mv.createImage(mv.getWidth(), mv.getHeight()) 116 114 Graphics2D g = img.createGraphics() 117 115 g.setClip(0,0, mv.getWidth(), mv.getHeight()) 118 def visitor = new StyledMapRenderer() 119 visitor.setNavigatableComponent(Main.map.mapView) 120 visitor.setGraphics(g) 116 def visitor = new StyledMapRenderer(g, Main.map.mapView, false) 121 117 122 118 print "Rendering ..." … … 128 124 println "style file: ${STYLE_FILE}" 129 125 println "" 130 println "Rendering took $time ms." 126 println "Rendering took $time ms." 131 127 } 132 128 } -
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r7065 r7068 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm .fixtures;2 package org.openstreetmap.josm; 3 3 4 4 import static org.junit.Assert.fail; … … 6 6 import java.io.File; 7 7 import java.text.MessageFormat; 8 import java.util.Properties;9 import java.util.logging.Level;10 8 import java.util.logging.Logger; 11 9 12 import org.openstreetmap.josm.Main;13 10 import org.openstreetmap.josm.data.projection.Projections; 14 11 import org.openstreetmap.josm.io.OsmApi; … … 19 16 20 17 static public JOSMFixture createUnitTestFixture() { 21 return new JOSMFixture(" /test-unit-env.properties");18 return new JOSMFixture("test/config/unit-josm.home"); 22 19 } 23 20 24 21 static public JOSMFixture createFunctionalTestFixture() { 25 return new JOSMFixture(" /test-functional-env.properties");22 return new JOSMFixture("test/config/functional-josm.home"); 26 23 } 27 24 28 private Properties testProperties; 29 private String testPropertiesResourceName; 25 static public JOSMFixture createPerformanceTestFixture() { 26 return new JOSMFixture("test/config/performance-josm.home"); 27 } 30 28 31 public JOSMFixture(String testPropertiesResourceName) { 32 this.testPropertiesResourceName = testPropertiesResourceName; 29 private final String josmHome; 30 31 public JOSMFixture(String josmHome) { 32 this.josmHome = josmHome; 33 33 } 34 34 35 35 public void init() { 36 testProperties = new Properties();37 38 // load properties39 //40 try {41 testProperties.load(JOSMFixture.class.getResourceAsStream(testPropertiesResourceName));42 } catch(Exception e){43 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", testPropertiesResourceName));44 fail(MessageFormat.format("failed to load property file ''{0}''. \nMake sure the path ''$project_root/test/config'' is on the classpath.", testPropertiesResourceName));45 }46 36 47 37 // check josm.home 48 38 // 49 String josmHome = testProperties.getProperty("josm.home");50 39 if (josmHome == null) { 51 40 fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home")); … … 53 42 File f = new File(josmHome); 54 43 if (! f.exists() || ! f.canRead()) { 55 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable. \nEdit ''{2}'' and update the value ''josm.home''.", "josm.home", josmHome,testPropertiesResourceName));44 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable.", "josm.home", josmHome)); 56 45 } 57 46 } -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r7065 r7068 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap; 2 package org.openstreetmap.josm; 3 3 4 4 import static org.hamcrest.CoreMatchers.is; -
trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.groovy
r6597 r7068 1 1 package org.openstreetmap.josm.actions 2 2 3 import org.openstreetmap.TestUtils4 3 import org.openstreetmap.josm.Main 4 import org.openstreetmap.josm.TestUtils; 5 5 import org.openstreetmap.josm.actions.search.SearchCompiler 6 6 import org.openstreetmap.josm.data.osm.Relation -
trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java
r6226 r7068 6 6 import org.junit.Test; 7 7 8 /**9 * @author Vincent10 *11 */12 8 public class LatLonTest { 13 9 14 p rotectedstatic final double[]sampleValues= new double[]{10 public static final double[] SAMPLE_VALUES = new double[]{ 15 11 -180.0, -179.9, -179.6, -179.5, -179.4, -179.1, -179.0, -100.0, -99.9, -10.0, -9.9, -1.0, -0.1, 16 12 180.0, 179.9, 179.6, 179.5, 179.4, 179.1, 179.0, 100.0, 99.9, 10.0, 9.9, 1.0, 0.1, … … 20 16 100.12, 100.123, 100.1234, 100.12345, 100.123456, 100.1234567 21 17 }; 22 18 23 19 /** 24 20 * Test of {@link LatLon#roundToOsmPrecisionStrict} … … 26 22 @Test 27 23 public void testRoundToOsmPrecisionStrict() { 28 29 for (double value : sampleValues) {24 25 for (double value : SAMPLE_VALUES) { 30 26 assertEquals(LatLon.roundToOsmPrecisionStrict(value), value, 0); 31 27 } 32 28 33 29 assertEquals(LatLon.roundToOsmPrecisionStrict(0.0), 0.0, 0); 34 30 assertEquals(LatLon.roundToOsmPrecisionStrict(-0.0), 0.0, 0); 35 31 36 32 assertEquals(LatLon.roundToOsmPrecisionStrict(0.12345678), 0.1234568, 0); 37 33 assertEquals(LatLon.roundToOsmPrecisionStrict(0.123456789), 0.1234568, 0); … … 76 72 assertEquals(LatLon.roundToOsmPrecisionStrict(99.9999999), 99.9999999, 0); 77 73 } 78 74 79 75 /** 80 76 * Test of {@link LatLon#toIntervalLon} … … 107 103 @Test 108 104 public void testEquals() { 109 for (int i = 1; i < sampleValues.length; i++) {110 LatLon a = new LatLon( sampleValues[i-1],sampleValues[i]);111 LatLon b = new LatLon( sampleValues[i-1],sampleValues[i]);105 for (int i = 1; i < SAMPLE_VALUES.length; i++) { 106 LatLon a = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]); 107 LatLon b = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]); 112 108 assertEquals(a, b); 113 109 } … … 119 115 @Test 120 116 public void testHashCode() { 121 for (int i = 1; i < sampleValues.length; i++) {122 LatLon a = new LatLon( sampleValues[i-1],sampleValues[i]);123 LatLon b = new LatLon( sampleValues[i-1],sampleValues[i]);117 for (int i = 1; i < SAMPLE_VALUES.length; i++) { 118 LatLon a = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]); 119 LatLon b = new LatLon(SAMPLE_VALUES[i-1], SAMPLE_VALUES[i]); 124 120 assertEquals(a.hashCode(), b.hashCode()); 125 121 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/LanesTest.groovy
r6647 r7068 1 1 package org.openstreetmap.josm.data.validation.tests 2 2 3 import org.openstreetmap.TestUtils 3 import org.openstreetmap.josm.TestUtils; 4 4 5 5 class LanesTest extends GroovyTestCase { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r7065 r7068 13 13 import java.util.Map; 14 14 15 import org.junit.Before; 15 import org.junit.BeforeClass; 16 16 import org.junit.Test; 17 import org.openstreetmap.TestUtils;18 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.TestUtils; 19 19 import org.openstreetmap.josm.command.ChangePropertyCommand; 20 20 import org.openstreetmap.josm.data.osm.Node; … … 31 31 * Setup test. 32 32 */ 33 @Before 34 public void setUp() throws Exception{33 @BeforeClass 34 public static void setUp() { 35 35 Main.initApplicationPreferences(); 36 36 } -
trunk/test/unit/org/openstreetmap/josm/gui/JosmUserIdentityManagerTest.groovy
r2690 r7068 2 2 package org.openstreetmap.josm.gui; 3 3 4 import org.junit. BeforeClass;5 import org.junit.Test 6 import org. openstreetmap.josm.Main;7 import org. openstreetmap.josm.data.osm.UserInfo;8 import org.openstreetmap.josm. fixtures.JOSMFixture;9 10 import static org.junit.Assert.*;4 import static org.junit.Assert.* 5 6 import org.junit.BeforeClass 7 import org.junit.Test 8 import org.openstreetmap.josm.JOSMFixture 9 import org.openstreetmap.josm.Main 10 import org.openstreetmap.josm.data.osm.UserInfo 11 11 12 12 class JosmUserIdentityManagerTest { 13 13 14 14 final shouldFail = new GroovyTestCase().&shouldFail 15 15 16 16 private static JOSMFixture josmFixture 17 17 18 18 @BeforeClass 19 19 public static void initTestCase() { 20 20 josmFixture = JOSMFixture.createFunctionalTestFixture() 21 21 } 22 22 23 23 @Test 24 24 public void test_SingletonAccess() { 25 26 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 25 26 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 27 27 28 28 // created ? 29 29 assert im != null 30 31 // registered as listener ? 30 31 // registered as listener ? 32 32 assert Main.pref.@listeners.contains(im) 33 33 34 34 JosmUserIdentityManager im2 = JosmUserIdentityManager.getInstance() 35 35 36 36 // only one instance 37 assert im == im2 38 } 39 37 assert im == im2 38 } 39 40 40 @Test 41 41 public void test_setAnonymouse() { 42 42 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 43 43 44 44 im.setPartiallyIdentified "test" 45 45 im.setAnonymous() 46 46 47 47 assert im.isAnonymous() 48 48 assert ! im.isPartiallyIdentified() 49 49 assert ! im.isFullyIdentified() 50 50 51 51 assert im.getUserId() == 0 52 52 assert im.getUserName() == null 53 53 assert im.getUserInfo() == null 54 54 } 55 55 56 56 @Test 57 57 public void test_setPartiallyIdentified() { 58 58 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 59 59 60 60 im.setPartiallyIdentified "test" 61 61 62 62 shouldFail(IllegalArgumentException) { 63 63 im.setPartiallyIdentified null 64 64 } 65 65 66 66 shouldFail(IllegalArgumentException) { 67 67 im.setPartiallyIdentified "" 68 68 } 69 69 70 70 shouldFail(IllegalArgumentException) { 71 71 im.setPartiallyIdentified " \t " 72 72 } 73 73 74 74 im.setPartiallyIdentified "test" 75 75 76 76 assert ! im.isAnonymous() 77 77 assert im.isPartiallyIdentified() 78 78 assert ! im.isFullyIdentified() 79 79 80 80 assert im.getUserId() == 0 81 81 assert im.getUserName() == "test" 82 82 assert im.getUserInfo() == null 83 83 } 84 85 84 85 86 86 @Test 87 87 public void test_setFullyIdentified() { … … 89 89 90 90 UserInfo userInfo = new UserInfo(id: 1, description: "a description") 91 91 92 92 im.setFullyIdentified "test", userInfo 93 93 94 94 shouldFail(IllegalArgumentException) { 95 95 im.setFullyIdentified null, userInfo … … 104 104 im.setFullyIdentified "test", null 105 105 } 106 106 107 107 im.setFullyIdentified "test", userInfo 108 108 109 109 assert ! im.isAnonymous() 110 110 assert ! im.isPartiallyIdentified() 111 111 assert im.isFullyIdentified() 112 112 113 113 assert im.getUserId() == 1 114 114 assert im.getUserName() == "test" 115 115 assert im.getUserInfo() == userInfo 116 116 } 117 117 118 118 /** 119 119 * Preferences include neither an url nor a user name => we have 120 * an anonymous user 121 */ 122 @Test 120 * an anonymous user 121 */ 122 @Test 123 123 public void initFromPreferences_1() { 124 124 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 125 126 // reset it 127 im.@userName = null 128 im.@userInfo = null 129 125 126 // reset it 127 im.@userName = null 128 im.@userInfo = null 129 130 130 Main.pref.put "osm-server.url", null 131 131 Main.pref.put "osm-server.username", null 132 133 im.initFromPreferences() 134 135 assert im.isAnonymous() 136 } 137 132 133 im.initFromPreferences() 134 135 assert im.isAnonymous() 136 } 137 138 138 /** 139 139 * Preferences include neither an url nor a user name => we have 140 * an annoymous user 141 */ 142 @Test 140 * an annoymous user 141 */ 142 @Test 143 143 public void initFromPreferences_2() { 144 144 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 145 146 // reset it 147 im.@userName = null 148 im.@userInfo = null 149 145 146 // reset it 147 im.@userName = null 148 im.@userInfo = null 149 150 150 // for this test we disable the listener 151 151 Main.pref.removePreferenceChangeListener im 152 153 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 154 Main.pref.put "osm-server.username", null 155 156 im.initFromPreferences() 157 158 assert im.isAnonymous() 159 } 160 161 /** 162 * Preferences include an user name => we have a partially identified user 163 */ 164 @Test 152 153 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 154 Main.pref.put "osm-server.username", null 155 156 im.initFromPreferences() 157 158 assert im.isAnonymous() 159 } 160 161 /** 162 * Preferences include an user name => we have a partially identified user 163 */ 164 @Test 165 165 public void initFromPreferences_3() { 166 166 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() … … 169 169 Main.pref.removePreferenceChangeListener im 170 170 171 // reset it 172 im.@userName = null 173 im.@userInfo = null 174 171 // reset it 172 im.@userName = null 173 im.@userInfo = null 174 175 175 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 176 176 Main.pref.put "osm-server.username", "test" 177 178 im.initFromPreferences() 179 180 assert im.isPartiallyIdentified() 181 } 182 177 178 im.initFromPreferences() 179 180 assert im.isPartiallyIdentified() 181 } 182 183 183 /** 184 184 * Preferences include an user name which is different from the current 185 185 * user name and we are currently fully identifed => josm user becomes 186 * partially identified 187 */ 188 @Test 186 * partially identified 187 */ 188 @Test 189 189 public void initFromPreferences_4() { 190 190 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() … … 194 194 195 195 im.setFullyIdentified "test1", new UserInfo(id: 1) 196 196 197 197 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 198 198 Main.pref.put "osm-server.username", "test2" 199 200 im.initFromPreferences() 201 202 assert im.isPartiallyIdentified() 203 } 204 199 200 im.initFromPreferences() 201 202 assert im.isPartiallyIdentified() 203 } 204 205 205 /** 206 206 * Preferences include an user name which is the same as the current … … 208 208 * fully identified 209 209 */ 210 @Test 210 @Test 211 211 public void initFromPreferences_5() { 212 212 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() … … 214 214 // for this test we disable the listener 215 215 Main.pref.removePreferenceChangeListener im 216 216 217 217 im.setFullyIdentified "test1", new UserInfo(id: 1) 218 218 219 219 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 220 220 Main.pref.put "osm-server.username", "test1" 221 222 im.initFromPreferences() 223 221 222 im.initFromPreferences() 223 224 224 assert im.isFullyIdentified() 225 225 } 226 227 @Test 226 227 @Test 228 228 public void apiUrlChanged() { 229 229 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 230 231 // make sure im is a preference change listener 230 231 // make sure im is a preference change listener 232 232 Main.pref.addPreferenceChangeListener im 233 234 // reset it 235 im.@userName = null 236 im.@userInfo = null 237 238 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 239 assert im.isAnonymous() 240 233 234 // reset it 235 im.@userName = null 236 im.@userInfo = null 237 238 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 239 assert im.isAnonymous() 240 241 241 Main.pref.put "osm-server.url", null 242 242 assert im.isAnonymous() 243 244 // reset it 243 244 // reset it 245 245 im.@userName = "test" 246 246 im.@userInfo = null 247 248 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 249 assert im.isPartiallyIdentified() 250 assert im.getUserName() == "test" 251 247 248 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 249 assert im.isPartiallyIdentified() 250 assert im.getUserName() == "test" 251 252 252 Main.pref.put "osm-server.url", null 253 253 assert im.isAnonymous() 254 255 // reset it 254 255 // reset it 256 256 im.@userName = "test" 257 257 im.@userInfo = new UserInfo(id:1) 258 259 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 260 assert im.isPartiallyIdentified() 261 assert im.getUserName() == "test" 262 263 // reset it 258 259 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 260 assert im.isPartiallyIdentified() 261 assert im.getUserName() == "test" 262 263 // reset it 264 264 im.@userName = "test" 265 265 im.@userInfo = new UserInfo(id:1) 266 267 266 267 268 268 Main.pref.put "osm-server.url", null 269 assert im.isAnonymous() 270 } 271 272 @Test 269 assert im.isAnonymous() 270 } 271 272 @Test 273 273 public void userNameChanged() { 274 274 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 275 276 // make sure im is a preference change listener 275 276 // make sure im is a preference change listener 277 277 Main.pref.addPreferenceChangeListener im 278 279 // reset it 280 im.@userName = null 281 im.@userInfo = null 282 278 279 // reset it 280 im.@userName = null 281 im.@userInfo = null 282 283 283 Main.pref.put "osm-server.username", "test" 284 284 assert im.isPartiallyIdentified() 285 285 assert im.getUserName() == "test" 286 287 Main.pref.put "osm-server.username", null 288 assert im.isAnonymous() 289 290 // reset it 286 287 Main.pref.put "osm-server.username", null 288 assert im.isAnonymous() 289 290 // reset it 291 291 im.@userName = "test1" 292 292 im.@userInfo = null 293 293 294 294 Main.pref.put "osm-server.username", "test2" 295 295 assert im.isPartiallyIdentified() 296 296 assert im.getUserName() == "test2" 297 298 Main.pref.put "osm-server.username", null 299 assert im.isAnonymous() 300 301 // reset it 297 298 Main.pref.put "osm-server.username", null 299 assert im.isAnonymous() 300 301 // reset it 302 302 im.@userName = "test1" 303 303 im.@userInfo = new UserInfo(id:1) 304 304 305 305 Main.pref.put "osm-server.username", "test2" 306 306 assert im.isPartiallyIdentified() 307 307 assert im.getUserName() == "test2" 308 309 // reset it 308 309 // reset it 310 310 im.@userName = "test1" 311 311 im.@userInfo = new UserInfo(id:1) 312 313 314 Main.pref.put "osm-server.username", null 315 assert im.isAnonymous() 312 313 314 Main.pref.put "osm-server.username", null 315 assert im.isAnonymous() 316 316 } 317 317 } -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategyTest.groovy
r3991 r7068 3 3 4 4 import org.junit.* 5 import org.openstreetmap.josm. fixtures.JOSMFixture;5 import org.openstreetmap.josm.JOSMFixture; 6 6 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 7 7 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.StaticLabelCompositionStrategy; -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/MapCSSWithExtendedTextDirectivesTest.groovy
r4074 r7068 4 4 5 5 import org.junit.* 6 import org.openstreetmap.josm. fixtures.JOSMFixture6 import org.openstreetmap.josm.JOSMFixture; 7 7 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.DeriveLabelFromNameTagsCompositionStrategy 8 8 import org.openstreetmap.josm.gui.mappaint.LabelCompositionStrategy.TagLookupCompositionStrategy -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.groovy
r4069 r7068 7 7 8 8 import org.junit.* 9 import org.openstreetmap.josm.JOSMFixture; 9 10 import org.openstreetmap.josm.data.coor.LatLon 10 11 import org.openstreetmap.josm.data.osm.DataSet … … 13 14 import org.openstreetmap.josm.data.osm.RelationMember 14 15 import org.openstreetmap.josm.data.osm.Way 15 import org.openstreetmap.josm.fixtures.JOSMFixture16 16 import org.openstreetmap.josm.gui.mappaint.Environment 17 17 import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.groovy
r4074 r7068 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture; 7 8 import org.openstreetmap.josm.data.coor.LatLon 8 9 import org.openstreetmap.josm.data.osm.DataSet … … 10 11 import org.openstreetmap.josm.data.osm.Relation 11 12 import org.openstreetmap.josm.data.osm.RelationMember 12 import org.openstreetmap.josm.fixtures.JOSMFixture13 13 import org.openstreetmap.josm.gui.mappaint.Environment 14 14 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy
r4074 r7068 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm.JOSMFixture; 7 8 import org.openstreetmap.josm.data.coor.LatLon 8 9 import org.openstreetmap.josm.data.osm.DataSet … … 10 11 import org.openstreetmap.josm.data.osm.Relation 11 12 import org.openstreetmap.josm.data.osm.RelationMember 12 import org.openstreetmap.josm.fixtures.JOSMFixture13 13 import org.openstreetmap.josm.gui.mappaint.Environment 14 14 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy
r7066 r7068 5 5 import org.junit.Before 6 6 import org.junit.Test 7 import org.openstreetmap.TestUtils8 7 import org.openstreetmap.josm.Main 8 import org.openstreetmap.josm.TestUtils; 9 9 import org.openstreetmap.josm.data.coor.LatLon 10 10 import org.openstreetmap.josm.data.osm.DataSet -
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ParsingLinkSelectorTest.groovy
r4074 r7068 5 5 6 6 import org.junit.* 7 import org.openstreetmap.josm. fixtures.JOSMFixture7 import org.openstreetmap.josm.JOSMFixture; 8 8 9 9 -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r6881 r7068 13 13 import org.junit.BeforeClass; 14 14 import org.junit.Test; 15 import org.openstreetmap.TestUtils;16 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.TestUtils; 17 17 import org.openstreetmap.josm.tools.Utils; 18 18 import org.xml.sax.SAXException;
Note:
See TracChangeset
for help on using the changeset viewer.