Changeset 8510 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r8509 r8510 72 72 } else { 73 73 File f = new File(josmHome); 74 if (! f.exists() || !f.canRead()) {74 if (!f.exists() || !f.canRead()) { 75 75 fail(MessageFormat.format( 76 76 "property ''{0}'' points to ''{1}'' which is either not existing ({2}) or not readable ({3}). Current directory is ''{4}''.", -
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r8257 r8510 52 52 System.out.println("Validating Comparable contract on array of "+array.length+" elements"); 53 53 // Check each compare possibility 54 for (int i =0; i<array.length; i++) {54 for (int i = 0; i < array.length; i++) { 55 55 T r1 = array[i]; 56 for (int j =i; j<array.length; j++) {56 for (int j = i; j < array.length; j++) { 57 57 T r2 = array[j]; 58 58 int a = comparator.compare(r1, r2); 59 59 int b = comparator.compare(r2, r1); 60 if (i ==j || a==b) {60 if (i == j || a == b) { 61 61 if (a != 0 || b != 0) { 62 62 fail(getFailMessage(r1, r2, a, b)); … … 67 67 } 68 68 } 69 for (int k =j; k<array.length; k++) {69 for (int k = j; k < array.length; k++) { 70 70 T r3 = array[k]; 71 71 int c = comparator.compare(r1, r3); -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r8450 r8510 113 113 private static class ConstantTrafficHand implements GeoProperty<Boolean> { 114 114 boolean isLeft; 115 115 116 ConstantTrafficHand(boolean isLeft) { 116 117 this.isLeft = isLeft; 117 118 } 119 118 120 @Override 119 121 public Boolean get(LatLon ll) { 120 122 return isLeft; 121 123 } 124 122 125 @Override 123 126 public Boolean get(BBox box) { -
trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
r8450 r8510 89 89 assertSame("Unselected way seems to have change during split action.", 90 90 w1.getNodesCount(), 3); 91 for (int i = 0; i < 3; i++) {91 for (int i = 0; i < 3; i++) { 92 92 assertSame("Node change in unselected way during split action.", 93 93 w1.getNode(i), w1NodesArray[i]); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r8509 r8510 40 40 public OsmDataLayer layer; 41 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 }; 50 42 51 MapViewMock(DataSet dataSet, OsmDataLayer layer) { 43 52 super(null, null); 44 53 this.layer = layer; 45 54 this.currentDataSet = dataSet; 46 }; 55 } 56 47 57 @Override 48 58 public EastNorth getEastNorth(int x, int y) { 49 59 return new EastNorth(x, y); 50 60 } 61 51 62 @Override 52 63 public void addMouseListener(MouseListener ml) {} 64 53 65 @Override 54 66 public void removeMouseListener(MouseListener ml) {} 67 55 68 public void addMouseMotionListener(MouseListener ml) {} 69 56 70 public void removeMouseMotionListener(MouseListener ml) {} 71 57 72 public void mvRepaint() {} 73 58 74 @Override 59 75 public void setVirtualNodesEnabled(boolean enabled) {} 76 60 77 @Override 61 78 public void setNewCursor(Cursor cursor, Object reference) {} 79 62 80 @Override 63 81 public void setNewCursor(int cursor, Object reference) {} 82 64 83 @Override 65 84 public boolean isActiveLayerVisible() { 66 85 return true; 67 86 } 68 public Predicate<OsmPrimitive> isSelectablePredicate = 69 new Predicate<OsmPrimitive>() { 70 @Override 71 public boolean evaluate(OsmPrimitive prim) { 72 return true; 73 } 74 }; 87 75 88 @Override 76 89 public void requestClearRect() {} 90 77 91 @Override 78 92 public Point2D getPoint2D(EastNorth p) { 79 93 return new Point2D.Double(p.getX(), p.getY()); 80 94 } 95 81 96 @Override 82 97 public void setActiveLayer(Layer layer) {} 98 83 99 @Override 84 100 public Layer getActiveLayer() { 85 101 return layer; 86 102 } 103 87 104 @Override 88 105 protected DataSet getCurrentDataSet() { … … 119 136 } 120 137 } 138 121 139 @Override 122 140 public void mergeNodes(OsmDataLayer layer, Collection<Node> nodes, -
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r8450 r8510 32 32 try { 33 33 apiDataSet.adjustRelationUploadOrder(); 34 } catch (CyclicUploadDependencyException e) {34 } catch (CyclicUploadDependencyException e) { 35 35 fail("unexpected exception:" + e); 36 36 } … … 58 58 try { 59 59 apiDataSet.adjustRelationUploadOrder(); 60 } catch (CyclicUploadDependencyException e) {60 } catch (CyclicUploadDependencyException e) { 61 61 fail("unexpected exception:" + e); 62 62 } … … 96 96 try { 97 97 apiDataSet.adjustRelationUploadOrder(); 98 } catch (CyclicUploadDependencyException e) {98 } catch (CyclicUploadDependencyException e) { 99 99 fail("unexpected exception:" + e); 100 100 } … … 134 134 try { 135 135 apiDataSet.adjustRelationUploadOrder(); 136 } catch (CyclicUploadDependencyException e) {136 } catch (CyclicUploadDependencyException e) { 137 137 fail("unexpected exception:" + e); 138 138 } … … 181 181 try { 182 182 apiDataSet.adjustRelationUploadOrder(); 183 } catch (CyclicUploadDependencyException e) {183 } catch (CyclicUploadDependencyException e) { 184 184 fail("unexpected exception:" + e); 185 185 } … … 256 256 apiDataSet.adjustRelationUploadOrder(); 257 257 fail("expected cyclic upload dependency exception not thrown"); 258 } catch (CyclicUploadDependencyException e) {258 } catch (CyclicUploadDependencyException e) { 259 259 System.out.println(e); 260 260 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetCacheTest.groovy
r7938 r8510 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.net.InetAddress.Cache; 5 import org.junit.Test 4 import static org.junit.Assert.* 5 6 import org.junit.Test 7 8 class ChangesetCacheTest { 9 10 @Test 11 public void test_Constructor() { 12 ChangesetCache cache = ChangesetCache.getInstance() 13 assert cache != null 14 } 15 16 @Test 17 public void test_addAndRemoveListeners() { 18 ChangesetCache cache = ChangesetCache.getInstance() 19 cache.clear() 20 21 // should work 22 cache.addChangesetCacheListener null 23 24 // should work 25 def listener = new ChangesetCacheListener() { 26 public void changesetCacheUpdated(ChangesetCacheEvent event) {} 27 } 28 cache.addChangesetCacheListener listener 29 // adding a second time - should work too 30 cache.addChangesetCacheListener listener 31 assert cache.@listeners.size() == 1 // ... but only added once 32 33 cache.removeChangesetCacheListener null 34 35 cache.removeChangesetCacheListener listener 36 assert cache.@listeners.size() == 0 37 } 38 39 @Test 40 public void update_get_remove_cycle() { 41 ChangesetCache cache = ChangesetCache.getInstance() 42 cache.clear() 43 44 cache.update new Changeset(1) 45 assert cache.size() == 1 46 assert cache.get(1) != null 47 assert cache.get(1).id == 1 48 cache.remove(1) 49 assert cache.size() == 0 50 } 51 52 @Test 53 public void updateTwice() { 54 ChangesetCache cache = ChangesetCache.getInstance() 55 cache.clear() 56 57 Changeset cs = new Changeset(1) 58 cs.incomplete = false 59 cs.put "key1", "value1" 60 cs.open = true 61 cache.update cs 62 63 Changeset cs2 = new Changeset(cs) 64 assert cs2 != null 65 cs2.put "key2", "value2" 66 cs2.open = false 67 cache.update(cs2) 68 69 assert cache.size() == 1 70 assert cache.get(1) != null 71 72 cs = cache.get(1) 73 assert cs.get("key1") == "value1" 74 assert cs.get("key2") == "value2" 75 assert !cs.open 76 } 6 77 7 78 8 import static org.junit.Assert.*; 79 @Test 80 public void contains() { 81 ChangesetCache cache = ChangesetCache.getInstance() 82 cache.@listeners.clear() 83 cache.clear() 9 84 10 class ChangesetCacheTest {11 12 @Test13 public void test_Constructor() {14 ChangesetCache cache = ChangesetCache.getInstance()15 assert cache != null16 }17 18 @Test19 public void test_addAndRemoveListeners() {20 ChangesetCache cache = ChangesetCache.getInstance()21 cache.clear()22 23 // should work24 cache.addChangesetCacheListener null25 26 // should work27 def listener = new ChangesetCacheListener() {28 public void changesetCacheUpdated(ChangesetCacheEvent event) {}29 }30 cache.addChangesetCacheListener listener31 // adding a second time - should work too32 cache.addChangesetCacheListener listener33 assert cache.@listeners.size() == 1 // ... but only added once34 35 cache.removeChangesetCacheListener null36 37 cache.removeChangesetCacheListener listener38 assert cache.@listeners.size() == 039 }40 41 @Test42 public void update_get_remove_cycle() {43 ChangesetCache cache = ChangesetCache.getInstance()44 cache.clear()45 46 cache.update new Changeset(1)47 assert cache.size() == 148 assert cache.get(1) != null49 assert cache.get(1).id == 150 cache.remove(1)51 assert cache.size() == 052 }53 54 @Test55 public void updateTwice() {56 ChangesetCache cache = ChangesetCache.getInstance()57 cache.clear()58 85 59 Changeset cs = new Changeset(1) 60 cs.incomplete = false 61 cs.put "key1", "value1" 62 cs.open = true 63 cache.update cs 64 65 Changeset cs2 = new Changeset(cs) 66 assert cs2 != null 67 cs2.put "key2", "value2" 68 cs2.open = false 69 cache.update(cs2) 70 71 assert cache.size() == 1 72 assert cache.get(1) != null 73 74 cs = cache.get(1) 75 assert cs.get("key1") == "value1" 76 assert cs.get("key2") == "value2" 77 assert !cs.open 78 } 79 80 81 @Test 82 public void contains() { 83 ChangesetCache cache = ChangesetCache.getInstance() 84 cache.@listeners.clear() 85 cache.clear() 86 87 88 Changeset cs = new Changeset(1) 89 cache.update cs 90 91 assert cache.contains(1) 92 assert cache.contains(cs) 93 assert cache.contains(new Changeset(cs)) 94 95 assert ! cache.contains(2) 96 assert ! cache.contains(new Changeset(2)) 97 assert ! cache.contains(null) 98 } 99 100 @Test 101 public void fireingEvents_AddAChangeset() { 102 ChangesetCache cache = ChangesetCache.getInstance() 103 cache.clear() 104 cache.@listeners.clear() 105 106 // should work 107 def listener = new ChangesetCacheListener() { 108 public void changesetCacheUpdated(ChangesetCacheEvent event) { 109 assert event != null 110 assert event.getAddedChangesets().size() == 1 111 assert event.getRemovedChangesets().empty 112 assert event.getUpdatedChangesets().empty 113 assert event.getSource() == cache 114 } 115 } 116 cache.addChangesetCacheListener listener 117 cache.update(new Changeset(1)) 118 cache.removeChangesetCacheListener listener 119 } 120 121 @Test 122 public void fireingEvents_UpdateChangeset() { 123 ChangesetCache cache = ChangesetCache.getInstance() 124 cache.clear() 125 cache.@listeners.clear() 126 127 // should work 128 def listener = new ChangesetCacheListener() { 129 public void changesetCacheUpdated(ChangesetCacheEvent event) { 130 assert event != null 131 assert event.getAddedChangesets().empty 132 assert event.getRemovedChangesets().empty 133 assert event.getUpdatedChangesets().size() == 1 134 assert event.getSource() == cache 135 } 136 } 137 cache.update(new Changeset(1)) 138 139 cache.addChangesetCacheListener listener 140 cache.update(new Changeset(1)) 141 cache.removeChangesetCacheListener listener 142 } 143 144 @Test 145 public void fireingEvents_RemoveChangeset() { 146 ChangesetCache cache = ChangesetCache.getInstance() 147 cache.clear() 148 cache.@listeners.clear() 149 150 // should work 151 def listener = new ChangesetCacheListener() { 152 public void changesetCacheUpdated(ChangesetCacheEvent event) { 153 assert event != null 154 assert event.getAddedChangesets().empty 155 assert event.getRemovedChangesets().size() == 1 156 assert event.getUpdatedChangesets().empty 157 assert event.getSource() == cache 158 } 159 } 160 cache.update(new Changeset(1)) 161 162 cache.addChangesetCacheListener listener 163 cache.remove 1 164 cache.removeChangesetCacheListener listener 165 } 166 86 Changeset cs = new Changeset(1) 87 cache.update cs 88 89 assert cache.contains(1) 90 assert cache.contains(cs) 91 assert cache.contains(new Changeset(cs)) 92 93 assert ! cache.contains(2) 94 assert ! cache.contains(new Changeset(2)) 95 assert ! cache.contains(null) 96 } 97 98 @Test 99 public void fireingEvents_AddAChangeset() { 100 ChangesetCache cache = ChangesetCache.getInstance() 101 cache.clear() 102 cache.@listeners.clear() 103 104 // should work 105 def listener = new ChangesetCacheListener() { 106 public void changesetCacheUpdated(ChangesetCacheEvent event) { 107 assert event != null 108 assert event.getAddedChangesets().size() == 1 109 assert event.getRemovedChangesets().empty 110 assert event.getUpdatedChangesets().empty 111 assert event.getSource() == cache 112 } 113 } 114 cache.addChangesetCacheListener listener 115 cache.update(new Changeset(1)) 116 cache.removeChangesetCacheListener listener 117 } 118 119 @Test 120 public void fireingEvents_UpdateChangeset() { 121 ChangesetCache cache = ChangesetCache.getInstance() 122 cache.clear() 123 cache.@listeners.clear() 124 125 // should work 126 def listener = new ChangesetCacheListener() { 127 public void changesetCacheUpdated(ChangesetCacheEvent event) { 128 assert event != null 129 assert event.getAddedChangesets().empty 130 assert event.getRemovedChangesets().empty 131 assert event.getUpdatedChangesets().size() == 1 132 assert event.getSource() == cache 133 } 134 } 135 cache.update(new Changeset(1)) 136 137 cache.addChangesetCacheListener listener 138 cache.update(new Changeset(1)) 139 cache.removeChangesetCacheListener listener 140 } 141 142 @Test 143 public void fireingEvents_RemoveChangeset() { 144 ChangesetCache cache = ChangesetCache.getInstance() 145 cache.clear() 146 cache.@listeners.clear() 147 148 // should work 149 def listener = new ChangesetCacheListener() { 150 public void changesetCacheUpdated(ChangesetCacheEvent event) { 151 assert event != null 152 assert event.getAddedChangesets().empty 153 assert event.getRemovedChangesets().size() == 1 154 assert event.getUpdatedChangesets().empty 155 assert event.getSource() == cache 156 } 157 } 158 cache.update(new Changeset(1)) 159 160 cache.addChangesetCacheListener listener 161 cache.remove 1 162 cache.removeChangesetCacheListener listener 163 } 167 164 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java
r8450 r8510 75 75 @Test 76 76 public void nodeSimple_IdenticalNoConflict() { 77 Node n = new Node(new LatLon(0, 0));78 n.setOsmId(1, 1);77 Node n = new Node(new LatLon(0, 0)); 78 n.setOsmId(1, 1); 79 79 n.setModified(false); 80 80 n.put("key1", "value1"); 81 81 my.addPrimitive(n); 82 82 83 Node n1 = new Node(new LatLon(0, 0));84 n1.setOsmId(1, 1);83 Node n1 = new Node(new LatLon(0, 0)); 84 n1.setOsmId(1, 1); 85 85 n1.setModified(false); 86 86 n1.put("key1", "value1"); … … 88 88 89 89 90 DataSetMerger visitor = new DataSetMerger(my, their);91 visitor.merge(); 92 93 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);90 DataSetMerger visitor = new DataSetMerger(my, their); 91 visitor.merge(); 92 93 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 94 94 assertTrue(visitor.getConflicts().isEmpty()); 95 95 assertNotSame(n1, n2); // make sure we have a clone … … 110 110 @Test 111 111 public void nodeSimple_locallyUnmodifiedNoConflict() { 112 Node n = new Node(new LatLon(0, 0));113 n.setOsmId(1, 1);112 Node n = new Node(new LatLon(0, 0)); 113 n.setOsmId(1, 1); 114 114 n.setModified(false); 115 115 n.put("key1", "value1"); 116 116 my.addPrimitive(n); 117 117 118 Node n1 = new Node(new LatLon(0, 0));119 n1.setOsmId(1, 2);118 Node n1 = new Node(new LatLon(0, 0)); 119 n1.setOsmId(1, 2); 120 120 n1.setModified(false); 121 121 n1.put("key1", "value1-new"); … … 124 124 125 125 126 DataSetMerger visitor = new DataSetMerger(my, their);127 visitor.merge(); 128 129 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);126 DataSetMerger visitor = new DataSetMerger(my, their); 127 visitor.merge(); 128 129 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 130 130 assertTrue(visitor.getConflicts().isEmpty()); 131 131 assertSame(n, n2); // make sure the merged node is still the original node … … 150 150 @Test 151 151 public void nodeSimple_TagConflict() { 152 Node n = new Node(new LatLon(0, 0));153 n.setOsmId(1, 1);152 Node n = new Node(new LatLon(0, 0)); 153 n.setOsmId(1, 1); 154 154 n.setModified(true); 155 155 n.put("key1", "value1"); … … 157 157 my.addPrimitive(n); 158 158 159 Node n1 = new Node(new LatLon(0, 0));160 n1.setOsmId(1, 2);159 Node n1 = new Node(new LatLon(0, 0)); 160 n1.setOsmId(1, 2); 161 161 n1.setModified(false); 162 162 n1.put("key1", "value1-new"); … … 165 165 166 166 167 DataSetMerger visitor = new DataSetMerger(my, their);168 visitor.merge(); 169 170 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);171 assertEquals(1, visitor.getConflicts().size());167 DataSetMerger visitor = new DataSetMerger(my, their); 168 visitor.merge(); 169 170 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 171 assertEquals(1, visitor.getConflicts().size()); 172 172 assertSame(n, n2); 173 173 assertNotSame(n1, n2); … … 185 185 public void nodeSimple_DeleteConflict() { 186 186 Node n = new Node(1, 1); 187 n.setCoor(new LatLon(0, 0));187 n.setCoor(new LatLon(0, 0)); 188 188 n.setDeleted(true); 189 189 n.put("key1", "value1"); 190 190 my.addPrimitive(n); 191 191 192 Node n1 = new Node(new LatLon(0, 0));193 n1.setOsmId(1, 2);192 Node n1 = new Node(new LatLon(0, 0)); 193 n1.setOsmId(1, 2); 194 194 n1.setModified(false); 195 195 n1.put("key1", "value1-new"); … … 198 198 199 199 200 DataSetMerger visitor = new DataSetMerger(my, their);201 visitor.merge(); 202 203 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);204 assertEquals(1, visitor.getConflicts().size());200 DataSetMerger visitor = new DataSetMerger(my, their); 201 visitor.merge(); 202 203 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 204 assertEquals(1, visitor.getConflicts().size()); 205 205 assertSame(n, n2); 206 206 assertNotSame(n1, n2); … … 215 215 @Test 216 216 public void nodeSimple_DeleteConflict_2() { 217 Node n = new Node(new LatLon(0, 0));218 n.setOsmId(1, 1);217 Node n = new Node(new LatLon(0, 0)); 218 n.setOsmId(1, 1); 219 219 n.setDeleted(true); 220 220 my.addPrimitive(n); 221 221 222 Node n1 = new Node(new LatLon(0, 0));223 n1.setOsmId(1, 1);224 their.addPrimitive(n1); 225 226 227 DataSetMerger visitor = new DataSetMerger(my, their);228 visitor.merge(); 229 230 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);231 assertEquals(0, visitor.getConflicts().size());222 Node n1 = new Node(new LatLon(0, 0)); 223 n1.setOsmId(1, 1); 224 their.addPrimitive(n1); 225 226 227 DataSetMerger visitor = new DataSetMerger(my, their); 228 visitor.merge(); 229 230 Node n2 = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 231 assertEquals(0, visitor.getConflicts().size()); 232 232 assertTrue(n2.isVisible()); 233 233 assertSame(n, n2); … … 243 243 @Test 244 244 public void nodeSimple_DeleteConflict_3() { 245 Node n = new Node(new LatLon(1, 1));245 Node n = new Node(new LatLon(1, 1)); 246 246 n.setDeleted(true); 247 247 my.addPrimitive(n); 248 248 249 Node n1 = new Node(new LatLon(1, 1));250 their.addPrimitive(n1); 251 252 253 DataSetMerger visitor = new DataSetMerger(my, their);249 Node n1 = new Node(new LatLon(1, 1)); 250 their.addPrimitive(n1); 251 252 253 DataSetMerger visitor = new DataSetMerger(my, their); 254 254 visitor.merge(); 255 255 … … 267 267 @Test 268 268 public void nodeSimple_DeleteConflict_4() { 269 Node n = new Node(new LatLon(1, 1));269 Node n = new Node(new LatLon(1, 1)); 270 270 n.setDeleted(true); 271 271 my.addPrimitive(n); 272 272 273 Node n1 = new Node(new LatLon(1, 1));273 Node n1 = new Node(new LatLon(1, 1)); 274 274 n1.setDeleted(true); 275 275 their.addPrimitive(n1); 276 276 277 277 278 DataSetMerger visitor = new DataSetMerger(my, their);279 visitor.merge(); 280 281 assertEquals(0, visitor.getConflicts().size());282 Node n2 = (Node) my.getNodes().toArray()[0];278 DataSetMerger visitor = new DataSetMerger(my, their); 279 visitor.merge(); 280 281 assertEquals(0, visitor.getConflicts().size()); 282 Node n2 = (Node) my.getNodes().toArray()[0]; 283 283 assertSame(n2, n); 284 284 assertTrue(n2.isDeleted()); … … 301 301 302 302 Node n = new Node(); 303 n.setCoor(new LatLon(0, 0));303 n.setCoor(new LatLon(0, 0)); 304 304 n.put("key1", "value1"); 305 305 n.setUser(myUser); … … 309 309 310 310 Node n1 = new Node(); 311 n1.setCoor(new LatLon(0, 0));311 n1.setCoor(new LatLon(0, 0)); 312 312 n1.put("key1", "value1"); 313 313 cal.add(Calendar.HOUR, 1); … … 318 318 319 319 320 DataSetMerger visitor = new DataSetMerger(my, their);320 DataSetMerger visitor = new DataSetMerger(my, their); 321 321 visitor.merge(); 322 322 323 323 Node n2 = my.getNodes().iterator().next(); 324 assertEquals(0, visitor.getConflicts().size());325 assertEquals("value1", n2.get("key1"));324 assertEquals(0, visitor.getConflicts().size()); 325 assertEquals("value1", n2.get("key1")); 326 326 assertTrue(n1.getTimestamp().equals(n2.getTimestamp())); 327 assertEquals(theirUser, n2.getUser());327 assertEquals(theirUser, n2.getUser()); 328 328 assertSame(n2, n); 329 329 assertNotSame(n2, n1); … … 344 344 345 345 Node n1 = new Node(); 346 n1.setCoor(new LatLon(0, 0));347 n1.setOsmId(1, 1);346 n1.setCoor(new LatLon(0, 0)); 347 n1.setOsmId(1, 1); 348 348 n1.put("key1", "value1"); 349 349 Date timestamp = new Date(); … … 352 352 353 353 354 DataSetMerger visitor = new DataSetMerger(my, their);354 DataSetMerger visitor = new DataSetMerger(my, their); 355 355 visitor.merge(); 356 356 357 357 Node n2 = my.getNodes().iterator().next(); 358 assertEquals(0, visitor.getConflicts().size());359 assertEquals("value1", n2.get("key1"));358 assertEquals(0, visitor.getConflicts().size()); 359 assertEquals("value1", n2.get("key1")); 360 360 assertTrue(n1.getTimestamp().equals(n2.getTimestamp())); 361 361 assertFalse(n2.isIncomplete()); … … 376 376 377 377 Node n1 = new Node(); 378 n1.setCoor(new LatLon(0, 0));379 n1.setOsmId(1, 1);378 n1.setCoor(new LatLon(0, 0)); 379 n1.setOsmId(1, 1); 380 380 my.addPrimitive(n1); 381 381 382 382 Node n2 = new Node(); 383 n2.setCoor(new LatLon(0, 0));384 n2.setOsmId(2, 1);383 n2.setCoor(new LatLon(0, 0)); 384 n2.setOsmId(2, 1); 385 385 386 386 my.addPrimitive(n2); 387 387 388 388 Way myWay = new Way(); 389 myWay.setOsmId(3, 1);389 myWay.setOsmId(3, 1); 390 390 myWay.put("key1", "value1"); 391 391 myWay.addNode(n1); … … 395 395 // -- the source data set 396 396 397 Node n3 = new Node(new LatLon(0, 0));398 n3.setOsmId(1, 1);397 Node n3 = new Node(new LatLon(0, 0)); 398 n3.setOsmId(1, 1); 399 399 their.addPrimitive(n3); 400 400 401 Node n4 = new Node(new LatLon(1, 1));402 n4.setOsmId(2, 1);401 Node n4 = new Node(new LatLon(1, 1)); 402 n4.setOsmId(2, 1); 403 403 their.addPrimitive(n4); 404 404 405 405 Way theirWay = new Way(); 406 theirWay.setOsmId(3, 2);406 theirWay.setOsmId(3, 2); 407 407 theirWay.put("key1", "value1"); 408 408 theirWay.put("key2", "value2"); … … 412 412 413 413 414 DataSetMerger visitor = new DataSetMerger(my, their);414 DataSetMerger visitor = new DataSetMerger(my, their); 415 415 visitor.merge(); 416 416 417 417 // -- tests 418 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);419 assertEquals(0, visitor.getConflicts().size());420 assertEquals("value1", merged.get("key1"));421 assertEquals("value2", merged.get("key2"));422 assertEquals(3, merged.getId());423 assertEquals(2, merged.getVersion());424 assertEquals(2, merged.getNodesCount());425 assertEquals(1, merged.getNode(0).getId());426 assertEquals(2, merged.getNode(1).getId());418 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 419 assertEquals(0, visitor.getConflicts().size()); 420 assertEquals("value1", merged.get("key1")); 421 assertEquals("value2", merged.get("key2")); 422 assertEquals(3, merged.getId()); 423 assertEquals(2, merged.getVersion()); 424 assertEquals(2, merged.getNodesCount()); 425 assertEquals(1, merged.getNode(0).getId()); 426 assertEquals(2, merged.getNode(1).getId()); 427 427 assertSame(merged, myWay); 428 428 assertSame(merged.getDataSet(), my); 429 429 430 Node mergedNode = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);430 Node mergedNode = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 431 431 assertSame(mergedNode, n1); 432 mergedNode = (Node) my.getPrimitiveById(2, OsmPrimitiveType.NODE);432 mergedNode = (Node) my.getPrimitiveById(2, OsmPrimitiveType.NODE); 433 433 assertSame(mergedNode, n2); 434 434 … … 448 448 // -- my data set 449 449 450 Node n1 = new Node(new LatLon(0, 0));451 n1.setOsmId(1, 1);450 Node n1 = new Node(new LatLon(0, 0)); 451 n1.setOsmId(1, 1); 452 452 my.addPrimitive(n1); 453 453 454 Node n2 = new Node(new LatLon(1, 1));455 n2.setOsmId(2, 1);454 Node n2 = new Node(new LatLon(1, 1)); 455 n2.setOsmId(2, 1); 456 456 my.addPrimitive(n2); 457 457 458 458 Way myWay = new Way(); 459 myWay.setOsmId(3, 1);459 myWay.setOsmId(3, 1); 460 460 myWay.addNode(n1); 461 461 myWay.addNode(n2); … … 464 464 // --- their data set 465 465 466 Node n3 = new Node(new LatLon(0, 0));467 n3.setOsmId(1, 1);466 Node n3 = new Node(new LatLon(0, 0)); 467 n3.setOsmId(1, 1); 468 468 their.addPrimitive(n3); 469 469 470 Node n5 = new Node(new LatLon(1, 1));471 n5.setOsmId(4, 1);470 Node n5 = new Node(new LatLon(1, 1)); 471 n5.setOsmId(4, 1); 472 472 473 473 their.addPrimitive(n5); 474 474 475 Node n4 = new Node(new LatLon(2, 2));476 n4.setOsmId(2, 2);475 Node n4 = new Node(new LatLon(2, 2)); 476 n4.setOsmId(2, 2); 477 477 n4.put("key1", "value1"); 478 478 their.addPrimitive(n4); … … 480 480 481 481 Way theirWay = new Way(); 482 theirWay.setOsmId(3, 2);482 theirWay.setOsmId(3, 2); 483 483 theirWay.addNode(n3); 484 484 theirWay.addNode(n5); // insert a node … … 486 486 their.addPrimitive(theirWay); 487 487 488 DataSetMerger visitor = new DataSetMerger(my, their);488 DataSetMerger visitor = new DataSetMerger(my, their); 489 489 visitor.merge(); 490 490 491 491 // -- tests 492 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);493 assertEquals(0, visitor.getConflicts().size());494 assertEquals(3, merged.getId());495 assertEquals(2, merged.getVersion());496 assertEquals(3, merged.getNodesCount());497 assertEquals(1, merged.getNode(0).getId());498 assertEquals(4, merged.getNode(1).getId());499 assertEquals(2, merged.getNode(2).getId());500 assertEquals("value1", merged.getNode(2).get("key1"));492 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 493 assertEquals(0, visitor.getConflicts().size()); 494 assertEquals(3, merged.getId()); 495 assertEquals(2, merged.getVersion()); 496 assertEquals(3, merged.getNodesCount()); 497 assertEquals(1, merged.getNode(0).getId()); 498 assertEquals(4, merged.getNode(1).getId()); 499 assertEquals(2, merged.getNode(2).getId()); 500 assertEquals("value1", merged.getNode(2).get("key1")); 501 501 502 502 assertSame(merged.getNode(0), n1); … … 518 518 // -- the target dataset 519 519 520 Node n1 = new Node(new LatLon(0, 0));521 n1.setOsmId(1, 1);520 Node n1 = new Node(new LatLon(0, 0)); 521 n1.setOsmId(1, 1); 522 522 my.addPrimitive(n1); 523 523 524 Node n2 = new Node(new LatLon(1, 1));525 n2.setOsmId(2, 1);524 Node n2 = new Node(new LatLon(1, 1)); 525 n2.setOsmId(2, 1); 526 526 my.addPrimitive(n2); 527 527 528 528 Way myWay = new Way(); 529 myWay.setOsmId(3, 1);529 myWay.setOsmId(3, 1); 530 530 531 531 myWay.addNode(n1); … … 537 537 // -- the source dataset 538 538 539 Node n3 = new Node(new LatLon(0, 0));540 n3.setOsmId(1, 1);539 Node n3 = new Node(new LatLon(0, 0)); 540 n3.setOsmId(1, 1); 541 541 their.addPrimitive(n3); 542 542 543 Node n5 = new Node(new LatLon(1, 1));544 n5.setOsmId(4, 1);543 Node n5 = new Node(new LatLon(1, 1)); 544 n5.setOsmId(4, 1); 545 545 their.addPrimitive(n5); 546 546 547 Node n4 = new Node(new LatLon(2, 2));548 n4.setOsmId(2, 1);547 Node n4 = new Node(new LatLon(2, 2)); 548 n4.setOsmId(2, 1); 549 549 n4.put("key1", "value1"); 550 550 their.addPrimitive(n4); 551 551 552 553 552 Way theirWay = new Way(); 554 theirWay.setOsmId(3, 2);553 theirWay.setOsmId(3, 2); 555 554 556 555 theirWay.addNode(n3); … … 563 562 visitor.merge(); 564 563 565 Way merged = (Way)my.getPrimitiveById(3, OsmPrimitiveType.WAY); 566 assertEquals(1,visitor.getConflicts().size()); 567 assertEquals(3,merged.getId()); 568 assertEquals(1,merged.getVersion()); 569 assertEquals(2,merged.getNodesCount()); 570 assertEquals(1,merged.getNode(0).getId()); 571 assertEquals(2,merged.getNode(1).getId()); 572 assertEquals("value1",merged.get("key1")); 573 } 574 564 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 565 assertEquals(1, visitor.getConflicts().size()); 566 assertEquals(3, merged.getId()); 567 assertEquals(1, merged.getVersion()); 568 assertEquals(2, merged.getNodesCount()); 569 assertEquals(1, merged.getNode(0).getId()); 570 assertEquals(2, merged.getNode(1).getId()); 571 assertEquals("value1", merged.get("key1")); 572 } 575 573 576 574 /** … … 583 581 public void waySimple_TheirVersionNotVisibleMyIsModified() { 584 582 585 586 Node mn1 = new Node(new LatLon(0,0)); 587 mn1.setOsmId(1,1); 583 Node mn1 = new Node(new LatLon(0, 0)); 584 mn1.setOsmId(1, 1); 588 585 my.addPrimitive(mn1); 589 586 590 Node mn2 = new Node(new LatLon(1, 1));591 mn2.setOsmId(2, 1);587 Node mn2 = new Node(new LatLon(1, 1)); 588 mn2.setOsmId(2, 1); 592 589 my.addPrimitive(mn2); 593 590 594 591 Way myWay = new Way(); 595 myWay.setOsmId(3, 1);592 myWay.setOsmId(3, 1); 596 593 myWay.addNode(mn1); 597 594 myWay.addNode(mn2); … … 599 596 my.addPrimitive(myWay); 600 597 601 602 598 Way theirWay = new Way(); 603 theirWay.setOsmId(3, 2);599 theirWay.setOsmId(3, 2); 604 600 theirWay.setVisible(false); 605 601 /* Invisible objects fetched from the server should be marked as "deleted". … … 609 605 their.addPrimitive(theirWay); 610 606 611 DataSetMerger visitor = new DataSetMerger(my, their);612 visitor.merge(); 613 614 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);615 assertEquals(1, visitor.getConflicts().size());607 DataSetMerger visitor = new DataSetMerger(my, their); 608 visitor.merge(); 609 610 Way merged = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 611 assertEquals(1, visitor.getConflicts().size()); 616 612 assertTrue(visitor.getConflicts().hasConflictForMy(myWay)); 617 613 assertTrue(visitor.getConflicts().hasConflictForTheir(theirWay)); 618 assertEquals(myWay, merged);614 assertEquals(myWay, merged); 619 615 } 620 616 … … 630 626 // -- my data set 631 627 632 Node n1 = new Node(new LatLon(0, 0));633 n1.setOsmId(1, 1);628 Node n1 = new Node(new LatLon(0, 0)); 629 n1.setOsmId(1, 1); 634 630 my.addPrimitive(n1); 635 631 636 Node n2 = new Node(new LatLon(1, 1));637 n2.setOsmId(2, 1);632 Node n2 = new Node(new LatLon(1, 1)); 633 n2.setOsmId(2, 1); 638 634 my.addPrimitive(n2); 639 635 … … 645 641 // -- their data set 646 642 647 Node n3 = new Node(new LatLon(0, 0));648 n3.setOsmId(1, 1);643 Node n3 = new Node(new LatLon(0, 0)); 644 n3.setOsmId(1, 1); 649 645 their.addPrimitive(n3); 650 646 651 Node n4 = new Node(new LatLon(1, 1));652 n4.setOsmId(2, 1);647 Node n4 = new Node(new LatLon(1, 1)); 648 n4.setOsmId(2, 1); 653 649 their.addPrimitive(n4); 654 650 … … 661 657 their.addPrimitive(theirWay); 662 658 663 DataSetMerger visitor = new DataSetMerger(my, their);659 DataSetMerger visitor = new DataSetMerger(my, their); 664 660 visitor.merge(); 665 661 666 662 // -- tests 667 Way merged = (Way) my.getWays().toArray()[0];668 assertEquals(0, visitor.getConflicts().size());663 Way merged = (Way) my.getWays().toArray()[0]; 664 assertEquals(0, visitor.getConflicts().size()); 669 665 assertEquals("their", merged.getUser().getName()); 670 666 assertEquals(1111, merged.getUser().getId()); … … 688 684 // -- my data set 689 685 690 Node n1 = new Node(new LatLon(0, 0));686 Node n1 = new Node(new LatLon(0, 0)); 691 687 my.addPrimitive(n1); 692 688 693 Node n2 = new Node(new LatLon(1, 1));689 Node n2 = new Node(new LatLon(1, 1)); 694 690 my.addPrimitive(n2); 695 691 … … 701 697 // -- their data set 702 698 703 Node n3 = new Node(new LatLon(0, 0));699 Node n3 = new Node(new LatLon(0, 0)); 704 700 their.addPrimitive(n3); 705 701 706 Node n4 = new Node(new LatLon(1, 1));702 Node n4 = new Node(new LatLon(1, 1)); 707 703 their.addPrimitive(n4); 708 704 … … 715 711 their.addPrimitive(theirWay); 716 712 717 DataSetMerger visitor = new DataSetMerger(my, their);713 DataSetMerger visitor = new DataSetMerger(my, their); 718 714 visitor.merge(); 719 715 720 716 // -- tests 721 Way merged = (Way) my.getWays().toArray()[0];722 assertEquals(0, visitor.getConflicts().size());717 Way merged = (Way) my.getWays().toArray()[0]; 718 assertEquals(0, visitor.getConflicts().size()); 723 719 assertEquals("their", merged.getUser().getName()); 724 720 assertEquals(1111, merged.getUser().getId()); … … 731 727 } 732 728 733 734 729 /** 735 730 * My dataset includes a deleted node. … … 745 740 // -- my dataset 746 741 747 Node mn1 = new Node(new LatLon(0, 0));748 mn1.setOsmId(1, 1);742 Node mn1 = new Node(new LatLon(0, 0)); 743 mn1.setOsmId(1, 1); 749 744 mn1.setDeleted(true); 750 745 my.addPrimitive(mn1); 751 746 752 753 Node tn1 = new Node(new LatLon(0,0)); 754 tn1.setOsmId(1,1); 747 Node tn1 = new Node(new LatLon(0, 0)); 748 tn1.setOsmId(1, 1); 755 749 their.addPrimitive(tn1); 756 750 757 Node tn2 = new Node(new LatLon(1, 1));758 tn2.setOsmId(2, 1);751 Node tn2 = new Node(new LatLon(1, 1)); 752 tn2.setOsmId(2, 1); 759 753 their.addPrimitive(tn2); 760 754 761 Node tn3 = new Node(new LatLon(2, 2));762 tn3.setOsmId(3, 1);755 Node tn3 = new Node(new LatLon(2, 2)); 756 tn3.setOsmId(3, 1); 763 757 their.addPrimitive(tn3); 764 758 765 759 // -- their data set 766 760 Way theirWay = new Way(); 767 theirWay.setOsmId(4, 1);761 theirWay.setOsmId(4, 1); 768 762 theirWay.addNode(tn1); 769 763 theirWay.addNode(tn2); … … 773 767 their.addPrimitive(theirWay); 774 768 775 DataSetMerger visitor = new DataSetMerger(my, their);769 DataSetMerger visitor = new DataSetMerger(my, their); 776 770 visitor.merge(); 777 771 … … 779 773 assertTrue(visitor.getConflicts().get(0).isMyDeleted()); 780 774 781 Way myWay = (Way) my.getPrimitiveById(4, OsmPrimitiveType.WAY);775 Way myWay = (Way) my.getPrimitiveById(4, OsmPrimitiveType.WAY); 782 776 assertEquals(3, myWay.getNodesCount()); 783 777 784 Node n = (Node) my.getPrimitiveById(1,OsmPrimitiveType.NODE);778 Node n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 785 779 assertTrue(myWay.getNodes().contains(n)); 786 780 … … 799 793 public void relationComplex_mergingADeletedNode() { 800 794 801 802 Node mn1 = new Node(new LatLon(0,0)); 803 mn1.setOsmId(1,1); 795 Node mn1 = new Node(new LatLon(0, 0)); 796 mn1.setOsmId(1, 1); 804 797 mn1.setDeleted(true); 805 798 my.addPrimitive(mn1); 806 799 807 800 808 Node tn1 = new Node(new LatLon(0, 0));809 tn1.setOsmId(1, 1);801 Node tn1 = new Node(new LatLon(0, 0)); 802 tn1.setOsmId(1, 1); 810 803 their.addPrimitive(tn1); 811 804 812 Node tn2 = new Node(new LatLon(1, 1));813 tn2.setOsmId(2, 1);805 Node tn2 = new Node(new LatLon(1, 1)); 806 tn2.setOsmId(2, 1); 814 807 their.addPrimitive(tn2); 815 808 816 Node tn3 = new Node(new LatLon(2, 2));817 tn3.setOsmId(3, 1);809 Node tn3 = new Node(new LatLon(2, 2)); 810 tn3.setOsmId(3, 1); 818 811 their.addPrimitive(tn3); 819 812 820 813 821 814 Relation theirRelation = new Relation(); 822 theirRelation.setOsmId(4, 1);815 theirRelation.setOsmId(4, 1); 823 816 824 817 theirRelation.addMember(new RelationMember("", tn1)); … … 827 820 their.addPrimitive(theirRelation); 828 821 829 DataSetMerger visitor = new DataSetMerger(my, their);830 visitor.merge(); 831 832 Node n = (Node) my.getPrimitiveById(1,OsmPrimitiveType.NODE);822 DataSetMerger visitor = new DataSetMerger(my, their); 823 visitor.merge(); 824 825 Node n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 833 826 assertNotNull(n); 834 827 … … 837 830 assertTrue(visitor.getConflicts().get(0).isMyDeleted()); 838 831 839 Relation r = (Relation) my.getPrimitiveById(4,OsmPrimitiveType.RELATION);832 Relation r = (Relation) my.getPrimitiveById(4, OsmPrimitiveType.RELATION); 840 833 assertEquals(3, r.getMembersCount()); 841 834 … … 858 851 859 852 Way w3 = new Way(3); 860 w3.setNodes(Arrays.asList(n1, n2));853 w3.setNodes(Arrays.asList(n1, n2)); 861 854 their.addPrimitive(w3); 862 855 assertTrue(w3.isIncomplete()); 863 856 864 865 DataSetMerger visitor = new DataSetMerger(my, their); 866 visitor.merge(); 867 868 assertEquals(0,visitor.getConflicts().size()); 869 870 OsmPrimitive p= my.getPrimitiveById(1, OsmPrimitiveType.NODE); 857 DataSetMerger visitor = new DataSetMerger(my, their); 858 visitor.merge(); 859 860 assertEquals(0, visitor.getConflicts().size()); 861 862 OsmPrimitive p = my.getPrimitiveById(1, OsmPrimitiveType.NODE); 871 863 assertNotNull(p); 872 864 assertTrue(p.isIncomplete()); 873 p = my.getPrimitiveById(2, OsmPrimitiveType.NODE);865 p = my.getPrimitiveById(2, OsmPrimitiveType.NODE); 874 866 assertNotNull(p); 875 867 assertTrue(p.isIncomplete()); 876 p = my.getPrimitiveById(3, OsmPrimitiveType.WAY);868 p = my.getPrimitiveById(3, OsmPrimitiveType.WAY); 877 869 assertNotNull(p); 878 870 assertTrue(p.isIncomplete()); 879 871 880 Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);872 Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 881 873 assertNotNull(w); 882 874 assertTrue(p.isIncomplete()); … … 904 896 // an incomplete way with two incomplete nodes 905 897 Way w3 = new Way(3); 906 w3.setNodes(Arrays.asList(n1, n2));898 w3.setNodes(Arrays.asList(n1, n2)); 907 899 their.addPrimitive(w3); 908 900 909 910 Node n4 = new Node(new LatLon(0,0)); 911 n4.setOsmId(1,1); 901 Node n4 = new Node(new LatLon(0, 0)); 902 n4.setOsmId(1, 1); 912 903 my.addPrimitive(n4); 913 904 914 Node n5 = new Node(new LatLon(1, 1));915 n5.setOsmId(2, 1);905 Node n5 = new Node(new LatLon(1, 1)); 906 n5.setOsmId(2, 1); 916 907 my.addPrimitive(n5); 917 908 918 909 Way w6 = new Way(3, 1); 919 w6.setNodes(Arrays.asList(n4, n5));910 w6.setNodes(Arrays.asList(n4, n5)); 920 911 my.addPrimitive(w6); 921 912 922 DataSetMerger visitor = new DataSetMerger(my, their);923 visitor.merge(); 924 925 assertEquals(0, visitor.getConflicts().size());926 927 OsmPrimitive p = my.getPrimitiveById(1, OsmPrimitiveType.NODE);913 DataSetMerger visitor = new DataSetMerger(my, their); 914 visitor.merge(); 915 916 assertEquals(0, visitor.getConflicts().size()); 917 918 OsmPrimitive p = my.getPrimitiveById(1, OsmPrimitiveType.NODE); 928 919 assertNotNull(p); 929 920 assertFalse(p.isIncomplete()); 930 p = my.getPrimitiveById(2, OsmPrimitiveType.NODE);921 p = my.getPrimitiveById(2, OsmPrimitiveType.NODE); 931 922 assertNotNull(p); 932 923 assertFalse(p.isIncomplete()); 933 p = my.getPrimitiveById(3,OsmPrimitiveType.WAY);924 p = my.getPrimitiveById(3, OsmPrimitiveType.WAY); 934 925 assertNotNull(p); 935 926 assertFalse(p.isIncomplete()); 936 927 937 Way w = (Way) my.getPrimitiveById(3,OsmPrimitiveType.WAY);928 Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 938 929 assertNotNull(w); 939 930 assertFalse(p.isIncomplete()); … … 954 945 // an complete node 955 946 Node n1 = new Node(1, 1); 956 n1.setCoor(new LatLon(1, 1));947 n1.setCoor(new LatLon(1, 1)); 957 948 their.addPrimitive(n1); 958 949 959 950 // another complete node 960 951 Node n2 = new Node(2, 1); 961 n2.setCoor(new LatLon(2, 2));952 n2.setCoor(new LatLon(2, 2)); 962 953 their.addPrimitive(n2); 963 954 … … 980 971 981 972 // -- test it 982 assertEquals(0, visitor.getConflicts().size());983 984 Node n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE);973 assertEquals(0, visitor.getConflicts().size()); 974 975 Node n = (Node) my.getPrimitiveById(1, OsmPrimitiveType.NODE); 985 976 assertNotNull(n); 986 977 assertFalse(n.isIncomplete()); 987 978 988 n = (Node) my.getPrimitiveById(2, OsmPrimitiveType.NODE);979 n = (Node) my.getPrimitiveById(2, OsmPrimitiveType.NODE); 989 980 assertNotNull(n); 990 981 assertFalse(n.isIncomplete()); 991 982 992 Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY);983 Way w = (Way) my.getPrimitiveById(3, OsmPrimitiveType.WAY); 993 984 assertNotNull(w); 994 985 assertFalse(w.hasIncompleteNodes()); -
trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java
r8509 r8510 64 64 @Test 65 65 public void filter_test() throws ParseError, IllegalDataException, IOException { 66 for (int i : new int [] {1,2,3, 11,12,13,14, 15}) {66 for (int i : new int[] {1, 2, 3, 11, 12, 13, 14, 15}) { 67 67 DataSet ds; 68 68 try (InputStream is = new FileInputStream("data_nodist/filterTests.osm")) { -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java
r8450 r8510 117 117 public void hasEqualSemanticAttributes() { 118 118 Node n1 = new Node(1); 119 n1.setCoor(new LatLon(0, 0));119 n1.setCoor(new LatLon(0, 0)); 120 120 n1.put("key.1", "value.1"); 121 121 n1.put("key.2", "value.2"); 122 122 123 123 Node n2 = new Node(1); 124 n2.setCoor(new LatLon(0, 0));124 n2.setCoor(new LatLon(0, 0)); 125 125 n2.put("key.2", "value.2"); 126 126 n2.put("key.1", "value.1"); … … 135 135 public void hasEqualSemanticAttributes_2() { 136 136 Node n1 = new Node(1); 137 n1.setCoor(new LatLon(0, 0));137 n1.setCoor(new LatLon(0, 0)); 138 138 n1.put("key.1", "value.1"); 139 139 n1.put("key.2", "value.3"); 140 140 141 141 Node n2 = new Node(1); 142 n2.setCoor(new LatLon(0, 0));142 n2.setCoor(new LatLon(0, 0)); 143 143 n2.put("key.1", "value.1"); 144 144 n2.put("key.2", "value.4"); -
trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java
r7937 r8510 143 143 } 144 144 145 @Test(expected =DataIntegrityProblemException.class)145 @Test(expected = DataIntegrityProblemException.class) 146 146 public void checkMustBeInDatasate() { 147 147 Node n = new Node(); 148 148 n.getReferrers(); 149 149 } 150 151 150 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java
r7937 r8510 20 20 } 21 21 22 @Test(expected =NullPointerException.class)22 @Test(expected = NullPointerException.class) 23 23 public void createNewRelation() { 24 24 new Relation(null); -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryNodeTest.java
r8450 r8510 24 24 4l, 25 25 d, 26 new LatLon(0, 0)26 new LatLon(0, 0) 27 27 ); 28 28 … … 46 46 4, 47 47 d, 48 new LatLon(0, 0)48 new LatLon(0, 0) 49 49 ); 50 50 -
trunk/test/unit/org/openstreetmap/josm/data/osm/history/HistoryWayTest.java
r8450 r8510 71 71 way.getNodeId(1); 72 72 fail("expected expection of type " + IndexOutOfBoundsException.class.toString()); 73 } catch (IndexOutOfBoundsException e) {73 } catch (IndexOutOfBoundsException e) { 74 74 // OK 75 75 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r7937 r8510 45 45 DataSet source = new DataSet(); 46 46 Node n1 = new Node(1); 47 Node n2 = new Node(new LatLon(10.0, 10.0));48 n2.put("name", "n2");47 Node n2 = new Node(new LatLon(10.0, 10.0)); 48 n2.put("name", "n2"); 49 49 Node n3 = new Node(3); 50 Node n4 = new Node(new LatLon(20.0, 20.0));51 n4.put("name", "n4");50 Node n4 = new Node(new LatLon(20.0, 20.0)); 51 n4.put("name", "n4"); 52 52 source.addPrimitive(n1); 53 53 source.addPrimitive(n2); 54 54 source.addPrimitive(n3); 55 55 source.addPrimitive(n4); 56 source.setSelected(n1, n2);56 source.setSelected(n1, n2); 57 57 58 58 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source); … … 61 61 assertEquals(2, hull.getNodes().size()); 62 62 63 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.NODE);63 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.NODE); 64 64 assertNotNull(p); 65 65 assertEquals(p.getClass(), Node.class); 66 66 67 p = hull.getPrimitiveById(3, OsmPrimitiveType.NODE);67 p = hull.getPrimitiveById(3, OsmPrimitiveType.NODE); 68 68 assertNull(p); 69 69 … … 74 74 assertNull(p); 75 75 } 76 77 76 78 77 @Test … … 95 94 assertEquals(2, hull.getNodes().size()); 96 95 97 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.NODE);96 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.NODE); 98 97 assertNotNull(p); 99 98 assertEquals(p.getClass(), Node.class); 100 99 101 p = hull.getPrimitiveById(2, OsmPrimitiveType.NODE);100 p = hull.getPrimitiveById(2, OsmPrimitiveType.NODE); 102 101 assertNotNull(p); 103 102 assertEquals(p.getClass(), Node.class); … … 119 118 source.addPrimitive(n2); 120 119 source.addPrimitive(w1); 121 source.setSelected(w1, n1,n2);120 source.setSelected(w1, n1, n2); 122 121 123 122 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source); … … 127 126 assertEquals(2, hull.getNodes().size()); 128 127 129 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.NODE);128 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.NODE); 130 129 assertNotNull(p); 131 130 assertEquals(p.getClass(), Node.class); … … 135 134 assertEquals(p.getClass(), Node.class); 136 135 137 p = hull.getPrimitiveById(3, OsmPrimitiveType.WAY);136 p = hull.getPrimitiveById(3, OsmPrimitiveType.WAY); 138 137 assertNotNull(p); 139 138 assertEquals(p.getClass(), Way.class); … … 164 163 Node n20 = new Node(20, 1); 165 164 n20.setCoor(new LatLon(0, 0)); 166 r1.addMember(new RelationMember("node-20", n20));165 r1.addMember(new RelationMember("node-20", n20)); 167 166 Way w30 = new Way(30, 1); 168 167 Node n21 = new Node(21); … … 170 169 Node n22 = new Node(22); 171 170 w30.addNode(n22); 172 r1.addMember(new RelationMember("way-30", w30));171 r1.addMember(new RelationMember("way-30", w30)); 173 172 Relation r40 = new Relation(40); 174 173 r1.addMember(new RelationMember("relation-40", r40)); … … 179 178 source.addPrimitive(r40); 180 179 source.addPrimitive(r1); 181 source.setSelected(r1, n20,w30,r40);180 source.setSelected(r1, n20, w30, r40); 182 181 183 182 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source); … … 192 191 assertEquals(p.getClass(), Relation.class); 193 192 194 Way w = (Way) hull.getPrimitiveById(30,OsmPrimitiveType.WAY);193 Way w = (Way) hull.getPrimitiveById(30, OsmPrimitiveType.WAY); 195 194 assertNotNull(w); 196 195 assertEquals(2, w.getNodesCount()); 197 Node n = (Node) hull.getPrimitiveById(21, OsmPrimitiveType.NODE);196 Node n = (Node) hull.getPrimitiveById(21, OsmPrimitiveType.NODE); 198 197 assertNotNull(n); 199 198 assertTrue(w.containsNode(n)); 200 199 201 n = (Node) hull.getPrimitiveById(22,OsmPrimitiveType.NODE);200 n = (Node) hull.getPrimitiveById(22, OsmPrimitiveType.NODE); 202 201 assertNotNull(n); 203 202 assertTrue(w.containsNode(n)); 204 203 205 Relation r = (Relation) hull.getPrimitiveById(40,OsmPrimitiveType.RELATION);206 assertNotNull(r); 207 208 r = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);204 Relation r = (Relation) hull.getPrimitiveById(40, OsmPrimitiveType.RELATION); 205 assertNotNull(r); 206 207 r = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 209 208 assertNotNull(r); 210 209 assertEquals(3, r.getMembersCount()); 211 RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20, OsmPrimitiveType.NODE));210 RelationMember m = new RelationMember("node-20", hull.getPrimitiveById(20, OsmPrimitiveType.NODE)); 212 211 assertTrue(r.getMembers().contains(m)); 213 212 m = new RelationMember("way-30", hull.getPrimitiveById(30, OsmPrimitiveType.WAY)); … … 222 221 Relation r1 = new Relation(1, 1); 223 222 Node n20 = new Node(20); 224 r1.addMember(new RelationMember("node-20", n20));223 r1.addMember(new RelationMember("node-20", n20)); 225 224 Way w30 = new Way(30, 1); 226 225 Node n21; … … 228 227 Node n22; 229 228 w30.addNode(n22 = new Node(22)); 230 r1.addMember(new RelationMember("way-30", w30));229 r1.addMember(new RelationMember("way-30", w30)); 231 230 Relation r40 = new Relation(40); 232 231 r1.addMember(new RelationMember("relation-40", r40)); … … 250 249 assertEquals(p.getClass(), Relation.class); 251 250 252 Way w = (Way) hull.getPrimitiveById(30, OsmPrimitiveType.WAY);251 Way w = (Way) hull.getPrimitiveById(30, OsmPrimitiveType.WAY); 253 252 assertNotNull(w); 254 253 assertTrue(w.isIncomplete()); 255 254 256 255 257 Node n = (Node) hull.getPrimitiveById(21,OsmPrimitiveType.NODE);256 Node n = (Node) hull.getPrimitiveById(21, OsmPrimitiveType.NODE); 258 257 assertNull(n); 259 258 260 n = (Node) hull.getPrimitiveById(22, OsmPrimitiveType.NODE);259 n = (Node) hull.getPrimitiveById(22, OsmPrimitiveType.NODE); 261 260 assertNull(n); 262 261 263 Relation r = (Relation) hull.getPrimitiveById(40, OsmPrimitiveType.RELATION);262 Relation r = (Relation) hull.getPrimitiveById(40, OsmPrimitiveType.RELATION); 264 263 assertNotNull(r); 265 264 assertTrue(r.isIncomplete()); 266 265 267 r = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);266 r = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 268 267 assertNotNull(r); 269 268 assertEquals(3, r.getMembersCount()); … … 281 280 Relation r1 = new Relation(); 282 281 r1.put("name", "r1"); 283 Node n20 = new Node(new LatLon(20.0, 20.0));282 Node n20 = new Node(new LatLon(20.0, 20.0)); 284 283 n20.put("name", "n20"); 285 r1.addMember(new RelationMember("node-20", n20));284 r1.addMember(new RelationMember("node-20", n20)); 286 285 287 286 Way w30 = new Way(); 288 287 w30.put("name", "w30"); 289 288 Node n21; 290 w30.addNode(n21 = new Node(new LatLon(21.0, 21.0)));291 n21.put("name", "n21");289 w30.addNode(n21 = new Node(new LatLon(21.0, 21.0))); 290 n21.put("name", "n21"); 292 291 Node n22; 293 w30.addNode(n22 = new Node(new LatLon(22.0, 22.0)));294 n22.put("name", "n22");295 r1.addMember(new RelationMember("way-30", w30));292 w30.addNode(n22 = new Node(new LatLon(22.0, 22.0))); 293 n22.put("name", "n22"); 294 r1.addMember(new RelationMember("way-30", w30)); 296 295 Relation r40 = new Relation(); 297 296 r40.put("name", "r40"); … … 317 316 assertEquals(p.getClass(), Relation.class); 318 317 319 Way w = (Way) lookupByName(hull.getWays(), "w30");318 Way w = (Way) lookupByName(hull.getWays(), "w30"); 320 319 assertNotNull(w); 321 320 assertEquals(2, w.getNodesCount()); 322 321 323 Node n = (Node) lookupByName(hull.getNodes(), "n21");322 Node n = (Node) lookupByName(hull.getNodes(), "n21"); 324 323 assertNotNull(n); 325 324 assertTrue(w.containsNode(n)); 326 325 327 n = (Node) lookupByName(hull.getNodes(), "n22");326 n = (Node) lookupByName(hull.getNodes(), "n22"); 328 327 assertNotNull(n); 329 328 assertTrue(w.containsNode(n)); 330 329 331 Relation r = (Relation) lookupByName(hull.getRelations(), "r40");332 assertNotNull(r); 333 334 r = (Relation) lookupByName(hull.getRelations(), "r1");330 Relation r = (Relation) lookupByName(hull.getRelations(), "r40"); 331 assertNotNull(r); 332 333 r = (Relation) lookupByName(hull.getRelations(), "r1"); 335 334 assertNotNull(r); 336 335 assertEquals(3, r.getMembersCount()); … … 347 346 DataSet source = new DataSet(); 348 347 Relation r1 = new Relation(1, 1); 349 r1.addMember(new RelationMember("relation-1", r1));348 r1.addMember(new RelationMember("relation-1", r1)); 350 349 source.addPrimitive(r1); 351 350 source.setSelected(r1); … … 356 355 assertEquals(1, hull.getRelations().size()); 357 356 358 Relation r = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);357 Relation r = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 359 358 assertNotNull(r); 360 359 assertEquals(1, r.getMembersCount()); 361 assertTrue(r.getMembers().contains(new RelationMember("relation-1", r)));360 assertTrue(r.getMembers().contains(new RelationMember("relation-1", r))); 362 361 } 363 362 … … 367 366 Relation r1 = new Relation(); 368 367 r1.put("name", "r1"); 369 r1.addMember(new RelationMember("relation-1", r1));368 r1.addMember(new RelationMember("relation-1", r1)); 370 369 source.addPrimitive(r1); 371 370 source.setSelected(r1); … … 376 375 assertEquals(1, hull.getRelations().size()); 377 376 378 Relation r = (Relation) lookupByName(hull.getRelations(), "r1");377 Relation r = (Relation) lookupByName(hull.getRelations(), "r1"); 379 378 assertNotNull(r); 380 379 assertEquals(1, r.getMembersCount()); 381 assertTrue(r.getMembers().contains(new RelationMember("relation-1", r)));380 assertTrue(r.getMembers().contains(new RelationMember("relation-1", r))); 382 381 } 383 382 … … 389 388 Relation r2 = new Relation(2, 3); 390 389 source.addPrimitive(r2); 391 r1.addMember(new RelationMember("relation-2", r2));392 r2.addMember(new RelationMember("relation-1", r1));393 source.setSelected(r1, r2);390 r1.addMember(new RelationMember("relation-2", r2)); 391 r2.addMember(new RelationMember("relation-1", r1)); 392 source.setSelected(r1, r2); 394 393 395 394 MergeSourceBuildingVisitor builder = new MergeSourceBuildingVisitor(source); … … 398 397 assertEquals(2, hull.getRelations().size()); 399 398 400 r1 = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION);399 r1 = (Relation) hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); 401 400 assertNotNull(r1); 402 r2 = (Relation) hull.getPrimitiveById(2, OsmPrimitiveType.RELATION);401 r2 = (Relation) hull.getPrimitiveById(2, OsmPrimitiveType.RELATION); 403 402 assertNotNull(r2); 404 403 assertEquals(1, r1.getMembersCount()); 405 assertTrue(r1.getMembers().contains(new RelationMember("relation-2", r2)));404 assertTrue(r1.getMembers().contains(new RelationMember("relation-2", r2))); 406 405 assertEquals(1, r2.getMembersCount()); 407 assertTrue(r2.getMembers().contains(new RelationMember("relation-1", r1)));406 assertTrue(r2.getMembers().contains(new RelationMember("relation-1", r1))); 408 407 } 409 408 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r6881 r8510 20 20 double maxErrLat = 0, maxErrLon = 0; 21 21 Ellipsoid ellips = Ellipsoid.WGS84; 22 for (int num =0; num<1000; ++num) {22 for (int num = 0; num < 1000; ++num) { 23 23 24 24 double lat = r.nextDouble() * 180.0 - 90.0; 25 25 double lon = r.nextDouble() * 360.0 - 180.0; 26 LatLon ll = new LatLon(lat, lon);26 LatLon ll = new LatLon(lat, lon); 27 27 28 for (int i =0; i<1000; ++i) {28 for (int i = 0; i < 1000; ++i) { 29 29 double[] cart = ellips.latLon2Cart(ll); 30 30 ll = ellips.cart2LatLon(cart); 31 31 32 if (!(Math.abs(lat - ll.lat()) <EPSILON && Math.abs(lon - ll.lon())<EPSILON)) {32 if (!(Math.abs(lat - ll.lat()) < EPSILON && Math.abs(lon - ll.lon()) < EPSILON)) { 33 33 String error = String.format("point: %s iterations: %s current: %s errorLat: %s errorLon %s", 34 34 new LatLon(lat, lon), i, ll, Math.abs(lat - ll.lat()), Math.abs(lon - ll.lon())); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r8509 r8510 65 65 prevData = readData(); 66 66 } 67 Map<String, TestData> prevCodesMap = new HashMap<>();67 Map<String, TestData> prevCodesMap = new HashMap<>(); 68 68 for (TestData data : prevData) { 69 69 prevCodesMap.put(data.code, data); … … 116 116 TestData next = new TestData(); 117 117 118 Pair<Double, Double> ll = readLine("ll", in.readLine());119 Pair<Double, Double> en = readLine("en", in.readLine());120 Pair<Double, Double> ll2 = readLine("ll2", in.readLine());118 Pair<Double, Double> ll = readLine("ll", in.readLine()); 119 Pair<Double, Double> en = readLine("en", in.readLine()); 120 Pair<Double, Double> ll2 = readLine("ll2", in.readLine()); 121 121 122 122 next.code = line; … … 131 131 } 132 132 133 private static Pair<Double, Double> readLine(String expectedName, String input) {133 private static Pair<Double, Double> readLine(String expectedName, String input) { 134 134 String[] fields = input.trim().split("[ ]+"); 135 135 if (fields.length != 3) throw new AssertionError(); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r6881 r8510 28 28 } 29 29 30 for (int i =0; i<=3; ++i) {30 for (int i = 0; i <= 3; ++i) { 31 31 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(27561+i))); // Lambert 4 Zones France 32 32 } 33 33 34 for (int i =0; i<=4; ++i) {34 for (int i = 0; i <= 4; ++i) { 35 35 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2176+i))); // PUWG Poland 36 36 } … … 38 38 testProj(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid 39 39 40 for (int i =0; i<=60; ++i) {40 for (int i = 0; i <= 60; ++i) { 41 41 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32601+i))); // UTM North 42 42 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32701+i))); // UTM South … … 44 44 45 45 if (!"yes".equals(System.getProperty("suppressPermanentFailure"))) { 46 for (int i =0; i<=4; ++i) {46 for (int i = 0; i <= 4; ++i) { 47 47 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2969+i))); // UTM France DOM 48 48 } 49 49 } 50 50 51 for (int i =0; i<=8; ++i) {51 for (int i = 0; i <= 8; ++i) { 52 52 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(3942+i))); // Lambert CC9 Zones France 53 53 } … … 65 65 66 66 text += String.format("*** %s %s%n", p.toString(), p.toCode()); 67 for (int num =0; num < 1000; ++num) {67 for (int num = 0; num < 1000; ++num) { 68 68 69 69 double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat(); … … 72 72 LatLon ll = new LatLon(lat, lon); 73 73 74 for (int i =0; i<10; ++i) {74 for (int i = 0; i < 10; ++i) { 75 75 EastNorth en = p.latlon2eastNorth(ll); 76 76 ll = p.eastNorth2latlon(en); -
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r8450 r8510 28 28 */ 29 29 ProjData[] data = { 30 new ProjData("Zimmerwald", d(7, 27,54.983506), d(46,52,37.540562), 947.149, 602030.680, 191775.030, 897.915),31 new ProjData("Chrischona", d(7, 40,6.983077), d(47,34, 1.385301), 504.935, 617306.300, 268507.300, 456.064),32 new ProjData("Pfaender", d(9, 47,3.697723), d(47,30,55.172797), 1089.372, 776668.105, 265372.681, 1042.624),33 new ProjData("La Givrine", d(6, 6,7.326361), d(46,27,14.690021), 1258.274, 497313.292, 145625.438, 1207.434),34 new ProjData("Monte Generoso", d(9, 1,16.389053), d(45,55,45.438020), 1685.027, 722758.810, 87649.670, 1636.600) };30 new ProjData("Zimmerwald", d(7, 27, 54.983506), d(46, 52, 37.540562), 947.149, 602030.680, 191775.030, 897.915), 31 new ProjData("Chrischona", d(7, 40, 6.983077), d(47, 34, 1.385301), 504.935, 617306.300, 268507.300, 456.064), 32 new ProjData("Pfaender", d(9, 47, 3.697723), d(47, 30, 55.172797), 1089.372, 776668.105, 265372.681, 1042.624), 33 new ProjData("La Givrine", d(6, 6, 7.326361), d(46, 27, 14.690021), 1258.274, 497313.292, 145625.438, 1207.434), 34 new ProjData("Monte Generoso", d(9, 1, 16.389053), d(45, 55, 45.438020), 1685.027, 722758.810, 87649.670, 1636.600) }; 35 35 36 36 private double d(double deg, double min, double sec) { … … 42 42 public LatLon ll; 43 43 public EastNorth en; 44 44 45 public ProjData(String name, double lon, double lat, double h1, double x, double y, double h2) { 45 46 this.name = name; … … 128 129 } 129 130 130 131 131 @Test 132 132 public void b_eastNorth2latlon_test() { -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java
r7937 r8510 42 42 nodes.add(new Node(new LatLon(0, 2))); 43 43 44 Way w = (Way) OsmUtils.createPrimitive("way "+tags);44 Way w = (Way) OsmUtils.createPrimitive("way "+tags); 45 45 w.setNodes(nodes); 46 46 return w; -
trunk/test/unit/org/openstreetmap/josm/gui/JosmUserIdentityManagerTest.groovy
r7938 r8510 12 12 class JosmUserIdentityManagerTest { 13 13 14 final shouldFail = new GroovyTestCase().&shouldFail 15 16 @BeforeClass 17 public static void initTestCase() { 18 JOSMFixture.createUnitTestFixture().init() 19 } 20 21 @Test 22 public void test_SingletonAccess() { 23 24 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 25 26 // created ? 27 assert im != null 28 29 // registered as listener ? 30 assert Main.pref.@listeners.contains(im) 31 32 JosmUserIdentityManager im2 = JosmUserIdentityManager.getInstance() 33 34 // only one instance 35 assert im == im2 36 } 37 38 @Test 39 public void test_setAnonymouse() { 40 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 41 42 im.setPartiallyIdentified "test" 43 im.setAnonymous() 44 45 assert im.isAnonymous() 46 assert ! im.isPartiallyIdentified() 47 assert ! im.isFullyIdentified() 48 49 assert im.getUserId() == 0 50 assert im.getUserName() == null 51 assert im.getUserInfo() == null 52 } 53 54 @Test 55 public void test_setPartiallyIdentified() { 56 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 57 58 im.setPartiallyIdentified "test" 59 60 shouldFail(IllegalArgumentException) { 61 im.setPartiallyIdentified null 62 } 63 64 shouldFail(IllegalArgumentException) { 65 im.setPartiallyIdentified "" 66 } 67 68 shouldFail(IllegalArgumentException) { 69 im.setPartiallyIdentified " \t " 70 } 71 72 im.setPartiallyIdentified "test" 73 74 assert ! im.isAnonymous() 75 assert im.isPartiallyIdentified() 76 assert ! im.isFullyIdentified() 77 78 assert im.getUserId() == 0 79 assert im.getUserName() == "test" 80 assert im.getUserInfo() == null 81 } 82 83 84 @Test 85 public void test_setFullyIdentified() { 86 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 87 88 UserInfo userInfo = new UserInfo(id: 1, description: "a description") 89 90 im.setFullyIdentified "test", userInfo 91 92 shouldFail(IllegalArgumentException) { 93 im.setFullyIdentified null, userInfo 94 } 95 shouldFail(IllegalArgumentException) { 96 im.setFullyIdentified "", userInfo 97 } 98 shouldFail(IllegalArgumentException) { 99 im.setFullyIdentified " \t ", userInfo 100 } 101 shouldFail(IllegalArgumentException) { 102 im.setFullyIdentified "test", null 103 } 104 105 im.setFullyIdentified "test", userInfo 106 107 assert ! im.isAnonymous() 108 assert ! im.isPartiallyIdentified() 109 assert im.isFullyIdentified() 110 111 assert im.getUserId() == 1 112 assert im.getUserName() == "test" 113 assert im.getUserInfo() == userInfo 114 } 115 116 /** 117 * Preferences include neither an url nor a user name => we have 118 * an anonymous user 119 */ 120 @Test 121 public void initFromPreferences_1() { 122 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 123 124 // reset it 125 im.@userName = null 126 im.@userInfo = null 127 128 Main.pref.put "osm-server.url", null 129 Main.pref.put "osm-server.username", null 130 131 im.initFromPreferences() 132 133 assert im.isAnonymous() 134 } 135 136 /** 137 * Preferences include neither an url nor a user name => we have 138 * an annoymous user 139 */ 140 @Test 141 public void initFromPreferences_2() { 142 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 143 144 // reset it 145 im.@userName = null 146 im.@userInfo = null 147 148 // for this test we disable the listener 149 Main.pref.removePreferenceChangeListener im 150 151 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 152 Main.pref.put "osm-server.username", null 153 154 im.initFromPreferences() 155 156 assert im.isAnonymous() 157 } 158 159 /** 160 * Preferences include an user name => we have a partially identified user 161 */ 162 @Test 163 public void initFromPreferences_3() { 164 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 14 final shouldFail = new GroovyTestCase().&shouldFail 15 16 @BeforeClass 17 public static void initTestCase() { 18 JOSMFixture.createUnitTestFixture().init() 19 } 20 21 @Test 22 public void test_SingletonAccess() { 23 24 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 25 26 // created ? 27 assert im != null 28 29 // registered as listener ? 30 assert Main.pref.@listeners.contains(im) 31 32 JosmUserIdentityManager im2 = JosmUserIdentityManager.getInstance() 33 34 // only one instance 35 assert im == im2 36 } 37 38 @Test 39 public void test_setAnonymouse() { 40 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 41 42 im.setPartiallyIdentified "test" 43 im.setAnonymous() 44 45 assert im.isAnonymous() 46 assert ! im.isPartiallyIdentified() 47 assert ! im.isFullyIdentified() 48 49 assert im.getUserId() == 0 50 assert im.getUserName() == null 51 assert im.getUserInfo() == null 52 } 53 54 @Test 55 public void test_setPartiallyIdentified() { 56 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 57 58 im.setPartiallyIdentified "test" 59 60 shouldFail(IllegalArgumentException) { 61 im.setPartiallyIdentified null 62 } 63 64 shouldFail(IllegalArgumentException) { 65 im.setPartiallyIdentified "" 66 } 67 68 shouldFail(IllegalArgumentException) { 69 im.setPartiallyIdentified " \t " 70 } 71 72 im.setPartiallyIdentified "test" 73 74 assert ! im.isAnonymous() 75 assert im.isPartiallyIdentified() 76 assert ! im.isFullyIdentified() 77 78 assert im.getUserId() == 0 79 assert im.getUserName() == "test" 80 assert im.getUserInfo() == null 81 } 82 83 84 @Test 85 public void test_setFullyIdentified() { 86 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 87 88 UserInfo userInfo = new UserInfo(id: 1, description: "a description") 89 90 im.setFullyIdentified "test", userInfo 91 92 shouldFail(IllegalArgumentException) { 93 im.setFullyIdentified null, userInfo 94 } 95 shouldFail(IllegalArgumentException) { 96 im.setFullyIdentified "", userInfo 97 } 98 shouldFail(IllegalArgumentException) { 99 im.setFullyIdentified " \t ", userInfo 100 } 101 shouldFail(IllegalArgumentException) { 102 im.setFullyIdentified "test", null 103 } 104 105 im.setFullyIdentified "test", userInfo 106 107 assert ! im.isAnonymous() 108 assert ! im.isPartiallyIdentified() 109 assert im.isFullyIdentified() 110 111 assert im.getUserId() == 1 112 assert im.getUserName() == "test" 113 assert im.getUserInfo() == userInfo 114 } 115 116 /** 117 * Preferences include neither an url nor a user name => we have 118 * an anonymous user 119 */ 120 @Test 121 public void initFromPreferences_1() { 122 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 123 124 // reset it 125 im.@userName = null 126 im.@userInfo = null 127 128 Main.pref.put "osm-server.url", null 129 Main.pref.put "osm-server.username", null 130 131 im.initFromPreferences() 132 133 assert im.isAnonymous() 134 } 135 136 /** 137 * Preferences include neither an url nor a user name => we have 138 * an annoymous user 139 */ 140 @Test 141 public void initFromPreferences_2() { 142 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 143 144 // reset it 145 im.@userName = null 146 im.@userInfo = null 165 147 166 148 // for this test we disable the listener 167 Main.pref.removePreferenceChangeListener im 168 169 // reset it 170 im.@userName = null 171 im.@userInfo = null 172 173 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 174 Main.pref.put "osm-server.username", "test" 175 176 im.initFromPreferences() 177 178 assert im.isPartiallyIdentified() 179 } 180 181 /** 182 * Preferences include an user name which is different from the current 183 * user name and we are currently fully identifed => josm user becomes 184 * partially identified 185 */ 186 @Test 187 public void initFromPreferences_4() { 188 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 149 Main.pref.removePreferenceChangeListener im 150 151 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 152 Main.pref.put "osm-server.username", null 153 154 im.initFromPreferences() 155 156 assert im.isAnonymous() 157 } 158 159 /** 160 * Preferences include an user name => we have a partially identified user 161 */ 162 @Test 163 public void initFromPreferences_3() { 164 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 189 165 190 166 // for this test we disable the listener 191 Main.pref.removePreferenceChangeListener im 192 193 im.setFullyIdentified "test1", new UserInfo(id: 1) 194 195 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 196 Main.pref.put "osm-server.username", "test2" 197 198 im.initFromPreferences() 199 200 assert im.isPartiallyIdentified() 201 } 202 203 /** 204 * Preferences include an user name which is the same as the current 205 * user name and we are currently fully identifed => josm user remains 206 * fully identified 207 */ 208 @Test 209 public void initFromPreferences_5() { 210 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 167 Main.pref.removePreferenceChangeListener im 168 169 // reset it 170 im.@userName = null 171 im.@userInfo = null 172 173 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 174 Main.pref.put "osm-server.username", "test" 175 176 im.initFromPreferences() 177 178 assert im.isPartiallyIdentified() 179 } 180 181 /** 182 * Preferences include an user name which is different from the current 183 * user name and we are currently fully identifed => josm user becomes 184 * partially identified 185 */ 186 @Test 187 public void initFromPreferences_4() { 188 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 211 189 212 190 // for this test we disable the listener 213 Main.pref.removePreferenceChangeListener im 214 215 im.setFullyIdentified "test1", new UserInfo(id: 1) 216 217 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 218 Main.pref.put "osm-server.username", "test1" 219 220 im.initFromPreferences() 221 222 assert im.isFullyIdentified() 223 } 224 225 @Test 226 public void apiUrlChanged() { 227 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 228 229 // make sure im is a preference change listener 230 Main.pref.addPreferenceChangeListener im 231 232 // reset it 233 im.@userName = null 234 im.@userInfo = null 235 236 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 237 assert im.isAnonymous() 191 Main.pref.removePreferenceChangeListener im 192 193 im.setFullyIdentified "test1", new UserInfo(id: 1) 194 195 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 196 Main.pref.put "osm-server.username", "test2" 197 198 im.initFromPreferences() 199 200 assert im.isPartiallyIdentified() 201 } 202 203 /** 204 * Preferences include an user name which is the same as the current 205 * user name and we are currently fully identifed => josm user remains 206 * fully identified 207 */ 208 @Test 209 public void initFromPreferences_5() { 210 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 211 212 // for this test we disable the listener 213 Main.pref.removePreferenceChangeListener im 214 215 im.setFullyIdentified "test1", new UserInfo(id: 1) 216 217 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 218 Main.pref.put "osm-server.username", "test1" 219 220 im.initFromPreferences() 221 222 assert im.isFullyIdentified() 223 } 224 225 @Test 226 public void apiUrlChanged() { 227 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 228 229 // make sure im is a preference change listener 230 Main.pref.addPreferenceChangeListener im 231 232 // reset it 233 im.@userName = null 234 im.@userInfo = null 235 236 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 237 assert im.isAnonymous() 238 238 239 239 Main.pref.put "osm-server.url", null 240 240 assert im.isAnonymous() 241 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 242 // reset it 243 im.@userName = "test" 244 im.@userInfo = null 245 246 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 247 assert im.isPartiallyIdentified() 248 assert im.getUserName() == "test" 249 250 Main.pref.put "osm-server.url", null 251 assert im.isAnonymous() 252 253 // reset it 254 im.@userName = "test" 255 im.@userInfo = new UserInfo(id:1) 256 257 Main.pref.put "osm-server.url", "http://api.openstreetmap.org" 258 assert im.isPartiallyIdentified() 259 assert im.getUserName() == "test" 260 261 // reset it 262 im.@userName = "test" 263 im.@userInfo = new UserInfo(id:1) 264 265 266 Main.pref.put "osm-server.url", null 267 assert im.isAnonymous() 268 } 269 270 @Test 271 public void userNameChanged() { 272 JosmUserIdentityManager im = JosmUserIdentityManager.getInstance() 273 274 // make sure im is a preference change listener 275 Main.pref.addPreferenceChangeListener im 276 277 // reset it 278 im.@userName = null 279 im.@userInfo = null 280 281 Main.pref.put "osm-server.username", "test" 282 assert im.isPartiallyIdentified() 283 assert im.getUserName() == "test" 284 285 Main.pref.put "osm-server.username", null 286 assert im.isAnonymous() 287 288 // reset it 289 im.@userName = "test1" 290 im.@userInfo = null 291 292 Main.pref.put "osm-server.username", "test2" 293 assert im.isPartiallyIdentified() 294 assert im.getUserName() == "test2" 295 296 Main.pref.put "osm-server.username", null 297 assert im.isAnonymous() 298 299 // reset it 300 im.@userName = "test1" 301 im.@userInfo = new UserInfo(id:1) 302 303 Main.pref.put "osm-server.username", "test2" 304 assert im.isPartiallyIdentified() 305 assert im.getUserName() == "test2" 306 307 // reset it 308 im.@userName = "test1" 309 im.@userInfo = new UserInfo(id:1) 310 311 312 Main.pref.put "osm-server.username", null 313 assert im.isAnonymous() 314 } 315 315 } -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/nodes/NodeListMergeModelTest.java
r8450 r8510 52 52 protected void ensureSelected(DefaultListSelectionModel model, Object... idx) { 53 53 if (idx == null) return; 54 for (int i =0; i < idx.length; i++) {54 for (int i = 0; i < idx.length; i++) { 55 55 if (idx[i] instanceof Integer) { 56 int j = (Integer) idx[i];56 int j = (Integer) idx[i]; 57 57 assertTrue("expected row " + j + " to be selected", model.isSelectedIndex(j)); 58 58 break; 59 59 } 60 60 try { 61 int rows[] = (int[]) idx[i];61 int rows[] = (int[]) idx[i]; 62 62 if (rows.length != 2) { 63 63 fail("illegal selection range. Either null or not length 2: " + Arrays.toString(rows)); … … 69 69 assertTrue("expected row " + j + " to be selected", model.isSelectedIndex(j)); 70 70 } 71 } catch (ClassCastException e) {71 } catch (ClassCastException e) { 72 72 fail("illegal selection range:" + idx[i]); 73 73 } … … 95 95 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 96 96 ensureSelected(mergedSelection, 0); 97 98 } 99 97 } 100 98 101 99 @Test … … 123 121 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 124 122 ensureSelected(mergedSelection, 0); 125 126 123 } 127 124 … … 167 164 mergedNodes.add(new Node(1)); 168 165 169 model.copyMyToTop(new int[]{1, 2}); // copy node 3 and 4166 model.copyMyToTop(new int[]{1, 2}); // copy node 3 and 4 170 167 171 168 mergedNodes = inspectNodeList(model, "Merged"); … … 176 173 177 174 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 178 ensureSelected(mergedSelection, 0,1); // first two rows selected 179 } 180 175 ensureSelected(mergedSelection, 0, 1); // first two rows selected 176 } 181 177 182 178 @Test … … 269 265 mergedNodes.add(new Node(1)); 270 266 271 model.copyMyToEnd(new int[]{1, 2}); // copy node 3 and 4267 model.copyMyToEnd(new int[]{1, 2}); // copy node 3 and 4 272 268 273 269 mergedNodes = inspectNodeList(model, "Merged"); … … 279 275 280 276 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 281 ensureSelected(mergedSelection, 1, 2); // last two rows selected277 ensureSelected(mergedSelection, 1, 2); // last two rows selected 282 278 } 283 279 … … 313 309 } 314 310 315 316 311 @Test 317 312 public void test_copyMyNodesBeforeCurrent_2() { … … 329 324 mergedNodes.add(new Node(12)); 330 325 331 model.copyMyBeforeCurrent(new int[]{0, 1}, 0);326 model.copyMyBeforeCurrent(new int[]{0, 1}, 0); 332 327 333 328 assertEquals(5, mergedNodes.size()); … … 339 334 340 335 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 341 ensureSelected(mergedSelection, 0, 1); // position 0 and 1 selected336 ensureSelected(mergedSelection, 0, 1); // position 0 and 1 selected 342 337 } 343 338 … … 358 353 359 354 try { 360 model.copyMyBeforeCurrent(new int[]{0, 1}, -1);355 model.copyMyBeforeCurrent(new int[]{0, 1}, -1); 361 356 fail("expected IllegalArgumentException"); 362 } catch (IllegalArgumentException e) {357 } catch (IllegalArgumentException e) { 363 358 // OK 364 359 } 365 360 366 361 try { 367 model.copyMyBeforeCurrent(new int[]{0, 1}, 4);362 model.copyMyBeforeCurrent(new int[]{0, 1}, 4); 368 363 fail("expected IllegalArgumentException"); 369 } catch (IllegalArgumentException e) {364 } catch (IllegalArgumentException e) { 370 365 // OK 371 366 } … … 402 397 } 403 398 404 405 399 @Test 406 400 public void test_copyMyNodesAfterCurrent_2() { … … 419 413 mergedNodes.add(new Node(12)); 420 414 421 model.copyMyAfterCurrent(new int[]{0, 1}, 2);415 model.copyMyAfterCurrent(new int[]{0, 1}, 2); 422 416 423 417 assertEquals(5, mergedNodes.size()); … … 428 422 assertEquals(2, mergedNodes.get(4).getId()); // copied node 2 at position 4 429 423 430 431 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 432 ensureSelected(mergedSelection, 3,4); // position 3,4 selected 424 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 425 ensureSelected(mergedSelection, 3, 4); // position 3,4 selected 433 426 } 434 427 … … 449 442 mergedNodes.add(new Node(12)); 450 443 451 model.copyMyAfterCurrent(new int[]{0, 2}, 0);444 model.copyMyAfterCurrent(new int[]{0, 2}, 0); 452 445 453 446 assertEquals(5, mergedNodes.size()); … … 459 452 460 453 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 461 ensureSelected(mergedSelection, 1, 2); // position 1,2 selected454 ensureSelected(mergedSelection, 1, 2); // position 1,2 selected 462 455 } 463 456 … … 509 502 mergedNodes.add(new Node(14)); 510 503 511 model.moveUpMerged(new int[]{1, 4});504 model.moveUpMerged(new int[]{1, 4}); 512 505 513 506 assertEquals(5, mergedNodes.size()); … … 519 512 520 513 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 521 ensureSelected(mergedSelection, 0, 3); // position 0 and 3 selecte0514 ensureSelected(mergedSelection, 0, 3); // position 0 and 3 selecte0 522 515 } 523 516 … … 539 532 mergedNodes.add(new Node(14)); 540 533 541 model.moveUpMerged(new int[]{1, 2,3,4});534 model.moveUpMerged(new int[]{1, 2, 3, 4}); 542 535 543 536 assertEquals(5, mergedNodes.size()); … … 549 542 550 543 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 551 ensureSelected(mergedSelection, 0, 1,2,3);544 ensureSelected(mergedSelection, 0, 1, 2, 3); 552 545 } 553 546 … … 598 591 mergedNodes.add(new Node(14)); 599 592 600 model.moveDownMerged(new int[]{1, 3});593 model.moveDownMerged(new int[]{1, 3}); 601 594 602 595 assertEquals(5, mergedNodes.size()); … … 608 601 609 602 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 610 ensureSelected(mergedSelection, 2, 4);603 ensureSelected(mergedSelection, 2, 4); 611 604 } 612 605 … … 628 621 mergedNodes.add(new Node(14)); 629 622 630 model.moveDownMerged(new int[]{1, 2,3});623 model.moveDownMerged(new int[]{1, 2, 3}); 631 624 632 625 assertEquals(5, mergedNodes.size()); … … 638 631 639 632 DefaultListSelectionModel mergedSelection = inspectListSelectionModel(model, "mergedEntriesSelectionModel"); 640 ensureSelected(mergedSelection, 2, 3,4);633 ensureSelected(mergedSelection, 2, 3, 4); 641 634 } 642 635 … … 712 705 } 713 706 } 707 714 708 MyListener listener = new MyListener(); 715 709 model.addPropertyChangeListener(listener); … … 722 716 assertEquals(!oldValue, listener.events.get(0).getNewValue()); 723 717 } 724 725 718 } -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/properties/PropertiesMergeModelTest.java
r7937 r8510 94 94 assertFalse(model.hasCoordConflict()); 95 95 96 n1.setCoor(new LatLon(1, 1));96 n1.setCoor(new LatLon(1, 1)); 97 97 populate(n1, n2); 98 98 assertTrue(model.hasCoordConflict()); … … 100 100 101 101 n1.cloneFrom(new Node(1)); 102 n2.setCoor(new LatLon(2, 2));102 n2.setCoor(new LatLon(2, 2)); 103 103 populate(n1, n2); 104 104 assertTrue(model.hasCoordConflict()); 105 105 106 n1.setCoor(new LatLon(1, 1));107 n2.setCoor(new LatLon(2, 2));106 n1.setCoor(new LatLon(1, 1)); 107 n2.setCoor(new LatLon(2, 2)); 108 108 populate(n1, n2); 109 109 assertTrue(model.hasCoordConflict()); -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeItemTest.java
r8509 r8510 68 68 assertEquals("key", item.getKey()); 69 69 assertNull(item.getMyTagValue()); 70 assertEquals("theirvalue", item.getTheirTagValue());70 assertEquals("theirvalue", item.getTheirTagValue()); 71 71 assertEquals(MergeDecisionType.UNDECIDED, item.getMergeDecision()); 72 72 } 73 74 73 75 74 @Test … … 86 85 item.decide(null); 87 86 fail("expected IllegalArgumentException not thrown"); 88 } catch (IllegalArgumentException e) {87 } catch (IllegalArgumentException e) { 89 88 // OK 90 89 } … … 104 103 item.applyToMyPrimitive(n1); 105 104 assertEquals("myvalue", n1.get("key")); 106 107 105 } 108 106 … … 133 131 item.applyToMyPrimitive(n1); 134 132 fail("expected IllegalStateException"); 135 } catch (IllegalStateException e) {133 } catch (IllegalStateException e) { 136 134 // OK 137 135 } … … 145 143 item.applyToMyPrimitive(null); 146 144 fail("expected IllegalArgumentException"); 147 } catch (IllegalArgumentException e) {145 } catch (IllegalArgumentException e) { 148 146 // OK 149 147 } -
trunk/test/unit/org/openstreetmap/josm/gui/conflict/tags/TagMergeModelTest.java
r8391 r8510 210 210 211 211 TagMergeModel model = new TagMergeModel(); 212 for (int i =0; i < 10; i++) {212 for (int i = 0; i < 10; i++) { 213 213 model.addItem(new TagMergeItem("key-" + i, "myvalue-" + i, "theirvalue-" +i)); 214 214 } … … 222 222 223 223 model.decide(new int[] {0, 3, 5}, MergeDecisionType.KEEP_MINE); 224 for (int i = 0; i < 10; i++) {224 for (int i = 0; i < 10; i++) { 225 225 TagMergeItem item = list.get(i); 226 226 if (i == 0 || i == 3 || i == 5) { -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r7937 r8510 43 43 private String[] getNames(List<RelationMember> members) { 44 44 String[] result = new String[members.size()]; 45 for (int i =0; i<result.length; i++) {45 for (int i = 0; i < result.length; i++) { 46 46 result[i] = members.get(i).getMember().get("name"); 47 47 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r7937 r8510 44 44 private String getConnections(List<WayConnectionType> connections) { 45 45 String[] result = new String[connections.size()]; 46 for (int i =0; i<result.length; i++) {46 for (int i = 0; i < result.length; i++) { 47 47 WayConnectionType wc = connections.get(i); 48 48 -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/ToolbarPreferencesTest.java
r8509 r8510 44 44 private void checkAction(ActionDefinition a, Object... params) { 45 45 Map<String, Object> expected = new HashMap<>(); 46 for (int i =0; i<params.length; i+=2) {47 expected.put((String) params[i], params[i+1]);46 for (int i = 0; i < params.length; i += 2) { 47 expected.put((String) params[i], params[i+1]); 48 48 } 49 49 Assert.assertEquals(expected, a.getParameters()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java
r7937 r8510 67 67 String presetfile = "resource://data/defaultpresets.xml"; 68 68 final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, true); 69 Assert.assertTrue("Default presets are empty", presets.size() >0);69 Assert.assertTrue("Default presets are empty", presets.size() > 0); 70 70 } 71 71 } -
trunk/test/unit/org/openstreetmap/josm/io/ChangesetQueryUrlParserTest.groovy
r7938 r8510 2 2 package org.openstreetmap.josm.io; 3 3 4 5 import java.util.Calendar; 6 import java.util.GregorianCalendar; 7 import java.util.TimeZone; 8 9 import org.junit.Test 10 import org.openstreetmap.josm.io.ChangesetQuery.ChangesetQueryUrlException; 11 import org.openstreetmap.josm.io.ChangesetQuery.ChangesetQueryUrlParser; 12 13 14 import static org.junit.Assert.*; 4 import static org.junit.Assert.* 5 6 import org.junit.Test 7 import org.openstreetmap.josm.io.ChangesetQuery.ChangesetQueryUrlException 8 import org.openstreetmap.josm.io.ChangesetQuery.ChangesetQueryUrlParser 15 9 16 10 class ChangesetQueryUrlParserTest { 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 @Test 41 42 43 44 45 46 47 48 49 50 q = parser.parse("uid=0") 51 52 53 54 q = parser.parse("uid=-1") 55 56 57 58 q = parser.parse("uid=abc") 59 60 61 62 @Test 63 64 65 66 67 68 69 70 71 72 73 74 @Test 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 // illegal value for open 90 91 q = parser.parse("open=abcd") 92 } 93 94 95 @Test 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 // illegal value for open 111 112 q = parser.parse("closed=abcd") 113 } 114 115 116 117 @Test 118 119 120 121 122 // we can't have both an uid and a display name 123 124 q = parser.parse("uid=1&display_name=abcd") 125 } 126 127 128 @Test 129 130 131 132 133 134 135 136 assert q.@closedAfter != null 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 q = parser.parse("time=asdf") 155 } 156 157 158 @Test 159 160 161 162 163 164 165 166 167 168 169 170 q = parser.parse("bbox=-91,-1,1,1") 171 } 172 173 174 175 q = parser.parse("bbox=-1,-181,1,1") 176 } 177 178 179 180 q = parser.parse("bbox=-1,-1,91,1") 181 } 182 183 184 q = parser.parse("bbox=-1,-1,1,181") 185 } 186 187 188 q = parser.parse("bbox=-1,-1,1") 189 } 190 11 final shouldFail = new GroovyTestCase().&shouldFail 12 13 @Test 14 public void test_constructor() { 15 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 16 } 17 18 @Test 19 public void test_parse_basic() { 20 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 21 22 // OK 23 parser.parse "" 24 25 // should be OK 26 ChangesetQuery q = parser.parse(null) 27 assert q != null 28 29 // should be OK 30 q = parser.parse("") 31 assert q != null 32 } 33 34 @Test 35 public void test_uid() { 36 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 37 def ChangesetQuery q 38 39 // OK 40 q = parser.parse("uid=1234") 41 assert q != null 42 43 shouldFail(ChangesetQueryUrlException) { 44 q = parser.parse("uid=0") 45 } 46 47 shouldFail(ChangesetQueryUrlException) { 48 q = parser.parse("uid=-1") 49 } 50 51 shouldFail(ChangesetQueryUrlException) { 52 q = parser.parse("uid=abc") 53 } 54 } 55 56 @Test 57 public void test_display_name() { 58 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 59 def ChangesetQuery q 60 61 // OK 62 q = parser.parse("display_name=abcd") 63 assert q != null 64 assert q.@userName == "abcd" 65 } 66 67 68 @Test 69 public void test_open() { 70 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 71 def ChangesetQuery q 72 73 // OK 74 q = parser.parse("open=true") 75 assert q != null 76 assert q.@open == true 77 78 // OK 79 q = parser.parse("open=false") 80 assert q != null 81 assert q.@open == false 82 83 // illegal value for open 84 shouldFail(ChangesetQueryUrlException) { 85 q = parser.parse("open=abcd") 86 } 87 } 88 89 @Test 90 public void test_closed() { 91 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 92 def ChangesetQuery q 93 94 // OK 95 q = parser.parse("closed=true") 96 assert q != null 97 assert q.@closed == true 98 99 // OK 100 q = parser.parse("closed=false") 101 assert q != null 102 assert q.@closed == false 103 104 // illegal value for open 105 shouldFail(ChangesetQueryUrlException) { 106 q = parser.parse("closed=abcd") 107 } 108 } 109 110 111 @Test 112 public void test_uid_and_display_name() { 113 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 114 def ChangesetQuery q 115 116 // we can't have both an uid and a display name 117 shouldFail(ChangesetQueryUrlException) { 118 q = parser.parse("uid=1&display_name=abcd") 119 } 120 } 121 122 @Test 123 public void test_time() { 124 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 125 def ChangesetQuery q 126 127 // OK 128 q = parser.parse("time=2009-12-25T10:00:00Z") 129 assert q != null 130 assert q.@closedAfter != null 131 Calendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT+0")); 132 cal.setTime(q.@closedAfter); 133 assert cal.get(Calendar.YEAR) == 2009 134 assert cal.get(Calendar.MONTH) == 11 // calendar is 0-based 135 assert cal.get(Calendar.DAY_OF_MONTH) == 25 136 assert cal.get(Calendar.HOUR_OF_DAY) == 10 137 assert cal.get(Calendar.MINUTE) == 0 138 assert cal.get(Calendar.SECOND) == 0 139 140 // OK 141 q = parser.parse("time=2009-12-25T10:00:00Z,2009-11-25T10:00:00Z") 142 assert q!= null 143 assert q.@closedAfter != null 144 assert q.@createdBefore != null 145 146 // should fail 147 shouldFail(ChangesetQueryUrlException) { 148 q = parser.parse("time=asdf") 149 } 150 } 151 152 @Test 153 public void test_bbox() { 154 ChangesetQueryUrlParser parser = new ChangesetQueryUrlParser(); 155 def ChangesetQuery q 156 157 // OK 158 q = parser.parse("bbox=-1,-1,1,1") 159 assert q != null 160 assert q.@bounds != null 161 162 // should fail 163 shouldFail(ChangesetQueryUrlException) { 164 q = parser.parse("bbox=-91,-1,1,1") 165 } 166 167 // should fail 168 shouldFail(ChangesetQueryUrlException) { 169 q = parser.parse("bbox=-1,-181,1,1") 170 } 171 172 // should fail 173 shouldFail(ChangesetQueryUrlException) { 174 q = parser.parse("bbox=-1,-1,91,1") 175 } 176 // should fail 177 shouldFail(ChangesetQueryUrlException) { 178 q = parser.parse("bbox=-1,-1,1,181") 179 } 180 // should fail 181 shouldFail(ChangesetQueryUrlException) { 182 q = parser.parse("bbox=-1,-1,1") 183 } 184 } 191 185 192 186 @Test -
trunk/test/unit/org/openstreetmap/josm/io/DiffResultProcessorTest.groovy
r8351 r8510 17 17 class DiffResultProcessorTest { 18 18 19 @Test 20 public void testConstructor() { 21 Node n = new Node(1) 22 // these calls should not fail 23 // 24 def DiffResultProcessor processor = new DiffResultProcessor(null) 25 processor = new DiffResultProcessor([]) 26 processor = new DiffResultProcessor([n]) 27 } 19 28 20 @Test 21 public void testConstructor() { 22 Node n = new Node(1) 23 // these calls should not fail 24 // 25 def DiffResultProcessor processor = new DiffResultProcessor(null) 26 processor = new DiffResultProcessor([]) 27 processor = new DiffResultProcessor([n]) 28 } 29 @Test 30 public void testParse_NOK_Cases() { 31 def DiffResultProcessor processor = new DiffResultProcessor([]) 29 32 30 @Test 31 public void testParse_NOK_Cases() { 32 def DiffResultProcessor processor = new DiffResultProcessor([]) 33 final shouldFail = new GroovyTestCase().&shouldFail 33 34 34 final shouldFail = new GroovyTestCase().&shouldFail 35 shouldFail(IllegalArgumentException) { 36 processor.parse null, NullProgressMonitor.INSTANCE 37 } 35 38 36 shouldFail(IllegalArgumentException) {37 processor.parse null, NullProgressMonitor.INSTANCE38 39 shouldFail(XmlParsingException) { 40 processor.parse "", NullProgressMonitor.INSTANCE 41 } 39 42 40 shouldFail(XmlParsingException) { 41 processor.parse "", NullProgressMonitor.INSTANCE 42 } 43 shouldFail(XmlParsingException) { 44 processor.parse "<x></x>", NullProgressMonitor.INSTANCE 45 } 46 } 43 47 44 shouldFail(XmlParsingException) { 45 processor.parse "<x></x>", NullProgressMonitor.INSTANCE 46 } 47 } 48 49 @Test 50 public void testParse_OK_Cases() { 51 def DiffResultProcessor processor = new DiffResultProcessor([]) 52 String doc = """\ 53 <diffResult version="0.6" generator="Test Data"> 54 <node old_id="-1" new_id="1" new_version="1"/> 55 <way old_id="-2" new_id="2" new_version="1"/> 56 <relation old_id="-3" new_id="3" new_version="1"/> 57 </diffResult> 58 """ 59 60 processor.parse doc, null 61 assert processor.@diffResults.size() == 3 62 SimplePrimitiveId id = new SimplePrimitiveId(-1, OsmPrimitiveType.NODE) 63 def entry = processor.@diffResults[id] 64 assert entry != null 65 assert entry.newId == 1 66 assert entry.newVersion == 1 67 68 id = new SimplePrimitiveId(-2, OsmPrimitiveType.WAY) 69 entry = processor.@diffResults[id] 70 assert entry != null 71 assert entry.newId == 2 72 assert entry.newVersion == 1 73 74 id = new SimplePrimitiveId(-3, OsmPrimitiveType.RELATION) 75 entry = processor.@diffResults[id] 76 assert entry != null 77 assert entry.newId == 3 78 assert entry.newVersion == 1 79 } 80 81 @Test 82 public void testPostProcess_Invocation_Variants() { 83 def DiffResultProcessor processor = new DiffResultProcessor([]) 84 String doc = """\ 48 @Test 49 public void testParse_OK_Cases() { 50 def DiffResultProcessor processor = new DiffResultProcessor([]) 51 String doc = """\ 85 52 <diffResult version="0.6" generator="Test Data"> 86 53 <node old_id="-1" new_id="1" new_version="1"/> … … 90 57 """ 91 58 92 processor.parse doc, null 59 processor.parse doc, null 60 assert processor.@diffResults.size() == 3 61 SimplePrimitiveId id = new SimplePrimitiveId(-1, OsmPrimitiveType.NODE) 62 def entry = processor.@diffResults[id] 63 assert entry != null 64 assert entry.newId == 1 65 assert entry.newVersion == 1 93 66 94 // should all be ok 95 // 96 processor.postProcess null, null 97 processor.postProcess null, NullProgressMonitor.INSTANCE 98 processor.postProcess new Changeset(1), null 99 processor.postProcess new Changeset(1), NullProgressMonitor.INSTANCE 100 } 67 id = new SimplePrimitiveId(-2, OsmPrimitiveType.WAY) 68 entry = processor.@diffResults[id] 69 assert entry != null 70 assert entry.newId == 2 71 assert entry.newVersion == 1 101 72 102 @Test 103 public void testPostProcess_OK() { 73 id = new SimplePrimitiveId(-3, OsmPrimitiveType.RELATION) 74 entry = processor.@diffResults[id] 75 assert entry != null 76 assert entry.newId == 3 77 assert entry.newVersion == 1 78 } 104 79 105 Node n = new Node() 106 Way w = new Way() 107 Relation r = new Relation() 80 @Test 81 public void testPostProcess_Invocation_Variants() { 82 def DiffResultProcessor processor = new DiffResultProcessor([]) 83 String doc = """\ 84 <diffResult version="0.6" generator="Test Data"> 85 <node old_id="-1" new_id="1" new_version="1"/> 86 <way old_id="-2" new_id="2" new_version="1"/> 87 <relation old_id="-3" new_id="3" new_version="1"/> 88 </diffResult> 89 """ 108 90 109 String doc = """\ 110 <diffResult version="0.6" generator="Test Data"> 111 <node old_id="${n.uniqueId}" new_id="1" new_version="10"/> 112 <way old_id="${w.uniqueId}" new_id="2" new_version="11"/> 113 <relation old_id="${r.uniqueId}" new_id="3" new_version="12"/> 114 </diffResult> 115 """ 91 processor.parse doc, null 116 92 117 def DiffResultProcessor processor = new DiffResultProcessor([n,w,r]) 118 processor.parse doc, null 119 def processed = processor.postProcess(new Changeset(5), null) 120 assert processed.size() == 3 121 n = processed.find {it.uniqueId == 1} 122 assert n.changesetId == 5 123 assert n.version == 10 93 // should all be ok 94 // 95 processor.postProcess null, null 96 processor.postProcess null, NullProgressMonitor.INSTANCE 97 processor.postProcess new Changeset(1), null 98 processor.postProcess new Changeset(1), NullProgressMonitor.INSTANCE 99 } 124 100 125 w = processed.find {it.uniqueId == 2} 126 assert w.changesetId == 5 127 assert w.version == 11 101 @Test 102 public void testPostProcess_OK() { 128 103 129 r = processed.find {it.uniqueId == 3} 130 assert r.changesetId == 5 131 assert r.version == 12 132 } 104 Node n = new Node() 105 Way w = new Way() 106 Relation r = new Relation() 133 107 134 @Test 135 public void testPostProcess_ForCreatedElement() { 108 String doc = """\ 109 <diffResult version="0.6" generator="Test Data"> 110 <node old_id="${n.uniqueId}" new_id="1" new_version="10"/> 111 <way old_id="${w.uniqueId}" new_id="2" new_version="11"/> 112 <relation old_id="${r.uniqueId}" new_id="3" new_version="12"/> 113 </diffResult> 114 """ 136 115 137 Node n = new Node() 138 String doc = """\ 116 def DiffResultProcessor processor = new DiffResultProcessor([n,w,r]) 117 processor.parse doc, null 118 def processed = processor.postProcess(new Changeset(5), null) 119 assert processed.size() == 3 120 n = processed.find {it.uniqueId == 1} 121 assert n.changesetId == 5 122 assert n.version == 10 123 124 w = processed.find {it.uniqueId == 2} 125 assert w.changesetId == 5 126 assert w.version == 11 127 128 r = processed.find {it.uniqueId == 3} 129 assert r.changesetId == 5 130 assert r.version == 12 131 } 132 133 @Test 134 public void testPostProcess_ForCreatedElement() { 135 136 Node n = new Node() 137 String doc = """\ 139 138 <diffResult version="0.6" generator="Test Data"> 140 139 <node old_id="${n.uniqueId}" new_id="1" new_version="1"/> … … 142 141 """ 143 142 144 145 146 147 148 149 150 151 143 def DiffResultProcessor processor = new DiffResultProcessor([n]) 144 processor.parse doc, null 145 def processed = processor.postProcess(new Changeset(5), null) 146 assert processed.size() == 1 147 n = processed.find {it.uniqueId == 1} 148 assert n.changesetId == 5 149 assert n.version == 1 150 } 152 151 153 154 152 @Test 153 public void testPostProcess_ForModifiedElement() { 155 154 156 157 158 159 160 155 Node n = new Node(1) 156 n.coor = new LatLon(1,1) 157 n.setOsmId 1, 2 158 n.modified = true 159 String doc = """\ 161 160 <diffResult version="0.6" generator="Test Data"> 162 161 <node old_id="${n.uniqueId}" new_id="${n.uniqueId}" new_version="3"/> … … 164 163 """ 165 164 166 167 168 169 170 171 172 173 165 def DiffResultProcessor processor = new DiffResultProcessor([n]) 166 processor.parse doc, null 167 def processed = processor.postProcess(new Changeset(5), null) 168 assert processed.size() == 1 169 n = processed.find {it.uniqueId == 1} 170 assert n.changesetId == 5 171 assert n.version == 3 172 } 174 173 175 176 174 @Test 175 public void testPostProcess_ForDeletedElement() { 177 176 178 179 180 181 182 177 Node n = new Node(1) 178 n.coor = new LatLon(1,1) 179 n.setOsmId 1, 2 180 n.deleted = true 181 String doc = """\ 183 182 <diffResult version="0.6" generator="Test Data"> 184 183 <node old_id="${n.uniqueId}"/> … … 186 185 """ 187 186 188 189 190 191 192 193 194 195 187 def DiffResultProcessor processor = new DiffResultProcessor([n]) 188 processor.parse doc, null 189 def processed = processor.postProcess(new Changeset(5), null) 190 assert processed.size() == 1 191 n = processed.find {it.uniqueId == 1} 192 assert n.changesetId == 5 193 assert n.version == 2 194 } 196 195 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmChangeBuilderTest.groovy
r7938 r8510 10 10 class OsmChangeBuilderTest { 11 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 12 /** 13 * Test various constructor invocations 14 */ 15 @Test 16 public void testConstructor() { 17 def Changeset cs = new Changeset(1) 18 // should not fail 19 OsmChangeBuilder builder = new OsmChangeBuilder(cs) 20 21 // should not fail either - null allowed 22 builder = new OsmChangeBuilder(null) 23 24 // should not fail 25 builder = new OsmChangeBuilder(cs, "0.5") 26 27 builder = new OsmChangeBuilder(cs, null) 28 29 builder = new OsmChangeBuilder(null, null) 30 } 31 32 /** 33 * Test the sequence of method calls. Should throw IllegalStateException if 34 * the protocol start(),append()*, finish() is violated. 35 */ 36 @Test 37 public void testSequenceOfMethodCalls() { 38 def Changeset cs = new Changeset(1) 39 OsmChangeBuilder builder = new OsmChangeBuilder(cs) 40 41 final shouldFail = new GroovyTestCase().&shouldFail 42 43 // should be OK 44 builder.start() 45 Node n = new Node(new LatLon(0,0)) 46 builder.append n 47 builder.finish() 48 49 shouldFail(IllegalStateException) { 50 builder = new OsmChangeBuilder(cs) 51 builder.append n 52 } 53 54 shouldFail(IllegalStateException) { 55 builder = new OsmChangeBuilder(cs) 56 builder.append([n]) 57 } 58 59 shouldFail(IllegalStateException) { 60 builder = new OsmChangeBuilder(cs) 61 builder.finish() 62 } 63 64 shouldFail(IllegalStateException) { 65 builder = new OsmChangeBuilder(cs) 66 builder.start() 67 builder.start() 68 } 69 } 70 71 @Test 72 public void testDocumentWithNewNode() { 73 def Changeset cs = new Changeset(1) 74 OsmChangeBuilder builder = new OsmChangeBuilder(cs) 75 Node n = new Node(new LatLon(0,0)) 76 77 builder.start() 78 builder.append n 79 builder.finish() 80 81 def doc = new XmlParser().parseText(builder.document) 82 assert doc.@version == "0.6" 83 assert doc.@generator == "JOSM" 84 assert doc.name() == "osmChange" 85 assert doc.children().size() == 1 86 def create = doc.create 87 assert create != null 88 89 assert create.size() == 1 90 def nodes = create[0].node 91 assert nodes.size() == 1 92 def node = nodes[0] 93 assert node.@id == n.uniqueId.toString() 94 assert node.@lat != null 95 assert node.@lon != null 96 assert node.@changeset == cs.id.toString() 97 } 98 99 /** 100 * Test building a document with a modified node 101 */ 102 @Test 103 public void testDocumentWithModifiedNode() { 104 def Changeset cs = new Changeset(1) 105 OsmChangeBuilder builder = new OsmChangeBuilder(cs) 106 Node n = new Node(1) 107 n.coor = new LatLon(0,0) 108 n.incomplete = false 109 n.modified = true 110 111 builder.start() 112 builder.append n 113 builder.finish() 114 115 def doc = new XmlParser().parseText(builder.document) 116 assert doc.@version == "0.6" 117 assert doc.@generator == "JOSM" 118 assert doc.name() == "osmChange" 119 assert doc.children().size() == 1 120 def modify = doc.modify 121 assert modify != null 122 123 assert modify.size() == 1 124 def nodes = modify[0].node 125 assert nodes.size() == 1 126 def node = nodes[0] 127 assert node.@id == n.uniqueId.toString() 128 assert node.@lat != null 129 assert node.@lon != null 130 assert node.@changeset == cs.id.toString() 131 } 132 133 /** 134 * Test building a document with a deleted node 135 */ 136 @Test 137 public void testDocumentWithDeletedNode() { 138 def Changeset cs = new Changeset(1) 139 OsmChangeBuilder builder = new OsmChangeBuilder(cs) 140 Node n = new Node(1) 141 n.coor = new LatLon(0,0) 142 n.incomplete = false 143 n.deleted = true 144 145 builder.start() 146 builder.append n 147 builder.finish() 148 149 def doc = new XmlParser().parseText(builder.document) 150 assert doc.@version == "0.6" 151 assert doc.@generator == "JOSM" 152 assert doc.name() == "osmChange" 153 assert doc.children().size() == 1 154 def delete = doc.delete 155 assert delete != null 156 157 assert delete.size() == 1 158 def nodes = delete[0].node 159 assert nodes.size() == 1 160 def node = nodes[0] 161 assert node.@id == n.uniqueId.toString() 162 assert node.@lat == null 163 assert node.@lon == null 164 assert node.@changeset == cs.id.toString() 165 } 166 167 /** 168 * Test building a mixed document. 169 * 170 */ 171 @Test 172 public void testMixed() { 173 def Changeset cs = new Changeset(1) 174 OsmChangeBuilder builder = new OsmChangeBuilder(cs) 175 Node n1 = new Node(1) 176 n1.coor = new LatLon(0,0) 177 n1.incomplete = false 178 n1.deleted = true 179 180 Node n2 = new Node(new LatLon(0,0)) 181 182 Node n3 = new Node(2) 183 n3.coor = new LatLon(0,0) 184 n3.incomplete = false 185 n3.modified = true 186 187 builder.start() 188 builder.append([n1,n2,n3]) 189 builder.finish() 190 191 def doc = new XmlParser().parseText(builder.document) 192 193 assert doc.children().size() == 3 194 assert doc.children()[0].name() == "delete" 195 assert doc.children()[1].name() == "create" 196 assert doc.children()[2].name() == "modify" 197 198 def node = doc.children()[0].node[0] 199 assert node.@id == n1.uniqueId.toString() 200 201 node = doc.children()[1].node[0] 202 assert node.@id == n2.uniqueId.toString() 203 204 node = doc.children()[2].node[0] 205 assert node.@id == n3.uniqueId.toString() 206 } 207 207 } -
trunk/test/unit/org/openstreetmap/josm/io/OsmChangesetContentParserTest.groovy
r7938 r8510 2 2 package org.openstreetmap.josm.io; 3 3 4 import java.nio.charset.StandardCharsets 5 4 6 import org.junit.Test 5 6 import java.nio.charset.StandardCharsets 7 8 import org.openstreetmap.josm.data.osm.ChangesetDataSet; 9 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 10 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; 11 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType; 12 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 13 import org.openstreetmap.josm.data.osm.history.HistoryRelation; 14 import org.openstreetmap.josm.data.osm.history.HistoryWay; 15 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 16 7 import org.openstreetmap.josm.data.osm.ChangesetDataSet 8 import org.openstreetmap.josm.data.osm.OsmPrimitiveType 9 import org.openstreetmap.josm.data.osm.SimplePrimitiveId 10 import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType 11 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive 12 import org.openstreetmap.josm.data.osm.history.HistoryRelation 13 import org.openstreetmap.josm.data.osm.history.HistoryWay 14 import org.openstreetmap.josm.gui.progress.NullProgressMonitor 17 15 18 16 class OsmChangesetContentParserTest { 19 20 21 22 23 OsmChangesetContentParser parser 24 25 // should be OK 26 17 final shouldFail = new GroovyTestCase().&shouldFail 18 19 @Test 20 public void test_Constructor() { 21 OsmChangesetContentParser parser 22 23 // should be OK 24 parser = new OsmChangesetContentParser(new ByteArrayInputStream("".bytes)) 27 25 28 26 shouldFail(IllegalArgumentException) { … … 33 31 parser = new OsmChangesetContentParser((InputStream) null) 34 32 } 35 36 37 38 39 40 OsmChangesetContentParser parser 41 42 43 44 45 46 47 // should be OK 48 49 50 51 // should be OK 52 53 54 55 // should be OK 56 parser = new OsmChangesetContentParser(doc) 57 parser.parse null 58 } 59 60 61 * A simple changeset content document with one created node 62 * 63 64 65 66 OsmChangesetContentParser parser 67 68 69 <osmChange version="0.6" generator="OpenStreetMap server"> 70 71 72 73 </osmChange> 74 """ 75 76 // should be OK 77 parser = new OsmChangesetContentParser(doc) 78 79 80 assert ds.size() == 1 81 82 83 84 85 86 87 88 89 90 91 92 * A simple changeset content document with one updated node 93 * 94 95 96 97 OsmChangesetContentParser parser 98 99 33 } 34 35 36 @Test 37 public void test_parse_arguments() { 38 OsmChangesetContentParser parser 39 40 def String doc = """ 41 <osmChange version="0.6" generator="OpenStreetMap server"> 42 </osmChange> 43 """ 44 45 // should be OK 46 parser = new OsmChangesetContentParser(new ByteArrayInputStream(doc.getBytes(StandardCharsets.UTF_8))) 47 parser.parse null 48 49 // should be OK 50 parser = new OsmChangesetContentParser(new ByteArrayInputStream(doc.getBytes(StandardCharsets.UTF_8))) 51 parser.parse NullProgressMonitor.INSTANCE 52 53 // should be OK 54 parser = new OsmChangesetContentParser(doc) 55 parser.parse null 56 } 57 58 /** 59 * A simple changeset content document with one created node 60 * 61 */ 62 @Test 63 public void test_OK_OneCreatedNode() { 64 OsmChangesetContentParser parser 65 66 def String doc = """ 67 <osmChange version="0.6" generator="OpenStreetMap server"> 68 <create> 69 <node id="1" version="1" visible="true" changeset="1" lat="1.0" lon="1.0" timestamp="2009-12-22" /> 70 </create> 71 </osmChange> 72 """ 73 74 // should be OK 75 parser = new OsmChangesetContentParser(doc) 76 ChangesetDataSet ds = parser.parse() 77 78 assert ds.size() == 1 79 HistoryOsmPrimitive p = ds.getPrimitive(new SimplePrimitiveId(1, OsmPrimitiveType.NODE)); 80 assert p != null 81 assert p.getId() == 1 82 assert p.getVersion() == 1 83 assert p.getChangesetId() == 1 84 assert p.getTimestamp() != null 85 assert ds.getModificationType(p.getPrimitiveId()) == ChangesetModificationType.CREATED 86 assert ds.isCreated(p.getPrimitiveId()) 87 } 88 89 /** 90 * A simple changeset content document with one updated node 91 * 92 */ 93 @Test 94 public void test_OK_OneUpdatedNode() { 95 OsmChangesetContentParser parser 96 97 def String doc = """ 100 98 <osmChange version="0.6" generator="OpenStreetMap server"> 101 99 <modify> … … 104 102 </osmChange> 105 103 """ 106 107 // should be OK 108 parser = new OsmChangesetContentParser(doc) 109 110 111 assert ds.size() == 1 112 113 114 115 116 117 118 119 120 121 122 123 * A simple changeset content document with one deleted node 124 * 125 126 127 128 OsmChangesetContentParser parser 129 130 104 105 // should be OK 106 parser = new OsmChangesetContentParser(doc) 107 ChangesetDataSet ds = parser.parse() 108 109 assert ds.size() == 1 110 HistoryOsmPrimitive p = ds.getPrimitive(new SimplePrimitiveId(1, OsmPrimitiveType.NODE)); 111 assert p != null 112 assert p.getId() == 1 113 assert p.getVersion() == 1 114 assert p.getChangesetId() == 1 115 assert p.getTimestamp() != null 116 assert ds.getModificationType(p.getPrimitiveId()) == ChangesetModificationType.UPDATED 117 assert ds.isUpdated(p.getPrimitiveId()) 118 } 119 120 /** 121 * A simple changeset content document with one deleted node 122 * 123 */ 124 @Test 125 public void test_OK_OneDeletedNode() { 126 OsmChangesetContentParser parser 127 128 def String doc = """ 131 129 <osmChange version="0.6" generator="OpenStreetMap server"> 132 130 <delete> … … 135 133 </osmChange> 136 134 """ 137 138 // should be OK 139 parser = new OsmChangesetContentParser(doc) 140 141 142 assert ds.size() == 1 143 144 145 146 147 148 149 150 151 152 153 154 * A more complex test with a document including nodes, ways, and relations. 155 * 156 157 158 159 OsmChangesetContentParser parser 160 161 135 136 // should be OK 137 parser = new OsmChangesetContentParser(doc) 138 ChangesetDataSet ds = parser.parse() 139 140 assert ds.size() == 1 141 HistoryOsmPrimitive p = ds.getPrimitive(new SimplePrimitiveId(1, OsmPrimitiveType.NODE)); 142 assert p != null 143 assert p.getId() == 1 144 assert p.getVersion() == 1 145 assert p.getChangesetId() == 1 146 assert p.getTimestamp() != null 147 assert ds.getModificationType(p.getPrimitiveId()) == ChangesetModificationType.DELETED 148 assert ds.isDeleted(p.getPrimitiveId()) 149 } 150 151 /** 152 * A more complex test with a document including nodes, ways, and relations. 153 * 154 */ 155 @Test 156 public void test_OK_ComplexTestCase() { 157 OsmChangesetContentParser parser 158 159 def String doc = """ 162 160 <osmChange version="0.6" generator="OpenStreetMap server"> 163 161 <create> 164 162 <node id="1" version="1" visible="true" changeset="1" lat="1.0" lon="1.0" timestamp="2009-12-22"> 165 166 163 <tag k="a.key" v="a.value" /> 164 </node> 167 165 </create> 168 166 <modify> 169 167 <way id="2" version="2" visible="true" changeset="1" timestamp="2009-12-22"> 170 171 172 168 <nd ref="21"/> 169 <nd ref="22"/> 170 </way> 173 171 </modify> 174 172 <delete> 175 173 <relation id="3" version="3" visible="true" changeset="1" timestamp="2009-12-22" /> 176 174 </delete> 177 175 </osmChange> 178 176 """ 179 180 // should be OK 181 parser = new OsmChangesetContentParser(doc) 182 183 184 assert ds.size() == 3 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 177 178 // should be OK 179 parser = new OsmChangesetContentParser(doc) 180 ChangesetDataSet ds = parser.parse() 181 182 assert ds.size() == 3 183 184 HistoryOsmPrimitive p = ds.getPrimitive(new SimplePrimitiveId(1, OsmPrimitiveType.NODE)); 185 assert p != null 186 assert p.getId() == 1 187 assert p.getVersion() == 1 188 assert p.getChangesetId() == 1 189 assert p.getTimestamp() != null 190 assert ds.getModificationType(p.getPrimitiveId()) == ChangesetModificationType.CREATED 191 assert ds.isCreated(p.getPrimitiveId()) 192 assert p.get("a.key") == "a.value" 193 194 HistoryWay w = (HistoryWay)ds.getPrimitive(new SimplePrimitiveId(2, OsmPrimitiveType.WAY)); 195 assert w != null 196 assert w.getId() == 2 197 assert w.getVersion() == 2 198 assert w.getChangesetId() == 1 199 assert w.getTimestamp() != null 200 assert ds.getModificationType(w.getPrimitiveId()) == ChangesetModificationType.UPDATED 201 assert ds.isUpdated(w.getPrimitiveId()) 202 assert w.getNumNodes() == 2 203 assert w.getNodes() == [21,22] 204 205 HistoryRelation r = (HistoryRelation)ds.getPrimitive(new SimplePrimitiveId(3, OsmPrimitiveType.RELATION)); 206 assert r != null 207 assert r.getId() == 3 208 assert r.getVersion() == 3 209 assert r.getChangesetId() == 1 210 assert r.getTimestamp() != null 211 assert ds.getModificationType(r.getPrimitiveId()) == ChangesetModificationType.DELETED 212 assert ds.isDeleted(r.getPrimitiveId()) 213 } 216 214 } -
trunk/test/unit/org/openstreetmap/josm/io/ParseWithChangesetReaderTest.groovy
r7938 r8510 20 20 } 21 21 22 23 24 25 26 27 22 /** 23 * A new node with a changeset id. Ignore it. 24 */ 25 @Test 26 public void test_1() { 27 String doc = """\ 28 28 <osm version="0.6"> 29 29 <node id="-1" lat="0.0" lon="0.0" changeset="1"> … … 33 33 """ 34 34 35 36 Node n = ds.nodes.find {it.get("external-id") == "-1"} 37 38 39 40 41 42 43 44 45 46 35 DataSet ds = getDataSet(doc) 36 Node n = ds.nodes.find {it.get("external-id") == "-1"} 37 assert n != null 38 assert n.changesetId == 0 39 } 40 41 /** 42 * A new node with an invalid changeset id. Ignore it. 43 */ 44 @Test 45 public void test_11() { 46 String doc = """\ 47 47 <osm version="0.6"> 48 48 <node id="-1" lat="0.0" lon="0.0" changeset="0"> 49 50 51 </osm> 52 """ 53 54 DataSet ds = getDataSet(doc) 55 56 57 58 59 60 61 62 63 64 65 49 <tag k="external-id" v="-1"/> 50 </node> 51 </osm> 52 """ 53 54 DataSet ds = getDataSet(doc) 55 Node n = ds.nodes.find {it.get("external-id") == "-1"} 56 assert n != null 57 assert n.changesetId == 0 58 } 59 60 /** 61 * A new node with an invalid changeset id. Ignore it. 62 */ 63 @Test 64 public void test_12() { 65 String doc = """\ 66 66 <osm version="0.6"> 67 67 <node id="-1" lat="0.0" lon="0.0" changeset="-1"> 68 69 </node> 70 </osm> 71 """ 72 73 DataSet ds = getDataSet(doc) 74 75 76 77 78 79 80 81 82 83 84 68 <tag k="external-id" v="-1"/> 69 </node> 70 </osm> 71 """ 72 73 DataSet ds = getDataSet(doc) 74 Node n = ds.nodes.find {it.get("external-id") == "-1"} 75 assert n != null 76 assert n.changesetId == 0 77 } 78 79 /** 80 * A new node with an invalid changeset id. Ignore it. 81 */ 82 @Test 83 public void test_13() { 84 String doc = """\ 85 85 <osm version="0.6"> 86 86 <node id="-1" lat="0.0" lon="0.0" changeset="aaa"> 87 88 </node> 89 </osm> 90 """ 91 92 DataSet ds = getDataSet(doc) 93 94 95 96 97 98 99 100 101 102 103 104 87 <tag k="external-id" v="-1"/> 88 </node> 89 </osm> 90 """ 91 92 DataSet ds = getDataSet(doc) 93 Node n = ds.nodes.find {it.get("external-id") == "-1"} 94 assert n != null 95 assert n.changesetId == 0 96 } 97 98 /** 99 * A new node with a missing changeset id. That's fine. The changeset id 100 * is reset to 0. 101 */ 102 @Test 103 public void test_14() { 104 String doc = """\ 105 105 <osm version="0.6"> 106 106 <node id="-1" lat="0.0" lon="0.0" > 107 108 </node> 109 </osm> 110 """ 111 112 DataSet ds = getDataSet(doc) 113 114 115 116 117 118 119 120 121 122 123 124 125 107 <tag k="external-id" v="-1"/> 108 </node> 109 </osm> 110 """ 111 112 DataSet ds = getDataSet(doc) 113 Node n = ds.nodes.find {it.get("external-id") == "-1"} 114 assert n != null 115 assert n.changesetId == 0 116 } 117 118 119 /** 120 * An existing node with a missing changeset id. That's fine. The changeset id 121 * is reset to 0. 122 */ 123 @Test 124 public void test_2() { 125 String doc = """\ 126 126 <osm version="0.6"> 127 127 <node id="1" lat="0.0" lon="0.0" version="1"/> … … 130 130 131 131 DataSet ds = getDataSet(doc) 132 133 134 135 136 137 138 132 Node n = ds.getPrimitiveById(1, OsmPrimitiveType.NODE) 133 assert n != null 134 assert n.uniqueId == 1 135 assert n.changesetId == 0 136 } 137 138 /** 139 139 * An existing node with a valid changeset id id. That's fine. The changeset id 140 140 * is applied. 141 141 */ 142 143 144 142 @Test 143 public void test_3() { 144 String doc = """\ 145 145 <osm version="0.6"> 146 146 <node id="1" lat="0.0" lon="0.0" version="1" changeset="4"/> … … 149 149 150 150 DataSet ds = getDataSet(doc) 151 152 153 154 155 156 157 158 159 160 161 162 163 151 Node n = ds.getPrimitiveById(1, OsmPrimitiveType.NODE) 152 assert n != null 153 assert n.uniqueId == 1 154 assert n.changesetId == 4 155 } 156 157 /** 158 * An existing node with an invalid changeset id. That's a problem. An exception 159 * is thrown. 160 */ 161 @Test 162 public void test_4() { 163 String doc = """\ 164 164 <osm version="0.6"> 165 165 <node id="1" lat="0.0" lon="0.0" version="1" changeset="-1"/> … … 167 167 """ 168 168 169 170 171 169 final shouldFail = new GroovyTestCase().&shouldFail 170 171 shouldFail(IllegalDataException) { 172 172 DataSet ds = getDataSet(doc) 173 174 175 176 177 178 179 180 181 173 } 174 } 175 /** 176 * An existing node with an invalid changeset id. That's a problem. An exception 177 * is thrown. 178 */ 179 @Test 180 public void test_5() { 181 String doc = """\ 182 182 <osm version="0.6"> 183 183 <node id="1" lat="0.0" lon="0.0" version="1" changeset="0"/> … … 185 185 """ 186 186 187 188 189 187 final shouldFail = new GroovyTestCase().&shouldFail 188 189 shouldFail(IllegalDataException) { 190 190 DataSet ds = getDataSet(doc) 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 191 } 192 } 193 /** 194 * An existing node with an invalid changeset id. That's a problem. An exception 195 * is thrown. 196 */ 197 @Test 198 public void test_6() { 199 String doc = """\ 200 <osm version="0.6"> 201 <node id="1" lat="0.0" lon="0.0" version="1" changeset="abc"/> 202 </osm> 203 """ 204 205 final shouldFail = new GroovyTestCase().&shouldFail 206 207 shouldFail(IllegalDataException) { 208 208 DataSet ds = getDataSet(doc) 209 210 209 } 210 } 211 211 } -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
r7937 r8510 72 72 return null; 73 73 } 74 74 75 public void checkClientTrusted(X509Certificate[] certs, String authType) { 75 76 } 77 76 78 public void checkServerTrusted(X509Certificate[] certs, String authType) { 77 79 } … … 137 139 try (BufferedReader in = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) { 138 140 String s; 139 while ((s = in.readLine()) != null) {141 while ((s = in.readLine()) != null) { 140 142 responseBody.append(s); 141 143 responseBody.append("\n"); -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandlerTest.java
r8509 r8510 43 43 } 44 44 45 46 45 @Test 47 46 public void testRequestParameter1() { -
trunk/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
r8338 r8510 33 33 super(layer); 34 34 } 35 35 36 @Override 36 37 public boolean requiresZip() { … … 43 44 super(layer); 44 45 } 46 45 47 @Override 46 48 public boolean requiresZip() { … … 93 95 } 94 96 SessionWriter sw = new SessionWriter(layers, -1, exporters, new MultiMap<Layer, Layer>(), zip); 95 File file = new File(System.getProperty("java.io.tmpdir"), getClass().getName()+(zip ?".joz":".jos"));97 File file = new File(System.getProperty("java.io.tmpdir"), getClass().getName()+(zip ? ".joz" : ".jos")); 96 98 try { 97 99 sw.write(file); -
trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
r8482 r8510 42 42 Map<String, String> correctTags = new HashMap<String, String>() { { 43 43 put("a", "1"); put("b", "2"); put("c", "the value with \"quotes\""); 44 } };44 } }; 45 45 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 46 46 Assert.assertEquals(correctTags, tags); … … 53 53 put("key1", "value"); put("key2", "long value"); 54 54 put("tag3", "hotel \"Quote\""); 55 } };55 } }; 56 56 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 57 57 Assert.assertEquals(correctTags, tags); … … 63 63 Map<String, String> tags, correctTags; 64 64 txt = "{ \"a\":\"1\", \"b\":\"2 3 4\" }"; 65 correctTags = new HashMap<String, String>() { { put("a", "1"); put("b", "2 3 4"); }};65 correctTags = new HashMap<String, String>() { { put("a", "1"); put("b", "2 3 4"); } }; 66 66 tags = TextTagParser.readTagsFromText(txt); 67 67 Assert.assertEquals(correctTags, tags); 68 68 69 69 txt = "\"a\" : \"1 1 1\", \"b2\" :\"2 \\\"3 qwe\\\" 4\""; 70 correctTags = new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4");}};70 correctTags = new HashMap<String, String>() { { put("a", "1 1 1"); put("b2", "2 \"3 qwe\" 4"); } }; 71 71 tags = TextTagParser.readTagsFromText(txt); 72 72 Assert.assertEquals(correctTags, tags); 73 73 74 74 txt = " \"aыыы\" : \"val\\\"\\\"\\\"ue1\""; 75 correctTags = new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1");} };75 correctTags = new HashMap<String, String>() { { put("aыыы", "val\"\"\"ue1"); } }; 76 76 tags = TextTagParser.readTagsFromText(txt); 77 77 Assert.assertEquals(correctTags, tags); … … 83 83 Map<String, String> correctTags = new HashMap<String, String>() { { 84 84 put("a", "1"); put("b", "2"); put("c", "hello === \"\"world"); 85 } };85 } }; 86 86 Map<String, String> tags = TextTagParser.readTagsFromText(txt); 87 87 Assert.assertEquals(correctTags, tags); -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r8435 r8510 70 70 */ 71 71 @Test 72 public void testToHexString() {72 public void testToHexString() { 73 73 Assert.assertEquals("", Utils.toHexString(null)); 74 74 Assert.assertEquals("", Utils.toHexString(new byte[0])); 75 75 Assert.assertEquals("01", Utils.toHexString(new byte[]{0x1})); 76 Assert.assertEquals("0102", Utils.toHexString(new byte[]{0x1, 0x2}));76 Assert.assertEquals("0102", Utils.toHexString(new byte[]{0x1, 0x2})); 77 77 Assert.assertEquals("12", Utils.toHexString(new byte[]{0x12})); 78 78 Assert.assertEquals("127f", Utils.toHexString(new byte[]{0x12, 0x7f})); -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEngineTest.java
r8509 r8510 93 93 } 94 94 } 95 95 96 @Override 96 97 public boolean evaluateCondition(Match condition) { 97 98 return true; 98 99 } 100 99 101 @Override 100 102 public List<String> getTemplateKeys() { … … 245 247 } 246 248 247 @Test(expected =ParseError.class)249 @Test(expected = ParseError.class) 248 250 public void testErrorsNot() throws ParseError { 249 251 TemplateParser parser = new TemplateParser("!{-parent() '{name}'}"); … … 251 253 } 252 254 253 @Test(expected =ParseError.class)255 @Test(expected = ParseError.class) 254 256 public void testErrorOr() throws ParseError { 255 257 TemplateParser parser = new TemplateParser("!{parent() | type=type1 '{name}'}");
Note:
See TracChangeset
for help on using the changeset viewer.