Changeset 8857 in josm


Ignore:
Timestamp:
2015-10-11T17:28:19+02:00 (9 years ago)
Author:
Don-vip
Message:

improve/cleanup unit tests

Location:
trunk
Files:
49 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r8840 r8857  
    256256
    257257    /**
    258      * Replies the first lines of last 10 error and warning messages, used for bug reports
    259      * @return the first lines of last 10 error and warning messages
     258     * Replies the first lines of last 5 error and warning messages, used for bug reports
     259     * @return the first lines of last 5 error and warning messages
    260260     * @since 7420
    261261     */
  • trunk/test/unit/org/CustomMatchers.java

    r8759 r8857  
    1414import org.openstreetmap.josm.tools.Predicate;
    1515
     16/**
     17 * Custom matchers for unit tests.
     18 */
    1619@Ignore("no test")
    1720public final class CustomMatchers {
     
    2124    }
    2225
     26    /**
     27     * Matcher for a predicate.
     28     * @param predicate the predicate
     29     * @return matcher for a predicate
     30     */
    2331    public static <T> Matcher<? extends T> forPredicate(final Predicate<T> predicate) {
    2432        return new TypeSafeMatcher<T>() {
     
    3644    }
    3745
     46    /**
     47     * Matcher for a collection of a given size.
     48     * @param size of collection
     49     * @return matcher for a collection of a given size
     50     */
    3851    public static Matcher<Collection<?>> hasSize(final int size) {
    3952        return new TypeSafeMatcher<Collection<?>>() {
     
    5063    }
    5164
     65    /**
     66     * Matcher for an empty collection.
     67     * @return matcher for an empty collection
     68     */
    5269    public static Matcher<Collection<?>> isEmpty() {
    5370        return new TypeSafeMatcher<Collection<?>>() {
     
    6481    }
    6582
     83    /**
     84     * Matcher for a point at a given location.
     85     * @param expected expected location
     86     * @return matcher for a point at a given location
     87     */
    6688    public static Matcher<? super Point2D> is(final Point2D expected) {
    6789        return new CustomTypeSafeMatcher<Point2D>("the same Point2D") {
     
    7395    }
    7496
     97    /**
     98     * Matcher for a point at a given location.
     99     * @param expected expected location
     100     * @return matcher for a point at a given location
     101     */
    75102    public static Matcher<? super LatLon> is(final LatLon expected) {
    76103        return new CustomTypeSafeMatcher<LatLon>("the same LatLon") {
     
    83110    }
    84111
     112    /**
     113     * Matcher for a point at a given location.
     114     * @param expected expected location
     115     * @return matcher for a point at a given location
     116     */
    85117    public static Matcher<? super EastNorth> is(final EastNorth expected) {
    86118        return new CustomTypeSafeMatcher<EastNorth>("the same EastNorth") {
     
    92124        };
    93125    }
    94 
    95126}
  • trunk/test/unit/org/openstreetmap/josm/MainTest.java

    r8809 r8857  
    22package org.openstreetmap.josm;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertNull;
     7import static org.junit.Assert.assertTrue;
     8
     9import java.util.Collection;
    610
    711import org.junit.Test;
     12import org.openstreetmap.josm.Main.DownloadParamType;
    813
     14/**
     15 * Unit tests of {@link Main} class.
     16 */
    917public class MainTest {
     18
     19    /**
     20     * Unit test of {@link DownloadParamType#paramType} method.
     21     */
    1022    @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;
    1374    }
    1475}
  • trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java

    r7937 r8857  
    1616
    1717/**
    18  * Unit tests for class AlignInLineAction.
     18 * Unit tests for class {@link AlignInLineAction}.
    1919 */
    2020public final class AlignInLineActionTest {
  • trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java

    r8856 r8857  
    2222
    2323/**
    24  * Unit tests for class CombineWayAction.
     24 * Unit tests for class {@link CombineWayAction}.
    2525 */
    2626public class CombineWayActionTest {
     
    3131    @BeforeClass
    3232    public static void setUp() {
    33         JOSMFixture.createUnitTestFixture().init(false);
     33        JOSMFixture.createUnitTestFixture().init();
    3434    }
    3535
  • trunk/test/unit/org/openstreetmap/josm/actions/CopyActionTest.java

    r8624 r8857  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import java.util.Arrays;
     
    1413import org.openstreetmap.josm.data.osm.Way;
    1514
     15/**
     16 * Unit tests for class {@link CopyAction}.
     17 */
    1618public class CopyActionTest {
    1719
     20    /**
     21     * Setup test.
     22     */
    1823    @BeforeClass
    1924    public static void setUpBeforeClass() {
     
    2429    public void testCopyStringWay() throws Exception {
    2530        final Way way = new Way(123L);
    26         assertThat(CopyAction.getCopyString(Collections.singleton(way)), is("way 123"));
     31        assertEquals("way 123", CopyAction.getCopyString(Collections.singleton(way)));
    2732    }
    2833
     
    3136        final Way way = new Way(123L);
    3237        final Relation relation = new Relation(456);
    33         assertThat(CopyAction.getCopyString(Arrays.asList(way, relation)), is("way 123,relation 456"));
    34         assertThat(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)));
    3540    }
    3641}
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java

    r8624 r8857  
    3131
    3232/**
    33  * Unit tests for class CreateCircleAction.
     33 * Unit tests for class {@link CreateCircleAction}.
    3434 */
    3535public final class CreateCircleActionTest {
  • trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java

    r8624 r8857  
    1818
    1919/**
    20  * Unit tests for class SplitWayAction.
     20 * Unit tests for class {@link SplitWayAction}.
    2121 */
    2222public final class SplitWayActionTest {
  • trunk/test/unit/org/openstreetmap/josm/actions/UnJoinNodeWayActionTest.java

    r8624 r8857  
    1717
    1818/**
    19  * Unit tests for class UnJoinNodeWayAction.
     19 * Unit tests for class {@link UnJoinNodeWayAction}.
    2020 */
    2121public final class UnJoinNodeWayActionTest {
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java

    r8836 r8857  
    2424import org.openstreetmap.josm.data.osm.DataSet;
    2525import org.openstreetmap.josm.data.osm.Node;
    26 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2726import org.openstreetmap.josm.data.osm.Way;
    2827import org.openstreetmap.josm.gui.MapFrame;
     
    3029import org.openstreetmap.josm.gui.layer.Layer;
    3130import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    32 import org.openstreetmap.josm.tools.Predicate;
    3331
    3432/**
     
    3735public class SelectActionTest {
    3836
    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;
    5040
    5141        MapViewMock(DataSet dataSet, OsmDataLayer layer) {
     
    6555        @Override
    6656        public void removeMouseListener(MouseListener ml) {}
    67 
    68         public void addMouseMotionListener(MouseListener ml) {}
    69 
    70         public void removeMouseMotionListener(MouseListener ml) {}
    71 
    72         public void mvRepaint() {}
    7357
    7458        @Override
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r8838 r8857  
    1313import org.openstreetmap.josm.data.osm.Way;
    1414
     15/**
     16 * Unit tests for class {@link SearchCompiler}.
     17 */
    1518public class SearchCompilerTest {
    1619
     
    109112    public void testNthParseNegative() throws Exception {
    110113        Assert.assertThat(SearchCompiler.compile("nth:-1").toString(), CoreMatchers.is("Nth{nth=-1, modulo=false}"));
    111 
    112114    }
    113115}
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java

    r8836 r8857  
    1313import org.openstreetmap.josm.JOSMFixture;
    1414
     15/**
     16 * Unit tests for class {@link JCSCachedTileLoaderJob}.
     17 */
    1518public class JCSCachedTileLoaderJobTest {
     19
    1620    private static class TestCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, CacheEntry> {
    1721        private String url;
     
    4448            return new CacheEntry("dummy".getBytes());
    4549        }
    46 
    4750    }
    4851
    4952    private static class Listener implements ICachedLoaderListener {
    50         private CacheEntry data;
    5153        private CacheEntryAttributes attributes;
    52         private LoadResult result;
    5354        private boolean ready;
    5455
    5556        @Override
    5657        public synchronized void loadingFinished(CacheEntry data, CacheEntryAttributes attributes, LoadResult result) {
    57             this.data = data;
    5858            this.attributes = attributes;
    59             this.result = result;
    6059            this.ready = true;
    6160            this.notify();
    6261        }
     62    }
    6363
    64     }
    6564    /**
    6665     * Setup test.
     
    108107        }
    109108        assertEquals(responseCode, listener.attributes.getResponseCode());
    110 
    111109    }
    112110
     
    114112        return new TestCachedTileLoaderJob("http://httpstat.us/" + responseCode);
    115113    }
    116 
    117114}
    118 
  • trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

    r7937 r8857  
    66import org.junit.Test;
    77
     8/**
     9 * Unit tests for class {@link LatLon}.
     10 */
    811public class LatLonTest {
    912
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java

    r8770 r8857  
    2020import org.openstreetmap.josm.data.projection.Projections;
    2121
     22/**
     23 * Unit tests for class {@link TemplatedWMSTileSource}.
     24 */
    2225public class TemplatedWMSTileSourceTest {
    2326
    2427    private ImageryInfo testImageryWMS =  new ImageryInfo("test imagery", "http://localhost", "wms", null, null);
    2528    private ImageryInfo testImageryTMS =  new ImageryInfo("test imagery", "http://localhost", "tms", null, null);
    26     //private TileSource testSource = new TemplatedWMSTileSource(testImageryWMS);
     29
    2730    /**
    2831     * Setup test.
     
    5255        verifyLocation(source, new LatLon(53.5937132, 19.5652017));
    5356        verifyLocation(source, new LatLon(53.501565692302854, 18.54455233898721));
    54 
    5557    }
    5658
     
    107109        verifyLocation(source, new LatLon(60, 18), 3);
    108110        verifyLocation(source, new LatLon(60, 18));
    109 
    110111    }
    111112
     
    120121        verifyLocation(source, new LatLon(60, 18.1), 3);
    121122        verifyLocation(source, new LatLon(60, 18.1));
    122 
    123123    }
    124124
     
    129129        assertEquals(expected.getLat(), result.lat(), 1e-4);
    130130        assertEquals(expected.getLon(), result.lon(), 1e-4);
    131         //assertTrue("result: " + result.toDisplayString() + " osmMercator: " +  expected.toDisplayString(), result.equalsEpsilon(expected));
    132131        LatLon tileCenter = new Bounds(result, getTileLatLon(source, x+1, y+1, z)).getCenter();
    133132        TileXY backwardsResult = source.latLonToTileXY(tileCenter.toCoordinate(), z);
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

    r8855 r8857  
    1818import org.openstreetmap.josm.data.projection.Projections;
    1919
     20/**
     21 * Unit tests for class {@link WMTSTileSource}.
     22 */
    2023public class WMTSTileSourceTest {
    2124
     
    2831    private ImageryInfo testImageryOntario = getImagery("test/data/wmts/WMTSCapabilities-Ontario.xml");
    2932
     33    /**
     34     * Setup test.
     35     */
    3036    @BeforeClass
    3137    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java

    r8510 r8857  
    1414import org.openstreetmap.josm.data.APIDataSet;
    1515
     16/**
     17 * Unit tests for class {@link APIDataSet}.
     18 */
    1619public class APIDataSetTest {
    1720
     21    /**
     22     * Setup test.
     23     */
    1824    @BeforeClass
    1925    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r8565 r8857  
    2424import org.openstreetmap.josm.data.projection.Projections;
    2525
     26/**
     27 * Unit tests for class {@link DataSetMerger}.
     28 */
    2629public class DataSetMergerTest {
    2730
     31    /**
     32     * Setup test.
     33     */
    2834    @BeforeClass
    2935    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r8510 r8857  
    2424import org.openstreetmap.josm.io.OsmReader;
    2525
     26/**
     27 * Unit tests for class {@link Filter}.
     28 */
    2629public class FilterTest {
    2730
     
    3538
    3639    @Test
    37     public void basic_test() throws ParseError {
     40    public void basic() throws ParseError {
    3841        DataSet ds = new DataSet();
    3942        Node n1 = new Node(new LatLon(0, 0));
     
    6366
    6467    @Test
    65     public void filter_test() throws ParseError, IllegalDataException, IOException {
     68    public void filter() throws ParseError, IllegalDataException, IOException {
    6669        for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) {
    6770            DataSet ds;
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java

    r8510 r8857  
    1515 * Some unit test cases for basic tag management on {@link OsmPrimitive}. Uses
    1616 * {@link Node} for the tests, {@link OsmPrimitive} is abstract.
    17  *
    1817 */
    1918public class OsmPrimitiveKeyHandlingTest {
    2019
     20    /**
     21     * Setup test.
     22     */
    2123    @BeforeClass
    2224    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r8510 r8857  
    1515public class OsmPrimitiveTest {
    1616
     17    /**
     18     * Setup test.
     19     */
    1720    @BeforeClass
    1821    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmUtilsTest.java

    r8624 r8857  
    22package org.openstreetmap.josm.data.osm;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65import static org.junit.Assert.assertTrue;
    76
     
    1211public class OsmUtilsTest {
    1312
     13    /**
     14     * Setup test.
     15     */
    1416    @BeforeClass
    1517    public static void setUp() {
     
    2123        final OsmPrimitive p = OsmUtils.createPrimitive("way name=Foo railway=rail");
    2224        assertTrue(p instanceof Way);
    23         assertThat(p.keySet().size(), is(2));
    24         assertThat(p.get("name"), is("Foo"));
    25         assertThat(p.get("railway"), is("rail"));
     25        assertEquals(2, p.keySet().size());
     26        assertEquals("Foo", p.get("name"));
     27        assertEquals("rail", p.get("railway"));
    2628    }
    2729
     
    2931    public void testArea() throws Exception {
    3032        final OsmPrimitive p = OsmUtils.createPrimitive("area name=Foo railway=rail");
    31         assertThat(p.getType(), is(OsmPrimitiveType.WAY));
     33        assertEquals(OsmPrimitiveType.WAY, p.getType());
    3234        assertTrue(p.getKeys().equals(OsmUtils.createPrimitive("way name=Foo railway=rail").getKeys()));
    33 
    3435    }
    3536
     
    3839        OsmUtils.createPrimitive("noway name=Foo");
    3940    }
    40 
    4141}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r7937 r8857  
    2323public class QuadBucketsTest {
    2424
     25    /**
     26     * Setup test.
     27     */
    2528    @BeforeClass
    2629    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java

    r8514 r8857  
    1212import org.openstreetmap.josm.data.osm.User;
    1313
     14/**
     15 * Unit tests for class {@link HistoryNode}.
     16 */
    1417public class HistoryNodeTest {
    1518
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryWayTest.java

    r8513 r8857  
    1414import org.openstreetmap.josm.data.osm.User;
    1515
     16/**
     17 * Unit tests for class {@link HistoryWay}.
     18 */
    1619public class HistoryWayTest {
    1720
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

    r8510 r8857  
    2121import org.openstreetmap.josm.data.osm.Way;
    2222
     23/**
     24 * Unit tests for class {@link MergeSourceBuildingVisitor}.
     25 */
    2326public class MergeSourceBuildingVisitorTest {
    2427
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r8741 r8857  
    22package org.openstreetmap.josm.data.validation.tests;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.hamcrest.CoreMatchers.notNullValue;
     4import static org.junit.Assert.assertEquals;
    65import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertThat;
     6import static org.junit.Assert.assertNotNull;
    87import static org.junit.Assert.assertTrue;
    98
     
    3332
    3433/**
    35  * JUnit Test of MapCSS TagChecker.
     34 * JUnit Test of {@link MapCSSTagChecker}.
    3635 */
    3736public class MapCSSTagCheckerTest {
     
    5352    @Test
    5453    public void testNaturalMarsh() throws Exception {
    55 
    5654        final List<MapCSSTagChecker.TagCheck> checks = MapCSSTagChecker.TagCheck.readMapCSS(new StringReader("" +
    5755                "*[natural=marsh] {\n" +
     
    6159                "   fixAdd: \"wetland=marsh\";\n" +
    6260                "}"));
    63         assertThat(checks.size(), is(1));
     61        assertEquals(1, checks.size());
    6462        final MapCSSTagChecker.TagCheck check = checks.get(0);
    65         assertThat(check, notNullValue());
    66         assertThat(check.getDescription(null), is("{0.key}=null is deprecated"));
    67         assertThat(check.fixCommands.get(0).toString(), is("fixRemove: {0.key}"));
    68         assertThat(check.fixCommands.get(1).toString(), is("fixAdd: natural=wetland"));
    69         assertThat(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());
    7068        final Node n1 = new Node();
    7169        n1.put("natural", "marsh");
    7270        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());
    7875        final Node n2 = new Node();
    7976        n2.put("natural", "wood");
    8077        assertFalse(check.evaluate(n2));
    81         assertThat(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));
    8380    }
    8481
     
    9289                "}")).get(0);
    9390        final Command command = check.fixPrimitive(p);
    94         assertThat(command instanceof SequenceCommand, is(true));
     91        assertTrue(command instanceof SequenceCommand);
    9592        final Iterator<PseudoCommand> it = command.getChildren().iterator();
    96         assertThat(it.next() instanceof ChangePropertyKeyCommand, is(true));
    97         assertThat(it.next() instanceof ChangePropertyCommand, is(true));
     93        assertTrue(it.next() instanceof ChangePropertyKeyCommand);
     94        assertTrue(it.next() instanceof ChangePropertyCommand);
    9895    }
    9996
     
    104101        final OsmPrimitive p = OsmUtils.createPrimitive("way alt_name=Foo");
    105102        final Collection<TestError> errors = test.getErrorsForPrimitive(p, false);
    106         assertThat(errors.size(), is(1));
    107         assertThat(errors.iterator().next().getMessage(), is("has alt_name but not name"));
    108         assertThat(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());
    109106    }
    110107
     
    115112        final OsmPrimitive p = OsmUtils.createPrimitive("way highway=footway foot=no");
    116113        final Collection<TestError> errors = test.getErrorsForPrimitive(p, false);
    117         assertThat(errors.size(), is(1));
    118         assertThat(errors.iterator().next().getMessage(), is("footway used with foot=no"));
    119         assertThat(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());
    120117    }
    121118
     
    125122                "@media (min-josm-version: 1) { *[foo] { throwWarning: \"!\"; } }\n" +
    126123                "@media (min-josm-version: 2147483647) { *[bar] { throwWarning: \"!\"; } }\n");
    127         assertThat(test.getErrorsForPrimitive(OsmUtils.createPrimitive("way foo=1"), false).size(), is(1));
    128         assertThat(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());
    129126    }
    130127
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r8680 r8857  
    44import static org.CustomMatchers.hasSize;
    55import static org.CustomMatchers.isEmpty;
    6 import static org.hamcrest.CoreMatchers.is;
    76import static org.hamcrest.CoreMatchers.not;
     7import static org.junit.Assert.assertEquals;
    88import static org.junit.Assert.assertFalse;
    99import static org.junit.Assert.assertThat;
     
    5656        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00,04:00-sunrise; Fr-Sa sunset-sunrise"), isEmpty());
    5757        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Su-Th sunset-24:00, 04:00-sunrise; Fr-Sa sunset-sunrise"), hasSize(1));
    58         assertThat(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         assertThat(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() {
    6666        assertTrue(OPENING_HOUR_TEST.checkOpeningHourSyntax("opening_hours", ".", OpeningHourTest.CheckMode.POINTS_IN_TIME, false, "de")
    6767                .get(0).toString().contains("Unerwartetes Zeichen"));
     
    7878        final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Tue");
    7979        assertThat(errors, hasSize(2));
    80         assertThat(errors.get(0).getMessage(), is(key + " - Mo-Tue <--- (Please use the abbreviation \"Tu\" for \"tue\".)"));
    81         assertThat(errors.get(0).getSeverity(), is(Severity.WARNING));
    82         assertThat(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 +
    8383                " - 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         assertThat(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());
    8686    }
    8787
     
    9494        final List<OpeningHourTest.OpeningHoursTestError> errors = OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Sa-Su 10.00-20.00");
    9595        assertThat(errors, hasSize(2));
    96         assertThat(errors.get(0).getMessage(), is(key + " - Sa-Su 10. <--- (Please use \":\" as hour/minute-separator)"));
    97         assertThat(errors.get(0).getSeverity(), is(Severity.WARNING));
    98         assertThat(errors.get(0).getPrettifiedValue(), is("Sa-Su 10:00-20:00"));
    99         assertThat(errors.get(1).getMessage(), is(key + " - Sa-Su 10.00-20. <--- (Please use \":\" as hour/minute-separator)"));
    100         assertThat(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());
    101101    }
    102102
     
    118118        final String key = "opening_hours";
    119119        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "badtext"), hasSize(1));
    120         assertThat(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());
    122122        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "5.00 p.m-11.00 p.m"), hasSize(1));
    123         assertThat(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());
    126126    }
    127127
     
    142142        final String key = "opening_hours";
    143143        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00"), hasSize(1));
    144         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "9:00-18:00").get(0).getSeverity(), is(Severity.OTHER));
    145         assertThat(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());
    146146    }
    147147
     
    152152    public void testCheckOpeningHourSyntaxTicket9367() {
    153153        final String key = "opening_hours";
    154         assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo,Tu 04-17").get(0).getSeverity(), is(Severity.WARNING));
    155         assertThat(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         assertThat(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());
    159159    }
    160160
     
    174174        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00",
    175175                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());
    180182    }
    181183
     
    194196        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax(key, "Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00",
    195197                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());
    200204    }
    201205
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    r8753 r8857  
    22package org.openstreetmap.josm.data.validation.tests;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import java.io.IOException;
     
    1615import org.openstreetmap.josm.gui.tagging.TaggingPresets;
    1716
     17/**
     18 * JUnit Test of {@link TagChecker}.
     19 */
    1820public class TagCheckerTest {
     21
    1922    /**
    2023     * Setup test.
     
    3740    public void testInvalidKey() throws Exception {
    3841        final List<TestError> errors = test(OsmUtils.createPrimitive("node Name=Main"));
    39         assertThat(errors.size(), is(1));
    40         assertThat(errors.get(0).getMessage(), is("Misspelled property key"));
    41         assertThat(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());
    4245    }
    4346
     
    4548    public void testMisspelledKey() throws Exception {
    4649        final List<TestError> errors = test(OsmUtils.createPrimitive("node landuse;=forest"));
    47         assertThat(errors.size(), is(1));
    48         assertThat(errors.get(0).getMessage(), is("Misspelled property key"));
    49         assertThat(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());
    5053    }
    5154
     
    5356    public void testTranslatedNameKey() throws Exception {
    5457        final List<TestError> errors = test(OsmUtils.createPrimitive("node namez=Baz"));
    55         assertThat(errors.size(), is(1));
    56         assertThat(errors.get(0).getMessage(), is("Presets do not contain property key"));
    57         assertThat(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());
    5861    }
    5962
     
    6164    public void testMisspelledTag() throws Exception {
    6265        final List<TestError> errors = test(OsmUtils.createPrimitive("node landuse=forrest"));
    63         assertThat(errors.size(), is(1));
    64         assertThat(errors.get(0).getMessage(), is("Presets do not contain property value"));
    65         assertThat(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());
    6669    }
    67 
    6870}
  • trunk/test/unit/org/openstreetmap/josm/gui/DefaultNameFormatterTest.java

    r8509 r8857  
    22package org.openstreetmap.josm.gui;
    33
    4 import static org.hamcrest.CoreMatchers.is;
     4import static org.junit.Assert.assertEquals;
    55import static org.junit.Assert.assertSame;
    6 import static org.junit.Assert.assertThat;
    76
    87import java.io.FileInputStream;
     
    3029/**
    3130 * Unit tests of {@link DefaultNameFormatter} class.
    32  *
    3331 */
    3432public class DefaultNameFormatterTest {
     
    8987    @Test
    9088    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"));
    100103    }
    101104
     
    105108    @Test
    106109    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"));
    112114    }
    113115
  • trunk/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    r8759 r8857  
    22package org.openstreetmap.josm.gui;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    54import static org.junit.Assert.assertEquals;
    65import static org.junit.Assert.assertThat;
     
    107106        component.zoomToFactor(0.5);
    108107        assertEquals(initialScale / 2, component.getScale(), 0.00000001);
    109         assertThat(component.getCenter(), is(center));
     108        assertEquals(center, component.getCenter());
    110109        component.zoomToFactor(2);
    111110        assertEquals(initialScale, component.getScale(), 0.00000001);
    112         assertThat(component.getCenter(), is(center));
     111        assertEquals(center, component.getCenter());
    113112
    114113        // zoomToFactor(EastNorth, double)
     
    116115        component.zoomToFactor(newCenter, 0.5);
    117116        assertEquals(initialScale / 2, component.getScale(), 0.00000001);
    118         assertThat(component.getCenter(), is(newCenter));
     117        assertEquals(newCenter, component.getCenter());
    119118        component.zoomToFactor(newCenter, 2);
    120119        assertEquals(initialScale, component.getScale(), 0.00000001);
    121         assertThat(component.getCenter(), is(newCenter));
     120        assertEquals(newCenter, component.getCenter());
    122121    }
    123122
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java

    r8514 r8857  
    3232    private DatasetFactory their = new DatasetFactory();
    3333
     34    /**
     35     * Setup test.
     36     */
    3437    @BeforeClass
    3538    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r8511 r8857  
    4242    PropertiesMergeModel model;
    4343
     44    /**
     45     * Setup test.
     46     */
    4447    @BeforeClass
    4548    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeItemTest.java

    r8513 r8857  
    1414import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeItem;
    1515
     16/**
     17 * Unit tests of {@link TagMergeItem} class.
     18 */
    1619public class TagMergeItemTest {
    1720
     21    /**
     22     * Setup test.
     23     */
    1824    @BeforeClass
    1925    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java

    r8510 r8857  
    1919import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeModel;
    2020
     21/**
     22 * Unit tests of {@link TagMergeModel} class.
     23 */
    2124@SuppressWarnings("unchecked")
    2225public class TagMergeModelTest {
    2326
     27    /**
     28     * Setup test.
     29     */
    2430    @BeforeClass
    2531    public static void init() {
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/LatLonDialogTest.java

    r8540 r8857  
    22package org.openstreetmap.josm.gui.dialogs;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import org.junit.Test;
    87import org.openstreetmap.josm.data.coor.LatLon;
    98
     9/**
     10 * Unit tests of {@link LatLonDialog} class.
     11 */
    1012public class LatLonDialogTest {
     13
     14    /**
     15     * Unit test of {@link LatLonDialog#parseLatLon} method.
     16     */
    1117    @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"));
    10137    }
    10238}
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

    r8510 r8857  
    1919import org.openstreetmap.josm.io.OsmReader;
    2020
     21/**
     22 * Unit tests of {@link RelationSorter} class.
     23 */
    2124public class RelationSorterTest {
    2225
    23     private RelationSorter sorter = new RelationSorter();
     26    private final RelationSorter sorter = new RelationSorter();
    2427    private static DataSet testDataset;
    2528
     
    6972        Assert.assertArrayEquals(new String[]{"t2w1", "t2w2", "t2n1", "t2n2", "t2n3", "t2n4", "playground", "tree"}, actual);
    7073    }
    71 
    7274}
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java

    r8836 r8857  
    1919import org.openstreetmap.josm.io.OsmReader;
    2020
     21/**
     22 * Unit tests of {@link WayConnectionTypeCalculator} class.
     23 */
    2124public class WayConnectionTypeCalculatorTest {
    2225
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/ToolbarPreferencesTest.java

    r8836 r8857  
    1919import org.openstreetmap.josm.gui.preferences.ToolbarPreferences.ActionParser;
    2020
     21/**
     22 * Unit tests of {@link ToolbarPreferences} class.
     23 */
    2124public class ToolbarPreferencesTest {
    2225
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java

    r8510 r8857  
    33
    44import static org.CustomMatchers.hasSize;
    5 import static org.hamcrest.CoreMatchers.is;
     5import static org.junit.Assert.assertEquals;
    66import static org.junit.Assert.assertThat;
    77
     
    5656            }
    5757        });
    58         assertThat(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());
    5959    }
    6060
  • trunk/test/unit/org/openstreetmap/josm/gui/util/RotationAngleTest.java

    r8624 r8857  
    22package org.openstreetmap.josm.gui.util;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import org.junit.Test;
    87
     8/**
     9 * Unit tests of {@link RotationAngle} class.
     10 */
    911public class RotationAngleTest {
    1012
     13    private static final double EPSILON = 1e-11;
     14
    1115    @Test
    12     public void testParseCardinal() throws Exception {
    13         assertThat(RotationAngle.buildStaticRotation("south").getRotationAngle(null), is(Math.PI));
    14         assertThat(RotationAngle.buildStaticRotation("s").getRotationAngle(null), is(Math.PI));
    15         assertThat(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);
    1620    }
    1721
    1822    @Test(expected = IllegalArgumentException.class)
    19     public void testParseFail() throws Exception {
     23    public void testParseFail() {
    2024        RotationAngle.buildStaticRotation("bad");
    2125    }
    2226
    2327    @Test(expected = NullPointerException.class)
    24     public void testParseNull() throws Exception {
     28    public void testParseNull() {
    2529        RotationAngle.buildStaticRotation(null);
    2630    }
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java

    r8624 r8857  
    77import org.junit.Test;
    88
     9/**
     10 * Unit tests of {@link ImportHandler} class.
     11 */
    912public class ImportHandlerTest {
    1013
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandlerTest.java

    r8624 r8857  
    22package org.openstreetmap.josm.io.remotecontrol.handler;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import java.util.Collections;
     
    1211import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
    1312
     13/**
     14 * Unit tests of {@link RequestHandler} class.
     15 */
    1416public class RequestHandlerTest {
    1517
     
    4850        expected.put("query", "a");
    4951        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"));
    5253    }
    5354
    5455    @Test
    5556    public void testRequestParameter12() {
    56         assertThat(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"));
    5859    }
    5960
    6061    @Test
    6162    public void testRequestParameter3() {
    62         assertThat(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());
    6465    }
    6566
     
    7071    @Test
    7172    public void testRequestParameter4() {
    72         assertThat(getRequestParameter(
     73        assertEquals(Collections.singletonMap("/?:@-._~!$'()* ,;", "/?:@-._~!$'()* ,;=="), getRequestParameter(
    7374                // CHECKSTYLE.OFF: LineLength
    74                 "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$'()*+,;=/?:@-._~!$'()*+,;==#/?:@-._~!$&'()*+,;="),
     75                "http://example.com/:@-._~!$&'()*+,=;:@-._~!$&'()*+,=:@-._~!$&'()*+,==?/?:@-._~!$'()*+,;=/?:@-._~!$'()*+,;==#/?:@-._~!$&'()*+,;="));
    7576                // CHECKSTYLE.ON: LineLength
    76                 is(Collections.singletonMap("/?:@-._~!$'()* ,;", "/?:@-._~!$'()* ,;==")));
    7777    }
    7878
     
    8282        expected.put("space", " ");
    8383        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"));
    8685    }
    8786}
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java

    r8803 r8857  
    22package org.openstreetmap.josm.io.session;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    54import static org.junit.Assert.assertEquals;
    65import static org.junit.Assert.assertNotNull;
    76import static org.junit.Assert.assertSame;
    8 import static org.junit.Assert.assertThat;
    97import static org.junit.Assert.assertTrue;
    108
     
    122120        assertTrue(layers.get(0) instanceof ImageryLayer);
    123121        final ImageryLayer image = (ImageryLayer) layers.get(0);
    124         assertThat(image.getName(), is("Bing aerial imagery"));
     122        assertEquals("Bing aerial imagery", image.getName());
    125123        assertEquals(image.getDx(), 12.34, 1e-9);
    126124        assertEquals(image.getDy(), -56.78, 1e-9);
  • trunk/test/unit/org/openstreetmap/josm/tools/ImageProviderTest.java

    r7937 r8857  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertNotNull;
    66
    77import java.awt.Transparency;
     8import java.awt.image.BufferedImage;
    89import java.io.File;
    910import java.io.IOException;
     
    2425    public void testTicket9984() throws IOException {
    2526        File file = new File(TestUtils.getRegressionDataFile(9984, "tile.png"));
    26         assertThat(ImageProvider.read(file, true, true).getTransparency(), is(Transparency.TRANSLUCENT));
    27         assertThat(ImageProvider.read(file, false, true).getTransparency(), is(Transparency.TRANSLUCENT));
    28         assertThat(ImageProvider.read(file, false, false).getTransparency(), is(Transparency.OPAQUE));
    29         assertThat(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());
    3031    }
    3132
     
    3738    public void testTicket10030() throws IOException {
    3839        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);
    4042    }
    4143}
  • trunk/test/unit/org/openstreetmap/josm/tools/OverpassTurboQueryWizardTest.java

    r8744 r8857  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import org.junit.BeforeClass;
     
    98import org.openstreetmap.josm.JOSMFixture;
    109
     10/**
     11 * Unit tests of {@link OverpassTurboQueryWizard} class.
     12 */
    1113public class OverpassTurboQueryWizardTest {
    1214
     
    2123
    2224    @Test
    23     public void testKeyValue() throws Exception {
     25    public void testKeyValue() {
    2426        final String query = OverpassTurboQueryWizard.getInstance().constructQuery("amenity=drinking_water");
    25         assertThat(query, is("" +
     27        assertEquals("" +
    2628                "[timeout:25];\n" +
    2729                "// gather results\n" +
     
    3537                "out meta;\n" +
    3638                ">;\n" +
    37                 "out meta;"));
     39                "out meta;", query);
    3840    }
    3941
    4042    @Test(expected = OverpassTurboQueryWizard.ParseException.class)
    41     public void testErroneous() throws Exception {
     43    public void testErroneous() {
    4244        OverpassTurboQueryWizard.getInstance().constructQuery("foo");
    4345    }
  • trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

    r8510 r8857  
    1111import org.openstreetmap.josm.JOSMFixture;
    1212
     13/**
     14 * Unit tests of {@link TextTagParser} class.
     15 */
    1316public class TextTagParserTest {
    1417
     
    2124    }
    2225
     26    /**
     27     * Test of {@link TextTagParser#unescape} method.
     28     */
    2329    @Test
    2430    public void testUnescape() {
     
    3743    }
    3844
     45    /**
     46     * Test of {@link TextTagParser#readTagsFromText} method with tabs and new lines.
     47     */
    3948    @Test
    4049    public void testTNformat() {
     
    4756    }
    4857
     58    /**
     59     * Test of {@link TextTagParser#readTagsFromText} method with quotes.
     60     */
    4961    @Test
    5062    public void testEQformat() {
     
    5870    }
    5971
     72    /**
     73     * Test of {@link TextTagParser#readTagsFromText} method with JSON.
     74     */
    6075    @Test
    6176    public void testJSONformat() {
     
    7893    }
    7994
     95    /**
     96     * Test of {@link TextTagParser#readTagsFromText} method with free format.
     97     */
    8098    @Test
    8199    public void testFreeformat() {
     
    88106    }
    89107
     108    /**
     109     * Test of {@link TextTagParser#readTagsFromText} method (error detection).
     110     */
    90111    @Test
    91112    public void errorDetect() {
     
    93114        Map<String, String> tags = TextTagParser.readTagsFromText(txt);
    94115        Assert.assertEquals(Collections.EMPTY_MAP, tags);
    95 
    96116    }
    97117
     118    /**
     119     * Test of {@link TextTagParser#readTagsFromText} method with tabs.
     120     */
    98121    @Test
    99     public void testTab() throws Exception {
     122    public void testTab() {
    100123        Assert.assertEquals(TextTagParser.readTagsFromText("shop\tjewelry"), Collections.singletonMap("shop", "jewelry"));
    101124        Assert.assertEquals(TextTagParser.readTagsFromText("!shop\tjewelry"), Collections.singletonMap("shop", "jewelry"));
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r8756 r8857  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import java.io.BufferedReader;
     
    109108    @Test
    110109    public void testPositionListString() {
    111         assertThat(Utils.getPositionListString(Arrays.asList(1)), is("1"));
    112         assertThat(Utils.getPositionListString(Arrays.asList(1, 2, 3)), is("1-3"));
    113         assertThat(Utils.getPositionListString(Arrays.asList(3, 1, 2)), is("1-3"));
    114         assertThat(Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8)), is("1-3,6-8"));
    115         assertThat(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)));
    116115    }
    117116
     
    122121    public void testDurationString() {
    123122        I18n.set("en");
    124         assertThat(Utils.getDurationString(123), is("123 ms"));
    125         assertThat(Utils.getDurationString(1234), is("1.2 s"));
    126         assertThat(Utils.getDurationString(57 * 1000), is("57.0 s"));
    127         assertThat(Utils.getDurationString(507 * 1000), is("8 min 27 s"));
    128         assertThat(Utils.getDurationString((long) (8.4 * 60 * 60 * 1000)), is("8 h 24 min"));
    129         assertThat(Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000)), is("1 day 12 h"));
    130         assertThat(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)));
    131130    }
    132131
     132    /**
     133     * Test of {@link Utils#escapeReservedCharactersHTML} method.
     134     */
    133135    @Test
    134     public void testEscapeReservedCharactersHTML() throws Exception {
    135         assertThat(Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"), is("foo -&gt; bar -&gt; '&amp;'"));
     136    public void testEscapeReservedCharactersHTML() {
     137        assertEquals("foo -&gt; bar -&gt; '&amp;'", Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"));
    136138    }
    137139
     140    /**
     141     * Test of {@link Utils#restrictStringLines} method.
     142     */
    138143    @Test
    139     public void testRestrictStringLines() throws Exception {
    140         assertThat(Utils.restrictStringLines("1\n2\n3", 2), is("1\n..."));
    141         assertThat(Utils.restrictStringLines("1\n2\n3", 3), is("1\n2\n3"));
    142         assertThat(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));
    143148    }
    144149}
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r8624 r8857  
    22package org.openstreetmap.josm.tools.date;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import org.junit.Test;
    87
     8/**
     9 * Unit tests of {@link DateUtils} class.
     10 */
    911public class DateUtilsTest {
    1012    @Test
    1113    public void testMapDate() throws Exception {
    12         assertThat(DateUtils.fromString("2012-08-13T15:10:37Z").getTime(), is(1344870637000L));
     14        assertEquals(1344870637000L, DateUtils.fromString("2012-08-13T15:10:37Z").getTime());
    1315
    1416    }
     
    1618    @Test
    1719    public void testNoteDate() throws Exception {
    18         assertThat(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());
    1921    }
    2022}
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java

    r8811 r8857  
    1717import org.unitils.reflectionassert.ReflectionAssert;
    1818
     19/**
     20 * Unit tests of {@link TemplateParser} class.
     21 */
    1922public class TemplateEngineTest {
    2023
     
    286289        Assert.assertEquals("child2", sb.toString());
    287290    }
    288 
    289291}
Note: See TracChangeset for help on using the changeset viewer.