You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2017/01/15 23:08:48 UTC

svn commit: r1778955 [2/2] - in /poi/trunk/src: examples/src/org/apache/poi/ss/examples/ examples/src/org/apache/poi/xssf/usermodel/examples/ integrationtest/org/apache/poi/stress/ java/org/apache/poi/hssf/extractor/ java/org/apache/poi/ss/usermodel/ o...

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/extractor/TestExtractor.java Sun Jan 15 23:08:47 2017
@@ -25,6 +25,9 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
 
@@ -36,10 +39,9 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.OPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -49,13 +51,11 @@ public final class TestExtractor {
     /**
      * Extractor primed on the 2 page basic test data
      */
-    private PowerPointExtractor ppe;
     private static final String expectText = "This is a test title\nThis is a test subtitle\nThis is on page 1\nThis is the title on page 2\nThis is page two\nIt has several blocks of text\nNone of them have formatting\n";
 
     /**
      * Extractor primed on the 1 page but text-box'd test data
      */
-    private PowerPointExtractor ppe2;
     private static final String expectText2 = "Hello, World!!!\nI am just a poor boy\nThis is Times New Roman\nPlain Text \n";
 
     /**
@@ -63,49 +63,59 @@ public final class TestExtractor {
      */
     private static POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
 
-    @Before
-    public void setUp() throws Exception {
-        ppe = new PowerPointExtractor(slTests.getFile("basic_test_ppt_file.ppt").getCanonicalPath());
-        ppe2 = new PowerPointExtractor(slTests.getFile("with_textbox.ppt").getCanonicalPath());
-    }
-
-    @After
-    public void closeResources() throws Exception {
-        ppe2.close();
-        ppe.close();
+//    @Before
+//    public void setUp() throws Exception {
+//        ppe = new PowerPointExtractor(slTests.getFile("basic_test_ppt_file.ppt").getCanonicalPath());
+//        ppe2 = new PowerPointExtractor(slTests.getFile("with_textbox.ppt").getCanonicalPath());
+//    }
+
+//    @After
+//    public void closeResources() throws Exception {
+//        ppe2.close();
+//        ppe.close();
+//    }
+
+    private PowerPointExtractor openExtractor(String fileName) throws IOException {
+        InputStream is = slTests.openResourceAsStream(fileName);
+        try {
+            return new PowerPointExtractor(is);
+        } finally {
+            is.close();
+        }
     }
-
+    
     @Test
-    public void testReadSheetText() {
+    public void testReadSheetText() throws IOException {
         // Basic 2 page example
-        String sheetText = ppe.getText();
-
-        ensureTwoStringsTheSame(expectText, sheetText);
-
+        PowerPointExtractor ppe = openExtractor("basic_test_ppt_file.ppt");
+        ensureTwoStringsTheSame(expectText, ppe.getText());
+        ppe.close();
 
         // 1 page example with text boxes
-        sheetText = ppe2.getText();
-
-        ensureTwoStringsTheSame(expectText2, sheetText);
+        PowerPointExtractor ppe2 = openExtractor("with_textbox.ppt");
+        ensureTwoStringsTheSame(expectText2, ppe2.getText());
+        ppe2.close();
     }
 
     @Test
-    public void testReadNoteText() {
+    public void testReadNoteText() throws IOException {
         // Basic 2 page example
+        PowerPointExtractor ppe = openExtractor("basic_test_ppt_file.ppt");
         String notesText = ppe.getNotes();
         String expText = "These are the notes for page 1\nThese are the notes on page two, again lacking formatting\n";
-
         ensureTwoStringsTheSame(expText, notesText);
+        ppe.close();
 
         // Other one doesn't have notes
+        PowerPointExtractor ppe2 = openExtractor("with_textbox.ppt");
         notesText = ppe2.getNotes();
         expText = "";
-
         ensureTwoStringsTheSame(expText, notesText);
+        ppe2.close();
     }
 
     @Test
-    public void testReadBoth() {
+    public void testReadBoth() throws IOException {
         String[] slText = new String[]{
                 "This is a test title\nThis is a test subtitle\nThis is on page 1\n",
                 "This is the title on page 2\nThis is page two\nIt has several blocks of text\nNone of them have formatting\n"
@@ -115,6 +125,7 @@ public final class TestExtractor {
                 "These are the notes on page two, again lacking formatting\n"
         };
 
+        PowerPointExtractor ppe = openExtractor("basic_test_ppt_file.ppt");
         ppe.setSlidesByDefault(true);
         ppe.setNotesByDefault(false);
         assertEquals(slText[0] + slText[1], ppe.getText());
@@ -126,6 +137,7 @@ public final class TestExtractor {
         ppe.setSlidesByDefault(true);
         ppe.setNotesByDefault(true);
         assertEquals(slText[0] + slText[1] + "\n" + ntText[0] + ntText[1], ppe.getText());
+        ppe.close();
     }
 
     /**
@@ -135,9 +147,8 @@ public final class TestExtractor {
      * @throws Exception
      */
     @Test
-    public void testMissingCoreRecords() throws Exception {
-        ppe.close();
-        ppe = new PowerPointExtractor(slTests.openResourceAsStream("missing_core_records.ppt"));
+    public void testMissingCoreRecords() throws IOException {
+        PowerPointExtractor ppe = openExtractor("missing_core_records.ppt");
 
         String text = ppe.getText(true, false);
         String nText = ppe.getNotes();
@@ -150,6 +161,8 @@ public final class TestExtractor {
 
         // Slide records were fine
         assertTrue(text.startsWith("Using Disease Surveillance and Response"));
+        
+        ppe.close();
     }
 
     private void ensureTwoStringsTheSame(String exp, String act) {
@@ -163,49 +176,37 @@ public final class TestExtractor {
     }
 
     @Test
-    public void testExtractFromEmbeded() throws Exception {
-        POIFSFileSystem fs = new POIFSFileSystem(
-                POIDataSamples.getSpreadSheetInstance().openResourceAsStream("excel_with_embeded.xls")
-        );
-        HSLFSlideShowImpl ss;
-
-        DirectoryNode dirA = (DirectoryNode)
-                fs.getRoot().getEntry("MBD0000A3B6");
-        DirectoryNode dirB = (DirectoryNode)
-                fs.getRoot().getEntry("MBD0000A3B3");
-
-        assertNotNull(dirA.getEntry("PowerPoint Document"));
-        assertNotNull(dirB.getEntry("PowerPoint Document"));
+    public void testExtractFromEmbeded() throws IOException {
+        InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream("excel_with_embeded.xls");
+        POIFSFileSystem fs = new POIFSFileSystem(is);
+        DirectoryNode root = fs.getRoot();
+        PowerPointExtractor ppe1 = assertExtractFromEmbedded(root, "MBD0000A3B6", "Sample PowerPoint file\nThis is the 1st file\nNot much too it\n");
+        PowerPointExtractor ppe2 = assertExtractFromEmbedded(root, "MBD0000A3B3", "Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n");
+        ppe2.close();
+        ppe1.close();
+        fs.close();
+    }
+    
+    private PowerPointExtractor assertExtractFromEmbedded(DirectoryNode root, String entryName, String expected)
+    throws IOException {
+        DirectoryNode dir = (DirectoryNode)root.getEntry(entryName);
+        assertTrue(dir.hasEntry("PowerPoint Document"));
 
         // Check the first file
-        ss = new HSLFSlideShowImpl(dirA);
-        ppe.close();
-        ppe = new PowerPointExtractor(ss);
-        assertEquals("Sample PowerPoint file\nThis is the 1st file\nNot much too it\n",
-                ppe.getText(true, false)
-        );
-
-        // And the second
-        ss = new HSLFSlideShowImpl(dirB);
-        ppe.close();
-        ppe = new PowerPointExtractor(ss);
-        assertEquals("Sample PowerPoint file\nThis is the 2nd file\nNot much too it either\n",
-                ppe.getText(true, false)
-        );
-        fs.close();
+        HSLFSlideShowImpl ppt = new HSLFSlideShowImpl(dir);
+        PowerPointExtractor ppe = new PowerPointExtractor(ppt);
+        assertEquals(expected, ppe.getText(true, false));
+        return ppe;
     }
 
     /**
      * A powerpoint file with embeded powerpoint files
      */
-    @SuppressWarnings("unused")
     @Test
-    public void testExtractFromOwnEmbeded() throws Exception {
-        String path = "ppt_with_embeded.ppt";
-        ppe.close();
-        ppe = new PowerPointExtractor(POIDataSamples.getSlideShowInstance().openResourceAsStream(path));
+    public void testExtractFromOwnEmbeded() throws IOException {
+        PowerPointExtractor ppe = openExtractor("ppt_with_embeded.ppt");
         List<OLEShape> shapes = ppe.getOLEShapes();
-        assertEquals("Expected 6 ole shapes in " + path, 6, shapes.size());
+        assertEquals("Expected 6 ole shapes", 6, shapes.size());
         int num_ppt = 0, num_doc = 0, num_xls = 0;
         for (OLEShape ole : shapes) {
             String name = ole.getInstanceName();
@@ -217,6 +218,7 @@ public final class TestExtractor {
             } else if ("Document".equals(name)) {
                 HWPFDocument doc = new HWPFDocument(data);
                 num_doc++;
+                doc.close();
             } else if ("Presentation".equals(name)) {
                 num_ppt++;
                 HSLFSlideShow ppt = new HSLFSlideShow(data);
@@ -227,153 +229,147 @@ public final class TestExtractor {
         assertEquals("Expected 2 embedded Word Documents", 2, num_doc);
         assertEquals("Expected 2 embedded Excel Spreadsheets", 2, num_xls);
         assertEquals("Expected 2 embedded PowerPoint Presentations", 2, num_ppt);
+        ppe.close();
     }
 
     /**
      * A powerpoint file with embeded powerpoint files
      */
     @Test
-    public void test52991() throws Exception {
-        String path = "badzip.ppt";
-        ppe.close();
-        ppe = new PowerPointExtractor(POIDataSamples.getSlideShowInstance().openResourceAsStream(path));
-        List<OLEShape> shapes = ppe.getOLEShapes();
-
-        for (OLEShape shape : shapes) {
+    public void test52991() throws IOException {
+        PowerPointExtractor ppe = openExtractor("badzip.ppt");
+        for (OLEShape shape : ppe.getOLEShapes()) {
             IOUtils.copy(shape.getObjectData().getData(), new ByteArrayOutputStream());
         }
+        ppe.close();
     }
 
     /**
      * From bug #45543
      */
     @Test
-    public void testWithComments() throws Exception {
-        ppe.close();
-        ppe = new PowerPointExtractor(slTests.openResourceAsStream("WithComments.ppt"));
-
-        String text = ppe.getText();
+    public void testWithComments() throws IOException {
+        PowerPointExtractor ppe1 = openExtractor("WithComments.ppt");
+        String text = ppe1.getText();
         assertFalse("Comments not in by default", text.contains("This is a test comment"));
 
-        ppe.setCommentsByDefault(true);
+        ppe1.setCommentsByDefault(true);
 
-        text = ppe.getText();
+        text = ppe1.getText();
         assertContains(text, "This is a test comment");
+        ppe1.close();
 
 
         // And another file
-        ppe.close();
-        ppe = new PowerPointExtractor(slTests.openResourceAsStream("45543.ppt"));
-
-        text = ppe.getText();
+        PowerPointExtractor ppe2 = openExtractor("45543.ppt");
+        text = ppe2.getText();
         assertFalse("Comments not in by default", text.contains("testdoc"));
 
-        ppe.setCommentsByDefault(true);
+        ppe2.setCommentsByDefault(true);
 
-        text = ppe.getText();
+        text = ppe2.getText();
         assertContains(text, "testdoc");
+        ppe2.close();
     }
 
     /**
      * From bug #45537
      */
     @Test
-    public void testHeaderFooter() throws Exception {
+    public void testHeaderFooter() throws IOException {
         String text;
 
         // With a header on the notes
-        HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("45537_Header.ppt"));
-        HSLFSlideShow ss = new HSLFSlideShow(hslf);
-        assertNotNull(ss.getNotesHeadersFooters());
-        assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getHeaderText());
-        ppe.close();
+        InputStream is1 = slTests.openResourceAsStream("45537_Header.ppt");
+        HSLFSlideShow ppt1 = new HSLFSlideShow(is1);
+        is1.close();
+        assertNotNull(ppt1.getNotesHeadersFooters());
+        assertEquals("testdoc test phrase", ppt1.getNotesHeadersFooters().getHeaderText());
 
-        ppe = new PowerPointExtractor(hslf);
+        PowerPointExtractor ppe1 = new PowerPointExtractor(ppt1.getSlideShowImpl());
 
-        text = ppe.getText();
+        text = ppe1.getText();
         assertFalse("Header shouldn't be there by default\n" + text, text.contains("testdoc"));
         assertFalse("Header shouldn't be there by default\n" + text, text.contains("test phrase"));
 
-        ppe.setNotesByDefault(true);
-        text = ppe.getText();
+        ppe1.setNotesByDefault(true);
+        text = ppe1.getText();
         assertContains(text, "testdoc");
         assertContains(text, "test phrase");
-        ss.close();
+        ppe1.close();
+        ppt1.close();
 
         // And with a footer, also on notes
-        hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("45537_Footer.ppt"));
-        ss = new HSLFSlideShow(hslf);
-        assertNotNull(ss.getNotesHeadersFooters());
-        assertEquals("testdoc test phrase", ss.getNotesHeadersFooters().getFooterText());
-        ppe.close();
+        InputStream is2 = slTests.openResourceAsStream("45537_Footer.ppt");
+        HSLFSlideShow ppt2 = new HSLFSlideShow(is2);
+        is2.close();
+        
+        assertNotNull(ppt2.getNotesHeadersFooters());
+        assertEquals("testdoc test phrase", ppt2.getNotesHeadersFooters().getFooterText());
+        ppt2.close();
 
-        ppe = new PowerPointExtractor(slTests.openResourceAsStream("45537_Footer.ppt"));
+        PowerPointExtractor ppe2 = openExtractor("45537_Footer.ppt");
 
-        text = ppe.getText();
+        text = ppe2.getText();
         assertFalse("Header shouldn't be there by default\n" + text, text.contains("testdoc"));
         assertFalse("Header shouldn't be there by default\n" + text, text.contains("test phrase"));
 
-        ppe.setNotesByDefault(true);
-        text = ppe.getText();
+        ppe2.setNotesByDefault(true);
+        text = ppe2.getText();
         assertContains(text, "testdoc");
         assertContains(text, "test phrase");
+        ppe2.close();
     }
 
     @SuppressWarnings("unused")
     @Test
-    public void testSlideMasterText() throws Exception {
+    public void testSlideMasterText() throws IOException {
         String masterTitleText = "This is the Master Title";
         String masterRandomText = "This text comes from the Master Slide";
         String masterFooterText = "Footer from the master slide";
-        HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithMaster.ppt"));
-        ppe.close();
-
-        ppe = new PowerPointExtractor(hslf);
+        PowerPointExtractor ppe = openExtractor("WithMaster.ppt");
+        ppe.setMasterByDefault(true);
 
         String text = ppe.getText();
-        //assertContains(text, masterTitleText); // TODO Is this available in PPT?
-        //assertContains(text, masterRandomText); // TODO Extract
+        assertContains(text, masterRandomText);
         assertContains(text, masterFooterText);
+        ppe.close();
     }
 
     @Test
-    public void testMasterText() throws Exception {
-        ppe.close();
-        ppe = new PowerPointExtractor(slTests.openResourceAsStream("master_text.ppt"));
+    public void testMasterText() throws IOException {
+        PowerPointExtractor ppe1 = openExtractor("master_text.ppt");
 
         // Initially not there
-        String text = ppe.getText();
+        String text = ppe1.getText();
         assertFalse(text.contains("Text that I added to the master slide"));
 
         // Enable, shows up
-        ppe.setMasterByDefault(true);
-        text = ppe.getText();
+        ppe1.setMasterByDefault(true);
+        text = ppe1.getText();
         assertTrue(text.contains("Text that I added to the master slide"));
 
         // Make sure placeholder text does not come out
         assertFalse(text.contains("Click to edit Master"));
+        ppe1.close();
 
         // Now with another file only containing master text
         // Will always show up
+        PowerPointExtractor ppe2 = openExtractor("WithMaster.ppt");
         String masterText = "Footer from the master slide";
-        HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("WithMaster.ppt"));
-        ppe.close();
-
-        ppe = new PowerPointExtractor(hslf);
 
-        text = ppe.getText();
+        text = ppe2.getText();
         assertContainsIgnoreCase(text, "master");
         assertContains(text, masterText);
+        ppe2.close();
     }
 
     /**
      * Bug #54880 Chinese text not extracted properly
      */
     @Test
-    public void testChineseText() throws Exception {
-        HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("54880_chinese.ppt"));
-        ppe.close();
-        ppe = new PowerPointExtractor(hslf);
+    public void testChineseText() throws IOException {
+        PowerPointExtractor ppe = openExtractor("54880_chinese.ppt");
 
         String text = ppe.getText();
 
@@ -388,6 +384,7 @@ public final class TestExtractor {
 
         // Check for the chinese only text line
         assertContains(text, "\uff8a\uff9d\uff76\uff78");
+        ppe.close();
     }
 
     /**
@@ -396,12 +393,15 @@ public final class TestExtractor {
      */
     @SuppressWarnings("resource")
     @Test
-    public void testDifferentPOIFS() throws Exception {
+    public void testDifferentPOIFS() throws IOException {
         // Open the two filesystems
-        DirectoryNode[] files = new DirectoryNode[2];
-        files[0] = (new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"))).getRoot();
-        NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(slTests.getFile("basic_test_ppt_file.ppt"));
-        files[1] = npoifsFileSystem.getRoot();
+        File pptFile = slTests.getFile("basic_test_ppt_file.ppt");
+        InputStream is1 = new FileInputStream(pptFile);
+        OPOIFSFileSystem opoifs = new OPOIFSFileSystem(is1);
+        is1.close();
+        NPOIFSFileSystem npoifs = new NPOIFSFileSystem(pptFile);
+        
+        DirectoryNode[] files = { opoifs.getRoot(), npoifs.getRoot() };
 
         // Open directly
         for (DirectoryNode dir : files) {
@@ -409,48 +409,48 @@ public final class TestExtractor {
             assertEquals(expectText, extractor.getText());
         }
 
-        // Open via a HWPFDocument
+        // Open via a HSLFSlideShow
         for (DirectoryNode dir : files) {
             HSLFSlideShowImpl slideshow = new HSLFSlideShowImpl(dir);
             PowerPointExtractor extractor = new PowerPointExtractor(slideshow);
             assertEquals(expectText, extractor.getText());
+            extractor.close();
+            slideshow.close();
         }
 
-        npoifsFileSystem.close();
+        npoifs.close();
     }
 
     @Test
     public void testTable() throws Exception {
-//        ppe = new PowerPointExtractor(slTests.openResourceAsStream("54111.ppt"));
-//        String text = ppe.getText();
-//        String target = "TH Cell 1\tTH Cell 2\tTH Cell 3\tTH Cell 4\n"+
-//                         "Row 1, Cell 1\tRow 1, Cell 2\tRow 1, Cell 3\tRow 1, Cell 4\n"+   
-//                         "Row 2, Cell 1\tRow 2, Cell 2\tRow 2, Cell 3\tRow 2, Cell 4\n"+
-//                         "Row 3, Cell 1\tRow 3, Cell 2\tRow 3, Cell 3\tRow 3, Cell 4\n"+
-//                         "Row 4, Cell 1\tRow 4, Cell 2\tRow 4, Cell 3\tRow 4, Cell 4\n"+ 
-//                         "Row 5, Cell 1\tRow 5, Cell 2\tRow 5, Cell 3\tRow 5, Cell 4\n";
-//        assertTrue(text.contains(target));
-        ppe.close();
+        PowerPointExtractor ppe1 = openExtractor("54111.ppt");
+        String text1 = ppe1.getText();
+        String target1 = "TH Cell 1\tTH Cell 2\tTH Cell 3\tTH Cell 4\n"+
+                         "Row 1, Cell 1\tRow 1, Cell 2\tRow 1, Cell 3\tRow 1, Cell 4\n"+   
+                         "Row 2, Cell 1\tRow 2, Cell 2\tRow 2, Cell 3\tRow 2, Cell 4\n"+
+                         "Row 3, Cell 1\tRow 3, Cell 2\tRow 3, Cell 3\tRow 3, Cell 4\n"+
+                         "Row 4, Cell 1\tRow 4, Cell 2\tRow 4, Cell 3\tRow 4, Cell 4\n"+ 
+                         "Row 5, Cell 1\tRow 5, Cell 2\tRow 5, Cell 3\tRow 5, Cell 4\n";
+        assertTrue(text1.contains(target1));
+        ppe1.close();
 
-        ppe = new PowerPointExtractor(slTests.openResourceAsStream("54722.ppt"));
-        String text = ppe.getText();
+        PowerPointExtractor ppe2 = openExtractor("54722.ppt");
+        String text2 = ppe2.getText();
 
-        String target = "this\tText\tis\twithin\ta\n" +
+        String target2 = "this\tText\tis\twithin\ta\n" +
                 "table\t1\t2\t3\t4";
-        assertTrue(text.contains(target));
+        assertTrue(text2.contains(target2));
+        ppe2.close();
     }
 
     // bug 60003
     @Test
     public void testExtractMasterSlideFooterText() throws Exception {
-        HSLFSlideShowImpl hslf = new HSLFSlideShowImpl(slTests.openResourceAsStream("60003.ppt"));
-        ppe.close();
-
-        ppe = new PowerPointExtractor(hslf);
+        PowerPointExtractor ppe = openExtractor("60003.ppt");
         ppe.setMasterByDefault(true);
 
         String text = ppe.getText();
         assertContains(text, "Prague");
-        hslf.close();
+        ppe.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java Sun Jan 15 23:08:47 2017
@@ -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);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestDrawingAggregate.java Sun Jan 15 23:08:47 2017
@@ -16,6 +16,7 @@
 ==================================================================== */
 package org.apache.poi.hssf.model;
 
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -32,9 +33,6 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.zip.GZIPInputStream;
-
-import javax.xml.bind.DatatypeConverter;
 
 import org.apache.poi.ddf.DefaultEscherRecordFactory;
 import org.apache.poi.ddf.EscherContainerRecord;
@@ -59,7 +57,6 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFTestHelper;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.util.HexDump;
-import org.apache.poi.util.IOUtils;
 import org.junit.Test;
 
 public class TestDrawingAggregate {
@@ -946,32 +943,4 @@ public class TestDrawingAggregate {
         assertEquals("different size of drawing data before and after save", dgBytes.length, dgBytesAfterSave.length);
         assertTrue("drawing data brefpore and after save is different", Arrays.equals(dgBytes, dgBytesAfterSave));
     }
-
-
-    /**
-     * Decompress previously gziped/base64ed data
-     *
-     * @param data the gziped/base64ed data
-     * @return the raw bytes
-     * @throws IOException if you copy and pasted the data wrong
-     */
-    public static byte[] decompress(String data) throws IOException {
-        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
-        return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
-    }
-    
-    /**
-     * Compress raw data for test runs - usually called while debugging :)
-     *
-     * @param data the raw data
-     * @return the gziped/base64ed data as String
-     * @throws IOException usually not ...
-     */
-    public static String compress(byte[] data) throws IOException {
-        java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
-        java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos);
-        gz.write(data);
-        gz.finish();
-        return DatatypeConverter.printBase64Binary(bos.toByteArray());        
-    }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStringRecord.java Sun Jan 15 23:08:47 2017
@@ -18,22 +18,22 @@
 package org.apache.poi.hssf.record;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
 import org.apache.poi.util.HexRead;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.LittleEndianByteArrayInputStream;
-import org.apache.poi.util.LittleEndianInput;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import org.junit.Test;
 
 /**
  * Tests the serialization and deserialization of the StringRecord
  * class works correctly.  Test data taken directly from a real
  * Excel file.
- *
- * @author Glen Stampoultzis (glens at apache.org)
  */
-public final class TestStringRecord extends TestCase {
+public final class TestStringRecord {
 	private static final byte[] data = HexRead.readFromString(
 			"0B 00 " + // length
 			"00 " +    // option
@@ -41,6 +41,7 @@ public final class TestStringRecord exte
 			"46 61 68 72 7A 65 75 67 74 79 70"
 	);
 
+	@Test
 	public void testLoad() {
 
 		StringRecord record = new StringRecord(TestcaseRecordInputStream.create(0x207, data));
@@ -49,17 +50,20 @@ public final class TestStringRecord exte
 		assertEquals( 18, record.getRecordSize() );
 	}
 
-	public void testStore() {
+	@Test
+    public void testStore() {
 		StringRecord record = new StringRecord();
 		record.setString("Fahrzeugtyp");
 
 		byte [] recordBytes = record.serialize();
 		assertEquals(recordBytes.length - 4, data.length);
-		for (int i = 0; i < data.length; i++)
-			assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+		for (int i = 0; i < data.length; i++) {
+            assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+        }
 	}
     
-	public void testContinue() {
+	@Test
+    public void testContinue() throws IOException {
 		int MAX_BIFF_DATA = RecordInputStream.MAX_RECORD_DATA_SIZE;
 		int TEXT_LEN = MAX_BIFF_DATA + 1000; // deliberately over-size
 		String textChunk = "ABCDEGGHIJKLMNOP"; // 16 chars
@@ -74,15 +78,14 @@ public final class TestStringRecord exte
 		byte[] ser = sr.serialize();
 		assertEquals(StringRecord.sid, LittleEndian.getUShort(ser, 0));
 		if (LittleEndian.getUShort(ser, 2) > MAX_BIFF_DATA) {
-			throw new AssertionFailedError(
-					"StringRecord should have been split with a continue record");
+		    fail("StringRecord should have been split with a continue record");
 		}
 		// Confirm expected size of first record, and ushort strLen.
 		assertEquals(MAX_BIFF_DATA, LittleEndian.getUShort(ser, 2));
 		assertEquals(TEXT_LEN, LittleEndian.getUShort(ser, 4));
 
 		// Confirm first few bytes of ContinueRecord
-		LittleEndianInput crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4));
+		LittleEndianByteArrayInputStream crIn = new LittleEndianByteArrayInputStream(ser, (MAX_BIFF_DATA + 4));
 		int nCharsInFirstRec = MAX_BIFF_DATA - (2 + 1); // strLen, optionFlags
 		int nCharsInSecondRec = TEXT_LEN - nCharsInFirstRec;
 		assertEquals(ContinueRecord.sid, crIn.readUShort());
@@ -95,5 +98,6 @@ public final class TestStringRecord exte
 		RecordInputStream in = TestcaseRecordInputStream.create(ser);
 		StringRecord sr2 = new StringRecord(in);
 		assertEquals(sb.toString(), sr2.getString());
+		crIn.close();
 	}
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFComment.java Sun Jan 15 23:08:47 2017
@@ -16,7 +16,7 @@
 ==================================================================== */
 package org.apache.poi.hssf.usermodel;
 
-import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
@@ -41,6 +41,7 @@ import org.apache.poi.ss.usermodel.Drawi
 import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.Test;
 
 /**
@@ -102,7 +103,7 @@ public final class TestHSSFComment exten
     public void testBug56380InsertComments() throws Exception {
         HSSFWorkbook workbook = new HSSFWorkbook();
         Sheet sheet = workbook.createSheet();
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         int noOfRows = 1025;
         String comment = "c";
         
@@ -139,7 +140,7 @@ public final class TestHSSFComment exten
         HSSFWorkbook workbook = new HSSFWorkbook();
         try {
             Sheet sheet = workbook.createSheet();
-            Drawing drawing = sheet.createDrawingPatriarch();
+            Drawing<?> drawing = sheet.createDrawingPatriarch();
             String comment = "c";
     
             for(int rowNum = 0;rowNum < 258;rowNum++) {
@@ -179,7 +180,7 @@ public final class TestHSSFComment exten
         }
     }
 
-    private Comment insertComment(Drawing drawing, Cell cell, String message) {
+    private Comment insertComment(Drawing<?> drawing, Cell cell, String message) {
         CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();
         
         ClientAnchor anchor = factory.createClientAnchor();
@@ -272,7 +273,7 @@ public final class TestHSSFComment exten
         HSSFWorkbook wb = new HSSFWorkbook();
         HSSFSheet sh = wb.createSheet();
         HSSFPatriarch patriarch = sh.createDrawingPatriarch();
-        int idx = wb.addPicture(new byte[]{1,2,3}, HSSFWorkbook.PICTURE_TYPE_PNG);
+        int idx = wb.addPicture(new byte[]{1,2,3}, Workbook.PICTURE_TYPE_PNG);
 
         HSSFComment comment = patriarch.createCellComment(new HSSFClientAnchor());
         comment.setColumn(5);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestPolygon.java Sun Jan 15 23:08:47 2017
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestText.java Sun Jan 15 23:08:47 2017
@@ -17,7 +17,7 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import static org.apache.poi.hssf.model.TestDrawingAggregate.decompress;
+import static org.apache.poi.poifs.storage.RawDataUtil.decompress;
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java Sun Jan 15 23:08:47 2017
@@ -16,11 +16,17 @@
 ==================================================================== */
 package org.apache.poi.poifs.storage;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.Arrays;
+import java.util.zip.GZIPInputStream;
+
+import javax.xml.bind.DatatypeConverter;
 
 import org.apache.poi.util.HexDump;
 import org.apache.poi.util.HexRead;
+import org.apache.poi.util.IOUtils;
 
 /**
  * Test utility class.<br/>
@@ -81,4 +87,31 @@ public final class RawDataUtil {
 			throw new RuntimeException("different");
 		}
 	}
+
+    /**
+     * Decompress previously gziped/base64ed data
+     *
+     * @param data the gziped/base64ed data
+     * @return the raw bytes
+     * @throws IOException if you copy and pasted the data wrong
+     */
+    public static byte[] decompress(String data) throws IOException {
+        byte[] base64Bytes = DatatypeConverter.parseBase64Binary(data);
+        return IOUtils.toByteArray(new GZIPInputStream(new ByteArrayInputStream(base64Bytes)));
+    }
+    
+    /**
+     * Compress raw data for test runs - usually called while debugging :)
+     *
+     * @param data the raw data
+     * @return the gziped/base64ed data as String
+     * @throws IOException usually not ...
+     */
+    public static String compress(byte[] data) throws IOException {
+        java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
+        java.util.zip.GZIPOutputStream gz = new java.util.zip.GZIPOutputStream(bos);
+        gz.write(data);
+        gz.finish();
+        return DatatypeConverter.printBase64Binary(bos.toByteArray());        
+    }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Sun Jan 15 23:08:47 2017
@@ -17,6 +17,23 @@
 
 package org.apache.poi.ss.usermodel;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextAttribute;
+import java.awt.font.TextLayout;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+import java.text.AttributedString;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.SpreadsheetVersion;
@@ -30,18 +47,6 @@ import org.junit.Assume;
 import org.junit.Ignore;
 import org.junit.Test;
 
-import java.awt.font.FontRenderContext;
-import java.awt.font.TextAttribute;
-import java.awt.font.TextLayout;
-import java.awt.geom.Rectangle2D;
-import java.io.IOException;
-import java.text.AttributedString;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
 /**
  * A base class for bugzilla issues that can be described in terms of common ss interfaces.
  *
@@ -70,8 +75,9 @@ public abstract class BaseTestBugzillaIs
     public static void assertAlmostEquals(double expected, double actual, float factor) {
         double diff = Math.abs(expected - actual);
         double fuzz = expected * factor;
-        if (diff > fuzz)
+        if (diff > fuzz) {
             fail(actual + " not within " + fuzz + " of " + expected);
+        }
     }
 
     /**
@@ -359,7 +365,9 @@ public abstract class BaseTestBugzillaIs
         fmla.append(name);
         fmla.append("(");
         for(int i=0; i < maxArgs; i++){
-            if(i > 0) fmla.append(',');
+            if(i > 0) {
+                fmla.append(',');
+            }
             fmla.append("A1");
         }
         fmla.append(")");
@@ -512,9 +520,15 @@ public abstract class BaseTestBugzillaIs
     private static void copyAttributes(Font font, AttributedString str, int endIdx) {
         str.addAttribute(TextAttribute.FAMILY, font.getFontName(), 0, endIdx);
         str.addAttribute(TextAttribute.SIZE, (float)font.getFontHeightInPoints());
-        if (font.getBold()) str.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, 0, endIdx);
-        if (font.getItalic() ) str.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, 0, endIdx);
-        if (font.getUnderline() == Font.U_SINGLE ) str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 0, endIdx);
+        if (font.getBold()) {
+            str.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, 0, endIdx);
+        }
+        if (font.getItalic() ) {
+            str.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, 0, endIdx);
+        }
+        if (font.getUnderline() == Font.U_SINGLE ) {
+            str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, 0, endIdx);
+        }
     }
 
     /**
@@ -1063,7 +1077,7 @@ public abstract class BaseTestBugzillaIs
         CreationHelper factory = wb.getCreationHelper();
 
         Sheet sheet = wb.createSheet();
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         ClientAnchor anchor = factory.createClientAnchor();
 
         Cell cell0 = sheet.createRow(0).createCell(0);
@@ -1513,7 +1527,7 @@ public abstract class BaseTestBugzillaIs
         
         CreationHelper helper = wb.getCreationHelper();
         ClientAnchor anchor = helper.createClientAnchor();
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         
         Row row = sheet.createRow(0);
         
@@ -1677,7 +1691,7 @@ public abstract class BaseTestBugzillaIs
         assertEquals(10, row.getRowNum());
 
         for (Cell cell : row) {
-            String cellValue = null;
+            String cellValue;
             switch (cell.getCellTypeEnum()) {
                 case STRING:
                     cellValue = cell.getRichStringCellValue().getString();
@@ -1685,6 +1699,9 @@ public abstract class BaseTestBugzillaIs
                 case FORMULA:
                     cellValue = cell.getCellFormula();
                     break;
+                default:
+                    fail("unexpected cell type");
+                    return;
             }
             assertNotNull(cellValue);
             cellValue = cellValue.isEmpty() ? null : cellValue;

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java Sun Jan 15 23:08:47 2017
@@ -253,7 +253,7 @@ public abstract class BaseTestCell {
         Font f = wb1.createFont();
         f.setFontHeightInPoints((short) 20);
         f.setColor(IndexedColors.RED.getIndex());
-        f.setBoldweight(Font.BOLDWEIGHT_BOLD);
+        f.setBold(true);
         f.setFontName("Arial Unicode MS");
         cs.setFillBackgroundColor((short)3);
         cs.setFont(f);
@@ -718,7 +718,7 @@ public abstract class BaseTestCell {
         assertFalse(style.getHidden());
         assertEquals(0, style.getIndention());
         assertEquals(0, style.getFontIndex());
-        assertEquals(0, style.getAlignment());
+        assertEquals(HorizontalAlignment.GENERAL, style.getAlignmentEnum());
         assertEquals(0, style.getDataFormat());
         assertEquals(false, style.getWrapText());
 
@@ -1004,7 +1004,7 @@ public abstract class BaseTestCell {
         anchor.setRow1(row.getRowNum());
         anchor.setRow2(row.getRowNum()+3);
 
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         Comment comment = drawing.createCellComment(anchor);
         RichTextString str = factory.createRichTextString("Hello, World!");
         comment.setString(str);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestCellComment.java Sun Jan 15 23:08:47 2017
@@ -77,7 +77,7 @@ public abstract class BaseTestCellCommen
         assertNull(cell.getCellComment());
         assertNull(sheet.getCellComment(new CellAddress(cellRow, cellColumn)));
 
-        Drawing patr = sheet.createDrawingPatriarch();
+        Drawing<?> patr = sheet.createDrawingPatriarch();
         ClientAnchor anchor = factory.createClientAnchor();
         anchor.setCol1(2);
         anchor.setCol2(5);
@@ -261,7 +261,7 @@ public abstract class BaseTestCellCommen
         Cell cell = sheet.createRow(3).createCell(5);
         cell.setCellValue("F4");
 
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
 
         ClientAnchor anchor = factory.createClientAnchor();
         Comment comment = drawing.createCellComment(anchor);
@@ -294,7 +294,7 @@ public abstract class BaseTestCellCommen
         Cell cell = row.createCell(5);
         CreationHelper factory = wb.getCreationHelper();
         
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         
         double r_mul, c_mul;
         if (sheet instanceof HSSFSheet) {
@@ -365,7 +365,7 @@ public abstract class BaseTestCellCommen
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet sh = wb.createSheet();
         CreationHelper factory = wb.getCreationHelper();
-        Drawing patriarch = sh.createDrawingPatriarch();
+        Drawing<?> patriarch = sh.createDrawingPatriarch();
         patriarch.createCellComment(factory.createClientAnchor());
         
         try {
@@ -388,7 +388,7 @@ public abstract class BaseTestCellCommen
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet sh = wb.createSheet();
         CreationHelper factory = wb.getCreationHelper();
-        Drawing patriarch = sh.createDrawingPatriarch();
+        Drawing<?> patriarch = sh.createDrawingPatriarch();
         Comment comment = patriarch.createCellComment(factory.createClientAnchor());
         
         assertEquals(CellAddress.A1, comment.getAddress());
@@ -402,7 +402,7 @@ public abstract class BaseTestCellCommen
         Workbook wb = _testDataProvider.createWorkbook();
         Sheet sh = wb.createSheet();
         CreationHelper factory = wb.getCreationHelper();
-        Drawing patriarch = sh.createDrawingPatriarch();
+        Drawing<?> patriarch = sh.createDrawingPatriarch();
         Comment comment = patriarch.createCellComment(factory.createClientAnchor());
         
         assertEquals(CellAddress.A1, comment.getAddress());

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestPicture.java Sun Jan 15 23:08:47 2017
@@ -105,7 +105,7 @@ public abstract class BaseTestPicture {
 
 
     private void handleResize(Workbook wb, Sheet sheet, Row row) throws IOException {
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         CreationHelper createHelper = wb.getCreationHelper();
 
         final byte[] bytes = HSSFITestDataProvider.instance.getTestDataFileContent("logoKarmokar4.png");

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java Sun Jan 15 23:08:47 2017
@@ -1141,7 +1141,7 @@ public abstract class BaseTestSheet {
     public void getCellComment() throws IOException {
         Workbook workbook = _testDataProvider.createWorkbook();
         Sheet sheet = workbook.createSheet();
-        Drawing dg = sheet.createDrawingPatriarch();
+        Drawing<?> dg = sheet.createDrawingPatriarch();
         Comment comment = dg.createCellComment(workbook.getCreationHelper().createClientAnchor());
         Cell cell = sheet.createRow(9).createCell(2);
         comment.setAuthor("test C10 author");
@@ -1165,7 +1165,7 @@ public abstract class BaseTestSheet {
         // a sheet with no cell comments should return an empty map (not null or raise NPE).
         assertEquals(Collections.emptyMap(), sheet.getCellComments());
 
-        Drawing dg = sheet.createDrawingPatriarch();
+        Drawing<?> dg = sheet.createDrawingPatriarch();
         ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor();
         
         int nRows = 5;

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java?rev=1778955&r1=1778954&r2=1778955&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java Sun Jan 15 23:08:47 2017
@@ -33,7 +33,6 @@ import java.io.OutputStream;
 import java.util.ConcurrentModificationException;
 import java.util.Iterator;
 
-import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.ss.ITestDataProvider;
 import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
@@ -908,7 +907,7 @@ public abstract class BaseTestWorkbook {
         Sheet sheet = wb.createSheet("Main Sheet");
         Row row0 = sheet.createRow(0);
         Row row1 = sheet.createRow(1);
-        Cell cell = row1.createCell(0);
+        row1.createCell(0);
         row0.createCell(1);
         row1.createCell(0);
         row1.createCell(1);
@@ -916,7 +915,7 @@ public abstract class BaseTestWorkbook {
         byte[] pictureData = _testDataProvider.getTestDataFileContent("logoKarmokar4.png");
 
         int handle = wb.addPicture(pictureData, Workbook.PICTURE_TYPE_PNG);
-        Drawing drawing = sheet.createDrawingPatriarch();
+        Drawing<?> drawing = sheet.createDrawingPatriarch();
         CreationHelper helper = wb.getCreationHelper();
         ClientAnchor anchor = helper.createClientAnchor();
         anchor.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org