1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.io;
|
---|
3 |
|
---|
4 | import java.io.ByteArrayInputStream;
|
---|
5 | import java.io.InputStream;
|
---|
6 | import java.util.LinkedList;
|
---|
7 |
|
---|
8 | import org.openstreetmap.josm.Main;
|
---|
9 | import org.openstreetmap.josm.data.osm.Segment;
|
---|
10 | import org.openstreetmap.josm.data.osm.Way;
|
---|
11 | import org.openstreetmap.josm.gui.PleaseWaitDialog;
|
---|
12 | import org.openstreetmap.josm.testframework.Bug;
|
---|
13 | import org.openstreetmap.josm.testframework.MotherObject;
|
---|
14 |
|
---|
15 | public class IncompleteDownloaderTest extends MotherObject {
|
---|
16 |
|
---|
17 |
|
---|
18 | @Bug(174)
|
---|
19 | public void testDownloadDoesNotWriteToMainDataDirectly() throws Exception {
|
---|
20 | LinkedList<Way> l = new LinkedList<Way>();
|
---|
21 | Way w = new Way();
|
---|
22 | w.segments.add(new Segment(23)); // incomplete segment
|
---|
23 | Main.ds.nodes.add(createNode(1));
|
---|
24 | Main.ds.nodes.add(createNode(2));
|
---|
25 | l.add(w);
|
---|
26 | IncompleteDownloader downloader = new IncompleteDownloader(l) {
|
---|
27 | @Override protected InputStream getInputStream(String urlStr, PleaseWaitDialog pleaseWaitDlg) {
|
---|
28 | String xml = "<osm version='0.4'><segment id='23' from='1' to='2'/></osm>";
|
---|
29 | return new ByteArrayInputStream(xml.getBytes());
|
---|
30 | }
|
---|
31 | };
|
---|
32 |
|
---|
33 | Main.pleaseWaitDlg = new PleaseWaitDialog(null);
|
---|
34 |
|
---|
35 | downloader.parse();
|
---|
36 |
|
---|
37 | assertEquals("Does not directly write to main data", 0, Main.ds.segments.size());
|
---|
38 | }
|
---|
39 | }
|
---|