Changeset 3577 in josm for trunk


Ignore:
Timestamp:
2010-10-01T19:26:20+02:00 (14 years ago)
Author:
jttt
Message:

Fix tests

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java

    r3025 r3577  
    77import java.util.List;
    88
     9import org.junit.BeforeClass;
    910import org.junit.Test;
     11import org.openstreetmap.josm.Main;
    1012import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
    1113import org.openstreetmap.josm.data.APIDataSet;
     14import org.openstreetmap.josm.data.Preferences;
    1215
    1316
    1417public class APIDataSetTest {
    1518
     19    @BeforeClass
     20    public static void init() {
     21        Main.pref = new Preferences();
     22    }
    1623
    1724    @Test
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r3459 r3577  
    1515import org.junit.After;
    1616import org.junit.Before;
     17import org.junit.BeforeClass;
    1718import org.junit.Test;
    1819import org.openstreetmap.josm.Main;
     20import org.openstreetmap.josm.data.Preferences;
    1921import org.openstreetmap.josm.data.coor.LatLon;
    2022import org.openstreetmap.josm.data.projection.Mercator;
     
    5961    }*/
    6062
     63    @BeforeClass
     64    public static void init() {
     65        Main.pref = new Preferences();
     66    }
     67
    6168    private DataSet my;
    6269    private DataSet their;
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r3459 r3577  
    1717import org.openstreetmap.josm.actions.search.SearchAction.SearchMode;
    1818import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
     19import org.openstreetmap.josm.data.Preferences;
    1920import org.openstreetmap.josm.data.coor.LatLon;
    2021import org.openstreetmap.josm.data.projection.Mercator;
     
    2526
    2627public class FilterTest {
     28
    2729    @BeforeClass
    2830    public static void setUp() {
    2931        Main.proj = new Mercator();
     32        Main.pref = new Preferences();
    3033    }
    3134
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandling.java

    r2917 r3577  
    44import static org.junit.Assert.assertTrue;
    55
     6import org.junit.BeforeClass;
    67import org.junit.Test;
     8import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.data.Preferences;
    710import org.openstreetmap.josm.data.coor.LatLon;
    811
     
    1013 * Some unit test cases for basic tag management on {@see OsmPrimitive}. Uses
    1114 * {@see Node} for the tests, {@see OsmPrimitive} is abstract.
    12  * 
     15 *
    1316 */
    1417public class OsmPrimitiveKeyHandling {
     18
     19    @BeforeClass
     20    public static void init() {
     21        Main.pref = new Preferences();
     22    }
    1523
    1624    /**
     
    3038    /**
    3139     * Add a tag to an empty node and test the query and get methods.
    32      * 
     40     *
    3341     */
    3442    @Test
     
    6270    /**
    6371     * Remove tags from a node with two tags and test the state of the node.
    64      * 
     72     *
    6573     */
    6674    @Test
     
    9098    /**
    9199     * Remove all tags from a node
    92      * 
     100     *
    93101     */
    94102    @Test
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r3459 r3577  
    99import org.junit.Test;
    1010import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.Preferences;
    1112import org.openstreetmap.josm.data.coor.LatLon;
    1213import org.openstreetmap.josm.data.projection.Mercator;
    1314
    1415public class OsmPrimitiveTest {
     16
     17    @BeforeClass
     18    public static void init() {
     19        Main.pref = new Preferences();
     20    }
    1521
    1622    private void compareReferrers(OsmPrimitive actual, OsmPrimitive... expected) {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r3476 r3577  
    1111import org.fest.reflect.reference.TypeRef;
    1212import org.junit.Assert;
     13import org.junit.BeforeClass;
    1314import org.junit.Test;
    1415import org.openstreetmap.josm.Main;
     16import org.openstreetmap.josm.data.Preferences;
    1517import org.openstreetmap.josm.data.coor.LatLon;
    1618import org.openstreetmap.josm.data.projection.Mercator;
     
    1921
    2022public class QuadBucketsTest {
     23
     24    @BeforeClass
     25    public static void init() {
     26        Main.pref = new Preferences();
     27    }
    2128
    2229    private void removeAllTest(DataSet ds) {
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r3283 r3577  
    88import org.junit.Test;
    99import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.data.Preferences;
    1011import org.openstreetmap.josm.data.coor.LatLon;
    1112import org.openstreetmap.josm.data.projection.Mercator;
     
    1617    public static void setUp() {
    1718        Main.proj = new Mercator();
     19        Main.pref = new Preferences();
    1820    }
    1921
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

    r3284 r3577  
    1212import org.junit.Test;
    1313import org.openstreetmap.josm.Main;
     14import org.openstreetmap.josm.data.Preferences;
    1415import org.openstreetmap.josm.data.coor.LatLon;
    1516import org.openstreetmap.josm.data.osm.DataSet;
     
    3738    public static void setUp() {
    3839        Main.proj = new Mercator();
     40        Main.pref = new Preferences();
    3941    }
    4042
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java

    r3025 r3577  
    1616import javax.swing.DefaultListSelectionModel;
    1717
     18import org.junit.BeforeClass;
    1819import org.junit.Test;
     20import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.data.Preferences;
    1922import org.openstreetmap.josm.data.osm.DatasetFactory;
    2023import org.openstreetmap.josm.data.osm.Node;
     
    2629    private DatasetFactory my = new DatasetFactory();
    2730    private DatasetFactory their = new DatasetFactory();
     31
     32    @BeforeClass
     33    public static void init() {
     34        Main.pref = new Preferences();
     35    }
    2836
    2937    @SuppressWarnings("unchecked")
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java

    r3034 r3577  
    1010
    1111import org.junit.Before;
     12import org.junit.BeforeClass;
    1213import org.junit.Test;
    1314import org.openstreetmap.josm.Main;
     15import org.openstreetmap.josm.data.Preferences;
    1416import org.openstreetmap.josm.data.conflict.Conflict;
    1517import org.openstreetmap.josm.data.coor.LatLon;
     
    4345    PropertiesMergeModel model;
    4446
     47    @BeforeClass
     48    public static void init() {
     49        Main.proj = new Epsg4326();
     50        Main.pref = new Preferences();
     51    }
     52
    4553    @Before
    4654    public void setUp() {
    4755        model = new PropertiesMergeModel();
    48         Main.proj = new Epsg4326();
    4956    }
    5057
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeItemTest.java

    r1954 r3577  
    22package org.openstreetmap.josm.gui.conflict.tags;
    33
    4 import org.junit.*;
     4import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertNull;
     6import static org.junit.Assert.fail;
     7
     8import org.junit.BeforeClass;
     9import org.junit.Test;
     10import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.Preferences;
    512import org.openstreetmap.josm.data.osm.Node;
    613import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
    714import org.openstreetmap.josm.gui.conflict.pair.tags.TagMergeItem;
    815
    9 import static org.junit.Assert.*;
    10 
    1116public class TagMergeItemTest {
    1217
    13    @Test
    14    public void test_TagMergeItem() {
    15        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    16        assertEquals("key", item.getKey());
    17        assertEquals("myvalue", item.getMyTagValue());
    18        assertEquals("theirvalue", item.getTheirTagValue());
    19        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());
    20    }
    21    
    22    @Test
    23    public void test_TagMergeItem_2() {
    24        Node n1 = new Node(1);
    25        Node n2 = new Node(1);
    26        n1.put("key", "myvalue");
    27        n2.put("key", "theirvalue");
    28        
    29        TagMergeItem item = new TagMergeItem("key", n1, n2);
    30        assertEquals("key", item.getKey());
    31        assertEquals("myvalue", item.getMyTagValue());
    32        assertEquals("theirvalue", item.getTheirTagValue());
    33        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());       
    34    }
    35    
    36    @Test
    37    public void test_TagMergeItem_3() {
    38        Node n1 = new Node(1);
    39        Node n2 = new Node(1);
    40        n1.put("key", "myvalue");
    41        // n2 does not have this key
    42        
    43        TagMergeItem item = new TagMergeItem("key", n1, n2);
    44        assertEquals("key", item.getKey());
    45        assertEquals("myvalue", item.getMyTagValue());
    46        assertNull(item.getTheirTagValue());
    47        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());       
    48    }
    49    
    50    @Test
    51    public void test_TagMergeItem_4() {
    52        Node n1 = new Node(1);
    53        Node n2 = new Node(1);
    54        // n1 does not have this key
    55        // n1.put("key", "myvalue");
    56        n2.put("key", "theirvalue");
    57        
    58        TagMergeItem item = new TagMergeItem("key", n1, n2);
    59        assertEquals("key", item.getKey());
    60        assertNull(item.getMyTagValue());
    61        assertEquals("theirvalue",item.getTheirTagValue());
    62        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());       
    63    }
    64    
    65    
    66    @Test
    67    public void test_decide() {
    68        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    69        item.decide(MergeDecisionType.KEEP_MINE);
    70        assertEquals(MergeDecisionType.KEEP_MINE, item.getMergeDecision());       
    71    }
    72    
    73    @Test()
    74    public void test_decide_1() {
    75        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    76        try {
    77            item.decide(null);
    78            fail("expected IllegalArgumentException not thrown");
    79        } catch(IllegalArgumentException e) {
    80            // OK
    81        }           
    82    }
    83    
    84    @Test()
    85    public void test_applyToMyPrimitive() {
    86        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    87        item.decide(MergeDecisionType.KEEP_MINE);
    88        
    89        Node n1 = new Node(1);
    90        n1.put("key", "oldvalue");
    91        item.applyToMyPrimitive(n1);       
    92        assertEquals("myvalue", n1.get("key"));
     18    @BeforeClass
     19    public static void init() {
     20        Main.pref = new Preferences();
     21    }
    9322
    94        n1 = new Node(1);       
    95        item.applyToMyPrimitive(n1);       
    96        assertEquals("myvalue", n1.get("key"));
     23    @Test
     24    public void test_TagMergeItem() {
     25        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     26        assertEquals("key", item.getKey());
     27        assertEquals("myvalue", item.getMyTagValue());
     28        assertEquals("theirvalue", item.getTheirTagValue());
     29        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());
     30    }
    9731
    98    }
    99    
    100    @Test()
    101    public void test_applyToMyPrimitive_2() {
    102        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    103        item.decide(MergeDecisionType.KEEP_THEIR);
    104        
    105        Node n1 = new Node(1);
    106        n1.put("key", "oldvalue");
    107        item.applyToMyPrimitive(n1);       
    108        assertEquals("theirvalue", n1.get("key"));
     32    @Test
     33    public void test_TagMergeItem_2() {
     34        Node n1 = new Node(1);
     35        Node n2 = new Node(1);
     36        n1.put("key", "myvalue");
     37        n2.put("key", "theirvalue");
    10938
    110        n1 = new Node(1);       
    111        item.applyToMyPrimitive(n1);       
    112        assertEquals("theirvalue", n1.get("key"));
    113    }
    114    
    115    @Test()
    116    public void test_applyToMyPrimitive_3() {
    117        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    118        // item is undecided
    119        // item.decide(MergeDecisionType.KEEP_THEIR);
    120        
    121        Node n1 = new Node(1);
    122        n1.put("key", "oldvalue");
    123        try {
    124            item.applyToMyPrimitive(n1);
    125            fail("expected IllegalStateException");
    126        } catch(IllegalStateException e) {
    127            // OK
    128        }
    129    }
    130    
    131    @Test()
    132    public void test_applyToMyPrimitive_4() {
    133        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
    134        
    135        try {
    136            item.applyToMyPrimitive(null);
    137            fail("expected IllegalArgumentException");
    138        } catch(IllegalArgumentException e) {
    139            // OK
    140        }
    141    }
     39        TagMergeItem item = new TagMergeItem("key", n1, n2);
     40        assertEquals("key", item.getKey());
     41        assertEquals("myvalue", item.getMyTagValue());
     42        assertEquals("theirvalue", item.getTheirTagValue());
     43        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());
     44    }
     45
     46    @Test
     47    public void test_TagMergeItem_3() {
     48        Node n1 = new Node(1);
     49        Node n2 = new Node(1);
     50        n1.put("key", "myvalue");
     51        // n2 does not have this key
     52
     53        TagMergeItem item = new TagMergeItem("key", n1, n2);
     54        assertEquals("key", item.getKey());
     55        assertEquals("myvalue", item.getMyTagValue());
     56        assertNull(item.getTheirTagValue());
     57        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());
     58    }
     59
     60    @Test
     61    public void test_TagMergeItem_4() {
     62        Node n1 = new Node(1);
     63        Node n2 = new Node(1);
     64        // n1 does not have this key
     65        // n1.put("key", "myvalue");
     66        n2.put("key", "theirvalue");
     67
     68        TagMergeItem item = new TagMergeItem("key", n1, n2);
     69        assertEquals("key", item.getKey());
     70        assertNull(item.getMyTagValue());
     71        assertEquals("theirvalue",item.getTheirTagValue());
     72        assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision());
     73    }
     74
     75
     76    @Test
     77    public void test_decide() {
     78        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     79        item.decide(MergeDecisionType.KEEP_MINE);
     80        assertEquals(MergeDecisionType.KEEP_MINE, item.getMergeDecision());
     81    }
     82
     83    @Test()
     84    public void test_decide_1() {
     85        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     86        try {
     87            item.decide(null);
     88            fail("expected IllegalArgumentException not thrown");
     89        } catch(IllegalArgumentException e) {
     90            // OK
     91        }
     92    }
     93
     94    @Test()
     95    public void test_applyToMyPrimitive() {
     96        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     97        item.decide(MergeDecisionType.KEEP_MINE);
     98
     99        Node n1 = new Node(1);
     100        n1.put("key", "oldvalue");
     101        item.applyToMyPrimitive(n1);
     102        assertEquals("myvalue", n1.get("key"));
     103
     104        n1 = new Node(1);
     105        item.applyToMyPrimitive(n1);
     106        assertEquals("myvalue", n1.get("key"));
     107
     108    }
     109
     110    @Test()
     111    public void test_applyToMyPrimitive_2() {
     112        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     113        item.decide(MergeDecisionType.KEEP_THEIR);
     114
     115        Node n1 = new Node(1);
     116        n1.put("key", "oldvalue");
     117        item.applyToMyPrimitive(n1);
     118        assertEquals("theirvalue", n1.get("key"));
     119
     120        n1 = new Node(1);
     121        item.applyToMyPrimitive(n1);
     122        assertEquals("theirvalue", n1.get("key"));
     123    }
     124
     125    @Test()
     126    public void test_applyToMyPrimitive_3() {
     127        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     128        // item is undecided
     129        // item.decide(MergeDecisionType.KEEP_THEIR);
     130
     131        Node n1 = new Node(1);
     132        n1.put("key", "oldvalue");
     133        try {
     134            item.applyToMyPrimitive(n1);
     135            fail("expected IllegalStateException");
     136        } catch(IllegalStateException e) {
     137            // OK
     138        }
     139    }
     140
     141    @Test()
     142    public void test_applyToMyPrimitive_4() {
     143        TagMergeItem item = new TagMergeItem("key", "myvalue", "theirvalue");
     144
     145        try {
     146            item.applyToMyPrimitive(null);
     147            fail("expected IllegalArgumentException");
     148        } catch(IllegalArgumentException e) {
     149            // OK
     150        }
     151    }
    142152}
  • trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java

    r3095 r3577  
    1010import java.util.List;
    1111
     12import org.junit.BeforeClass;
    1213import org.junit.Test;
     14import org.openstreetmap.josm.Main;
     15import org.openstreetmap.josm.data.Preferences;
    1316import org.openstreetmap.josm.data.osm.Node;
    1417import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
     
    1821@SuppressWarnings("unchecked")
    1922public class TagMergeModelTest {
     23
     24    @BeforeClass
     25    public static void init() {
     26        Main.pref = new Preferences();
     27    }
    2028
    2129    @Test
Note: See TracChangeset for help on using the changeset viewer.