Commit 533e5299 authored by Eric Duminil's avatar Eric Duminil
Browse files

try stdin

parent 83d927c6
Pipeline #6950 failed with stage
......@@ -2,9 +2,12 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
......@@ -75,13 +78,44 @@ void testExtractRegionFromTwoCitygmlsInWGS84() throws IOException {
}
new CommandLine(new RegionChooserCommandLineInterface()).execute("--input=" + citygml1 + "," + citygml2,
"--output=" + outGML, "--wkt=" + inWKT);
originalOut.println(err.toString());
String expectedLog = "EPSG:31463";
assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
expectedLog = "Buildings found in selected region 22";
assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
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);
}
}
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