diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2017-01-15 23:08:47 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2017-01-15 23:08:47 +0000 |
commit | 3cf6c40004a3beb5d8855478fb202429c25a1555 (patch) | |
tree | 0119eff3108bb6799526a55c04568a99abee930b /src/testcases/org/apache/poi/hssf/extractor | |
parent | d2d885990fea477e9efdae8858989350904e1c44 (diff) | |
download | poi-3cf6c40004a3beb5d8855478fb202429c25a1555.tar.gz poi-3cf6c40004a3beb5d8855478fb202429c25a1555.zip |
fix eclipse warnings - close resources / type generics
cleanup sources - add parenthesis to statements
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1778955 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/hssf/extractor')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java index c46867d2ed..659f769023 100644 --- a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java +++ b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java @@ -52,7 +52,7 @@ public final class TestOldExcelExtractor { } @Test - public void testSimpleExcel3() throws Exception { + public void testSimpleExcel3() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls"); // Check we can call getText without error @@ -78,7 +78,7 @@ public final class TestOldExcelExtractor { @Test - public void testSimpleExcel3NoReading() throws Exception { + public void testSimpleExcel3NoReading() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_3.xls"); assertNotNull(extractor); @@ -86,7 +86,7 @@ public final class TestOldExcelExtractor { } @Test - public void testSimpleExcel4() throws Exception { + public void testSimpleExcel4() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls"); // Check we can call getText without error @@ -108,7 +108,7 @@ public final class TestOldExcelExtractor { } @Test - public void testSimpleExcel5() throws Exception { + public void testSimpleExcel5() throws IOException { for (String ver : new String[] {"5", "95"}) { OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls"); @@ -135,7 +135,7 @@ public final class TestOldExcelExtractor { } @Test - public void testStrings() throws Exception { + public void testStrings() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls"); String text = extractor.getText(); @@ -156,7 +156,7 @@ public final class TestOldExcelExtractor { } @Test - public void testFormattedNumbersExcel4() throws Exception { + public void testFormattedNumbersExcel4() throws IOException { OldExcelExtractor extractor = createExtractor("testEXCEL_4.xls"); String text = extractor.getText(); @@ -177,7 +177,7 @@ public final class TestOldExcelExtractor { } @Test - public void testFormattedNumbersExcel5() throws Exception { + public void testFormattedNumbersExcel5() throws IOException { for (String ver : new String[] {"5", "95"}) { OldExcelExtractor extractor = createExtractor("testEXCEL_"+ver+".xls"); String text = extractor.getText(); @@ -204,7 +204,7 @@ public final class TestOldExcelExtractor { } @Test - public void testFromFile() throws Exception { + public void testFromFile() throws IOException { for (String ver : new String[] {"4", "5", "95"}) { String filename = "testEXCEL_"+ver+".xls"; File f = HSSFTestDataSamples.getSampleFile(filename); @@ -218,47 +218,39 @@ public final class TestOldExcelExtractor { } } - @Test - public void testOpenInvalidFile() throws Exception { + @Test(expected=OfficeXmlFileException.class) + public void testOpenInvalidFile1() throws IOException { // a file that exists, but is a different format - try { - createExtractor("WithVariousData.xlsx"); - fail("Should catch Exception here"); - } catch (OfficeXmlFileException e) { - // expected here - } - + createExtractor("WithVariousData.xlsx"); + } + + + @Test(expected=RecordFormatException.class) + public void testOpenInvalidFile2() throws IOException { // a completely different type of file - try { - createExtractor("48936-strings.txt"); - fail("Should catch Exception here"); - } catch (RecordFormatException e) { - // expected here - } + createExtractor("48936-strings.txt"); + } + @Test(expected=FileNotFoundException.class) + public void testOpenInvalidFile3() throws IOException { // a POIFS file which is not a Workbook + InputStream is = POIDataSamples.getDocumentInstance().openResourceAsStream("47304.doc"); try { - new OldExcelExtractor(POIDataSamples.getDocumentInstance().getFile("47304.doc")); - fail("Should catch Exception here"); - } catch (FileNotFoundException e) { - // expected here + new OldExcelExtractor(is).close(); + } finally { + is.close(); } } - @Test - public void testOpenNonExistingFile() throws Exception { + @Test(expected=EmptyFileException.class) + public void testOpenNonExistingFile() throws IOException { // a file that exists, but is a different format - try { - OldExcelExtractor extractor = new OldExcelExtractor(new File("notexistingfile.xls")); - extractor.close(); - fail("Should catch Exception here"); - } catch (EmptyFileException e) { - // expected here - } + OldExcelExtractor extractor = new OldExcelExtractor(new File("notexistingfile.xls")); + extractor.close(); } @Test - public void testInputStream() throws Exception { + public void testInputStream() throws IOException { File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls"); InputStream stream = new FileInputStream(file); try { @@ -272,7 +264,7 @@ public final class TestOldExcelExtractor { } @Test - public void testInputStreamNPOIHeader() throws Exception { + public void testInputStreamNPOIHeader() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); InputStream stream = new FileInputStream(file); try { @@ -284,7 +276,7 @@ public final class TestOldExcelExtractor { } @Test - public void testNPOIFSFileSystem() throws Exception { + public void testNPOIFSFileSystem() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { @@ -296,7 +288,7 @@ public final class TestOldExcelExtractor { } @Test - public void testDirectoryNode() throws Exception { + public void testDirectoryNode() throws IOException { File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { @@ -308,7 +300,7 @@ public final class TestOldExcelExtractor { } @Test - public void testDirectoryNodeInvalidFile() throws Exception { + public void testDirectoryNodeInvalidFile() throws IOException { File file = POIDataSamples.getDocumentInstance().getFile("test.doc"); NPOIFSFileSystem fs = new NPOIFSFileSystem(file); try { @@ -324,7 +316,7 @@ public final class TestOldExcelExtractor { @Ignore("Calls System.exit()") @Test - public void testMainUsage() throws Exception { + public void testMainUsage() throws IOException { PrintStream save = System.err; try { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -341,7 +333,7 @@ public final class TestOldExcelExtractor { } @Test - public void testMain() throws Exception { + public void testMain() throws IOException { File file = HSSFTestDataSamples.getSampleFile("testEXCEL_3.xls"); PrintStream save = System.out; try { @@ -362,7 +354,7 @@ public final class TestOldExcelExtractor { } @Test - public void testEncryptionException() throws Exception { + public void testEncryptionException() throws IOException { //test file derives from Common Crawl File file = HSSFTestDataSamples.getSampleFile("60284.xls"); OldExcelExtractor ex = new OldExcelExtractor(file); |