protected int downloadedAddresses;
protected int downloadedServices;
public void testServerList() throws Exception {
sl = new ServerList();
sl.addListener(new DownloadFinishedListener() {
public void downloadFinished(DownloadFinishedData dfd) {
List<URL> addresses = sl.getAddresses();
for (URL addr : addresses) {
System.out.println("Found: "+addr);
downloadedAddresses++;
}
synchronized(sl) {
sl.notifyAll();
}
}
public void downloadFailed(DownloadFinishedData dfd, Exception e) {
InfoWindow.showError(e);
synchronized(sl) {
sl.notifyAll();
}
}
});
sl.download(new URL("http://www.earth3d.org/earth3daddresses.xml"));
synchronized(sl) {
sl.wait();
}
assertTrue(downloadedAddresses>0);
// now download a service list
serviceList = new ServiceList();
serviceList.addListener(new DownloadFinishedListener() {
public void downloadFinished(DownloadFinishedData dfd) {
List<Service> services = serviceList.getServices();
for (Service s : services) {
System.out.println("Found: "+s.getConnectionList().getConnections().get(0));
downloadedServices++;
}
synchronized(sl) {
sl.notifyAll();
}
}
public void downloadFailed(DownloadFinishedData dfd, Exception e) {
InfoWindow.showError(e);
synchronized(sl) {
sl.notifyAll();
}
}
});
serviceList.download(sl.getAddresses().get(0));
synchronized(sl) {
sl.wait();
}
assertTrue(downloadedServices>0);
// now choose the first service for download
Service service = serviceList.getServices().get(0);
service.addListener(new DownloadFinishedListener() {
public void downloadFinished(DownloadFinishedData dfd) {
synchronized(sl) {
sl.notifyAll();
}
}
public void downloadFailed(DownloadFinishedData dfd, Exception e) {
InfoWindow.showError(e);
synchronized(sl) {
sl.notifyAll();
}
}
});
service.download();
synchronized(sl) {
sl.wait();
}
assertTrue(service.getGeometry() != null);
assertEquals("sphere", ((GeometryMapTree) service.getGeometry()).getBase());
// then download the first texture map tile and heightfield map tile
GeometryMapTree geometry = (GeometryMapTree) service.getGeometry();
geometry.addListener(new DownloadFinishedListener() {
public void downloadFinished(DownloadFinishedData dfd) {
synchronized(sl) {
sl.notifyAll();
}