Changeset 6881 in josm for trunk/test/unit/org/openstreetmap


Ignore:
Timestamp:
2014-02-24T17:49:12+01:00 (10 years ago)
Author:
Don-vip
Message:

javadoc/code style/minor refactorization

Location:
trunk/test/unit/org/openstreetmap
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/TestUtils.java

    r6601 r6881  
    22package org.openstreetmap;
    33
    4 import org.junit.Before;
     4import static org.hamcrest.CoreMatchers.is;
     5import static org.junit.Assert.assertThat;
     6import static org.junit.Assert.assertTrue;
     7
     8import java.util.Map;
     9
    510import org.junit.Test;
    611import org.openstreetmap.josm.Main;
     
    1015import org.openstreetmap.josm.data.osm.Way;
    1116import org.openstreetmap.josm.tools.TextTagParser;
    12 
    13 import java.util.Map;
    14 
    15 import static org.hamcrest.CoreMatchers.is;
    16 import static org.junit.Assert.assertThat;
    17 import static org.junit.Assert.assertTrue;
    1817
    1918public class TestUtils {
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r6471 r6881  
    55import org.junit.Test;
    66import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.Preferences;
    87import org.openstreetmap.josm.data.osm.Node;
    98import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    1110public class SearchCompilerTest {
    1211
     12    /**
     13     * Setup test.
     14     */
    1315    @Before
    14     public void setUp() throws Exception {
     16    public void setUp() {
    1517        Main.initApplicationPreferences();
    1618    }
  • trunk/test/unit/org/openstreetmap/josm/corrector/ReverseWayTagCorrectorTest.java

    r6471 r6881  
    66import org.junit.Test;
    77import org.openstreetmap.josm.Main;
    8 import org.openstreetmap.josm.data.Preferences;
    98import org.openstreetmap.josm.data.osm.Tag;
    109
     
    2120        Main.initApplicationPreferences();
    2221    }
    23    
     22
    2423    /**
    2524     * Test of {@link ReverseWayTagCorrector.TagSwitcher#apply} method.
     
    9392        assertSwitch(new Tag("type", "drawdown"), new Tag("type", "drawdown"));
    9493    }
    95    
     94
    9695    private void assertSwitch(Tag oldTag, Tag newTag) {
    9796        Assert.assertEquals(ReverseWayTagCorrector.TagSwitcher.apply(oldTag), newTag);
  • trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java

    r6801 r6881  
    1212import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
    1313import org.openstreetmap.josm.data.APIDataSet;
    14 import org.openstreetmap.josm.data.Preferences;
    15 
    1614
    1715public class APIDataSetTest {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r6471 r6881  
    1818import org.junit.Test;
    1919import org.openstreetmap.josm.Main;
    20 import org.openstreetmap.josm.data.Preferences;
    2120import org.openstreetmap.josm.data.coor.LatLon;
    2221import org.openstreetmap.josm.data.projection.Projections;
    2322
    2423public class DataSetMergerTest {
    25     /*private static Logger logger = Logger.getLogger(DataSetMergerTest.class.getName());
    26 
    27     static Properties testProperties;
    28 
    29     @BeforeClass
    30     static public void init() {
    31 
    32         if(System.getProperty("josm.home") == null){
    33             testProperties = new Properties();
    34 
    35             // load properties
    36             //
    37             try {
    38                 testProperties.load(DataSetMergerTest.class.getResourceAsStream("/test-unit-env.properties"));
    39             } catch(Exception e){
    40                 logger.log(Level.SEVERE, MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
    41                 fail(MessageFormat.format("failed to load property file ''{0}''", "/test-unit-env.properties"));
    42             }
    43 
    44             // check josm.home
    45             //
    46             String josmHome = testProperties.getProperty("josm.home");
    47             if (josmHome == null) {
    48                 fail(MessageFormat.format("property ''{0}'' not set in test environment", "josm.home"));
    49             } else {
    50                 File f = new File(josmHome);
    51                 if (! f.exists() || ! f.canRead()) {
    52                     fail(MessageFormat.format("property ''{0}'' points to ''{1}'' which is either not existing or not readable", "josm.home", josmHome));
    53                 }
    54             }
    55             System.setProperty("josm.home", josmHome);
    56         }
    57         Main.pref.init(false);
    58 
    59         // init projection
    60         Main.proj = new Mercator();
    61     }*/
    6224
    6325    @BeforeClass
     
    6931    private DataSet their;
    7032
     33    /**
     34     * Setup test.
     35     */
    7136    @Before
    7237    public void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r6471 r6881  
    1717import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
    1818import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
    19 import org.openstreetmap.josm.data.Preferences;
    2019import org.openstreetmap.josm.data.coor.LatLon;
    2120import org.openstreetmap.josm.data.projection.Projections;
     
    2423import org.openstreetmap.josm.io.OsmReader;
    2524
    26 
    2725public class FilterTest {
    2826
     27    /**
     28     * Setup test.
     29     */
    2930    @BeforeClass
    3031    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandling.java

    r6830 r6881  
    3636
    3737    /**
    38      * Add a tag to an empty node and test the query and get methods.
    39      *
     38     * Adds a tag to an empty node and test the query and get methods.
    4039     */
    4140    @Test
     
    5150
    5251    /**
    53      * Add two tags to an empty node and test the query and get methods.
     52     * Adds two tags to an empty node and test the query and get methods.
    5453     */
    5554    @Test
     
    6867
    6968    /**
    70      * Remove tags from a node with two tags and test the state of the node.
    71      *
     69     * Removes tags from a node with two tags and test the state of the node.
    7270     */
    7371    @Test
     
    9694
    9795    /**
    98      * Remove all tags from a node
    99      *
     96     * Removes all tags from a node.
    10097     */
    10198    @Test
     
    132129     * Test hasEqualSemanticAttributes on two nodes with different tags.
    133130     */
    134 
    135131    @Test
    136132    public void hasEqualSemanticAttributes_2() {
     
    147143        assertTrue(!n1.hasEqualSemanticAttributes(n2));
    148144    }
    149 
    150145}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r6471 r6881  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.Main;
    11 import org.openstreetmap.josm.data.Preferences;
    1211import org.openstreetmap.josm.data.coor.LatLon;
    1312import org.openstreetmap.josm.data.projection.Projections;
     
    2726    private DataSet dataSet = new DataSet();
    2827
     28    /**
     29     * Setup test.
     30     */
    2931    @BeforeClass
    3032    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r6471 r6881  
    1414import org.junit.Test;
    1515import org.openstreetmap.josm.Main;
    16 import org.openstreetmap.josm.data.Preferences;
    1716import org.openstreetmap.josm.data.coor.LatLon;
    1817import org.openstreetmap.josm.data.projection.Projections;
     
    8281        removeAllTest(ds);
    8382    }
    84 
    8583}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r6471 r6881  
    88import org.junit.Test;
    99import org.openstreetmap.josm.Main;
    10 import org.openstreetmap.josm.data.Preferences;
    1110import org.openstreetmap.josm.data.coor.LatLon;
    1211import org.openstreetmap.josm.data.projection.Projections;
     
    1413public class RelationTest {
    1514
     15    /**
     16     * Setup test.
     17     */
    1618    @BeforeClass
    1719    public static void setUp() {
     
    104106        Assert.assertEquals(new BBox(w1), r1.getBBox());
    105107    }
    106 
    107108}
  • trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java

    r4603 r6881  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm.history;
    3 
    43
    54import static org.junit.Assert.assertEquals;
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

    r6471 r6881  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.Main;
    14 import org.openstreetmap.josm.data.Preferences;
    1514import org.openstreetmap.josm.data.coor.LatLon;
    1615import org.openstreetmap.josm.data.osm.DataSet;
     
    3534    }
    3635
     36    /**
     37     * Setup test.
     38     */
    3739    @BeforeClass
    3840    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java

    r6334 r6881  
    4141            maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
    4242        }
    43         //System.err.println(String.format("maxerror lat: %s maxerror lon: %s", maxErrLat, maxErrLon));
    4443    }
    4544}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r6471 r6881  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.projection;
    3 
    43
    54import java.io.BufferedReader;
     
    2524import org.openstreetmap.josm.Main;
    2625import org.openstreetmap.josm.data.Bounds;
    27 import org.openstreetmap.josm.data.Preferences;
    2826import org.openstreetmap.josm.data.coor.EastNorth;
    2927import org.openstreetmap.josm.data.coor.LatLon;
     
    147145    }
    148146
     147    /**
     148     * Setup test.
     149     */
    149150    @BeforeClass
    150151    public static void setUp() {
     
    198199            throw new AssertionError(fail.toString());
    199200        }
    200 
    201201    }
    202202}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java

    r6334 r6881  
    1212public class ProjectionTest {
    1313
    14     private static final boolean debug = false;
    1514    private static Random rand = new Random(System.currentTimeMillis());
    1615
     
    6463            double maxErrLat = 0, maxErrLon = 0;
    6564            Bounds b = p.getWorldBoundsLatLon();
    66    
     65
    6766            text += String.format("*** %s %s%n", p.toString(), p.toCode());
    6867            for (int num=0; num < 1000; ++num) {
    69    
     68
    7069                double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat();
    7170                double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon();
    72    
     71
    7372                LatLon ll = new LatLon(lat, lon);
    74    
     73
    7574                for (int i=0; i<10; ++i) {
    7675                    EastNorth en = p.latlon2eastNorth(ll);
     
    8079                maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
    8180            }
    82    
     81
    8382            String mark = "";
    8483            if (maxErrLat + maxErrLon > 1e-5) {
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r6334 r6881  
    1313    private boolean debug = false;
    1414
     15    /**
     16     * Setup test.
     17     */
    1518    @BeforeClass
    1619    public static void setUp() {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/DuplicateNodeTest.java

    r6471 r6881  
    77import org.junit.Test;
    88import org.openstreetmap.josm.Main;
    9 import org.openstreetmap.josm.data.Preferences;
    109import org.openstreetmap.josm.data.coor.LatLon;
    1110import org.openstreetmap.josm.data.osm.DataSet;
     
    1514
    1615/**
    17  * JUnit Test of "Duplicate node" validation test. 
     16 * JUnit Test of "Duplicate node" validation test.
    1817 */
    1918public class DuplicateNodeTest {
    2019
    2120    /**
    22      * Setup test by initializing JOSM preferences and projection. 
     21     * Setup test by initializing JOSM preferences and projection.
    2322     */
    2423    @BeforeClass
     
    4443        test.visit(ds.allPrimitives());
    4544        test.endTest();
    46        
     45
    4746        assertEquals(1, test.getErrors().size());
    4847    }
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    r6677 r6881  
    2828public class MapCSSTagCheckerTest {
    2929
     30    /**
     31     * Setup test.
     32     */
    3033    @Before
    3134    public void setUp() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r6858 r6881  
    22package org.openstreetmap.josm.data.validation.tests;
    33
    4 import org.junit.Before;
    5 import org.junit.Test;
    6 import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.osm.Tag;
    8 import org.openstreetmap.josm.data.validation.Severity;
    9 import org.openstreetmap.josm.gui.preferences.map.TaggingPresetPreference;
    10 import org.openstreetmap.josm.gui.tagging.TaggingPreset;
    11 import org.openstreetmap.josm.gui.tagging.TaggingPresetItem;
    12 import org.openstreetmap.josm.gui.tagging.TaggingPresetItems;
    13 import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
    14 import org.openstreetmap.josm.gui.tagging.TaggingPresetSearchAction;
     4import static org.CustomMatchers.hasSize;
     5import static org.CustomMatchers.isEmpty;
     6import static org.hamcrest.CoreMatchers.is;
     7import static org.hamcrest.CoreMatchers.not;
     8import static org.junit.Assert.assertThat;
    159
    1610import java.util.Arrays;
     
    2014import java.util.Set;
    2115
    22 import static org.CustomMatchers.hasSize;
    23 import static org.CustomMatchers.isEmpty;
    24 import static org.hamcrest.CoreMatchers.is;
    25 import static org.hamcrest.CoreMatchers.not;
    26 import static org.junit.Assert.assertThat;
     16import org.junit.Before;
     17import org.junit.Test;
     18import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.data.osm.Tag;
     20import org.openstreetmap.josm.data.validation.Severity;
     21import org.openstreetmap.josm.gui.tagging.TaggingPreset;
     22import org.openstreetmap.josm.gui.tagging.TaggingPresetItem;
     23import org.openstreetmap.josm.gui.tagging.TaggingPresetItems;
     24import org.openstreetmap.josm.gui.tagging.TaggingPresetReader;
    2725
    2826/**
    29  * JUnit Test of "Opening hours" validation test. 
     27 * JUnit Test of "Opening hours" validation test.
    3028 */
    3129public class OpeningHourTestTest {
     
    3331    private static final OpeningHourTest OPENING_HOUR_TEST = new OpeningHourTest();
    3432
     33    /**
     34     * Setup test.
     35     */
    3536    @Before
    3637    public void setUp() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/UnconnectedWaysTest.java

    r6603 r6881  
    1919    UnconnectedWays bib;
    2020
     21    /**
     22     * Setup test.
     23     */
    2124    @Before
    2225    public void setUp() throws Exception {
  • trunk/test/unit/org/openstreetmap/josm/gui/SystemOfMeasurementTest.java

    r6471 r6881  
    11package org.openstreetmap.josm.gui;
    22
    3 import static org.junit.Assert.*;
     3import static org.junit.Assert.assertEquals;
     4
     5import java.text.DecimalFormat;
     6import java.text.DecimalFormatSymbols;
     7import java.util.Locale;
    48
    59import org.junit.BeforeClass;
    610import org.junit.Test;
    711import org.openstreetmap.josm.Main;
    8 import org.openstreetmap.josm.data.Preferences;
    912import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement;
    10 
    11 import java.text.DecimalFormat;
    12 import java.text.DecimalFormatSymbols;
    13 import java.util.Locale;
    1413
    1514/**
     
    2524        Main.initApplicationPreferences();
    2625    }
    27    
     26
    2827    /**
    2928     * Test of {@link SystemOfMeasurement#getDistText} method.
     
    3130    @Test
    3231    public void testGetDistText() {
    33        
     32
    3433        assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-1));
    3534        assertEquals("< 0.01 m", NavigatableComponent.METRIC_SOM.getDistText(-0.99));
     
    3837
    3938        assertEquals("0.01 m", NavigatableComponent.METRIC_SOM.getDistText(0.01));
    40        
     39
    4140        assertEquals("0.99 m", NavigatableComponent.METRIC_SOM.getDistText(0.99));
    4241        assertEquals("1.00 m", NavigatableComponent.METRIC_SOM.getDistText(1.0));
     
    6766    }
    6867
     68    /**
     69     * Test of {@link SystemOfMeasurement#getDistText} method with a non-English locale.
     70     */
    6971    @Test
    7072    public void testGetDistTextLocalized() {
     
    8890
    8991        assertEquals("0.01 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.01));
    90        
     92
    9193        assertEquals("0.99 m²", NavigatableComponent.METRIC_SOM.getAreaText(0.99));
    9294        assertEquals("1.00 m²", NavigatableComponent.METRIC_SOM.getAreaText(1.0));
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r6471 r6881  
    1313import org.junit.Test;
    1414import org.openstreetmap.josm.Main;
    15 import org.openstreetmap.josm.data.Preferences;
    1615import org.openstreetmap.josm.data.conflict.Conflict;
    1716import org.openstreetmap.josm.data.coor.LatLon;
     
    5150    }
    5251
     52    /**
     53     * Setup test.
     54     */
    5355    @Before
    5456    public void setUp() {
     
    141143        model.deleteObserver(observerTest);
    142144    }
    143 
    144 
    145145}
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java

    r6562 r6881  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging;
     3
     4import static org.CustomMatchers.hasSize;
     5import static org.hamcrest.CoreMatchers.is;
     6import static org.junit.Assert.assertThat;
     7
     8import java.io.IOException;
     9import java.util.Collection;
     10import java.util.List;
    311
    412import org.junit.Assert;
     
    1018import org.xml.sax.SAXException;
    1119
    12 import java.io.IOException;
    13 import java.util.Collection;
    14 import java.util.List;
    15 
    16 import static org.CustomMatchers.hasSize;
    17 import static org.hamcrest.CoreMatchers.is;
    18 import static org.junit.Assert.assertThat;
    19 
    2020/**
    2121 * Unit tests of {@link TaggingPresetReader} class.
     
    2323public class TaggingPresetReaderTest {
    2424
     25    /**
     26     * Setup test.
     27     */
    2528    @BeforeClass
    26     public static void setUpClass() {
     29    public static void setUp() {
    2730        Main.initApplicationPreferences();
    2831    }
     
    3033    /**
    3134     * Gets path to test data directory for given ticketid.
    32      * @param ticketid 
    33      * @return 
     35     * @param ticketid
     36     * @return
    3437     */
    3538    protected static String getRegressionDataDir(int ticketid) {
     
    4144     * @param ticketid
    4245     * @param filename
    43      * @return 
     46     * @return
    4447     */
    4548    protected static String getRegressionDataFile(int ticketid, String filename) {
     
    8588        Assert.assertTrue("Default presets are empty", presets.size()>0);
    8689    }
    87    
    8890}
  • trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

    r6471 r6881  
    1010import org.junit.Test;
    1111import org.openstreetmap.josm.Main;
    12 import org.openstreetmap.josm.data.Preferences;
    1312
    1413public class TextTagParserTest {
     14
     15    /**
     16     * Setup test.
     17     */
    1518    @BeforeClass
    16     public static void before() {
     19    public static void setUp() {
    1720        Main.initApplicationPreferences();
    1821    }
     
    2629        s = "\"2 \\\"3\\\" 4\"";       s1 = "2 \"3\" 4";
    2730        Assert.assertEquals(s1, TextTagParser.unescape(s));
    28        
     31
    2932        s = "\"2 3 ===4===\"";       s1 = "2 3 ===4===";
    3033        Assert.assertEquals(s1, TextTagParser.unescape(s));
     
    3336        Assert.assertEquals(s1, TextTagParser.unescape(s));
    3437    }
    35    
     38
    3639    @Test
    3740    public void testTNformat() {
     
    6366        tags = TextTagParser.readTagsFromText(txt);
    6467        Assert.assertEquals(correctTags, tags);
    65        
     68
    6669        txt = "\"a\"  :     \"1 1 1\", \"b2\"  :\"2 \\\"3 qwe\\\" 4\"";
    6770        correctTags= new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4");}};
    6871        tags = TextTagParser.readTagsFromText(txt);
    6972        Assert.assertEquals(correctTags, tags);
    70        
     73
    7174        txt = " \"aыыы\"   :    \"val\\\"\\\"\\\"ue1\"";
    7275        correctTags= new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1");} };
     
    7477        Assert.assertEquals(correctTags, tags);
    7578    }
    76    
     79
    7780    @Test
    7881    public void testFreeformat() {
     
    8487        Assert.assertEquals(correctTags, tags);
    8588    }
    86    
     89
    8790    @Test
    8891    public void errorDetect() {
     
    9093        Map<String, String> tags = TextTagParser.readTagsFromText(txt);
    9194        Assert.assertEquals(Collections.EMPTY_MAP, tags);
    92        
     95
    9396    }
    9497}
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java

    r6471 r6881  
    1919public class TemplateEngineTest {
    2020
     21    /**
     22     * Setup test.
     23     */
    2124    @BeforeClass
    22     public static void before() {
     25    public static void setUp() {
    2326        Main.initApplicationPreferences();
    2427    }
Note: See TracChangeset for help on using the changeset viewer.