Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
533e5299
Commit
533e5299
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
try stdin
parent
83d927c6
Pipeline
#6950
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
+36
-2
.../regionchooser/RegionChooserCommandLineInterfaceTest.java
with
36 additions
and
2 deletions
+36
-2
src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
+
36
-
2
View file @
533e5299
...
@@ -2,9 +2,12 @@
...
@@ -2,9 +2,12 @@
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
java.io.BufferedWriter
;
import
java.io.BufferedWriter
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
...
@@ -75,13 +78,44 @@ void testExtractRegionFromTwoCitygmlsInWGS84() throws IOException {
...
@@ -75,13 +78,44 @@ void testExtractRegionFromTwoCitygmlsInWGS84() throws IOException {
}
}
new
CommandLine
(
new
RegionChooserCommandLineInterface
()).
execute
(
"--input="
+
citygml1
+
","
+
citygml2
,
new
CommandLine
(
new
RegionChooserCommandLineInterface
()).
execute
(
"--input="
+
citygml1
+
","
+
citygml2
,
"--output="
+
outGML
,
"--wkt="
+
inWKT
);
"--output="
+
outGML
,
"--wkt="
+
inWKT
);
originalOut
.
println
(
err
.
toString
());
String
expectedLog
=
"EPSG:31463"
;
String
expectedLog
=
"EPSG:31463"
;
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
expectedLog
=
"Buildings found in selected region 22"
;
expectedLog
=
"Buildings found in selected region 22"
;
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
assertTrue
(
Files
.
size
(
outGML
)
>
300_000
);
assertTrue
(
Files
.
size
(
outGML
)
>
300_000
);
}
}
//TODO: Test with stdin
@Test
void
testExtractRegionWithStandardInput
()
throws
IOException
{
String
wktPolygon
=
"POLYGON((-73.9959209576448 40.73286384885367, -73.996317924579 40.732359794090684, -73.9947515145143 40.7315061442504, -73.99422580154739 40.73214841515045, -73.9959209576448 40.73286384885367))"
;
Path
citygml
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
Path
outGML
=
Files
.
createTempFile
(
"output"
,
".gml"
);
InputStream
stdin
=
new
ByteArrayInputStream
(
wktPolygon
.
getBytes
(
StandardCharsets
.
UTF_8
));
System
.
setIn
(
stdin
);
new
CommandLine
(
new
RegionChooserCommandLineInterface
()).
execute
(
"--input="
+
citygml
,
"--output="
+
outGML
,
"--wkt=-"
);
String
expectedLog
=
"EPSG:32118"
;
originalOut
.
println
(
err
.
toString
());
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
expectedLog
=
"Buildings found in selected region 2"
;
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
}
@Test
void
testExtractRegionWithMissingInput
()
throws
IOException
{
String
wktPolygon
=
"POLYGON((-73.9959209576448 40.73286384885367, -73.996317924579 40.732359794090684, -73.9947515145143 40.7315061442504, -73.99422580154739 40.73214841515045, -73.9959209576448 40.73286384885367))"
;
Path
citygml
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
Path
outGML
=
Files
.
createTempFile
(
"output"
,
".gml"
);
Path
inWKT
=
Files
.
createTempFile
(
"polygon"
,
".wkt"
);
try
(
BufferedWriter
wkt
=
Files
.
newBufferedWriter
(
inWKT
))
{
wkt
.
write
(
wktPolygon
);
}
new
CommandLine
(
new
RegionChooserCommandLineInterface
()).
execute
(
"--input="
+
citygml
,
"--output="
+
outGML
,
"--wkt=-"
);
String
expectedLog
=
"EPSG:32118"
;
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
expectedLog
=
"Please provide \"POLYGON((x1 y1, x2 y2, ...))\" to standard input."
;
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
}
}
}
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