diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2021-01-15 23:50:42 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2021-01-15 23:50:42 +0000 |
commit | 309e657b0d8479583847d684febc3db10f12b4c4 (patch) | |
tree | 071abc4dfe85ac20704cd2689620b72c464c4e95 /src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java | |
parent | ca71e9dacf96e9739581568c10d3b3954f12bb5e (diff) | |
download | poi-309e657b0d8479583847d684febc3db10f12b4c4.tar.gz poi-309e657b0d8479583847d684febc3db10f12b4c4.zip |
#65046 - Simplify integration tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885538 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java')
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java index 65ee09b428..088f77ef45 100644 --- a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java @@ -18,6 +18,7 @@ package org.apache.poi.stress; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assumptions.assumeFalse; import java.io.ByteArrayOutputStream; @@ -46,7 +47,7 @@ import org.junit.jupiter.api.Test; class HPSFFileHandler extends POIFSFileHandler { private static final String NL = System.getProperty("line.separator"); - private static File copyOutput; + private static final ThreadLocal<File> copyOutput = ThreadLocal.withInitial(HPSFFileHandler::getTempFile); static final Set<String> EXCLUDES_HANDLE_ADD = unmodifiableHashSet( "spreadsheet/45290.xls", @@ -58,12 +59,6 @@ class HPSFFileHandler extends POIFSFileHandler { "document/word2.doc" ); - static final Set<String> EXCLUDES_HANDLE_FILE = unmodifiableHashSet( - "hpsf/Test_Humor-Generation.ppt", - "slideshow/missing-moveto.ppt" // POIFS properties corrupted - ); - - private static Set<String> unmodifiableHashSet(String... a) { return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a))); } @@ -71,7 +66,6 @@ class HPSFFileHandler extends POIFSFileHandler { @Override public void handleFile(InputStream stream, String path) throws Exception { - assumeFalse(EXCLUDES_HANDLE_FILE.contains(path)); POIFSFileSystem poifs = new POIFSFileSystem(stream); HPSFPropertiesOnlyDocument hpsf = new HPSFPropertiesOnlyDocument(poifs); DocumentSummaryInformation dsi = hpsf.getDocumentSummaryInformation(); @@ -95,24 +89,26 @@ class HPSFFileHandler extends POIFSFileHandler { } } + private static File getTempFile() { + File f = null; + try { + f = TempFile.createTempFile("hpsfCopy", "out"); + } catch (IOException e) { + fail(e); + } + f.deleteOnExit(); + return f; + } + @Override public void handleAdditional(File file) throws Exception { assumeFalse(EXCLUDES_HANDLE_ADD.contains(file.getParentFile().getName()+"/"+file.getName())); - if (copyOutput == null) { - copyOutput = TempFile.createTempFile("hpsfCopy", "out"); - copyOutput.deleteOnExit(); - } ByteArrayOutputStream bos = new ByteArrayOutputStream(); PrintStream psNew = new PrintStream(bos, true, "ISO-8859-1"); - PrintStream ps = System.out; - try { - System.setOut(psNew); - CopyCompare.main(new String[]{file.getAbsolutePath(), copyOutput.getAbsolutePath()}); - assertEquals("Equal" + NL, bos.toString(StandardCharsets.UTF_8.name())); - } finally { - System.setOut(ps); - } + CopyCompare.setOut(psNew); + CopyCompare.main(new String[]{file.getAbsolutePath(), copyOutput.get().getAbsolutePath()}); + assertEquals("Equal" + NL, bos.toString(StandardCharsets.UTF_8.name())); } |