Skip to content

Commit 4734273

Browse files
committed
Ensure that streams are closed during test
1 parent d2d060a commit 4734273

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

jablib/src/test/java/org/jabref/logic/exporter/OpenOfficeDocumentCreatorTest.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jabref.logic.exporter;
22

33
import java.io.IOException;
4+
import java.io.InputStream;
45
import java.net.URISyntaxException;
56
import java.nio.charset.Charset;
67
import java.nio.charset.StandardCharsets;
@@ -72,15 +73,18 @@ void performExportForSingleEntry(@TempDir Path testFolder) throws IOException, S
7273
unzipContentXml(zipPath, testFolder.resolve(unzipFolder));
7374
Path contentXmlPath = unzipFolder.resolve("content.xml");
7475

75-
Input.Builder control = Input.from(Files.newInputStream(xmlFile));
76-
Input.Builder test = Input.from(Files.newInputStream(contentXmlPath));
7776
// for debugging purposes
78-
// Path testPath = xmlFile.resolveSibling("test.xml");
79-
// Files.copy(Files.newInputStream(contentXmlPath), testPath, StandardCopyOption.REPLACE_EXISTING);
80-
81-
assertThat(test, CompareMatcher.isSimilarTo(control)
82-
.normalizeWhitespace()
83-
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
77+
// Files.copy(contentXmlPath, xmlFile.resolveSibling("test.xml"), StandardCopyOption.REPLACE_EXISTING);
78+
79+
try (InputStream xmlFileInputStream = Files.newInputStream(xmlFile);
80+
InputStream contentXmlInputStream = Files.newInputStream(contentXmlPath);
81+
) {
82+
Input.Builder control = Input.from(xmlFileInputStream);
83+
Input.Builder test = Input.from(contentXmlInputStream);
84+
assertThat(test, CompareMatcher.isSimilarTo(control)
85+
.normalizeWhitespace()
86+
.withNodeMatcher(new DefaultNodeMatcher(ElementSelectors.byNameAndText)).throwComparisonFailure());
87+
}
8488
}
8589

8690
private static void unzipContentXml(Path zipFile, Path unzipFolder) throws IOException {

0 commit comments

Comments
 (0)