Changeset 6881 in josm for trunk/test/unit/org/openstreetmap/josm
- Timestamp:
- 2014-02-24T17:49:12+01:00 (11 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r6471 r6881 5 5 import org.junit.Test; 6 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.data.Preferences;8 7 import org.openstreetmap.josm.data.osm.Node; 9 8 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 11 10 public class SearchCompilerTest { 12 11 12 /** 13 * Setup test. 14 */ 13 15 @Before 14 public void setUp() throws Exception{16 public void setUp() { 15 17 Main.initApplicationPreferences(); 16 18 } -
trunk/test/unit/org/openstreetmap/josm/corrector/ReverseWayTagCorrectorTest.java
r6471 r6881 6 6 import org.junit.Test; 7 7 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.data.Preferences;9 8 import org.openstreetmap.josm.data.osm.Tag; 10 9 … … 21 20 Main.initApplicationPreferences(); 22 21 } 23 22 24 23 /** 25 24 * Test of {@link ReverseWayTagCorrector.TagSwitcher#apply} method. … … 93 92 assertSwitch(new Tag("type", "drawdown"), new Tag("type", "drawdown")); 94 93 } 95 94 96 95 private void assertSwitch(Tag oldTag, Tag newTag) { 97 96 Assert.assertEquals(ReverseWayTagCorrector.TagSwitcher.apply(oldTag), newTag); -
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r6801 r6881 12 12 import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException; 13 13 import org.openstreetmap.josm.data.APIDataSet; 14 import org.openstreetmap.josm.data.Preferences;15 16 14 17 15 public class APIDataSetTest { -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r6471 r6881 18 18 import org.junit.Test; 19 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.data.Preferences;21 20 import org.openstreetmap.josm.data.coor.LatLon; 22 21 import org.openstreetmap.josm.data.projection.Projections; 23 22 24 23 public class DataSetMergerTest { 25 /*private static Logger logger = Logger.getLogger(DataSetMergerTest.class.getName());26 27 static Properties testProperties;28 29 @BeforeClass30 static public void init() {31 32 if(System.getProperty("josm.home") == null){33 testProperties = new Properties();34 35 // load properties36 //37 try {38 testProperties.load(DataSetMergerTest.class.getResourceAsStream("/test-unit-env.properties"));39 } catch(Exception e){40 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));41 fail(MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));42 }43 44 // check josm.home45 //46 String josmHome = testProperties.getProperty("josm.home");47 if (josmHome == null) {48 fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));49 } else {50 File f = new File(josmHome);51 if (! f.exists() || ! f.canRead()) {52 fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));53 }54 }55 System.setProperty("josm.home", josmHome);56 }57 Main.pref.init(false);58 59 // init projection60 Main.proj = new Mercator();61 }*/62 24 63 25 @BeforeClass … … 69 31 private DataSet their; 70 32 33 /** 34 * Setup test. 35 */ 71 36 @Before 72 37 public void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r6471 r6881 17 17 import org.openstreetmap.josm.actions.search.SearchAction.SearchMode; 18 18 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 19 import org.openstreetmap.josm.data.Preferences;20 19 import org.openstreetmap.josm.data.coor.LatLon; 21 20 import org.openstreetmap.josm.data.projection.Projections; … … 24 23 import org.openstreetmap.josm.io.OsmReader; 25 24 26 27 25 public class FilterTest { 28 26 27 /** 28 * Setup test. 29 */ 29 30 @BeforeClass 30 31 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandling.java
r6830 r6881 36 36 37 37 /** 38 * Add a tag to an empty node and test the query and get methods. 39 * 38 * Adds a tag to an empty node and test the query and get methods. 40 39 */ 41 40 @Test … … 51 50 52 51 /** 53 * Add two tags to an empty node and test the query and get methods. 52 * Adds two tags to an empty node and test the query and get methods. 54 53 */ 55 54 @Test … … 68 67 69 68 /** 70 * Remove tags from a node with two tags and test the state of the node. 71 * 69 * Removes tags from a node with two tags and test the state of the node. 72 70 */ 73 71 @Test … … 96 94 97 95 /** 98 * Remove all tags from a node 99 * 96 * Removes all tags from a node. 100 97 */ 101 98 @Test … … 132 129 * Test hasEqualSemanticAttributes on two nodes with different tags. 133 130 */ 134 135 131 @Test 136 132 public void hasEqualSemanticAttributes_2() { … … 147 143 assertTrue(!n1.hasEqualSemanticAttributes(n2)); 148 144 } 149 150 145 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
r6471 r6881 9 9 import org.junit.Test; 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.Preferences;12 11 import org.openstreetmap.josm.data.coor.LatLon; 13 12 import org.openstreetmap.josm.data.projection.Projections; … … 27 26 private DataSet dataSet = new DataSet(); 28 27 28 /** 29 * Setup test. 30 */ 29 31 @BeforeClass 30 32 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r6471 r6881 14 14 import org.junit.Test; 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.Preferences;17 16 import org.openstreetmap.josm.data.coor.LatLon; 18 17 import org.openstreetmap.josm.data.projection.Projections; … … 82 81 removeAllTest(ds); 83 82 } 84 85 83 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
r6471 r6881 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.data.Preferences;11 10 import org.openstreetmap.josm.data.coor.LatLon; 12 11 import org.openstreetmap.josm.data.projection.Projections; … … 14 13 public class RelationTest { 15 14 15 /** 16 * Setup test. 17 */ 16 18 @BeforeClass 17 19 public static void setUp() { … … 104 106 Assert.assertEquals(new BBox(w1), r1.getBBox()); 105 107 } 106 107 108 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java
r4603 r6881 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.osm.history; 3 4 3 5 4 import static org.junit.Assert.assertEquals; -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r6471 r6881 12 12 import org.junit.Test; 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.Preferences;15 14 import org.openstreetmap.josm.data.coor.LatLon; 16 15 import org.openstreetmap.josm.data.osm.DataSet; … … 35 34 } 36 35 36 /** 37 * Setup test. 38 */ 37 39 @BeforeClass 38 40 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r6334 r6881 41 41 maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon())); 42 42 } 43 //System.err.println(String.format("maxerror lat: %s maxerror lon: %s", maxErrLat, maxErrLon));44 43 } 45 44 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r6471 r6881 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.projection; 3 4 3 5 4 import java.io.BufferedReader; … … 25 24 import org.openstreetmap.josm.Main; 26 25 import org.openstreetmap.josm.data.Bounds; 27 import org.openstreetmap.josm.data.Preferences;28 26 import org.openstreetmap.josm.data.coor.EastNorth; 29 27 import org.openstreetmap.josm.data.coor.LatLon; … … 147 145 } 148 146 147 /** 148 * Setup test. 149 */ 149 150 @BeforeClass 150 151 public static void setUp() { … … 198 199 throw new AssertionError(fail.toString()); 199 200 } 200 201 201 } 202 202 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r6334 r6881 12 12 public class ProjectionTest { 13 13 14 private static final boolean debug = false;15 14 private static Random rand = new Random(System.currentTimeMillis()); 16 15 … … 64 63 double maxErrLat = 0, maxErrLon = 0; 65 64 Bounds b = p.getWorldBoundsLatLon(); 66 65 67 66 text += String.format("*** %s %s%n", p.toString(), p.toCode()); 68 67 for (int num=0; num < 1000; ++num) { 69 68 70 69 double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat(); 71 70 double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon(); 72 71 73 72 LatLon ll = new LatLon(lat, lon); 74 73 75 74 for (int i=0; i<10; ++i) { 76 75 EastNorth en = p.latlon2eastNorth(ll); … … 80 79 maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon())); 81 80 } 82 81 83 82 String mark = ""; 84 83 if (maxErrLat + maxErrLon > 1e-5) { -
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r6334 r6881 13 13 private boolean debug = false; 14 14 15 /** 16 * Setup test. 17 */ 15 18 @BeforeClass 16 19 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateNodeTest.java
r6471 r6881 7 7 import org.junit.Test; 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.data.Preferences;10 9 import org.openstreetmap.josm.data.coor.LatLon; 11 10 import org.openstreetmap.josm.data.osm.DataSet; … … 15 14 16 15 /** 17 * JUnit Test of "Duplicate node" validation test. 16 * JUnit Test of "Duplicate node" validation test. 18 17 */ 19 18 public class DuplicateNodeTest { 20 19 21 20 /** 22 * Setup test by initializing JOSM preferences and projection. 21 * Setup test by initializing JOSM preferences and projection. 23 22 */ 24 23 @BeforeClass … … 44 43 test.visit(ds.allPrimitives()); 45 44 test.endTest(); 46 45 47 46 assertEquals(1, test.getErrors().size()); 48 47 } -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r6677 r6881 28 28 public class MapCSSTagCheckerTest { 29 29 30 /** 31 * Setup test. 32 */ 30 33 @Before 31 34 public void setUp() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r6858 r6881 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import org.junit.Before; 5 import org.junit.Test; 6 import org.openstreetmap.josm.Main; 7 import org.openstreetmap.josm.data.osm.Tag; 8 import org.openstreetmap.josm.data.validation.Severity; 9 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference; 10 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 11 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem; 12 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems; 13 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader; 14 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction; 4 import static org.CustomMatchers.hasSize; 5 import static org.CustomMatchers.isEmpty; 6 import static org.hamcrest.CoreMatchers.is; 7 import static org.hamcrest.CoreMatchers.not; 8 import static org.junit.Assert.assertThat; 15 9 16 10 import java.util.Arrays; … … 20 14 import java.util.Set; 21 15 22 import static org.CustomMatchers.hasSize; 23 import static org.CustomMatchers.isEmpty; 24 import static org.hamcrest.CoreMatchers.is; 25 import static org.hamcrest.CoreMatchers.not; 26 import static org.junit.Assert.assertThat; 16 import org.junit.Before; 17 import org.junit.Test; 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.data.osm.Tag; 20 import org.openstreetmap.josm.data.validation.Severity; 21 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 22 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem; 23 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems; 24 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader; 27 25 28 26 /** 29 * JUnit Test of "Opening hours" validation test. 27 * JUnit Test of "Opening hours" validation test. 30 28 */ 31 29 public class OpeningHourTestTest { … … 33 31 private static final OpeningHourTest OPENING_HOUR_TEST = new OpeningHourTest(); 34 32 33 /** 34 * Setup test. 35 */ 35 36 @Before 36 37 public void setUp() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java
r6603 r6881 19 19 UnconnectedWays bib; 20 20 21 /** 22 * Setup test. 23 */ 21 24 @Before 22 25 public void setUp() throws Exception { -
trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java
r6471 r6881 1 1 package org.openstreetmap.josm.gui; 2 2 3 import static org.junit.Assert.*; 3 import static org.junit.Assert.assertEquals; 4 5 import java.text.DecimalFormat; 6 import java.text.DecimalFormatSymbols; 7 import java.util.Locale; 4 8 5 9 import org.junit.BeforeClass; 6 10 import org.junit.Test; 7 11 import org.openstreetmap.josm.Main; 8 import org.openstreetmap.josm.data.Preferences;9 12 import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement; 10 11 import java.text.DecimalFormat;12 import java.text.DecimalFormatSymbols;13 import java.util.Locale;14 13 15 14 /** … … 25 24 Main.initApplicationPreferences(); 26 25 } 27 26 28 27 /** 29 28 * Test of {@link SystemOfMeasurement#getDistText} method. … … 31 30 @Test 32 31 public void testGetDistText() { 33 32 34 33 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-1)); 35 34 assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0.99)); … … 38 37 39 38 assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01)); 40 39 41 40 assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99)); 42 41 assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0)); … … 67 66 } 68 67 68 /** 69 * Test of {@link SystemOfMeasurement#getDistText} method with a non-English locale. 70 */ 69 71 @Test 70 72 public void testGetDistTextLocalized() { … … 88 90 89 91 assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01)); 90 92 91 93 assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99)); 92 94 assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0)); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
r6471 r6881 13 13 import org.junit.Test; 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.Preferences;16 15 import org.openstreetmap.josm.data.conflict.Conflict; 17 16 import org.openstreetmap.josm.data.coor.LatLon; … … 51 50 } 52 51 52 /** 53 * Setup test. 54 */ 53 55 @Before 54 56 public void setUp() { … … 141 143 model.deleteObserver(observerTest); 142 144 } 143 144 145 145 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r6562 r6881 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.tagging; 3 4 import static org.CustomMatchers.hasSize; 5 import static org.hamcrest.CoreMatchers.is; 6 import static org.junit.Assert.assertThat; 7 8 import java.io.IOException; 9 import java.util.Collection; 10 import java.util.List; 3 11 4 12 import org.junit.Assert; … … 10 18 import org.xml.sax.SAXException; 11 19 12 import java.io.IOException;13 import java.util.Collection;14 import java.util.List;15 16 import static org.CustomMatchers.hasSize;17 import static org.hamcrest.CoreMatchers.is;18 import static org.junit.Assert.assertThat;19 20 20 /** 21 21 * Unit tests of {@link TaggingPresetReader} class. … … 23 23 public class TaggingPresetReaderTest { 24 24 25 /** 26 * Setup test. 27 */ 25 28 @BeforeClass 26 public static void setUp Class() {29 public static void setUp() { 27 30 Main.initApplicationPreferences(); 28 31 } … … 30 33 /** 31 34 * Gets path to test data directory for given ticketid. 32 * @param ticketid 33 * @return 35 * @param ticketid 36 * @return 34 37 */ 35 38 protected static String getRegressionDataDir(int ticketid) { … … 41 44 * @param ticketid 42 45 * @param filename 43 * @return 46 * @return 44 47 */ 45 48 protected static String getRegressionDataFile(int ticketid, String filename) { … … 85 88 Assert.assertTrue("Default presets are empty", presets.size()>0); 86 89 } 87 88 90 } -
trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
r6471 r6881 10 10 import org.junit.Test; 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.data.Preferences;13 12 14 13 public class TextTagParserTest { 14 15 /** 16 * Setup test. 17 */ 15 18 @BeforeClass 16 public static void before() {19 public static void setUp() { 17 20 Main.initApplicationPreferences(); 18 21 } … … 26 29 s = "\"2 \\\"3\\\" 4\""; s1 = "2 \"3\" 4"; 27 30 Assert.assertEquals(s1, TextTagParser.unescape(s)); 28 31 29 32 s = "\"2 3 ===4===\""; s1 = "2 3 ===4==="; 30 33 Assert.assertEquals(s1, TextTagParser.unescape(s)); … … 33 36 Assert.assertEquals(s1, TextTagParser.unescape(s)); 34 37 } 35 38 36 39 @Test 37 40 public void testTNformat() { … … 63 66 tags = TextTagParser.readTagsFromText(txt); 64 67 Assert.assertEquals(correctTags, tags); 65 68 66 69 txt = "\"a\" : \"1 1 1\", \"b2\" :\"2 \\\"3 qwe\\\" 4\""; 67 70 correctTags= new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4");}}; 68 71 tags = TextTagParser.readTagsFromText(txt); 69 72 Assert.assertEquals(correctTags, tags); 70 73 71 74 txt = " \"aыыы\" : \"val\\\"\\\"\\\"ue1\""; 72 75 correctTags= new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1");} }; … … 74 77 Assert.assertEquals(correctTags, tags); 75 78 } 76 79 77 80 @Test 78 81 public void testFreeformat() { … … 84 87 Assert.assertEquals(correctTags, tags); 85 88 } 86 89 87 90 @Test 88 91 public void errorDetect() { … … 90 93 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 91 94 Assert.assertEquals(Collections.EMPTY_MAP, tags); 92 95 93 96 } 94 97 } -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java
r6471 r6881 19 19 public class TemplateEngineTest { 20 20 21 /** 22 * Setup test. 23 */ 21 24 @BeforeClass 22 public static void before() {25 public static void setUp() { 23 26 Main.initApplicationPreferences(); 24 27 }
Note:
See TracChangeset
for help on using the changeset viewer.