diff options
author | PJ Fanning <fanningpj@apache.org> | 2021-05-22 20:03:17 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2021-05-22 20:03:17 +0000 |
commit | 95279ea0349e41f333de67c5e45cf11bdc62172e (patch) | |
tree | 597cd41c23533b9342190612fda030edfbc20587 /poi-examples/src/test | |
parent | f21019db12ad2234d5681f49a0c5a40064fc2418 (diff) | |
download | poi-95279ea0349e41f333de67c5e45cf11bdc62172e.tar.gz poi-95279ea0349e41f333de67c5e45cf11bdc62172e.zip |
convert tabs to spaces
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1890117 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-examples/src/test')
-rw-r--r-- | poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java index 139b9115d3..bc9ab4491e 100644 --- a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java +++ b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java @@ -34,82 +34,82 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class TestXLSX2CSV { - private PrintStream err; - private final UnsynchronizedByteArrayOutputStream errorBytes = new UnsynchronizedByteArrayOutputStream(); - - @BeforeEach - public void setUp() throws UnsupportedEncodingException { - // remember and replace default error streams - err = System.err; - - PrintStream error = new PrintStream(errorBytes, true, "UTF-8"); - System.setErr(error); - } - - @AfterEach - public void tearDown() { - // restore output-streams again - System.setErr(err); - - // Print out found error - if (errorBytes.size() > 0) { - System.err.println("Had stderr: " + errorBytes.toString(StandardCharsets.UTF_8)); - } - } - - @Test - public void testNoArgument() throws Exception { - // returns with some System.err - XLSX2CSV.main(new String[0]); - - String output = errorBytes.toString(StandardCharsets.UTF_8); - assertTrue(output.contains("XLSX2CSV <xlsx file>"), "Had: " + output); - } - - @Test - public void testInvalidFile() throws Exception { - // returns with some System.err - XLSX2CSV.main(new String[] { "not-existing-file.xlsx" }); - - String output = errorBytes.toString("UTF-8"); - assertTrue(output.contains("Not found or not a file: not-existing-file.xlsx"), "Had: " + output); - } - - @Test - public void testSampleFile() throws Exception { - final UnsynchronizedByteArrayOutputStream outputBytes = new UnsynchronizedByteArrayOutputStream(); - PrintStream out = new PrintStream(outputBytes, true, "UTF-8"); - - // The package open is instantaneous, as it should be. - try (OPCPackage p = OPCPackage.open(XSSFTestDataSamples.getSampleFile("sample.xlsx").getAbsolutePath(), PackageAccess.READ)) { - XLSX2CSV xlsx2csv = new XLSX2CSV(p, out, -1); - xlsx2csv.process(); - } - - String errorOutput = errorBytes.toString(StandardCharsets.UTF_8); - assertEquals(errorOutput.length(), 0); - - String output = outputBytes.toString(StandardCharsets.UTF_8); - assertTrue(output.contains("\"Lorem\",111"), "Had: " + output); - assertTrue(output.contains(",\"hello, xssf\",,\"hello, xssf\""), "Had: " + output); - } - - @Test - public void testMinColumns() throws Exception { - final UnsynchronizedByteArrayOutputStream outputBytes = new UnsynchronizedByteArrayOutputStream(); - PrintStream out = new PrintStream(outputBytes, true, "UTF-8"); - - // The package open is instantaneous, as it should be. - try (OPCPackage p = OPCPackage.open(XSSFTestDataSamples.getSampleFile("sample.xlsx").getAbsolutePath(), PackageAccess.READ)) { - XLSX2CSV xlsx2csv = new XLSX2CSV(p, out, 5); - xlsx2csv.process(); - } - - String errorOutput = errorBytes.toString(StandardCharsets.UTF_8); - assertEquals(errorOutput.length(), 0); - - String output = outputBytes.toString(StandardCharsets.UTF_8); - assertTrue(output.contains("\"Lorem\",111,,,"), "Had: " + output); - assertTrue(output.contains(",\"hello, xssf\",,\"hello, xssf\","), "Had: " + output); - } + private PrintStream err; + private final UnsynchronizedByteArrayOutputStream errorBytes = new UnsynchronizedByteArrayOutputStream(); + + @BeforeEach + public void setUp() throws UnsupportedEncodingException { + // remember and replace default error streams + err = System.err; + + PrintStream error = new PrintStream(errorBytes, true, "UTF-8"); + System.setErr(error); + } + + @AfterEach + public void tearDown() { + // restore output-streams again + System.setErr(err); + + // Print out found error + if (errorBytes.size() > 0) { + System.err.println("Had stderr: " + errorBytes.toString(StandardCharsets.UTF_8)); + } + } + + @Test + public void testNoArgument() throws Exception { + // returns with some System.err + XLSX2CSV.main(new String[0]); + + String output = errorBytes.toString(StandardCharsets.UTF_8); + assertTrue(output.contains("XLSX2CSV <xlsx file>"), "Had: " + output); + } + + @Test + public void testInvalidFile() throws Exception { + // returns with some System.err + XLSX2CSV.main(new String[] { "not-existing-file.xlsx" }); + + String output = errorBytes.toString("UTF-8"); + assertTrue(output.contains("Not found or not a file: not-existing-file.xlsx"), "Had: " + output); + } + + @Test + public void testSampleFile() throws Exception { + final UnsynchronizedByteArrayOutputStream outputBytes = new UnsynchronizedByteArrayOutputStream(); + PrintStream out = new PrintStream(outputBytes, true, "UTF-8"); + + // The package open is instantaneous, as it should be. + try (OPCPackage p = OPCPackage.open(XSSFTestDataSamples.getSampleFile("sample.xlsx").getAbsolutePath(), PackageAccess.READ)) { + XLSX2CSV xlsx2csv = new XLSX2CSV(p, out, -1); + xlsx2csv.process(); + } + + String errorOutput = errorBytes.toString(StandardCharsets.UTF_8); + assertEquals(errorOutput.length(), 0); + + String output = outputBytes.toString(StandardCharsets.UTF_8); + assertTrue(output.contains("\"Lorem\",111"), "Had: " + output); + assertTrue(output.contains(",\"hello, xssf\",,\"hello, xssf\""), "Had: " + output); + } + + @Test + public void testMinColumns() throws Exception { + final UnsynchronizedByteArrayOutputStream outputBytes = new UnsynchronizedByteArrayOutputStream(); + PrintStream out = new PrintStream(outputBytes, true, "UTF-8"); + + // The package open is instantaneous, as it should be. + try (OPCPackage p = OPCPackage.open(XSSFTestDataSamples.getSampleFile("sample.xlsx").getAbsolutePath(), PackageAccess.READ)) { + XLSX2CSV xlsx2csv = new XLSX2CSV(p, out, 5); + xlsx2csv.process(); + } + + String errorOutput = errorBytes.toString(StandardCharsets.UTF_8); + assertEquals(errorOutput.length(), 0); + + String output = outputBytes.toString(StandardCharsets.UTF_8); + assertTrue(output.contains("\"Lorem\",111,,,"), "Had: " + output); + assertTrue(output.contains(",\"hello, xssf\",,\"hello, xssf\","), "Had: " + output); + } } |