diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2016-05-16 10:01:36 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2016-05-16 10:01:36 +0000 |
commit | d35aba8b169a0185773aede3139d0e7fa9448285 (patch) | |
tree | 04aabb170f7b75260ee47b7579ce2bf681bde685 /src/integrationtest | |
parent | 923a967aa899a7e83921731e80a7c3da3fdbb3aa (diff) | |
download | poi-d35aba8b169a0185773aede3139d0e7fa9448285.tar.gz poi-d35aba8b169a0185773aede3139d0e7fa9448285.zip |
Reduce calls to utf-related methods - the integration test took ages because of poc-shared-strings.xlsx
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1744004 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/integrationtest')
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index 65e539635c..97d2f5f6f5 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertNotNull; import java.io.*; import java.util.HashSet; import java.util.Iterator; +import java.util.Locale; import java.util.Set; import javax.xml.parsers.ParserConfigurationException; @@ -135,16 +136,13 @@ public class XSSFFileHandler extends SpreadsheetHandler { EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/sample-beta.xlsx"); } + @SuppressWarnings("resource") @Override public void handleAdditional(File file) throws Exception { // redirect stdout as the examples often write lots of text PrintStream oldOut = System.out; try { - System.setOut(new PrintStream(new OutputStream() { - @Override - public void write(int b) throws IOException { - } - })); + System.setOut(new NullPrintStream()); FromHowTo.main(new String[]{file.getAbsolutePath()}); XLSX2CSV.main(new String[]{file.getAbsolutePath()}); @@ -195,4 +193,45 @@ public class XSSFFileHandler extends SpreadsheetHandler { public void testAdditional() throws Exception { handleAdditional(new File("test-data/spreadsheet/poc-xmlbomb.xlsx")); } + + // need to override all methods to omit calls to UTF-handling methods + static class NullPrintStream extends PrintStream { + @SuppressWarnings("resource") + NullPrintStream() { + super(new OutputStream() { + public void write(int b) {} + public void write(byte[] b) {} + public void write(byte[] b, int off, int len) {} + }); + } + public void write(int b) {} + public void write(byte[] buf, int off, int len) {} + public void print(boolean b) {} + public void print(char c) {} + public void print(int i) {} + public void print(long l) {} + public void print(float f) {} + public void print(double d) {} + public void print(char[] s) {} + public void print(String s) {} + public void print(Object obj) {} + public void println() {} + public void println(boolean x) {} + public void println(char x) {} + public void println(int x) {} + public void println(long x) {} + public void println(float x) {} + public void println(double x) {} + public void println(char[] x) {} + public void println(String x) {} + public void println(Object x) {} + public PrintStream printf(String format, Object... args) { return this; } + public PrintStream printf(Locale l, String format, Object... args) { return this; } + public PrintStream format(String format, Object... args) { return this; } + public PrintStream format(Locale l, String format, Object... args) { return this; } + public PrintStream append(CharSequence csq) { return this; } + public PrintStream append(CharSequence csq, int start, int end) { return this; } + public PrintStream append(char c) { return this; } + public void write(byte[] b) {} + } } |