Changeset 2381 in josm for trunk/test/functional/org/openstreetmap
 Timestamp:
 20091102T07:51:28+01:00 (14 years ago)
 Location:
 trunk/test/functional/org/openstreetmap/josm/io
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r2199 r2381 35 35 import org.openstreetmap.josm.data.projection.Mercator; 36 36 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 37 import org.xml.sax.SAXException;38 37 39 38 public class MultiFetchServerObjectReaderTest { … … 124 123 logger.info("creating data set on the server ..."); 125 124 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 126 primitives.addAll(testDataSet. nodes);127 primitives.addAll(testDataSet. ways);128 primitives.addAll(testDataSet. relations);125 primitives.addAll(testDataSet.getNodes()); 126 primitives.addAll(testDataSet.getWays()); 127 primitives.addAll(testDataSet.getRelations()); 129 128 130 129 OsmServerWriter writer = new OsmServerWriter(); … … 247 246 } 248 247 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 249 assertEquals(10, out. nodes.size());248 assertEquals(10, out.getNodes().size()); 250 249 Iterator<Node> it = out.nodes.iterator(); 251 250 while(it.hasNext()) { … … 261 260 public void testMultiGet10Ways() throws OsmTransferException { 262 261 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 263 ArrayList<Way> ways= new ArrayList<Way>(ds. ways);262 ArrayList<Way> ways= new ArrayList<Way>(ds.getWays()); 264 263 for (int i =0; i< 10; i++) { 265 264 reader.append(ways.get(i)); 266 265 } 267 266 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 268 assertEquals(10, out.ways.size()); 269 Iterator<Way> it = out.ways.iterator(); 270 while(it.hasNext()) { 271 Way w1 = it.next(); 267 assertEquals(10, out.getWays().size()); 268 for (Way w1: out.getWays()) { 272 269 Way w2 = (Way)ds.getPrimitiveById(w1.getId(), OsmPrimitiveType.WAY); 273 270 assertNotNull(w2); … … 281 278 public void testMultiGet10Relations() throws OsmTransferException { 282 279 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 283 ArrayList<Relation> relations= new ArrayList<Relation>(ds. relations);280 ArrayList<Relation> relations= new ArrayList<Relation>(ds.getRelations()); 284 281 for (int i =0; i< 10; i++) { 285 282 reader.append(relations.get(i)); 286 283 } 287 284 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 288 assertEquals(10, out.relations.size()); 289 Iterator<Relation> it = out.relations.iterator(); 290 while(it.hasNext()) { 291 Relation r1 = it.next(); 285 assertEquals(10, out.getRelations().size()); 286 for (Relation r1: out.getRelations()) { 292 287 Relation r2 = (Relation)ds.getPrimitiveById(r1.getId(), OsmPrimitiveType.RELATION); 293 288 assertNotNull(r2); … … 301 296 public void testMultiGet800Nodes() throws OsmTransferException { 302 297 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 303 ArrayList<Node> nodes = new ArrayList<Node>(ds. nodes);298 ArrayList<Node> nodes = new ArrayList<Node>(ds.getNodes()); 304 299 for (int i =0; i< 812; i++) { 305 300 reader.append(nodes.get(i)); 306 301 } 307 302 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 308 assertEquals(812, out. nodes.size());303 assertEquals(812, out.getNodes().size()); 309 304 Iterator<Node> it = out.nodes.iterator(); 310 305 while(it.hasNext()) { … … 320 315 public void multiGetWithNonExistingNode() throws OsmTransferException { 321 316 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 322 ArrayList<Node> nodes = new ArrayList<Node>(ds. nodes);317 ArrayList<Node> nodes = new ArrayList<Node>(ds.getNodes()); 323 318 for (int i =0; i< 10; i++) { 324 319 reader.append(nodes.get(i)); … … 327 322 reader.append(n); // doesn't exist 328 323 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 329 assertEquals(10, out.nodes.size()); 330 Iterator<Node> it = out.nodes.iterator(); 331 while(it.hasNext()) { 332 Node n1 = it.next(); 324 assertEquals(10, out.getNodes().size()); 325 for (Node n1:out.getNodes()) { 333 326 Node n2 = (Node)ds.getPrimitiveById(n1.getId(), OsmPrimitiveType.NODE); 334 327 assertNotNull(n2); 
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r2199 r2381 34 34 import org.openstreetmap.josm.data.projection.Mercator; 35 35 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 36 import org.xml.sax.SAXException;37 36 38 37 public class OsmServerBackreferenceReaderTest { … … 40 39 41 40 protected static Node lookupNode(DataSet ds, int i) { 42 for (Node n : ds.nodes) {41 for (Node n : ds.getNodes()) { 43 42 if (("node" + i).equals(n.get("name"))) return n; 44 43 } … … 48 47 49 48 protected static Way lookupWay(DataSet ds, int i) { 50 for (Way w : ds.ways) {49 for (Way w : ds.getWays()) { 51 50 if (("way" + i).equals(w.get("name"))) return w; 52 51 } … … 55 54 56 55 protected static Relation lookupRelation(DataSet ds, int i) { 57 for (Relation r : ds.relations) {56 for (Relation r : ds.getRelations()) { 58 57 if (("relation" + i).equals(r.get("name"))) return r; 59 58 } … … 103 102 } 104 103 } 105 ds. relations.add(r);104 ds.addPrimitive(r); 106 105 } 107 106 } … … 127 126 logger.info("creating data set on the server ..."); 128 127 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 129 primitives.addAll(ds. nodes);130 primitives.addAll(ds. ways);131 primitives.addAll(ds. relations);128 primitives.addAll(ds.getNodes()); 129 primitives.addAll(ds.getWays()); 130 primitives.addAll(ds.getRelations()); 132 131 OsmServerWriter writer = new OsmServerWriter(); 133 132 Changeset cs = new Changeset(); … … 253 252 reader.setReadFull(false); 254 253 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 255 assertEquals(10, referers. nodes.size());256 assertEquals(1, referers. ways.size());257 assertEquals(0, referers. relations.size());258 for (Way way : referers.ways) {254 assertEquals(10, referers.getNodes().size()); 255 assertEquals(1, referers.getWays().size()); 256 assertEquals(0, referers.getRelations().size()); 257 for (Way way : referers.getWays()) { 259 258 assertEquals(w.getId(), way.getId()); 260 259 assertEquals(false, way.incomplete); … … 272 271 reader.setReadFull(true); 273 272 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 274 assertEquals(10, referers. nodes.size());275 assertEquals(1, referers. ways.size());276 assertEquals(0, referers. relations.size());277 for (Way way : referers.ways) {273 assertEquals(10, referers.getNodes().size()); 274 assertEquals(1, referers.getWays().size()); 275 assertEquals(0, referers.getRelations().size()); 276 for (Way way : referers.getWays()) { 278 277 assertEquals(w.getId(), way.getId()); 279 278 assertEquals(false, way.incomplete); … … 292 291 reader.setReadFull(false); 293 292 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 294 assertEquals(0, referers. nodes.size()); // no nodes loaded295 assertEquals(6, referers. ways.size()); // 6 ways referred by two relations296 for (Way w1 : referers.ways) {293 assertEquals(0, referers.getNodes().size()); // no nodes loaded 294 assertEquals(6, referers.getWays().size()); // 6 ways referred by two relations 295 for (Way w1 : referers.getWays()) { 297 296 assertEquals(true, w1.incomplete); 298 297 } 299 assertEquals(2, referers. relations.size()); // two relations referring to w298 assertEquals(2, referers.getRelations().size()); // two relations referring to w 300 299 301 300 Relation r = lookupRelation(referers, 0); … … 316 315 reader.setReadFull(true); 317 316 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 318 assertEquals(6, referers. ways.size()); // 6 ways referred by two relations319 for (Way w1 : referers.ways) {317 assertEquals(6, referers.getWays().size()); // 6 ways referred by two relations 318 for (Way w1 : referers.getWays()) { 320 319 assertEquals(false, w1.incomplete); 321 320 } 322 assertEquals(2, referers. relations.size()); // two relations referring to321 assertEquals(2, referers.getRelations().size()); // two relations referring to 323 322 Set<Long> expectedNodeIds = new HashSet<Long>(); 324 for (Way way : referers.ways) {325 Way orig = (Way) ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY);326 for (Node n: orig.getNodes()) {323 for (Way way : referers.getWays()) { 324 Way orig = (Way) ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY); 325 for (Node n : orig.getNodes()) { 327 326 expectedNodeIds.add(n.getId()); 328 327 } 329 328 } 330 assertEquals(expectedNodeIds.size(), referers. nodes.size());331 for (Node n : referers. nodes) {329 assertEquals(expectedNodeIds.size(), referers.getNodes().size()); 330 for (Node n : referers.getNodes()) { 332 331 assertEquals(true, expectedNodeIds.contains(n.getId())); 333 332 } … … 342 341 @Test 343 342 public void testBackrefrenceForRelation() throws OsmTransferException { 344 Relation r = lookupRelation(ds, 1);343 Relation r = lookupRelation(ds, 1); 345 344 assertNotNull(r); 346 345 // way with name "relation1" is referred to by four relations: … … 370 369 referringRelationsIds.add(r.getId()); 371 370 372 for (Relation r1 : referers.relations) {373 if (! 371 for (Relation r1 : referers.getRelations()) { 372 if (!referringRelationsIds.contains(r1.getId())) { 374 373 assertEquals(true, r1.incomplete); 375 374 } … … 401 400 } 402 401 403 assertEquals(expectedWayIds.size(), referers. ways.size());404 for (Way w1 : referers. ways) {402 assertEquals(expectedWayIds.size(), referers.getWays().size()); 403 for (Way w1 : referers.getWays()) { 405 404 assertEquals(true, expectedWayIds.contains(w1.getId())); 406 405 assertEquals(true, w1.incomplete); … … 409 408 // make sure we didn't read any nodes 410 409 // 411 assertEquals(0, referers. nodes.size());410 assertEquals(0, referers.getNodes().size()); 412 411 } 413 412 … … 438 437 @Test 439 438 public void testBackrefrenceForRelation_Full() throws OsmTransferException { 440 Relation r = lookupRelation(ds, 1);439 Relation r = lookupRelation(ds, 1); 441 440 assertNotNull(r); 442 441 // way with name "relation1" is referred to by four relations: … … 468 467 // all relations are fully loaded 469 468 // 470 for (Relation r1 : referers.relations) {469 for (Relation r1 : referers.getRelations()) { 471 470 assertEquals(false, r1.incomplete); 472 471 } … … 497 496 } 498 497 for (long id : expectedWayIds) { 499 Way w = (Way) referers.getPrimitiveById(id, OsmPrimitiveType.WAY);498 Way w = (Way) referers.getPrimitiveById(id, OsmPrimitiveType.WAY); 500 499 assertNotNull(w); 501 500 assertEquals(false, w.incomplete); … … 503 502 504 503 Set<Long> expectedNodeIds = new HashSet<Long>(); 505 for (int i=6; i< 10;i++) {504 for (int i = 6; i < 10; i++) { 506 505 Relation r1 = lookupRelation(ds, i); 507 506 expectedNodeIds.addAll(getNodeIdsInRelation(r1)); 508 507 } 509 508 510 assertEquals(expectedNodeIds.size(), referers. nodes.size());511 for (Node n : referers.nodes) {509 assertEquals(expectedNodeIds.size(), referers.getNodes().size()); 510 for (Node n : referers.getNodes()) { 512 511 assertEquals(true, expectedNodeIds.contains(n.getId())); 513 512 }
Note:
See TracChangeset
for help on using the changeset viewer.