Avoid a file-handle leak in tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1907445 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2023-02-05 21:11:09 +00:00
parent 1ca2e638ed
commit 3eae53357d
1 changed files with 9 additions and 8 deletions

View File

@ -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());
}
}
}