Changeset 8857 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2015-10-11T17:28:19+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/MainTest.java
r8809 r8857 2 2 package org.openstreetmap.josm; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertNull; 7 import static org.junit.Assert.assertTrue; 8 9 import java.util.Collection; 6 10 7 11 import org.junit.Test; 12 import org.openstreetmap.josm.Main.DownloadParamType; 8 13 14 /** 15 * Unit tests of {@link Main} class. 16 */ 9 17 public class MainTest { 18 19 /** 20 * Unit test of {@link DownloadParamType#paramType} method. 21 */ 10 22 @Test 11 public void testParamType() throws Exception { 12 assertThat(Main.DownloadParamType.paramType("48.000,16.000,48.001,16.001"), is(Main.DownloadParamType.bounds)); 23 public void testParamType() { 24 assertEquals(DownloadParamType.bounds, DownloadParamType.paramType("48.000,16.000,48.001,16.001")); 25 assertEquals(DownloadParamType.fileName, DownloadParamType.paramType("data.osm")); 26 assertEquals(DownloadParamType.fileUrl, DownloadParamType.paramType("file:///home/foo/data.osm")); 27 assertEquals(DownloadParamType.fileUrl, DownloadParamType.paramType("file://C:\\Users\\foo\\data.osm")); 28 assertEquals(DownloadParamType.httpUrl, DownloadParamType.paramType("http://somewhere.com/data.osm")); 29 assertEquals(DownloadParamType.httpUrl, DownloadParamType.paramType("https://somewhere.com/data.osm")); 30 } 31 32 /** 33 * Unit tests on log messages. 34 */ 35 @Test 36 public void testLogs() { 37 38 assertNull(Main.getErrorMessage(null)); 39 40 // Correct behaviour with errors 41 Main.error(new Exception("exception_error")); 42 Main.error("Error message on one line"); 43 Main.error("First line of error message on several lines\nline2\nline3\nline4"); 44 Collection<String> errors = Main.getLastErrorAndWarnings(); 45 assertTrue(errors.contains("E: java.lang.Exception: exception_error")); 46 assertTrue(errors.contains("E: Error message on one line")); 47 assertTrue(errors.contains("E: First line of error message on several lines")); 48 49 // Correct behaviour with warnings 50 Main.warn(new Exception("exception_warn", new Exception("root_cause"))); 51 Main.warn("Warning message on one line"); 52 Main.warn("First line of warning message on several lines\nline2\nline3\nline4"); 53 Collection<String> warnings = Main.getLastErrorAndWarnings(); 54 assertTrue(warnings.contains("W: java.lang.Exception: exception_warn. Cause: java.lang.Exception: root_cause")); 55 assertTrue(warnings.contains("W: Warning message on one line")); 56 assertTrue(warnings.contains("W: First line of warning message on several lines")); 57 58 int defaultLevel = Main.logLevel; 59 60 // Check levels 61 Main.logLevel = 5; 62 assertTrue(Main.isTraceEnabled()); 63 assertTrue(Main.isDebugEnabled()); 64 65 Main.logLevel = 4; 66 assertFalse(Main.isTraceEnabled()); 67 assertTrue(Main.isDebugEnabled()); 68 69 Main.logLevel = 3; 70 assertFalse(Main.isTraceEnabled()); 71 assertFalse(Main.isDebugEnabled()); 72 73 Main.logLevel = defaultLevel; 13 74 } 14 75 } -
trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java
r7937 r8857 16 16 17 17 /** 18 * Unit tests for class AlignInLineAction.18 * Unit tests for class {@link AlignInLineAction}. 19 19 */ 20 20 public final class AlignInLineActionTest { -
trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java
r8856 r8857 22 22 23 23 /** 24 * Unit tests for class CombineWayAction.24 * Unit tests for class {@link CombineWayAction}. 25 25 */ 26 26 public class CombineWayActionTest { … … 31 31 @BeforeClass 32 32 public static void setUp() { 33 JOSMFixture.createUnitTestFixture().init( false);33 JOSMFixture.createUnitTestFixture().init(); 34 34 } 35 35 -
trunk/test/unit/org/openstreetmap/josm/actions/CopyActionTest.java
r8624 r8857 2 2 package org.openstreetmap.josm.actions; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import java.util.Arrays; … … 14 13 import org.openstreetmap.josm.data.osm.Way; 15 14 15 /** 16 * Unit tests for class {@link CopyAction}. 17 */ 16 18 public class CopyActionTest { 17 19 20 /** 21 * Setup test. 22 */ 18 23 @BeforeClass 19 24 public static void setUpBeforeClass() { … … 24 29 public void testCopyStringWay() throws Exception { 25 30 final Way way = new Way(123L); 26 assert That(CopyAction.getCopyString(Collections.singleton(way)), is("way 123"));31 assertEquals("way 123", CopyAction.getCopyString(Collections.singleton(way))); 27 32 } 28 33 … … 31 36 final Way way = new Way(123L); 32 37 final Relation relation = new Relation(456); 33 assert That(CopyAction.getCopyString(Arrays.asList(way, relation)), is("way 123,relation 456"));34 assert That(CopyAction.getCopyString(Arrays.asList(relation, way)), is("relation 456,way 123"));38 assertEquals("way 123,relation 456", CopyAction.getCopyString(Arrays.asList(way, relation))); 39 assertEquals("relation 456,way 123", CopyAction.getCopyString(Arrays.asList(relation, way))); 35 40 } 36 41 } -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r8624 r8857 31 31 32 32 /** 33 * Unit tests for class CreateCircleAction.33 * Unit tests for class {@link CreateCircleAction}. 34 34 */ 35 35 public final class CreateCircleActionTest { -
trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
r8624 r8857 18 18 19 19 /** 20 * Unit tests for class SplitWayAction.20 * Unit tests for class {@link SplitWayAction}. 21 21 */ 22 22 public final class SplitWayActionTest { -
trunk/test/unit/org/openstreetmap/josm/actions/UnJoinNodeWayActionTest.java
r8624 r8857 17 17 18 18 /** 19 * Unit tests for class UnJoinNodeWayAction.19 * Unit tests for class {@link UnJoinNodeWayAction}. 20 20 */ 21 21 public final class UnJoinNodeWayActionTest { -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r8836 r8857 24 24 import org.openstreetmap.josm.data.osm.DataSet; 25 25 import org.openstreetmap.josm.data.osm.Node; 26 import org.openstreetmap.josm.data.osm.OsmPrimitive;27 26 import org.openstreetmap.josm.data.osm.Way; 28 27 import org.openstreetmap.josm.gui.MapFrame; … … 30 29 import org.openstreetmap.josm.gui.layer.Layer; 31 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 32 import org.openstreetmap.josm.tools.Predicate;33 31 34 32 /** … … 37 35 public class SelectActionTest { 38 36 39 public class MapViewMock extends MapView { 40 public OsmDataLayer layer; 41 public DataSet currentDataSet; 42 43 public Predicate<OsmPrimitive> isSelectablePredicate = 44 new Predicate<OsmPrimitive>() { 45 @Override 46 public boolean evaluate(OsmPrimitive prim) { 47 return true; 48 } 49 }; 37 private class MapViewMock extends MapView { 38 private OsmDataLayer layer; 39 private DataSet currentDataSet; 50 40 51 41 MapViewMock(DataSet dataSet, OsmDataLayer layer) { … … 65 55 @Override 66 56 public void removeMouseListener(MouseListener ml) {} 67 68 public void addMouseMotionListener(MouseListener ml) {}69 70 public void removeMouseMotionListener(MouseListener ml) {}71 72 public void mvRepaint() {}73 57 74 58 @Override -
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r8838 r8857 13 13 import org.openstreetmap.josm.data.osm.Way; 14 14 15 /** 16 * Unit tests for class {@link SearchCompiler}. 17 */ 15 18 public class SearchCompilerTest { 16 19 … … 109 112 public void testNthParseNegative() throws Exception { 110 113 Assert.assertThat(SearchCompiler.compile("nth:-1").toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}")); 111 112 114 } 113 115 } -
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
r8836 r8857 13 13 import org.openstreetmap.josm.JOSMFixture; 14 14 15 /** 16 * Unit tests for class {@link JCSCachedTileLoaderJob}. 17 */ 15 18 public class JCSCachedTileLoaderJobTest { 19 16 20 private static class TestCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, CacheEntry> { 17 21 private String url; … … 44 48 return new CacheEntry("dummy".getBytes()); 45 49 } 46 47 50 } 48 51 49 52 private static class Listener implements ICachedLoaderListener { 50 private CacheEntry data;51 53 private CacheEntryAttributes attributes; 52 private LoadResult result;53 54 private boolean ready; 54 55 55 56 @Override 56 57 public synchronized void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, LoadResult result) { 57 this.data = data;58 58 this.attributes = attributes; 59 this.result = result;60 59 this.ready = true; 61 60 this.notify(); 62 61 } 62 } 63 63 64 }65 64 /** 66 65 * Setup test. … … 108 107 } 109 108 assertEquals(responseCode, listener.attributes.getResponseCode()); 110 111 109 } 112 110 … … 114 112 return new TestCachedTileLoaderJob("http://httpstat.us/" + responseCode); 115 113 } 116 117 114 } 118 -
trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java
r7937 r8857 6 6 import org.junit.Test; 7 7 8 /** 9 * Unit tests for class {@link LatLon}. 10 */ 8 11 public class LatLonTest { 9 12 -
trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java
r8770 r8857 20 20 import org.openstreetmap.josm.data.projection.Projections; 21 21 22 /** 23 * Unit tests for class {@link TemplatedWMSTileSource}. 24 */ 22 25 public class TemplatedWMSTileSourceTest { 23 26 24 27 private ImageryInfo testImageryWMS = new ImageryInfo("test imagery", "http://localhost", "wms", null, null); 25 28 private ImageryInfo testImageryTMS = new ImageryInfo("test imagery", "http://localhost", "tms", null, null); 26 //private TileSource testSource = new TemplatedWMSTileSource(testImageryWMS); 29 27 30 /** 28 31 * Setup test. … … 52 55 verifyLocation(source, new LatLon(53.5937132, 19.5652017)); 53 56 verifyLocation(source, new LatLon(53.501565692302854, 18.54455233898721)); 54 55 57 } 56 58 … … 107 109 verifyLocation(source, new LatLon(60, 18), 3); 108 110 verifyLocation(source, new LatLon(60, 18)); 109 110 111 } 111 112 … … 120 121 verifyLocation(source, new LatLon(60, 18.1), 3); 121 122 verifyLocation(source, new LatLon(60, 18.1)); 122 123 123 } 124 124 … … 129 129 assertEquals(expected.getLat(), result.lat(), 1e-4); 130 130 assertEquals(expected.getLon(), result.lon(), 1e-4); 131 //assertTrue("result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString(), result.equalsEpsilon(expected));132 131 LatLon tileCenter = new Bounds(result, getTileLatLon(source, x+1, y+1, z)).getCenter(); 133 132 TileXY backwardsResult = source.latLonToTileXY(tileCenter.toCoordinate(), z); -
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java
r8855 r8857 18 18 import org.openstreetmap.josm.data.projection.Projections; 19 19 20 /** 21 * Unit tests for class {@link WMTSTileSource}. 22 */ 20 23 public class WMTSTileSourceTest { 21 24 … … 28 31 private ImageryInfo testImageryOntario = getImagery("test/data/wmts/WMTSCapabilities-Ontario.xml"); 29 32 33 /** 34 * Setup test. 35 */ 30 36 @BeforeClass 31 37 public static void setUp() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r8510 r8857 14 14 import org.openstreetmap.josm.data.APIDataSet; 15 15 16 /** 17 * Unit tests for class {@link APIDataSet}. 18 */ 16 19 public class APIDataSetTest { 17 20 21 /** 22 * Setup test. 23 */ 18 24 @BeforeClass 19 25 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r8565 r8857 24 24 import org.openstreetmap.josm.data.projection.Projections; 25 25 26 /** 27 * Unit tests for class {@link DataSetMerger}. 28 */ 26 29 public class DataSetMergerTest { 27 30 31 /** 32 * Setup test. 33 */ 28 34 @BeforeClass 29 35 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r8510 r8857 24 24 import org.openstreetmap.josm.io.OsmReader; 25 25 26 /** 27 * Unit tests for class {@link Filter}. 28 */ 26 29 public class FilterTest { 27 30 … … 35 38 36 39 @Test 37 public void basic _test() throws ParseError {40 public void basic() throws ParseError { 38 41 DataSet ds = new DataSet(); 39 42 Node n1 = new Node(new LatLon(0, 0)); … … 63 66 64 67 @Test 65 public void filter _test() throws ParseError, IllegalDataException, IOException {68 public void filter() throws ParseError, IllegalDataException, IOException { 66 69 for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) { 67 70 DataSet ds; -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java
r8510 r8857 15 15 * Some unit test cases for basic tag management on {@link OsmPrimitive}. Uses 16 16 * {@link Node} for the tests, {@link OsmPrimitive} is abstract. 17 *18 17 */ 19 18 public class OsmPrimitiveKeyHandlingTest { 20 19 20 /** 21 * Setup test. 22 */ 21 23 @BeforeClass 22 24 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
r8510 r8857 15 15 public class OsmPrimitiveTest { 16 16 17 /** 18 * Setup test. 19 */ 17 20 @BeforeClass 18 21 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmUtilsTest.java
r8624 r8857 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 import static org.junit.Assert.assertTrue; 7 6 … … 12 11 public class OsmUtilsTest { 13 12 13 /** 14 * Setup test. 15 */ 14 16 @BeforeClass 15 17 public static void setUp() { … … 21 23 final OsmPrimitive p = OsmUtils.createPrimitive("way name=Foo railway=rail"); 22 24 assertTrue(p instanceof Way); 23 assert That(p.keySet().size(), is(2));24 assert That(p.get("name"), is("Foo"));25 assert That(p.get("railway"), is("rail"));25 assertEquals(2, p.keySet().size()); 26 assertEquals("Foo", p.get("name")); 27 assertEquals("rail", p.get("railway")); 26 28 } 27 29 … … 29 31 public void testArea() throws Exception { 30 32 final OsmPrimitive p = OsmUtils.createPrimitive("area name=Foo railway=rail"); 31 assert That(p.getType(), is(OsmPrimitiveType.WAY));33 assertEquals(OsmPrimitiveType.WAY, p.getType()); 32 34 assertTrue(p.getKeys().equals(OsmUtils.createPrimitive("way name=Foo railway=rail").getKeys())); 33 34 35 } 35 36 … … 38 39 OsmUtils.createPrimitive("noway name=Foo"); 39 40 } 40 41 41 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r7937 r8857 23 23 public class QuadBucketsTest { 24 24 25 /** 26 * Setup test. 27 */ 25 28 @BeforeClass 26 29 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java
r8514 r8857 12 12 import org.openstreetmap.josm.data.osm.User; 13 13 14 /** 15 * Unit tests for class {@link HistoryNode}. 16 */ 14 17 public class HistoryNodeTest { 15 18 -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryWayTest.java
r8513 r8857 14 14 import org.openstreetmap.josm.data.osm.User; 15 15 16 /** 17 * Unit tests for class {@link HistoryWay}. 18 */ 16 19 public class HistoryWayTest { 17 20 -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r8510 r8857 21 21 import org.openstreetmap.josm.data.osm.Way; 22 22 23 /** 24 * Unit tests for class {@link MergeSourceBuildingVisitor}. 25 */ 23 26 public class MergeSourceBuildingVisitorTest { 24 27 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
r8741 r8857 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.hamcrest.CoreMatchers.notNullValue; 4 import static org.junit.Assert.assertEquals; 6 5 import static org.junit.Assert.assertFalse; 7 import static org.junit.Assert.assert That;6 import static org.junit.Assert.assertNotNull; 8 7 import static org.junit.Assert.assertTrue; 9 8 … … 33 32 34 33 /** 35 * JUnit Test of MapCSS TagChecker.34 * JUnit Test of {@link MapCSSTagChecker}. 36 35 */ 37 36 public class MapCSSTagCheckerTest { … … 53 52 @Test 54 53 public void testNaturalMarsh() throws Exception { 55 56 54 final List<MapCSSTagChecker.TagCheck> checks = MapCSSTagChecker.TagCheck.readMapCSS(new StringReader("" + 57 55 "*[natural=marsh] {\n" + … … 61 59 " fixAdd: \"wetland=marsh\";\n" + 62 60 "}")); 63 assert That(checks.size(), is(1));61 assertEquals(1, checks.size()); 64 62 final MapCSSTagChecker.TagCheck check = checks.get(0); 65 assert That(check, notNullValue());66 assert That(check.getDescription(null), is("{0.key}=null is deprecated"));67 assert That(check.fixCommands.get(0).toString(), is("fixRemove: {0.key}"));68 assert That(check.fixCommands.get(1).toString(), is("fixAdd: natural=wetland"));69 assert That(check.fixCommands.get(2).toString(), is("fixAdd: wetland=marsh"));63 assertNotNull(check); 64 assertEquals("{0.key}=null is deprecated", check.getDescription(null)); 65 assertEquals("fixRemove: {0.key}", check.fixCommands.get(0).toString()); 66 assertEquals("fixAdd: natural=wetland", check.fixCommands.get(1).toString()); 67 assertEquals("fixAdd: wetland=marsh", check.fixCommands.get(2).toString()); 70 68 final Node n1 = new Node(); 71 69 n1.put("natural", "marsh"); 72 70 assertTrue(check.evaluate(n1)); 73 assertThat(check.getErrorForPrimitive(n1).getMessage(), is("natural=marsh is deprecated")); 74 assertThat(check.getErrorForPrimitive(n1).getSeverity(), is(Severity.WARNING)); 75 assertThat(check.fixPrimitive(n1).getDescriptionText(), is("Sequence: Fix of natural=marsh is deprecated")); 76 assertThat(((ChangePropertyCommand) check.fixPrimitive(n1).getChildren().iterator().next()).getTags().toString(), 77 is("{natural=}")); 71 assertEquals("natural=marsh is deprecated", check.getErrorForPrimitive(n1).getMessage()); 72 assertEquals(Severity.WARNING, check.getErrorForPrimitive(n1).getSeverity()); 73 assertEquals("Sequence: Fix of natural=marsh is deprecated", check.fixPrimitive(n1).getDescriptionText()); 74 assertEquals("{natural=}", ((ChangePropertyCommand) check.fixPrimitive(n1).getChildren().iterator().next()).getTags().toString()); 78 75 final Node n2 = new Node(); 79 76 n2.put("natural", "wood"); 80 77 assertFalse(check.evaluate(n2)); 81 assert That(MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}", null),82 is("The key is natural and the value is marsh"));78 assertEquals("The key is natural and the value is marsh", 79 MapCSSTagChecker.TagCheck.insertArguments(check.rule.selectors.get(0), "The key is {0.key} and the value is {0.value}", null)); 83 80 } 84 81 … … 92 89 "}")).get(0); 93 90 final Command command = check.fixPrimitive(p); 94 assertT hat(command instanceof SequenceCommand, is(true));91 assertTrue(command instanceof SequenceCommand); 95 92 final Iterator<PseudoCommand> it = command.getChildren().iterator(); 96 assertT hat(it.next() instanceof ChangePropertyKeyCommand, is(true));97 assertT hat(it.next() instanceof ChangePropertyCommand, is(true));93 assertTrue(it.next() instanceof ChangePropertyKeyCommand); 94 assertTrue(it.next() instanceof ChangePropertyCommand); 98 95 } 99 96 … … 104 101 final OsmPrimitive p = OsmUtils.createPrimitive("way alt_name=Foo"); 105 102 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 106 assert That(errors.size(), is(1));107 assert That(errors.iterator().next().getMessage(), is("has alt_name but not name"));108 assert That(errors.iterator().next().getIgnoreSubGroup(), is("3000_*[.+_name][!name]"));103 assertEquals(1, errors.size()); 104 assertEquals("has alt_name but not name", errors.iterator().next().getMessage()); 105 assertEquals("3000_*[.+_name][!name]", errors.iterator().next().getIgnoreSubGroup()); 109 106 } 110 107 … … 115 112 final OsmPrimitive p = OsmUtils.createPrimitive("way highway=footway foot=no"); 116 113 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 117 assert That(errors.size(), is(1));118 assert That(errors.iterator().next().getMessage(), is("footway used with foot=no"));119 assert That(errors.iterator().next().getIgnoreSubGroup(), is("3000_way[highway=footway][foot]"));114 assertEquals(1, errors.size()); 115 assertEquals("footway used with foot=no", errors.iterator().next().getMessage()); 116 assertEquals("3000_way[highway=footway][foot]", errors.iterator().next().getIgnoreSubGroup()); 120 117 } 121 118 … … 125 122 "@media (min-josm-version: 1) { *[foo] { throwWarning: \"!\"; } }\n" + 126 123 "@media (min-josm-version: 2147483647) { *[bar] { throwWarning: \"!\"; } }\n"); 127 assert That(test.getErrorsForPrimitive(OsmUtils.createPrimitive("way foo=1"), false).size(), is(1));128 assert That(test.getErrorsForPrimitive(OsmUtils.createPrimitive("way bar=1"), false).size(), is(0));124 assertEquals(1, test.getErrorsForPrimitive(OsmUtils.createPrimitive("way foo=1"), false).size()); 125 assertEquals(0, test.getErrorsForPrimitive(OsmUtils.createPrimitive("way bar=1"), false).size()); 129 126 } 130 127 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java
r8680 r8857 4 4 import static org.CustomMatchers.hasSize; 5 5 import static org.CustomMatchers.isEmpty; 6 import static org.hamcrest.CoreMatchers.is;7 6 import static org.hamcrest.CoreMatchers.not; 7 import static org.junit.Assert.assertEquals; 8 8 import static org.junit.Assert.assertFalse; 9 9 import static org.junit.Assert.assertThat; … … 56 56 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise"), isEmpty()); 57 57 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise"), hasSize(1)); 58 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise")59 .get(0).getSeverity(), is(Severity.OTHER));60 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise")61 .get(0).getPrettifiedValue(), is("Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise"));62 } 63 64 @Test 65 public void testI18n() throws Exception{58 assertEquals(Severity.OTHER, OPENING_HOUR_TEST.checkOpeningHourSyntax( 59 key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise").get(0).getSeverity()); 60 assertEquals("Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise", OPENING_HOUR_TEST.checkOpeningHourSyntax( 61 key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise").get(0).getPrettifiedValue()); 62 } 63 64 @Test 65 public void testI18n() { 66 66 assertTrue(OPENING_HOUR_TEST.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "de") 67 67 .get(0).toString().contains("Unerwartetes Zeichen")); … … 78 78 final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Tue"); 79 79 assertThat(errors, hasSize(2)); 80 assert That(errors.get(0).getMessage(), is(key + " - Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)"));81 assert That(errors.get(0).getSeverity(), is(Severity.WARNING));82 assert That(errors.get(1).getMessage(), is(key +80 assertEquals(key + " - Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)", errors.get(0).getMessage()); 81 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 82 assertEquals(key + 83 83 " - Mo-Tue <--- (This rule is not very explicit because there is no time selector being used."+ 84 " Please add a time selector to this rule or use a comment to make it more explicit.)" ));85 assert That(errors.get(1).getSeverity(), is(Severity.WARNING));84 " Please add a time selector to this rule or use a comment to make it more explicit.)", errors.get(1).getMessage()); 85 assertEquals(Severity.WARNING, errors.get(1).getSeverity()); 86 86 } 87 87 … … 94 94 final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00"); 95 95 assertThat(errors, hasSize(2)); 96 assert That(errors.get(0).getMessage(), is(key + " - Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)"));97 assert That(errors.get(0).getSeverity(), is(Severity.WARNING));98 assert That(errors.get(0).getPrettifiedValue(), is("Sa-Su 10:00-20:00"));99 assert That(errors.get(1).getMessage(), is(key + " - Sa-Su 10.00-20. <--- (Please use \":\" as hour/minute-separator)"));100 assert That(errors.get(1).getSeverity(), is(Severity.WARNING));96 assertEquals(key + " - Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)", errors.get(0).getMessage()); 97 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 98 assertEquals("Sa-Su 10:00-20:00", errors.get(0).getPrettifiedValue()); 99 assertEquals(key + " - Sa-Su 10.00-20. <--- (Please use \":\" as hour/minute-separator)", errors.get(1).getMessage()); 100 assertEquals(Severity.WARNING, errors.get(1).getSeverity()); 101 101 } 102 102 … … 118 118 final String key = "opening_hours"; 119 119 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext"), hasSize(1)); 120 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext").get(0).getMessage(),121 is(key + " - ba <--- (Unexpected token: \"b\" Invalid/unsupported syntax.)"));120 assertEquals(key + " - ba <--- (Unexpected token: \"b\" Invalid/unsupported syntax.)", 121 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext").get(0).getMessage()); 122 122 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1)); 123 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getMessage(),124 is(key + " - 5.00 p <--- (hyphen (-) or open end (+) in time range expected. "125 + "For working with points in time, the mode for opening_hours.js has to be altered. Maybe wrong tag?)"));123 assertEquals(key + " - 5.00 p <--- (hyphen (-) or open end (+) in time range expected. " 124 + "For working with points in time, the mode for opening_hours.js has to be altered. Maybe wrong tag?)", 125 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m").get(0).getMessage()); 126 126 } 127 127 … … 142 142 final String key = "opening_hours"; 143 143 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00"), hasSize(1)); 144 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getSeverity(), is(Severity.OTHER));145 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getPrettifiedValue(), is("09:00-18:00"));144 assertEquals(Severity.OTHER, OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getSeverity()); 145 assertEquals("09:00-18:00", OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getPrettifiedValue()); 146 146 } 147 147 … … 152 152 public void testCheckOpeningHourSyntaxTicket9367() { 153 153 final String key = "opening_hours"; 154 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity(), is(Severity.WARNING));155 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage(),156 is(key + " - Mo,Tu 04-17 <--- (Time range without minutes specified. "157 + "Not very explicit! Please use this syntax instead \"04:00-17:00\".)"));158 assert That(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue(), is("Mo,Tu 04:00-17:00"));154 assertEquals(Severity.WARNING, OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity()); 155 assertEquals(key + " - Mo,Tu 04-17 <--- (Time range without minutes specified. " 156 + "Not very explicit! Please use this syntax instead \"04:00-17:00\".)", 157 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getMessage()); 158 assertEquals("Mo,Tu 04:00-17:00", OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getPrettifiedValue()); 159 159 } 160 160 … … 174 174 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", 175 175 OpeningHourTest.CheckMode.BOTH), hasSize(1)); 176 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", 177 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue(), is("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00")); 178 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", 179 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue(), is("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00")); 176 assertEquals("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00", 177 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", 178 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue()); 179 assertEquals("Mo-Fr 00:00-00:30,04:00-00:30; Sa,Su,PH 00:00-24:00", 180 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", 181 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue()); 180 182 } 181 183 … … 194 196 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", 195 197 OpeningHourTest.CheckMode.BOTH), hasSize(1)); 196 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", 197 OpeningHourTest.CheckMode.BOTH).get(0).getSeverity(), is(Severity.OTHER)); 198 assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", 199 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue(), is("Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00")); 198 assertEquals(Severity.OTHER, 199 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", 200 OpeningHourTest.CheckMode.BOTH).get(0).getSeverity()); 201 assertEquals("Mo-Fr 13:30,17:45,19:00; Sa 15:00; Su 11:00", 202 OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", 203 OpeningHourTest.CheckMode.BOTH).get(0).getPrettifiedValue()); 200 204 } 201 205 -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r8753 r8857 2 2 package org.openstreetmap.josm.data.validation.tests; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import java.io.IOException; … … 16 15 import org.openstreetmap.josm.gui.tagging.TaggingPresets; 17 16 17 /** 18 * JUnit Test of {@link TagChecker}. 19 */ 18 20 public class TagCheckerTest { 21 19 22 /** 20 23 * Setup test. … … 37 40 public void testInvalidKey() throws Exception { 38 41 final List<TestError> errors = test(OsmUtils.createPrimitive("node Name=Main")); 39 assert That(errors.size(), is(1));40 assert That(errors.get(0).getMessage(), is("Misspelled property key"));41 assert That(errors.get(0).getDescription(), is("Key 'Name' looks like 'name'."));42 assertEquals(1, errors.size()); 43 assertEquals("Misspelled property key", errors.get(0).getMessage()); 44 assertEquals("Key 'Name' looks like 'name'.", errors.get(0).getDescription()); 42 45 } 43 46 … … 45 48 public void testMisspelledKey() throws Exception { 46 49 final List<TestError> errors = test(OsmUtils.createPrimitive("node landuse;=forest")); 47 assert That(errors.size(), is(1));48 assert That(errors.get(0).getMessage(), is("Misspelled property key"));49 assert That(errors.get(0).getDescription(), is("Key 'landuse;' looks like 'landuse'."));50 assertEquals(1, errors.size()); 51 assertEquals("Misspelled property key", errors.get(0).getMessage()); 52 assertEquals("Key 'landuse;' looks like 'landuse'.", errors.get(0).getDescription()); 50 53 } 51 54 … … 53 56 public void testTranslatedNameKey() throws Exception { 54 57 final List<TestError> errors = test(OsmUtils.createPrimitive("node namez=Baz")); 55 assert That(errors.size(), is(1));56 assert That(errors.get(0).getMessage(), is("Presets do not contain property key"));57 assert That(errors.get(0).getDescription(), is("Key 'namez' not in presets."));58 assertEquals(1, errors.size()); 59 assertEquals("Presets do not contain property key", errors.get(0).getMessage()); 60 assertEquals("Key 'namez' not in presets.", errors.get(0).getDescription()); 58 61 } 59 62 … … 61 64 public void testMisspelledTag() throws Exception { 62 65 final List<TestError> errors = test(OsmUtils.createPrimitive("node landuse=forrest")); 63 assert That(errors.size(), is(1));64 assert That(errors.get(0).getMessage(), is("Presets do not contain property value"));65 assert That(errors.get(0).getDescription(), is("Value 'forrest' for key 'landuse' not in presets."));66 assertEquals(1, errors.size()); 67 assertEquals("Presets do not contain property value", errors.get(0).getMessage()); 68 assertEquals("Value 'forrest' for key 'landuse' not in presets.", errors.get(0).getDescription()); 66 69 } 67 68 70 } -
trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java
r8509 r8857 2 2 package org.openstreetmap.josm.gui; 3 3 4 import static org. hamcrest.CoreMatchers.is;4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertSame; 6 import static org.junit.Assert.assertThat;7 6 8 7 import java.io.FileInputStream; … … 30 29 /** 31 30 * Unit tests of {@link DefaultNameFormatter} class. 32 *33 31 */ 34 32 public class DefaultNameFormatterTest { … … 89 87 @Test 90 88 public void testRelationName() { 91 assertThat(getFormattedRelationName("X=Y"), is("relation (0, 0 members)")); 92 assertThat(getFormattedRelationName("name=Foo"), is("relation (\"Foo\", 0 members)")); 93 assertThat(getFormattedRelationName("type=route route=tram ref=123"), is("route (\"123\", 0 members)")); 94 assertThat(getFormattedRelationName("type=multipolygon building=yes"), is("multipolygon (\"building\", 0 members)")); 95 assertThat(getFormattedRelationName("type=multipolygon building=yes ref=123"), is("multipolygon (\"123\", 0 members)")); 96 assertThat(getFormattedRelationName("type=multipolygon building=yes addr:housenumber=123"), 97 is("multipolygon (\"building\", 0 members)")); 98 assertThat(getFormattedRelationName("type=multipolygon building=residential addr:housenumber=123"), 99 is("multipolygon (\"residential\", 0 members)")); 89 assertEquals("relation (0, 0 members)", 90 getFormattedRelationName("X=Y")); 91 assertEquals("relation (\"Foo\", 0 members)", 92 getFormattedRelationName("name=Foo")); 93 assertEquals("route (\"123\", 0 members)", 94 getFormattedRelationName("type=route route=tram ref=123")); 95 assertEquals("multipolygon (\"building\", 0 members)", 96 getFormattedRelationName("type=multipolygon building=yes")); 97 assertEquals("multipolygon (\"123\", 0 members)", 98 getFormattedRelationName("type=multipolygon building=yes ref=123")); 99 assertEquals("multipolygon (\"building\", 0 members)", 100 getFormattedRelationName("type=multipolygon building=yes addr:housenumber=123")); 101 assertEquals("multipolygon (\"residential\", 0 members)", 102 getFormattedRelationName("type=multipolygon building=residential addr:housenumber=123")); 100 103 } 101 104 … … 105 108 @Test 106 109 public void testWayName() { 107 assertThat(getFormattedWayName("building=yes"), is("building (0 nodes)")); 108 assertThat(getFormattedWayName("building=yes addr:housenumber=123"), is("House number 123 (0 nodes)")); 109 assertThat(getFormattedWayName("building=yes addr:housenumber=123 addr:street=FooStreet"), 110 is("House number 123 at FooStreet (0 nodes)")); 111 assertThat(getFormattedWayName("building=yes addr:housenumber=123 addr:housename=FooName"), is("House FooName (0 nodes)")); 110 assertEquals("building (0 nodes)", getFormattedWayName("building=yes")); 111 assertEquals("House number 123 (0 nodes)", getFormattedWayName("building=yes addr:housenumber=123")); 112 assertEquals("House number 123 at FooStreet (0 nodes)", getFormattedWayName("building=yes addr:housenumber=123 addr:street=FooStreet")); 113 assertEquals("House FooName (0 nodes)", getFormattedWayName("building=yes addr:housenumber=123 addr:housename=FooName")); 112 114 } 113 115 -
trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
r8759 r8857 2 2 package org.openstreetmap.josm.gui; 3 3 4 import static org.hamcrest.CoreMatchers.is;5 4 import static org.junit.Assert.assertEquals; 6 5 import static org.junit.Assert.assertThat; … … 107 106 component.zoomToFactor(0.5); 108 107 assertEquals(initialScale / 2, component.getScale(), 0.00000001); 109 assert That(component.getCenter(), is(center));108 assertEquals(center, component.getCenter()); 110 109 component.zoomToFactor(2); 111 110 assertEquals(initialScale, component.getScale(), 0.00000001); 112 assert That(component.getCenter(), is(center));111 assertEquals(center, component.getCenter()); 113 112 114 113 // zoomToFactor(EastNorth, double) … … 116 115 component.zoomToFactor(newCenter, 0.5); 117 116 assertEquals(initialScale / 2, component.getScale(), 0.00000001); 118 assert That(component.getCenter(), is(newCenter));117 assertEquals(newCenter, component.getCenter()); 119 118 component.zoomToFactor(newCenter, 2); 120 119 assertEquals(initialScale, component.getScale(), 0.00000001); 121 assert That(component.getCenter(), is(newCenter));120 assertEquals(newCenter, component.getCenter()); 122 121 } 123 122 -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java
r8514 r8857 32 32 private DatasetFactory their = new DatasetFactory(); 33 33 34 /** 35 * Setup test. 36 */ 34 37 @BeforeClass 35 38 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
r8511 r8857 42 42 PropertiesMergeModel model; 43 43 44 /** 45 * Setup test. 46 */ 44 47 @BeforeClass 45 48 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeItemTest.java
r8513 r8857 14 14 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeItem; 15 15 16 /** 17 * Unit tests of {@link TagMergeItem} class. 18 */ 16 19 public class TagMergeItemTest { 17 20 21 /** 22 * Setup test. 23 */ 18 24 @BeforeClass 19 25 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java
r8510 r8857 19 19 import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeModel; 20 20 21 /** 22 * Unit tests of {@link TagMergeModel} class. 23 */ 21 24 @SuppressWarnings("unchecked") 22 25 public class TagMergeModelTest { 23 26 27 /** 28 * Setup test. 29 */ 24 30 @BeforeClass 25 31 public static void init() { -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/LatLonDialogTest.java
r8540 r8857 2 2 package org.openstreetmap.josm.gui.dialogs; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import org.junit.Test; 8 7 import org.openstreetmap.josm.data.coor.LatLon; 9 8 9 /** 10 * Unit tests of {@link LatLonDialog} class. 11 */ 10 12 public class LatLonDialogTest { 13 14 /** 15 * Unit test of {@link LatLonDialog#parseLatLon} method. 16 */ 11 17 @Test 12 public void test1() throws Exception { 13 assertThat(LatLonDialog.parseLatLon("49.29918° 19.24788°"), is(new LatLon(49.29918, 19.24788))); 14 } 15 16 @Test 17 public void test2() throws Exception { 18 assertThat(LatLonDialog.parseLatLon("N 49.29918 E 19.24788°"), is(new LatLon(49.29918, 19.24788))); 19 } 20 21 @Test 22 public void test3() throws Exception { 23 assertThat(LatLonDialog.parseLatLon("49.29918° 19.24788°"), is(new LatLon(49.29918, 19.24788))); 24 } 25 26 @Test 27 public void test4() throws Exception { 28 assertThat(LatLonDialog.parseLatLon("N 49.29918 E 19.24788"), is(new LatLon(49.29918, 19.24788))); 29 } 30 31 @Test 32 public void test5() throws Exception { 33 assertThat(LatLonDialog.parseLatLon("W 49°29.918' S 19°24.788'"), is(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60))); 34 } 35 36 @Test 37 public void test6() throws Exception { 38 assertThat(LatLonDialog.parseLatLon("N 49°29'04\" E 19°24'43\""), 39 is(new LatLon(49 + 29. / 60 + 04. / 3600, 19 + 24. / 60 + 43. / 3600))); 40 } 41 42 @Test 43 public void test7() throws Exception { 44 assertThat(LatLonDialog.parseLatLon("49.29918 N, 19.24788 E"), is(new LatLon(49.29918, 19.24788))); 45 } 46 47 @Test 48 public void test8() throws Exception { 49 assertThat(LatLonDialog.parseLatLon("49°29'21\" N 19°24'38\" E"), 50 is(new LatLon(49 + 29. / 60 + 21. / 3600, 19 + 24. / 60 + 38. / 3600))); 51 } 52 53 @Test 54 public void test9() throws Exception { 55 assertThat(LatLonDialog.parseLatLon("49 29 51, 19 24 18"), is(new LatLon(49 + 29. / 60 + 51. / 3600, 19 + 24. / 60 + 18. / 3600))); 56 } 57 58 @Test 59 public void test10() throws Exception { 60 assertThat(LatLonDialog.parseLatLon("49 29, 19 24"), is(new LatLon(49 + 29. / 60, 19 + 24. / 60))); 61 } 62 63 @Test 64 public void test11() throws Exception { 65 assertThat(LatLonDialog.parseLatLon("E 49 29, N 19 24"), is(new LatLon(19 + 24. / 60, 49 + 29. / 60))); 66 } 67 68 @Test 69 public void test12() throws Exception { 70 assertThat(LatLonDialog.parseLatLon("49° 29; 19° 24"), is(new LatLon(49 + 29. / 60, 19 + 24. / 60))); 71 } 72 73 @Test 74 public void test13() throws Exception { 75 assertThat(LatLonDialog.parseLatLon("49° 29; 19° 24"), is(new LatLon(49 + 29. / 60, 19 + 24. / 60))); 76 } 77 78 @Test 79 public void test14() throws Exception { 80 assertThat(LatLonDialog.parseLatLon("N 49° 29, W 19° 24"), is(new LatLon(49 + 29. / 60, -19 - 24. / 60))); 81 } 82 83 @Test 84 public void test15() throws Exception { 85 assertThat(LatLonDialog.parseLatLon("49° 29.5 S, 19° 24.6 E"), is(new LatLon(-49 - 29.5 / 60, 19 + 24.6 / 60))); 86 } 87 88 @Test 89 public void test16() throws Exception { 90 assertThat(LatLonDialog.parseLatLon("N 49 29.918 E 19 15.88"), is(new LatLon(49 + 29.918 / 60, 19 + 15.88 / 60))); 91 } 92 93 @Test 94 public void test17() throws Exception { 95 assertThat(LatLonDialog.parseLatLon("49 29.4 19 24.5"), is(new LatLon(49 + 29.4 / 60, 19 + 24.5 / 60))); 96 } 97 98 @Test 99 public void test18() throws Exception { 100 assertThat(LatLonDialog.parseLatLon("-49 29.4 N -19 24.5 W"), is(new LatLon(-49 - 29.4 / 60, 19 + 24.5 / 60))); 18 public void testparseLatLon() { 19 assertEquals(new LatLon(49.29918, 19.24788), LatLonDialog.parseLatLon("49.29918° 19.24788°")); 20 assertEquals(new LatLon(49.29918, 19.24788), LatLonDialog.parseLatLon("N 49.29918 E 19.24788°")); 21 assertEquals(new LatLon(49.29918, 19.24788), LatLonDialog.parseLatLon("49.29918° 19.24788°")); 22 assertEquals(new LatLon(49.29918, 19.24788), LatLonDialog.parseLatLon("N 49.29918 E 19.24788")); 23 assertEquals(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60), LatLonDialog.parseLatLon("W 49°29.918' S 19°24.788'")); 24 assertEquals(new LatLon(49 + 29. / 60 + 04. / 3600, 19 + 24. / 60 + 43. / 3600), LatLonDialog.parseLatLon("N 49°29'04\" E 19°24'43\"")); 25 assertEquals(new LatLon(49.29918, 19.24788), LatLonDialog.parseLatLon("49.29918 N, 19.24788 E")); 26 assertEquals(new LatLon(49 + 29. / 60 + 21. / 3600, 19 + 24. / 60 + 38. / 3600), LatLonDialog.parseLatLon("49°29'21\" N 19°24'38\" E")); 27 assertEquals(new LatLon(49 + 29. / 60 + 51. / 3600, 19 + 24. / 60 + 18. / 3600), LatLonDialog.parseLatLon("49 29 51, 19 24 18")); 28 assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLonDialog.parseLatLon("49 29, 19 24")); 29 assertEquals(new LatLon(19 + 24. / 60, 49 + 29. / 60), LatLonDialog.parseLatLon("E 49 29, N 19 24")); 30 assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLonDialog.parseLatLon("49° 29; 19° 24")); 31 assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLonDialog.parseLatLon("49° 29; 19° 24")); 32 assertEquals(new LatLon(49 + 29. / 60, -19 - 24. / 60), LatLonDialog.parseLatLon("N 49° 29, W 19° 24")); 33 assertEquals(new LatLon(-49 - 29.5 / 60, 19 + 24.6 / 60), LatLonDialog.parseLatLon("49° 29.5 S, 19° 24.6 E")); 34 assertEquals(new LatLon(49 + 29.918 / 60, 19 + 15.88 / 60), LatLonDialog.parseLatLon("N 49 29.918 E 19 15.88")); 35 assertEquals(new LatLon(49 + 29.4 / 60, 19 + 24.5 / 60), LatLonDialog.parseLatLon("49 29.4 19 24.5")); 36 assertEquals(new LatLon(-49 - 29.4 / 60, 19 + 24.5 / 60), LatLonDialog.parseLatLon("-49 29.4 N -19 24.5 W")); 101 37 } 102 38 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r8510 r8857 19 19 import org.openstreetmap.josm.io.OsmReader; 20 20 21 /** 22 * Unit tests of {@link RelationSorter} class. 23 */ 21 24 public class RelationSorterTest { 22 25 23 private RelationSorter sorter = new RelationSorter();26 private final RelationSorter sorter = new RelationSorter(); 24 27 private static DataSet testDataset; 25 28 … … 69 72 Assert.assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual); 70 73 } 71 72 74 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r8836 r8857 19 19 import org.openstreetmap.josm.io.OsmReader; 20 20 21 /** 22 * Unit tests of {@link WayConnectionTypeCalculator} class. 23 */ 21 24 public class WayConnectionTypeCalculatorTest { 22 25 -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/ToolbarPreferencesTest.java
r8836 r8857 19 19 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser; 20 20 21 /** 22 * Unit tests of {@link ToolbarPreferences} class. 23 */ 21 24 public class ToolbarPreferencesTest { 22 25 -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r8510 r8857 3 3 4 4 import static org.CustomMatchers.hasSize; 5 import static org. hamcrest.CoreMatchers.is;5 import static org.junit.Assert.assertEquals; 6 6 import static org.junit.Assert.assertThat; 7 7 … … 56 56 } 57 57 }); 58 assert That(keys.toString(), is("[A1, A2, A3, B1, B2, B3, C1, C2, C3]"));58 assertEquals("[A1, A2, A3, B1, B2, B3, C1, C2, C3]", keys.toString()); 59 59 } 60 60 -
trunk/test/unit/org/openstreetmap/josm/gui/util/RotationAngleTest.java
r8624 r8857 2 2 package org.openstreetmap.josm.gui.util; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import org.junit.Test; 8 7 8 /** 9 * Unit tests of {@link RotationAngle} class. 10 */ 9 11 public class RotationAngleTest { 10 12 13 private static final double EPSILON = 1e-11; 14 11 15 @Test 12 public void testParseCardinal() throws Exception{13 assert That(RotationAngle.buildStaticRotation("south").getRotationAngle(null), is(Math.PI));14 assert That(RotationAngle.buildStaticRotation("s").getRotationAngle(null), is(Math.PI));15 assert That(RotationAngle.buildStaticRotation("northwest").getRotationAngle(null), is(Math.toRadians(315)));16 public void testParseCardinal() { 17 assertEquals(Math.PI, RotationAngle.buildStaticRotation("south").getRotationAngle(null), EPSILON); 18 assertEquals(Math.PI, RotationAngle.buildStaticRotation("s").getRotationAngle(null), EPSILON); 19 assertEquals(Math.toRadians(315), RotationAngle.buildStaticRotation("northwest").getRotationAngle(null), EPSILON); 16 20 } 17 21 18 22 @Test(expected = IllegalArgumentException.class) 19 public void testParseFail() throws Exception{23 public void testParseFail() { 20 24 RotationAngle.buildStaticRotation("bad"); 21 25 } 22 26 23 27 @Test(expected = NullPointerException.class) 24 public void testParseNull() throws Exception{28 public void testParseNull() { 25 29 RotationAngle.buildStaticRotation(null); 26 30 } -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java
r8624 r8857 7 7 import org.junit.Test; 8 8 9 /** 10 * Unit tests of {@link ImportHandler} class. 11 */ 9 12 public class ImportHandlerTest { 10 13 -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandlerTest.java
r8624 r8857 2 2 package org.openstreetmap.josm.io.remotecontrol.handler; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import java.util.Collections; … … 12 11 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; 13 12 13 /** 14 * Unit tests of {@link RequestHandler} class. 15 */ 14 16 public class RequestHandlerTest { 15 17 … … 48 50 expected.put("query", "a"); 49 51 expected.put("b", "=c"); 50 assertThat(getRequestParameter("http://example.com/?query=a&b==c"), 51 is(expected)); 52 assertEquals(expected, getRequestParameter("http://example.com/?query=a&b==c")); 52 53 } 53 54 54 55 @Test 55 56 public void testRequestParameter12() { 56 assert That(getRequestParameter("http://example.com/?query=a%26b==c"),57 is(Collections.singletonMap("query", "a&b==c")));57 assertEquals(Collections.singletonMap("query", "a&b==c"), 58 getRequestParameter("http://example.com/?query=a%26b==c")); 58 59 } 59 60 60 61 @Test 61 62 public void testRequestParameter3() { 62 assert That(getRequestParameter("http://example.com/blue+light%20blue?blue%2Blight+blue").keySet(),63 is((Collections.singleton("blue+light blue"))));63 assertEquals(Collections.singleton("blue+light blue"), 64 getRequestParameter("http://example.com/blue+light%20blue?blue%2Blight+blue").keySet()); 64 65 } 65 66 … … 70 71 @Test 71 72 public void testRequestParameter4() { 72 assert That(getRequestParameter(73 assertEquals(Collections.singletonMap("/?:@-._~!$'()* ,;", "/?:@-._~!$'()* ,;=="), getRequestParameter( 73 74 // CHECKSTYLE.OFF: LineLength 74 "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$'()*+,;=/?:@-._~!$'()*+,;==#/?:@-._~!$&'()*+,;=") ,75 "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$'()*+,;=/?:@-._~!$'()*+,;==#/?:@-._~!$&'()*+,;=")); 75 76 // CHECKSTYLE.ON: LineLength 76 is(Collections.singletonMap("/?:@-._~!$'()* ,;", "/?:@-._~!$'()* ,;==")));77 77 } 78 78 … … 82 82 expected.put("space", " "); 83 83 expected.put("tab", "\t"); 84 assertThat(getRequestParameter("http://example.com/?space=%20&tab=%09"), 85 is(expected)); 84 assertEquals(expected, getRequestParameter("http://example.com/?space=%20&tab=%09")); 86 85 } 87 86 } -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
r8803 r8857 2 2 package org.openstreetmap.josm.io.session; 3 3 4 import static org.hamcrest.CoreMatchers.is;5 4 import static org.junit.Assert.assertEquals; 6 5 import static org.junit.Assert.assertNotNull; 7 6 import static org.junit.Assert.assertSame; 8 import static org.junit.Assert.assertThat;9 7 import static org.junit.Assert.assertTrue; 10 8 … … 122 120 assertTrue(layers.get(0) instanceof ImageryLayer); 123 121 final ImageryLayer image = (ImageryLayer) layers.get(0); 124 assert That(image.getName(), is("Bing aerial imagery"));122 assertEquals("Bing aerial imagery", image.getName()); 125 123 assertEquals(image.getDx(), 12.34, 1e-9); 126 124 assertEquals(image.getDy(), -56.78, 1e-9); -
trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java
r7937 r8857 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org. hamcrest.CoreMatchers.is;5 import static org.junit.Assert.assert That;4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotNull; 6 6 7 7 import java.awt.Transparency; 8 import java.awt.image.BufferedImage; 8 9 import java.io.File; 9 10 import java.io.IOException; … … 24 25 public void testTicket9984() throws IOException { 25 26 File file = new File(TestUtils.getRegressionDataFile(9984, "tile.png")); 26 assert That(ImageProvider.read(file, true, true).getTransparency(), is(Transparency.TRANSLUCENT));27 assert That(ImageProvider.read(file, false, true).getTransparency(), is(Transparency.TRANSLUCENT));28 assert That(ImageProvider.read(file, false, false).getTransparency(), is(Transparency.OPAQUE));29 assert That(ImageProvider.read(file, true, false).getTransparency(), is(Transparency.OPAQUE));27 assertEquals(Transparency.TRANSLUCENT, ImageProvider.read(file, true, true).getTransparency()); 28 assertEquals(Transparency.TRANSLUCENT, ImageProvider.read(file, false, true).getTransparency()); 29 assertEquals(Transparency.OPAQUE, ImageProvider.read(file, false, false).getTransparency()); 30 assertEquals(Transparency.OPAQUE, ImageProvider.read(file, true, false).getTransparency()); 30 31 } 31 32 … … 37 38 public void testTicket10030() throws IOException { 38 39 File file = new File(TestUtils.getRegressionDataFile(10030, "tile.jpg")); 39 ImageProvider.read(file, true, true); 40 BufferedImage img = ImageProvider.read(file, true, true); 41 assertNotNull(img); 40 42 } 41 43 } -
trunk/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java
r8744 r8857 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import org.junit.BeforeClass; … … 9 8 import org.openstreetmap.josm.JOSMFixture; 10 9 10 /** 11 * Unit tests of {@link OverpassTurboQueryWizard} class. 12 */ 11 13 public class OverpassTurboQueryWizardTest { 12 14 … … 21 23 22 24 @Test 23 public void testKeyValue() throws Exception{25 public void testKeyValue() { 24 26 final String query = OverpassTurboQueryWizard.getInstance().constructQuery("amenity=drinking_water"); 25 assert That(query, is("" +27 assertEquals("" + 26 28 "[timeout:25];\n" + 27 29 "// gather results\n" + … … 35 37 "out meta;\n" + 36 38 ">;\n" + 37 "out meta;" ));39 "out meta;", query); 38 40 } 39 41 40 42 @Test(expected = OverpassTurboQueryWizard.ParseException.class) 41 public void testErroneous() throws Exception{43 public void testErroneous() { 42 44 OverpassTurboQueryWizard.getInstance().constructQuery("foo"); 43 45 } -
trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
r8510 r8857 11 11 import org.openstreetmap.josm.JOSMFixture; 12 12 13 /** 14 * Unit tests of {@link TextTagParser} class. 15 */ 13 16 public class TextTagParserTest { 14 17 … … 21 24 } 22 25 26 /** 27 * Test of {@link TextTagParser#unescape} method. 28 */ 23 29 @Test 24 30 public void testUnescape() { … … 37 43 } 38 44 45 /** 46 * Test of {@link TextTagParser#readTagsFromText} method with tabs and new lines. 47 */ 39 48 @Test 40 49 public void testTNformat() { … … 47 56 } 48 57 58 /** 59 * Test of {@link TextTagParser#readTagsFromText} method with quotes. 60 */ 49 61 @Test 50 62 public void testEQformat() { … … 58 70 } 59 71 72 /** 73 * Test of {@link TextTagParser#readTagsFromText} method with JSON. 74 */ 60 75 @Test 61 76 public void testJSONformat() { … … 78 93 } 79 94 95 /** 96 * Test of {@link TextTagParser#readTagsFromText} method with free format. 97 */ 80 98 @Test 81 99 public void testFreeformat() { … … 88 106 } 89 107 108 /** 109 * Test of {@link TextTagParser#readTagsFromText} method (error detection). 110 */ 90 111 @Test 91 112 public void errorDetect() { … … 93 114 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 94 115 Assert.assertEquals(Collections.EMPTY_MAP, tags); 95 96 116 } 97 117 118 /** 119 * Test of {@link TextTagParser#readTagsFromText} method with tabs. 120 */ 98 121 @Test 99 public void testTab() throws Exception{122 public void testTab() { 100 123 Assert.assertEquals(TextTagParser.readTagsFromText("shop\tjewelry"), Collections.singletonMap("shop", "jewelry")); 101 124 Assert.assertEquals(TextTagParser.readTagsFromText("!shop\tjewelry"), Collections.singletonMap("shop", "jewelry")); -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r8756 r8857 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import java.io.BufferedReader; … … 109 108 @Test 110 109 public void testPositionListString() { 111 assert That(Utils.getPositionListString(Arrays.asList(1)), is("1"));112 assert That(Utils.getPositionListString(Arrays.asList(1, 2, 3)), is("1-3"));113 assert That(Utils.getPositionListString(Arrays.asList(3, 1, 2)), is("1-3"));114 assert That(Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8)), is("1-3,6-8"));115 assert That(Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7)), is("1-2,5-7"));110 assertEquals("1", Utils.getPositionListString(Arrays.asList(1))); 111 assertEquals("1-3", Utils.getPositionListString(Arrays.asList(1, 2, 3))); 112 assertEquals("1-3", Utils.getPositionListString(Arrays.asList(3, 1, 2))); 113 assertEquals("1-3,6-8", Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8))); 114 assertEquals("1-2,5-7", Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7))); 116 115 } 117 116 … … 122 121 public void testDurationString() { 123 122 I18n.set("en"); 124 assert That(Utils.getDurationString(123), is("123 ms"));125 assert That(Utils.getDurationString(1234), is("1.2 s"));126 assert That(Utils.getDurationString(57 * 1000), is("57.0 s"));127 assert That(Utils.getDurationString(507 * 1000), is("8 min 27 s"));128 assert That(Utils.getDurationString((long) (8.4 * 60 * 60 * 1000)), is("8 h 24 min"));129 assert That(Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000)), is("1 day 12 h"));130 assert That(Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000)), is("8 days 12 h"));123 assertEquals("123 ms", Utils.getDurationString(123)); 124 assertEquals("1.2 s", Utils.getDurationString(1234)); 125 assertEquals("57.0 s", Utils.getDurationString(57 * 1000)); 126 assertEquals("8 min 27 s", Utils.getDurationString(507 * 1000)); 127 assertEquals("8 h 24 min", Utils.getDurationString((long) (8.4 * 60 * 60 * 1000))); 128 assertEquals("1 day 12 h", Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000))); 129 assertEquals("8 days 12 h", Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000))); 131 130 } 132 131 132 /** 133 * Test of {@link Utils#escapeReservedCharactersHTML} method. 134 */ 133 135 @Test 134 public void testEscapeReservedCharactersHTML() throws Exception{135 assert That(Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"), is("foo -> bar -> '&'"));136 public void testEscapeReservedCharactersHTML() { 137 assertEquals("foo -> bar -> '&'", Utils.escapeReservedCharactersHTML("foo -> bar -> '&'")); 136 138 } 137 139 140 /** 141 * Test of {@link Utils#restrictStringLines} method. 142 */ 138 143 @Test 139 public void testRestrictStringLines() throws Exception{140 assert That(Utils.restrictStringLines("1\n2\n3", 2), is("1\n..."));141 assert That(Utils.restrictStringLines("1\n2\n3", 3), is("1\n2\n3"));142 assert That(Utils.restrictStringLines("1\n2\n3", 4), is("1\n2\n3"));144 public void testRestrictStringLines() { 145 assertEquals("1\n...", Utils.restrictStringLines("1\n2\n3", 2)); 146 assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 3)); 147 assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 4)); 143 148 } 144 149 } -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r8624 r8857 2 2 package org.openstreetmap.josm.tools.date; 3 3 4 import static org.hamcrest.CoreMatchers.is; 5 import static org.junit.Assert.assertThat; 4 import static org.junit.Assert.assertEquals; 6 5 7 6 import org.junit.Test; 8 7 8 /** 9 * Unit tests of {@link DateUtils} class. 10 */ 9 11 public class DateUtilsTest { 10 12 @Test 11 13 public void testMapDate() throws Exception { 12 assert That(DateUtils.fromString("2012-08-13T15:10:37Z").getTime(), is(1344870637000L));14 assertEquals(1344870637000L, DateUtils.fromString("2012-08-13T15:10:37Z").getTime()); 13 15 14 16 } … … 16 18 @Test 17 19 public void testNoteDate() throws Exception { 18 assert That(DateUtils.fromString("2014-11-29 22:08:50 UTC").getTime(), is(1417298930000L));20 assertEquals(1417298930000L, DateUtils.fromString("2014-11-29 22:08:50 UTC").getTime()); 19 21 } 20 22 } -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java
r8811 r8857 17 17 import org.unitils.reflectionassert.ReflectionAssert; 18 18 19 /** 20 * Unit tests of {@link TemplateParser} class. 21 */ 19 22 public class TemplateEngineTest { 20 23 … … 286 289 Assert.assertEquals("child2", sb.toString()); 287 290 } 288 289 291 }
Note:
See TracChangeset
for help on using the changeset viewer.