Commit 3e13f68c authored by duminil's avatar duminil
Browse files

Some comments about Novafactory Export Job.

parent 80d2a209
package eu.simstadt.nf4j.async.test;
import static org.junit.Assert.assertTrue;
import java.io.File;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import eu.simstadt.nf4j.FailedTransmissionException;
import eu.simstadt.nf4j.InvalidJobDescriptorException;
import eu.simstadt.nf4j.JobStatus;
......@@ -16,82 +14,137 @@
import eu.simstadt.nf4j.async.Layer;
import eu.simstadt.nf4j.async.Unit;
/**
* This class contains client oriented export job tests. It will send an export job and listens to
* status updates. Every of the subsequent status' LOCAL, SENT, PENDING, RUNNING, FINISHED and DOWNLOAD
* have to be signaled to this test class.
*
* This class contains client oriented export job tests. It will send an export job and listens to status updates. Every
* of the subsequent status' LOCAL, SENT, PENDING, RUNNING, FINISHED and DOWNLOAD have to be signaled to this test
* class.
*
* @author Marcel Bruse
*/
public class SuccessfulExportJob implements JobStatusListener {
public AsyncExportJob job;
@Test
public void processJob() throws InterruptedException {
ExportJobDescription description= ExportJobDescription.getDefaultDescriptor();
description.setInitiator("2758");
description.setAccount("Bruse");
description.setProduct("WU3");
description.setJobnumber("Bruse_0815");
Unit unit = Unit.getDefaultUnit();
unit.setValue("821");
description.addUnit(unit);
Layer layer = Layer.getDefaultLayer();
layer.setProduct("WU3");
layer.setName("GML");
description.addLayer(layer);
job = new AsyncExportJob(description, new HTTPConnection("193.196.136.164"));
job.addJobStatusListener(this);
try {
job.send();
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
} catch (InvalidJobDescriptorException ex) {
ex.printStackTrace();
}
// Wait for timeout, failure or that all tests pass
long timeout = 1000 * 60 * 3l; // 3 minutes maximum
long interval = 10000l;
while (!job.hasFinished() && !job.hasFailed() && timeout > 0) {
Thread.sleep(interval);
timeout -= interval;
}
}
@Override
public void jobStatusChanged(JobStatusEvent event) {
JobStatus status = (JobStatus) event.getSource();
System.out.println(status);
if (status == JobStatus.LOCAL) {
assertTrue(true);
} else if (status == JobStatus.SENT) {
assertTrue(true);
} else if (status == JobStatus.PENDING) {
assertTrue(true);
} else if (status == JobStatus.RUNNING) {
assertTrue(true);
} else if (status == JobStatus.FINISHED) {
try {
assertTrue(true);
job.downloadResult();
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
}
} else if (status == JobStatus.DOWNLOAD) {
try {
File file = job.getResult();
assertTrue(file.canRead());
System.out.println("CityGML at " + file.getAbsolutePath());
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
}
}
}
public class SuccessfulExportJob implements JobStatusListener
{
public AsyncExportJob job;
@Test
public void processJob() throws InterruptedException {
ExportJobDescription description = ExportJobDescription.getDefaultDescriptor();
description.setInitiator("2758");
description.setAccount("Bruse");
description.setProduct("WU3");
description.setJobnumber("Bruse_0815");
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
//NOTE: Unit is a predefined Map Region.
// Some of those units are empty. 821 (Finsterrot) and 824 (Neulautern) are available on HFT nF Server.
// <designation>
// 820
// </designation><name>
// Wuestenrot
// </name></mapsheet><mapsheet nr="127"><designation>
// 821
// </designation><name>
// Finsterrot
// </name></mapsheet><mapsheet nr="128"><designation>
// 822
// </designation><name>
// Maienfels
// </name></mapsheet><mapsheet nr="129"><designation>
// 823
// </designation><name>
// Neuhütten
// </name></mapsheet><mapsheet nr="130"><designation>
// 824
// </designation><name>
// Neulautern
// </name></mapsheet><mapsheet nr="131"><designation>
// 824-1
// </designation><name>
// Neulautern (1)
// </name>
Unit unit = Unit.getDefaultUnit();
unit.setValue("824");
description.addUnit(unit);
//NOTE: Polygon selection. This would be for a small part of Neulautern
//TODO: Check if orientation is important
//TODO: Check if polygon needs to be closed (lastPoint == firstPoint)
// ArrayList<Coord> regionPolygon = new ArrayList<>();
// regionPolygon.add(new Coord(49.06020829807264, 9.432239985562616));
// regionPolygon.add(new Coord(49.05989193639516, 9.432497477628047));
// regionPolygon.add(new Coord(49.05968102749148, 9.432883715726192));
// regionPolygon.add(new Coord(49.05935060174289, 9.433001732922845));
// regionPolygon.add(new Coord(49.058422585764504, 9.433066105939206));
// regionPolygon.add(new Coord(49.05806402949591, 9.433248496152215));
// regionPolygon.add(new Coord(49.05748752183746, 9.434353566266353));
// regionPolygon.add(new Coord(49.05788826567445, 9.435544467068967));
// regionPolygon.add(new Coord(49.06072150273306, 9.435233330823237));
// regionPolygon.add(new Coord(49.06133312328379, 9.43515822897082));
// regionPolygon.add(new Coord(49.06143154427858, 9.43440721044665));
// regionPolygon.add(new Coord(49.06020829807264, 9.432239985562616));
//
// description.setRegionPolygon(regionPolygon);
Layer layer = Layer.getDefaultLayer();
layer.setProduct("WU3");
layer.setName("GML");
description.addLayer(layer);
job = new AsyncExportJob(description, new HTTPConnection("193.196.136.164"));
job.addJobStatusListener(this);
try {
job.send();
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
} catch (InvalidJobDescriptorException ex) {
ex.printStackTrace();
}
// Wait for timeout, failure or that all tests pass
long timeout = 1000 * 60 * 3l; // 3 minutes maximum
long interval = 10000l;
while (!job.hasFinished() && !job.hasFailed() && timeout > 0) {
Thread.sleep(interval);
timeout -= interval;
System.out.println("+");
}
}
@Override
public void jobStatusChanged(JobStatusEvent event) {
System.out.println("BOOM BOOM");
JobStatus status = (JobStatus) event.getSource();
System.out.println(status);
if (status == JobStatus.LOCAL) {
assertTrue(true);
} else if (status == JobStatus.SENT) {
assertTrue(true);
} else if (status == JobStatus.PENDING) {
assertTrue(true);
} else if (status == JobStatus.RUNNING) {
assertTrue(true);
} else if (status == JobStatus.FINISHED) {
try {
assertTrue(true);
job.downloadResult();
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
}
} else if (status == JobStatus.DOWNLOAD) {
try {
File file = job.getResult();
assertTrue(file.canRead());
System.out.println("CityGML at " + file.getAbsolutePath());
} catch (FailedTransmissionException ex) {
ex.printStackTrace();
}
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment