aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2023-02-05 21:11:09 +0000
committerDominik Stadler <centic@apache.org>2023-02-05 21:11:09 +0000
commit3eae53357d0ded614a5a0d7dd875b74eeb0fd18d (patch)
treedb78fd8dda472339b291f8e82e1d783789e8c9ea /poi-ooxml
parent1ca2e638ed1de3438cf660f1006d6cd42e265e3c (diff)
downloadpoi-3eae53357d0ded614a5a0d7dd875b74eeb0fd18d.tar.gz
poi-3eae53357d0ded614a5a0d7dd875b74eeb0fd18d.zip
Avoid a file-handle leak in tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1907445 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTheme.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTheme.java b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTheme.java
index 56fa5e20ca..0ae73cfd23 100644
--- a/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTheme.java
+++ b/poi-ooxml/src/test/java/org/apache/poi/xwpf/usermodel/TestXWPFTheme.java
@@ -31,13 +31,14 @@ public final class TestXWPFTheme {
@Test
void testRead() throws IOException {
- XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("sample.docx");
- XWPFTheme theme = docx.getTheme();
- assertEquals("Office Theme", theme.getName());
- assertEquals("Cambria", theme.getMajorFont());
- assertEquals("Calibri", theme.getMinorFont());
- CTColor accent1 = theme.getCTColor("accent1");
- XSLFColor color = new XSLFColor(accent1, null, null, null);
- assertEquals(new Color(79, 129, 189), color.getColor());
+ try (XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("sample.docx")) {
+ XWPFTheme theme = docx.getTheme();
+ assertEquals("Office Theme", theme.getName());
+ assertEquals("Cambria", theme.getMajorFont());
+ assertEquals("Calibri", theme.getMinorFont());
+ CTColor accent1 = theme.getCTColor("accent1");
+ XSLFColor color = new XSLFColor(accent1, null, null, null);
+ assertEquals(new Color(79, 129, 189), color.getColor());
+ }
}
}