Redirecting System.out/err is bad in concurrent test environment

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1892530 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2021-08-22 17:48:41 +00:00
parent 41f2ab056f
commit c270cf95fd
2 changed files with 6 additions and 3 deletions

View File

@ -169,9 +169,9 @@ public class OldExcelExtractor implements POITextExtractor {
System.err.println(" OldExcelExtractor <filename>");
System.exit(1);
}
OldExcelExtractor extractor = new OldExcelExtractor(new File(args[0]));
System.out.println(extractor.getText());
extractor.close();
try (OldExcelExtractor extractor = new OldExcelExtractor(new File(args[0]))) {
System.out.println(extractor.getText());
}
}
private void prepare() {

View File

@ -43,6 +43,7 @@ import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.RecordFormatException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
@ -305,6 +306,7 @@ final class TestOldExcelExtractor {
}
@Test
@Disabled("Redirecting System.out/err is bad in concurrent test environment")
void testMainUsage() {
PrintStream save = System.err;
SecurityManager sm = System.getSecurityManager();
@ -320,6 +322,7 @@ final class TestOldExcelExtractor {
}
@Test
@Disabled("Redirecting System.out/err is bad in concurrent test environment")
void testMain() throws IOException {
File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls");
PrintStream save = System.out;