Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
3e13f68c
Commit
3e13f68c
authored
10 years ago
by
duminil
Browse files
Options
Download
Email Patches
Plain Diff
Some comments about Novafactory Export Job.
parent
80d2a209
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/eu/simstadt/nf4j/async/test/SuccessfulExportJob.java
+130
-77
test/eu/simstadt/nf4j/async/test/SuccessfulExportJob.java
with
130 additions
and
77 deletions
+130
-77
test/eu/simstadt/nf4j/async/test/SuccessfulExportJob.java
+
130
-
77
View file @
3e13f68c
package
eu.simstadt.nf4j.async.test
;
package
eu.simstadt.nf4j.async.test
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.io.File
;
import
java.io.File
;
import
org.junit.Test
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
eu.simstadt.nf4j.FailedTransmissionException
;
import
eu.simstadt.nf4j.FailedTransmissionException
;
import
eu.simstadt.nf4j.InvalidJobDescriptorException
;
import
eu.simstadt.nf4j.InvalidJobDescriptorException
;
import
eu.simstadt.nf4j.JobStatus
;
import
eu.simstadt.nf4j.JobStatus
;
...
@@ -16,82 +14,137 @@
...
@@ -16,82 +14,137 @@
import
eu.simstadt.nf4j.async.Layer
;
import
eu.simstadt.nf4j.async.Layer
;
import
eu.simstadt.nf4j.async.Unit
;
import
eu.simstadt.nf4j.async.Unit
;
/**
/**
* This class contains client oriented export job tests. It will send an export job and listens to
* This class contains client oriented export job tests. It will send an export job and listens to
status updates. Every
*
status updates. Every
of the subsequent status' LOCAL, SENT, PENDING, RUNNING, FINISHED and DOWNLOAD
* of the subsequent status' LOCAL, SENT, PENDING, RUNNING, FINISHED and DOWNLOAD
have to be signaled to this test
*
have to be signaled to this test
class.
* class.
*
*
* @author Marcel Bruse
* @author Marcel Bruse
*/
*/
public
class
SuccessfulExportJob
implements
JobStatusListener
{
public
class
SuccessfulExportJob
implements
JobStatusListener
{
public
AsyncExportJob
job
;
public
AsyncExportJob
job
;
@Test
public
void
processJob
()
throws
InterruptedException
{
@Test
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
public
void
processJob
()
throws
InterruptedException
{
description
.
setInitiator
(
"2758"
);
ExportJobDescription
description
=
ExportJobDescription
.
getDefaultDescriptor
();
description
.
setAccount
(
"Bruse"
);
description
.
setInitiator
(
"2758"
);
description
.
setProduct
(
"WU3"
);
description
.
setAccount
(
"Bruse"
);
description
.
setJobnumber
(
"Bruse_0815"
);
description
.
setProduct
(
"WU3"
);
description
.
setJobnumber
(
"Bruse_0815"
);
Unit
unit
=
Unit
.
getDefaultUnit
();
unit
.
setValue
(
"821"
);
//FIXME: Zipped GMLs coming from nF don't have any defined srsName
description
.
addUnit
(
unit
);
//NOTE: Unit is a predefined Map Region.
Layer
layer
=
Layer
.
getDefaultLayer
();
// Some of those units are empty. 821 (Finsterrot) and 824 (Neulautern) are available on HFT nF Server.
layer
.
setProduct
(
"WU3"
);
// <designation>
layer
.
setName
(
"GML"
);
// 820
description
.
addLayer
(
layer
);
// </designation><name>
// Wuestenrot
job
=
new
AsyncExportJob
(
description
,
new
HTTPConnection
(
"193.196.136.164"
));
// </name></mapsheet><mapsheet nr="127"><designation>
job
.
addJobStatusListener
(
this
);
// 821
// </designation><name>
try
{
// Finsterrot
job
.
send
();
// </name></mapsheet><mapsheet nr="128"><designation>
}
catch
(
FailedTransmissionException
ex
)
{
// 822
ex
.
printStackTrace
();
// </designation><name>
}
catch
(
InvalidJobDescriptorException
ex
)
{
// Maienfels
ex
.
printStackTrace
();
// </name></mapsheet><mapsheet nr="129"><designation>
}
// 823
// </designation><name>
// Wait for timeout, failure or that all tests pass
// Neuhütten
long
timeout
=
1000
*
60
*
3
l
;
// 3 minutes maximum
// </name></mapsheet><mapsheet nr="130"><designation>
long
interval
=
10000
l
;
// 824
while
(!
job
.
hasFinished
()
&&
!
job
.
hasFailed
()
&&
timeout
>
0
)
{
// </designation><name>
Thread
.
sleep
(
interval
);
// Neulautern
timeout
-=
interval
;
// </name></mapsheet><mapsheet nr="131"><designation>
}
// 824-1
}
// </designation><name>
// Neulautern (1)
@Override
// </name>
public
void
jobStatusChanged
(
JobStatusEvent
event
)
{
Unit
unit
=
Unit
.
getDefaultUnit
();
JobStatus
status
=
(
JobStatus
)
event
.
getSource
();
unit
.
setValue
(
"824"
);
System
.
out
.
println
(
status
);
description
.
addUnit
(
unit
);
if
(
status
==
JobStatus
.
LOCAL
)
{
assertTrue
(
true
);
}
else
if
(
status
==
JobStatus
.
SENT
)
{
//NOTE: Polygon selection. This would be for a small part of Neulautern
assertTrue
(
true
);
//TODO: Check if orientation is important
}
else
if
(
status
==
JobStatus
.
PENDING
)
{
//TODO: Check if polygon needs to be closed (lastPoint == firstPoint)
assertTrue
(
true
);
}
else
if
(
status
==
JobStatus
.
RUNNING
)
{
// ArrayList<Coord> regionPolygon = new ArrayList<>();
assertTrue
(
true
);
// regionPolygon.add(new Coord(49.06020829807264, 9.432239985562616));
}
else
if
(
status
==
JobStatus
.
FINISHED
)
{
// regionPolygon.add(new Coord(49.05989193639516, 9.432497477628047));
try
{
// regionPolygon.add(new Coord(49.05968102749148, 9.432883715726192));
assertTrue
(
true
);
// regionPolygon.add(new Coord(49.05935060174289, 9.433001732922845));
job
.
downloadResult
();
// regionPolygon.add(new Coord(49.058422585764504, 9.433066105939206));
}
catch
(
FailedTransmissionException
ex
)
{
// regionPolygon.add(new Coord(49.05806402949591, 9.433248496152215));
ex
.
printStackTrace
();
// regionPolygon.add(new Coord(49.05748752183746, 9.434353566266353));
}
// regionPolygon.add(new Coord(49.05788826567445, 9.435544467068967));
}
else
if
(
status
==
JobStatus
.
DOWNLOAD
)
{
// regionPolygon.add(new Coord(49.06072150273306, 9.435233330823237));
try
{
// regionPolygon.add(new Coord(49.06133312328379, 9.43515822897082));
File
file
=
job
.
getResult
();
// regionPolygon.add(new Coord(49.06143154427858, 9.43440721044665));
assertTrue
(
file
.
canRead
());
// regionPolygon.add(new Coord(49.06020829807264, 9.432239985562616));
System
.
out
.
println
(
"CityGML at "
+
file
.
getAbsolutePath
());
//
}
catch
(
FailedTransmissionException
ex
)
{
// description.setRegionPolygon(regionPolygon);
ex
.
printStackTrace
();
}
}
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
*
3
l
;
// 3 minutes maximum
long
interval
=
10000
l
;
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
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets