From 4a46094986f467a5e8858ae141e4bd858f490954 Mon Sep 17 00:00:00 2001
From: Eric Duminil <eric.duminil@gmail.com>
Date: Tue, 11 Oct 2022 11:14:49 +0200
Subject: [PATCH] Tests for citygml stdout. Not working yet.

---
 .gitignore                                        |  1 +
 .../RegionChooserCommandLineInterfaceTest.java    | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/.gitignore b/.gitignore
index f190e4b..eb2353e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -272,3 +272,4 @@ $RECYCLE.BIN/
 *.lnk
 
 # End of https://www.gitignore.io/api/java,maven,macos,linux,eclipse,windows,netbeans,intellij
+/-
diff --git a/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java b/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
index b5b3584..4fec364 100644
--- a/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
+++ b/src/test/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterfaceTest.java
@@ -113,6 +113,21 @@ void testExtractRegionWithStandardInput() throws IOException {
 		assertEquals(2, countBuildings(outGML));
 	}
 
+	@Test
+	void testExtractRegionWithStandardInputAndStandardOutput() 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");
+		InputStream stdin = new ByteArrayInputStream(wktPolygon.getBytes(StandardCharsets.UTF_8));
+		System.setIn(stdin);
+		new CommandLine(new RegionChooserCommandLineInterface()).execute("--input=" + citygml, "--output=-", "--wkt=-");
+		String expectedLog = "EPSG:32118";
+		assertTrue(err.toString().contains(expectedLog), err.toString() + " should contain " + expectedLog);
+		originalOut.println(err.toString());
+		originalOut.println("--------------------");
+		originalOut.println(out.toString());
+		assertFalse(Files.exists(Paths.get("-")));
+	}
+
 	@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))";
-- 
GitLab