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 2018/08/31 00:25:51 UTC

svn commit: r1839709 [4/7] - in /poi: site/src/documentation/content/xdocs/components/poifs/ trunk/src/examples/src/org/apache/poi/hpsf/examples/ trunk/src/java/org/apache/poi/ trunk/src/java/org/apache/poi/extractor/ trunk/src/java/org/apache/poi/hpsf...

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestDocumentEncryption.java Fri Aug 31 00:25:50 2018
@@ -47,17 +47,14 @@ import org.apache.poi.poifs.crypt.Encryp
 import org.apache.poi.poifs.crypt.HashAlgorithm;
 import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIDecryptor;
 import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 
 /**
  * Tests that DocumentEncryption works properly.
  */
 public class TestDocumentEncryption {
-    POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
+    private static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
 
     @Test
     public void cryptoAPIDecryptionOther() throws Exception {
@@ -70,7 +67,7 @@ public class TestDocumentEncryption {
         Biff8EncryptionKey.setCurrentUserPassword("hello");
         try {
             for (String pptFile : encPpts) {
-                try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
+                try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
                      HSLFSlideShow ppt = new HSLFSlideShow(fs)) {
                     assertTrue(ppt.getSlides().size() > 0);
                 } catch (EncryptedPowerPointFileException e) {
@@ -86,7 +83,7 @@ public class TestDocumentEncryption {
     public void cryptoAPIChangeKeySize() throws Exception {
         String pptFile = "cryptoapi-proc2356.ppt";
         Biff8EncryptionKey.setCurrentUserPassword("crypto");
-        try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
+        try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
              HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
             // need to cache data (i.e. read all data) before changing the key size
             List<HSLFPictureData> picsExpected = hss.getPictureData();
@@ -99,7 +96,7 @@ public class TestDocumentEncryption {
             ByteArrayOutputStream bos = new ByteArrayOutputStream();
             hss.write(bos);
 
-            try (NPOIFSFileSystem fs2 = new NPOIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
+            try (POIFSFileSystem fs2 = new POIFSFileSystem(new ByteArrayInputStream(bos.toByteArray()));
                  HSLFSlideShowImpl hss2 = new HSLFSlideShowImpl(fs2)) {
                 List<HSLFPictureData> picsActual = hss2.getPictureData();
 
@@ -121,7 +118,7 @@ public class TestDocumentEncryption {
         ByteArrayOutputStream expected = new ByteArrayOutputStream();
         ByteArrayOutputStream actual = new ByteArrayOutputStream();
         try {
-            try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile(pptFile), true);
+            try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile(pptFile), true);
                  HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
                 hss.normalizeRecords();
 
@@ -135,7 +132,7 @@ public class TestDocumentEncryption {
 
             // decrypted
             ByteArrayInputStream bis = new ByteArrayInputStream(encrypted.toByteArray());
-            try (NPOIFSFileSystem fs = new NPOIFSFileSystem(bis);
+            try (POIFSFileSystem fs = new POIFSFileSystem(bis);
                  HSLFSlideShowImpl hss = new HSLFSlideShowImpl(fs)) {
                 Biff8EncryptionKey.setCurrentUserPassword(null);
                 hss.write(actual);
@@ -152,7 +149,7 @@ public class TestDocumentEncryption {
         // taken from a msdn blog:
         // http://blogs.msdn.com/b/openspecification/archive/2009/05/08/dominic-salemno.aspx
         Biff8EncryptionKey.setCurrentUserPassword("crypto");
-        try (NPOIFSFileSystem fs = new NPOIFSFileSystem(slTests.getFile("cryptoapi-proc2356.ppt"));
+        try (POIFSFileSystem fs = new POIFSFileSystem(slTests.getFile("cryptoapi-proc2356.ppt"));
              HSLFSlideShow ss = new HSLFSlideShow(fs)) {
 
             HSLFSlide slide = ss.getSlides().get(0);

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Fri Aug 31 00:25:50 2018
@@ -56,7 +56,6 @@ import org.apache.poi.ddf.EscherColorRef
 import org.apache.poi.ddf.EscherProperties;
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.exceptions.OldPowerPointFormatException;
-import org.apache.poi.hslf.extractor.PowerPointExtractor;
 import org.apache.poi.hslf.model.HeadersFooters;
 import org.apache.poi.hslf.record.DocInfoListContainer;
 import org.apache.poi.hslf.record.Document;
@@ -68,7 +67,7 @@ import org.apache.poi.hslf.record.TextHe
 import org.apache.poi.hslf.record.VBAInfoAtom;
 import org.apache.poi.hslf.record.VBAInfoContainer;
 import org.apache.poi.hssf.usermodel.DummyGraphics2d;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.macros.VBAMacroReader;
 import org.apache.poi.sl.draw.DrawFactory;
 import org.apache.poi.sl.draw.DrawPaint;
@@ -131,14 +130,14 @@ public final class TestBugs {
         assertNotNull(notes);
         txrun = notes.getTextParagraphs().get(0);
         assertEquals("Notes-1", HSLFTextParagraph.getRawText(txrun));
-        assertEquals(false, txrun.get(0).getTextRuns().get(0).isBold());
+        assertFalse(txrun.get(0).getTextRuns().get(0).isBold());
 
         //notes for the second slide are in bold
         notes = ppt.getSlides().get(1).getNotes();
         assertNotNull(notes);
         txrun = notes.getTextParagraphs().get(0);
         assertEquals("Notes-2", HSLFTextParagraph.getRawText(txrun));
-        assertEquals(true, txrun.get(0).getTextRuns().get(0).isBold());
+        assertTrue(txrun.get(0).getTextRuns().get(0).isBold());
 
         ppt.close();
     }
@@ -152,14 +151,14 @@ public final class TestBugs {
 
         //map slide number and starting phrase of its notes
         Map<Integer, String> notesMap = new HashMap<>();
-        notesMap.put(Integer.valueOf(4), "For  decades before calculators");
-        notesMap.put(Integer.valueOf(5), "Several commercial applications");
-        notesMap.put(Integer.valueOf(6), "There are three variations of LNS that are discussed here");
-        notesMap.put(Integer.valueOf(7), "Although multiply and square root are easier");
-        notesMap.put(Integer.valueOf(8), "The bus Z is split into Z_H and Z_L");
+        notesMap.put(4, "For  decades before calculators");
+        notesMap.put(5, "Several commercial applications");
+        notesMap.put(6, "There are three variations of LNS that are discussed here");
+        notesMap.put(7, "Although multiply and square root are easier");
+        notesMap.put(8, "The bus Z is split into Z_H and Z_L");
 
         for (HSLFSlide slide : ppt.getSlides()) {
-            Integer slideNumber = Integer.valueOf(slide.getSlideNumber());
+            Integer slideNumber = slide.getSlideNumber();
             HSLFNotes notes = slide.getNotes();
             if (notesMap.containsKey(slideNumber)){
                 assertNotNull(notes);
@@ -412,7 +411,6 @@ public final class TestBugs {
 
     /**
      * PowerPoint 95 files should throw a more helpful exception
-     * @throws IOException
      */
     @Test(expected=OldPowerPointFormatException.class)
     public void bug41711() throws IOException {
@@ -632,7 +630,7 @@ public final class TestBugs {
 
     @Test
     public void bug45124() throws IOException {
-        SlideShow<?,?> ppt = open("bug45124.ppt");
+        HSLFSlideShow ppt = open("bug45124.ppt");
         Slide<?,?> slide1 = ppt.getSlides().get(1);
 
         TextBox<?,?> res = slide1.createTextBox();
@@ -647,7 +645,7 @@ public final class TestBugs {
 
         tp.setBulletStyle(Color.red, 'A');
 
-        SlideShow<?,?> ppt2 = HSLFTestDataSamples.writeOutAndReadBack((HSLFSlideShow)ppt);
+        SlideShow<?,?> ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt);
         ppt.close();
 
         res = (TextBox<?,?>)ppt2.getSlides().get(1).getShapes().get(1);
@@ -887,7 +885,7 @@ public final class TestBugs {
                 // For the test file, common sl draws textruns one by one and not mixed
                 // so we evaluate the whole iterator
                 Map<Attribute, Object> attributes = null;
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 
                 for (char c = iterator.first();
                         c != CharacterIterator.DONE;
@@ -994,10 +992,10 @@ public final class TestBugs {
     //It isn't pretty, but it works...
     private Map<String, String> getMacrosFromHSLF(String fileName) throws IOException {
         InputStream is = null;
-        NPOIFSFileSystem npoifs = null;
+        POIFSFileSystem npoifs = null;
         try {
             is = new FileInputStream(POIDataSamples.getSlideShowInstance().getFile(fileName));
-            npoifs = new NPOIFSFileSystem(is);
+            npoifs = new POIFSFileSystem(is);
             //TODO: should we run the VBAMacroReader on this npoifs?
             //TBD: We know that ppt typically don't store macros in the regular place,
             //but _can_ they?
@@ -1011,11 +1009,8 @@ public final class TestBugs {
             long persistId = vbaAtom.getPersistIdRef();
             for (HSLFObjectData objData : ppt.getEmbeddedObjects()) {
                 if (objData.getExOleObjStg().getPersistId() == persistId) {
-                    VBAMacroReader mr = new VBAMacroReader(objData.getInputStream());
-                    try {
+                    try (VBAMacroReader mr = new VBAMacroReader(objData.getInputStream())) {
                         return mr.readMacros();
-                    } finally {
-                        mr.close();
                     }
                 }
             }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java Fri Aug 31 00:25:50 2018
@@ -33,7 +33,7 @@ import java.util.List;
 import org.apache.poi.hslf.HSLFTestDataSamples;
 import org.apache.poi.hslf.record.Record;
 import org.apache.poi.hslf.record.SlideListWithText;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -396,7 +396,7 @@ public final class TestRichTextRun {
 	 */
 	private static void assertMatchesFileC(HSLFSlideShow s) throws IOException {
 		// Grab the bytes of the file
-	    NPOIFSFileSystem fs = new NPOIFSFileSystem(HSLFTestDataSamples.openSampleFileStream(filenameC));
+	    POIFSFileSystem fs = new POIFSFileSystem(HSLFTestDataSamples.openSampleFileStream(filenameC));
 	    InputStream is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT);
 	    byte[] raw_file = IOUtils.toByteArray(is);
 	    is.close();
@@ -405,7 +405,7 @@ public final class TestRichTextRun {
 		// Now write out the slideshow
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 		s.write(baos);
-		fs = new NPOIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
+		fs = new POIFSFileSystem(new ByteArrayInputStream(baos.toByteArray()));
 		is = fs.createDocumentInputStream(HSLFSlideShow.POWERPOINT_DOCUMENT);
 		byte[] raw_ss = IOUtils.toByteArray(is);
         is.close();
@@ -515,7 +515,7 @@ public final class TestRichTextRun {
 		slide.addShape(shape);
 
 		assertEquals(42.0, tr.getFontSize(), 0);
-		assertEquals(true, rt.isBullet());
+		assertTrue(rt.isBullet());
 		assertEquals(50.0, rt.getLeftMargin(), 0);
 		assertEquals(0, rt.getIndent(), 0);
 		assertEquals('\u263A', (char)rt.getBulletChar());
@@ -530,7 +530,7 @@ public final class TestRichTextRun {
 		rt = shape.getTextParagraphs().get(0);
 		tr = rt.getTextRuns().get(0);
 		assertEquals(42.0, tr.getFontSize(), 0);
-		assertEquals(true, rt.isBullet());
+		assertTrue(rt.isBullet());
 		assertEquals(50.0, rt.getLeftMargin(), 0);
 		assertEquals(0, rt.getIndent(), 0);
 		assertEquals('\u263A', (char)rt.getBulletChar());
@@ -615,7 +615,7 @@ public final class TestRichTextRun {
 	}
 	
     @Test
-	public void testChineseParagraphs() throws Exception {
+	public void testChineseParagraphs() {
       List<HSLFTextRun> rts;
       HSLFTextRun rt;
       List<List<HSLFTextParagraph>> txt;

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFixedSizedProperties.java Fri Aug 31 00:25:50 2018
@@ -43,7 +43,7 @@ import org.apache.poi.hsmf.datatypes.Pro
 import org.apache.poi.hsmf.datatypes.PropertyValue.TimePropertyValue;
 import org.apache.poi.hsmf.dev.HSMFDump;
 import org.apache.poi.hsmf.extractor.OutlookTextExtactor;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -58,8 +58,8 @@ public final class TestFixedSizedPropert
    private static final String messageFails = "53784_fails.msg";
    private static MAPIMessage mapiMessageSucceeds;
    private static MAPIMessage mapiMessageFails;
-   private static NPOIFSFileSystem fsMessageSucceeds;
-   private static NPOIFSFileSystem fsMessageFails;
+   private static POIFSFileSystem fsMessageSucceeds;
+   private static POIFSFileSystem fsMessageFails;
    private static SimpleDateFormat messageDateFormat;
    private static TimeZone userTimeZone;
 
@@ -69,8 +69,8 @@ public final class TestFixedSizedPropert
    @BeforeClass
    public static void initMapi()  throws Exception {
        POIDataSamples samples = POIDataSamples.getHSMFInstance();
-       fsMessageSucceeds = new NPOIFSFileSystem(samples.getFile(messageSucceeds));
-       fsMessageFails = new NPOIFSFileSystem(samples.getFile(messageFails));
+       fsMessageSucceeds = new POIFSFileSystem(samples.getFile(messageSucceeds));
+       fsMessageFails = new POIFSFileSystem(samples.getFile(messageFails));
 
        mapiMessageSucceeds = new MAPIMessage(fsMessageSucceeds);
        mapiMessageFails = new MAPIMessage(fsMessageFails);        
@@ -95,7 +95,7 @@ public final class TestFixedSizedPropert
     * of our test files
     */
    @Test
-   public void testPropertiesFound() throws Exception {
+   public void testPropertiesFound() {
        Map<MAPIProperty,List<PropertyValue>> props;
        
        props = mapiMessageSucceeds.getMainChunks().getProperties();
@@ -109,7 +109,7 @@ public final class TestFixedSizedPropert
     * Check we find properties of a variety of different types
     */
    @Test
-   public void testPropertyValueTypes() throws Exception {
+   public void testPropertyValueTypes() {
        Chunks mainChunks = mapiMessageSucceeds.getMainChunks();
        
        // Ask to have the values looked up

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/extractor/TestOutlookTextExtractor.java Fri Aug 31 00:25:50 2018
@@ -29,7 +29,7 @@ import java.util.TimeZone;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hsmf.MAPIMessage;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -56,7 +56,7 @@ public final class TestOutlookTextExtrac
    
    @Test
    public void testQuick() throws Exception {
-      NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+      POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("quick.msg"), true);
       MAPIMessage msg = new MAPIMessage(poifs);
       
       OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -81,7 +81,7 @@ public final class TestOutlookTextExtrac
    
    @Test
    public void testSimple() throws Exception {
-      NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
+      POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
       MAPIMessage msg = new MAPIMessage(poifs);
       
       OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -107,7 +107,7 @@ public final class TestOutlookTextExtrac
         ext.close();
         fis.close();
 
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
+        POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
         ext = new OutlookTextExtactor(poifs);
         String poifsTxt = ext.getText();
         ext.close();
@@ -141,7 +141,7 @@ public final class TestOutlookTextExtrac
             "example_sent_regular.msg", "example_sent_unicode.msg"
       };
       for(String file : files) {
-         NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile(file), true);
+         POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile(file), true);
          MAPIMessage msg = new MAPIMessage(poifs);
          
          OutlookTextExtactor ext = new OutlookTextExtactor(msg);
@@ -181,7 +181,7 @@ public final class TestOutlookTextExtrac
             "example_received_regular.msg", "example_received_unicode.msg"
       };
       for(String file : files) {
-          NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile(file), true);
+          POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile(file), true);
           MAPIMessage msg = new MAPIMessage(poifs);
 
          
@@ -204,10 +204,12 @@ public final class TestOutlookTextExtrac
    }
    
    /**
-    * See also {@link org.apache.poi.extractor.TestExtractorFactory#testEmbeded()}
+    * See also {@link org.apache.poi.extractor.ooxml.TestExtractorFactory#testEmbeded()}
     */
+   @SuppressWarnings("JavadocReference")
+   @Test
    public void testWithAttachments() throws Exception {
-      NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
+      POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
       MAPIMessage msg = new MAPIMessage(poifs);
       OutlookTextExtactor ext = new OutlookTextExtactor(msg);
       
@@ -230,9 +232,10 @@ public final class TestOutlookTextExtrac
       ext.close();
       poifs.close();
    }
-   
+
+    @Test
    public void testWithAttachedMessage() throws Exception {
-       NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("58214_with_attachment.msg"), true);
+       POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("58214_with_attachment.msg"), true);
          MAPIMessage msg = new MAPIMessage(poifs);
          OutlookTextExtactor ext = new OutlookTextExtactor(msg);
          String text = ext.getText();
@@ -248,9 +251,10 @@ public final class TestOutlookTextExtrac
          ext.close();
          poifs.close();
    }
-   
+
+    @Test
    public void testEncodings() throws Exception {
-      NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("chinese-traditional.msg"), true);
+      POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("chinese-traditional.msg"), true);
       MAPIMessage msg = new MAPIMessage(poifs);
       OutlookTextExtactor ext = new OutlookTextExtactor(msg);
       String text = ext.getText();

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java Fri Aug 31 00:25:50 2018
@@ -20,9 +20,11 @@ package org.apache.poi.hsmf.parsers;
 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 java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Calendar;
 
@@ -38,7 +40,7 @@ import org.apache.poi.hsmf.datatypes.Rec
 import org.apache.poi.hsmf.datatypes.StringChunk;
 import org.apache.poi.hsmf.datatypes.Types;
 import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LocaleUtil;
 import org.junit.Test;
 
@@ -50,7 +52,7 @@ public final class TestPOIFSChunkParser
 
    @Test
    public void testFindsCore() throws IOException, ChunkNotFoundException {
-      NPOIFSFileSystem simple = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+      POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true);
 
       // Check a few core things are present
       simple.getRoot().getEntry(
@@ -77,7 +79,7 @@ public final class TestPOIFSChunkParser
 
    @Test
    public void testFindsRecips() throws IOException, ChunkNotFoundException {
-      NPOIFSFileSystem simple = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+      POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true);
 
       simple.getRoot().getEntry("__recip_version1.0_#00000000");
 
@@ -92,7 +94,7 @@ public final class TestPOIFSChunkParser
       assertEquals("/O=HOSTEDSERVICE2/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=Kevin.roast@ben",
             recips.recipientEmailChunk.getValue());
 
-      String search = new String(recips.recipientSearchChunk.getValue(), "ASCII");
+      String search = new String(recips.recipientSearchChunk.getValue(), StandardCharsets.US_ASCII);
       assertEquals("CN=KEVIN.ROAST@BEN\0", search.substring(search.length()-19));
 
       // Now via MAPIMessage
@@ -116,14 +118,14 @@ public final class TestPOIFSChunkParser
 
 
       // Now look at another message
-      simple = new NPOIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
+      simple = new POIFSFileSystem(samples.getFile("simple_test_msg.msg"), true);
       msg = new MAPIMessage(simple);
       assertNotNull(msg.getRecipientDetailsChunks());
       assertEquals(1, msg.getRecipientDetailsChunks().length);
 
       assertEquals("SMTP", msg.getRecipientDetailsChunks()[0].deliveryTypeChunk.getValue());
-      assertEquals(null, msg.getRecipientDetailsChunks()[0].recipientSMTPChunk);
-      assertEquals(null, msg.getRecipientDetailsChunks()[0].recipientNameChunk);
+      assertNull(msg.getRecipientDetailsChunks()[0].recipientSMTPChunk);
+      assertNull(msg.getRecipientDetailsChunks()[0].recipientNameChunk);
       assertEquals("travis@overwrittenstack.com", msg.getRecipientDetailsChunks()[0].recipientEmailChunk.getValue());
       assertEquals("travis@overwrittenstack.com", msg.getRecipientEmailAddress());
 
@@ -133,7 +135,7 @@ public final class TestPOIFSChunkParser
 
    @Test
    public void testFindsMultipleRecipients() throws IOException, ChunkNotFoundException {
-      NPOIFSFileSystem multiple = new NPOIFSFileSystem(samples.getFile("example_received_unicode.msg"), true);
+      POIFSFileSystem multiple = new POIFSFileSystem(samples.getFile("example_received_unicode.msg"), true);
 
       multiple.getRoot().getEntry("__recip_version1.0_#00000000");
       multiple.getRoot().getEntry("__recip_version1.0_#00000001");
@@ -226,7 +228,7 @@ public final class TestPOIFSChunkParser
 
    @Test
    public void testFindsNameId() throws IOException {
-      NPOIFSFileSystem simple = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+      POIFSFileSystem simple = new POIFSFileSystem(samples.getFile("quick.msg"), true);
 
       simple.getRoot().getEntry("__nameid_version1.0");
 
@@ -250,8 +252,8 @@ public final class TestPOIFSChunkParser
 
    @Test
    public void testFindsAttachments() throws IOException, ChunkNotFoundException {
-	  NPOIFSFileSystem with = new NPOIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
-      NPOIFSFileSystem without = new NPOIFSFileSystem(samples.getFile("quick.msg"), true);
+	  POIFSFileSystem with = new POIFSFileSystem(samples.getFile("attachment_test_msg.msg"), true);
+      POIFSFileSystem without = new POIFSFileSystem(samples.getFile("quick.msg"), true);
       AttachmentChunks attachment;
 
 
@@ -326,7 +328,7 @@ public final class TestPOIFSChunkParser
     */
    @Test
    public void testOlk10SideProps() throws IOException, ChunkNotFoundException {
-      NPOIFSFileSystem poifs = new NPOIFSFileSystem(samples.getFile("51873.msg"), true);
+      POIFSFileSystem poifs = new POIFSFileSystem(samples.getFile("51873.msg"), true);
       MAPIMessage msg = new MAPIMessage(poifs);
 
       // Check core details came through

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractor.java Fri Aug 31 00:25:50 2018
@@ -34,7 +34,6 @@ import org.apache.poi.hwpf.HWPFTestDataS
 import org.apache.poi.hwpf.OldWordFileFormatException;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
 import org.apache.poi.poifs.filesystem.Entry;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.StringUtil;
 import org.junit.Test;
@@ -338,13 +337,13 @@ public final class TestWordExtractor {
     
     /**
      * Tests that we can work with both {@link POIFSFileSystem}
-     *  and {@link NPOIFSFileSystem}
+     *  and {@link POIFSFileSystem}
      */
     @Test
     public void testDifferentPOIFS() throws Exception {
        // Open the two filesystems
        File file = docTests.getFile("test2.doc");
-       try (NPOIFSFileSystem npoifs = new NPOIFSFileSystem(file, true)) {
+       try (POIFSFileSystem npoifs = new POIFSFileSystem(file, true)) {
 
            DirectoryNode dir = npoifs.getRoot();
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/extractor/TestWordExtractorBugs.java Fri Aug 31 00:25:50 2018
@@ -20,7 +20,7 @@ package org.apache.poi.hwpf.extractor;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.extractor.POITextExtractor;
 import org.apache.poi.extractor.OLE2ExtractorFactory;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -60,7 +60,7 @@ public final class TestWordExtractorBugs
 
     @Test
     public void testBug60374() throws Exception {
-        NPOIFSFileSystem fs = new NPOIFSFileSystem(SAMPLES.openResourceAsStream("cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC"));
+        POIFSFileSystem fs = new POIFSFileSystem(SAMPLES.openResourceAsStream("cn.orthodox.www_divenbog_APRIL_30-APRIL.DOC"));
         final POITextExtractor extractor = OLE2ExtractorFactory.createExtractor(fs);
 
         // Check it gives text without error

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java Fri Aug 31 00:25:50 2018
@@ -25,6 +25,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -39,7 +40,6 @@ import org.apache.poi.hwpf.converter.Wor
 import org.apache.poi.hwpf.extractor.Word6Extractor;
 import org.apache.poi.hwpf.extractor.WordExtractor;
 import org.apache.poi.hwpf.model.*;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.POILogFactory;
@@ -56,8 +56,7 @@ public class TestBugs{
 
     private static final POILogger logger = POILogFactory.getLogger(TestBugs.class);
 
-    public static void assertEqualsIgnoreNewline(String expected, String actual )
-    {
+    private static void assertEqualsIgnoreNewline(String expected, String actual) {
         String newExpected = expected.replaceAll("\r\n", "\n" )
                 .replaceAll("\r", "\n").trim();
         String newActual = actual.replaceAll("\r\n", "\n" )
@@ -110,17 +109,6 @@ public class TestBugs{
             doc.close();
         }
     }
-    
-    private String getTextOldFile(String samplefile) throws IOException {
-        HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile(samplefile);
-        Word6Extractor extractor = new Word6Extractor(doc);
-        try {
-            return extractor.getText();
-        } finally {
-            extractor.close();
-            doc.close();
-        }
-    }
 
     /**
      * Bug 33519 - HWPF fails to read a file
@@ -448,7 +436,7 @@ public class TestBugs{
         try (InputStream is = POIDataSamples.getDocumentInstance()
                 .openResourceAsStream("Bug47742-text.txt")) {
             byte[] expectedBytes = IOUtils.toByteArray(is);
-            String expectedText = new String(expectedBytes, "utf-8")
+            String expectedText = new String(expectedBytes, StandardCharsets.UTF_8)
                     .substring(1); // strip-off the unicode marker
 
             assertEqualsIgnoreNewline(expectedText, foundText);
@@ -486,11 +474,11 @@ public class TestBugs{
     }
 
     @Test
-    public void test49933() throws IOException
-    {
-        String text = getTextOldFile("Bug49933.doc");
-
-        assertContains(text, "best.wine.jump.ru");
+    public void test49933() throws IOException {
+        try (HWPFOldDocument doc = HWPFTestDataSamples.openOldSampleFile("Bug49933.doc");
+            Word6Extractor extractor = new Word6Extractor(doc)) {
+            assertContains(extractor.getText(), "best.wine.jump.ru");
+        }
     }
 
     /**
@@ -544,8 +532,7 @@ public class TestBugs{
      * release from download site )
      */
     @Test
-    public void test51604p2() throws Exception
-    {
+    public void test51604p2() {
         HWPFDocument doc = HWPFTestDataSamples.openSampleFile("Bug51604.doc");
 
         Range range = doc.getRange();
@@ -627,7 +614,7 @@ public class TestBugs{
     {
         InputStream is = POIDataSamples.getDocumentInstance()
                 .openResourceAsStream("empty.doc");
-        try (NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(is)) {
+        try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(is)) {
             HWPFDocument hwpfDocument = new HWPFDocument(
                     npoifsFileSystem.getRoot());
             hwpfDocument.write(new ByteArrayOutputStream());
@@ -679,8 +666,7 @@ public class TestBugs{
      * corrupt document
      */
     @Test
-    public void testBug51834() throws Exception
-    {
+    public void testBug51834() {
         /*
          * we don't have Java test for this file - it should be checked using
          * Microsoft BFF Validator. But check read-write-read anyway. -- sergey
@@ -773,7 +759,7 @@ public class TestBugs{
      * Disabled pending a fix for the bug
      */
     @Test
-    public void test56880() throws Exception {
+    public void test56880() {
         HWPFDocument doc =
                 HWPFTestDataSamples.openSampleFile("56880.doc");
         assertEqualsIgnoreNewline("Check Request", doc.getRange().text());
@@ -787,20 +773,12 @@ public class TestBugs{
     {
         assertNotNull(getText("Bug61268.doc"));
     }
-    
-    // These are the values the are expected to be read when the file
-    // is checked.
-    private final int section1LeftMargin = 1440;
-    private final int section1RightMargin = 1440;
-    private final int section1TopMargin = 1440;
-    private final int section1BottomMargin = 1440;
-    private final int section1NumColumns = 1;
+
     private int section2LeftMargin = 1440;
     private int section2RightMargin = 1440;
     private int section2TopMargin = 1440;
     private int section2BottomMargin = 1440;
-    private final int section2NumColumns = 3;
-    
+
     @Test
     @SuppressWarnings("SuspiciousNameCombination")
     public void testHWPFSections() {
@@ -854,10 +832,17 @@ public class TestBugs{
 
     @SuppressWarnings("Duplicates")
     private void assertSection1Margin(Section section) {
+        int section1BottomMargin = 1440;
         assertEquals(section1BottomMargin, section.getMarginBottom());
+        // These are the values the are expected to be read when the file
+        // is checked.
+        int section1LeftMargin = 1440;
         assertEquals(section1LeftMargin, section.getMarginLeft());
+        int section1RightMargin = 1440;
         assertEquals(section1RightMargin, section.getMarginRight());
+        int section1TopMargin = 1440;
         assertEquals(section1TopMargin, section.getMarginTop());
+        int section1NumColumns = 1;
         assertEquals(section1NumColumns, section.getNumColumns());
     }
 
@@ -867,6 +852,7 @@ public class TestBugs{
         assertEquals(section2LeftMargin, section.getMarginLeft());
         assertEquals(section2RightMargin, section.getMarginRight());
         assertEquals(section2TopMargin, section.getMarginTop());
+        int section2NumColumns = 3;
         assertEquals(section2NumColumns, section.getNumColumns());
     }
 

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestHWPFWrite.java Fri Aug 31 00:25:50 2018
@@ -31,7 +31,6 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFTestCase;
 import org.apache.poi.hwpf.HWPFTestDataSamples;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.TempFile;
@@ -104,7 +103,7 @@ public final class TestHWPFWrite extends
         }
 
         // Open from the temp file in read-write mode
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(file, false);
+        POIFSFileSystem poifs = new POIFSFileSystem(file, false);
         HWPFDocument doc = new HWPFDocument(poifs.getRoot());
         Range r = doc.getRange();
         assertEquals("I am a test document\r", r.getParagraph(0).text());
@@ -117,7 +116,7 @@ public final class TestHWPFWrite extends
         doc.close();
         poifs.close();
 
-        poifs = new NPOIFSFileSystem(file);
+        poifs = new POIFSFileSystem(file);
         doc = new HWPFDocument(poifs.getRoot());
         r = doc.getRange();
         assertEquals("X XX a test document\r", r.getParagraph(0).text());
@@ -138,7 +137,7 @@ public final class TestHWPFWrite extends
     @Test(expected=IllegalStateException.class)
     public void testInvalidInPlaceWriteNPOIFS() throws Exception {
         // Can't work for Read-Only files
-        NPOIFSFileSystem fs = new NPOIFSFileSystem(SAMPLES.getFile("SampleDoc.doc"), true);
+        POIFSFileSystem fs = new POIFSFileSystem(SAMPLES.getFile("SampleDoc.doc"), true);
         HWPFDocument doc = new HWPFDocument(fs.getRoot());
         try {
             doc.write();

Modified: poi/trunk/src/testcases/org/apache/poi/TestPOIDocumentMain.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/TestPOIDocumentMain.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/TestPOIDocumentMain.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/TestPOIDocumentMain.java Fri Aug 31 00:25:50 2018
@@ -30,7 +30,6 @@ import org.apache.poi.hpsf.HPSFPropertie
 import org.apache.poi.hpsf.SummaryInformation;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Before;
 import org.junit.Test;
@@ -85,7 +84,7 @@ public final class TestPOIDocumentMain {
     @Test
     public void writeProperties() throws IOException {
         // Just check we can write them back out into a filesystem
-        NPOIFSFileSystem outFS = new NPOIFSFileSystem();
+        POIFSFileSystem outFS = new POIFSFileSystem();
         doc.readProperties();
         doc.writeProperties(outFS);
 
@@ -103,7 +102,7 @@ public final class TestPOIDocumentMain {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
         // Write them out
-        NPOIFSFileSystem outFS = new NPOIFSFileSystem();
+        POIFSFileSystem outFS = new POIFSFileSystem();
         doc.readProperties();
         doc.writeProperties(outFS);
         outFS.writeFilesystem(baos);

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestHPSFBugs.java Fri Aug 31 00:25:50 2018
@@ -37,7 +37,7 @@ import org.apache.poi.hpsf.PropertySetFa
 import org.apache.poi.hpsf.SummaryInformation;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 
 /**
@@ -114,7 +114,7 @@ public final class TestHPSFBugs {
    @Test
    public void test54233() throws IOException, NoPropertySetStreamException, MarkUnsupportedException {
        InputStream is = _samples.openResourceAsStream("TestNon4ByteBoundary.doc");
-       NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
+       POIFSFileSystem fs = new POIFSFileSystem(is);
        is.close();
 
        SummaryInformation si = (SummaryInformation)
@@ -134,7 +134,7 @@ public final class TestHPSFBugs {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        doc.write(baos);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-       doc = new HPSFPropertiesOnlyDocument(new NPOIFSFileSystem(bais));
+       doc = new HPSFPropertiesOnlyDocument(new POIFSFileSystem(bais));
 
        // Check properties are still there
        assertEquals("Microsoft Word 10.0", si.getApplicationName());
@@ -152,7 +152,7 @@ public final class TestHPSFBugs {
    @Test
    public void test56138() throws IOException, NoPropertySetStreamException {
        InputStream is = _samples.openResourceAsStream("TestZeroLengthCodePage.mpp");
-       NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
+       POIFSFileSystem fs = new POIFSFileSystem(is);
        is.close();
 
        SummaryInformation si = (SummaryInformation)
@@ -181,7 +181,7 @@ public final class TestHPSFBugs {
             si.setLastPrinted(new Date(millis));
             try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb)) {
                 SummaryInformation si2 = wb2.getSummaryInformation();
-                Date d = si.getLastPrinted();
+                Date d = si2.getLastPrinted();
                 assertNotNull(d);
                 assertEquals(millis, d.getTime());
             }

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestReadAllFiles.java Fri Aug 31 00:25:50 2018
@@ -41,7 +41,6 @@ import org.apache.poi.hpsf.NoPropertySet
 import org.apache.poi.hpsf.PropertySet;
 import org.apache.poi.hpsf.PropertySetFactory;
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -62,14 +61,11 @@ public class TestReadAllFiles {
     public static Iterable<Object[]> files() {
         final List<Object[]> files = new ArrayList<>();
         
-        _samples.getFile("").listFiles(new FileFilter() {
-            @Override
-            public boolean accept(final File f) {
-                if (f.getName().startsWith("Test")) { // && f.getName().equals("TestCorel.shw")
-                    files.add(new Object[]{ f });
-                }
-                return false;
+        _samples.getFile("").listFiles(f -> {
+            if (f.getName().startsWith("Test")) {
+                files.add(new Object[]{ f });
             }
+            return false;
         });
         
         return files;
@@ -86,11 +82,8 @@ public class TestReadAllFiles {
     public void read() throws IOException, NoPropertySetStreamException, MarkUnsupportedException {
         /* Read the POI filesystem's property set streams: */
         for (POIFile pf : Util.readPropertySets(file)) {
-            final InputStream in = new ByteArrayInputStream(pf.getBytes());
-            try {
+            try (InputStream in = new ByteArrayInputStream(pf.getBytes())) {
                 PropertySetFactory.create(in);
-            } finally {
-                in.close();
             }
         }
     }
@@ -148,18 +141,16 @@ public class TestReadAllFiles {
     }
     
     /**
-     * <p>This test method checks whether DocumentSummary information streams
+     * This test method checks whether DocumentSummary information streams
      * can be read. This is done by opening all "Test*" files in the 'poifs' directrory
      * pointed to by the "POI.testdata.path" system property, trying to extract
      * the document summary information stream in the root directory and calling
-     * its get... methods.</p>
-     * @throws Exception 
+     * its get... methods.
      */
     @Test
     public void readDocumentSummaryInformation() throws Exception {
         /* Read a test document <em>doc</em> into a POI filesystem. */
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(file, true);
-        try {
+        try (POIFSFileSystem poifs = new POIFSFileSystem(file, true)) {
             final DirectoryEntry dir = poifs.getRoot();
             /*
              * If there is a document summry information stream, read it from
@@ -167,7 +158,7 @@ public class TestReadAllFiles {
              */
             if (dir.hasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) {
                 final DocumentSummaryInformation dsi = TestWriteWellKnown.getDocumentSummaryInformation(poifs);
-    
+
                 /* Execute the get... methods. */
                 dsi.getByteCount();
                 dsi.getByteOrder();
@@ -187,22 +178,19 @@ public class TestReadAllFiles {
                 dsi.getScale();
                 dsi.getSlideCount();
             }
-        } finally {
-            poifs.close();
         }
     }
     
     /**
-     * <p>Tests the simplified custom properties by reading them from the
-     * available test files.</p>
+     * Tests the simplified custom properties by reading them from the
+     * available test files.
      *
-     * @throws Throwable if anything goes wrong.
+     * @throws Exception if anything goes wrong.
      */
     @Test
     public void readCustomPropertiesFromFiles() throws Exception {
         /* Read a test document <em>doc</em> into a POI filesystem. */
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(file);
-        try {
+        try (POIFSFileSystem poifs = new POIFSFileSystem(file)) {
             /*
              * If there is a document summry information stream, read it from
              * the POI filesystem, else create a new one.
@@ -222,8 +210,6 @@ public class TestReadAllFiles {
                 assertNotNull(cp.getName());
                 assertNotNull(cp.getValue());
             }
-        } finally {
-            poifs.close();
         }
     }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java Fri Aug 31 00:25:50 2018
@@ -45,7 +45,6 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.hpsf.ClassID;
 import org.apache.poi.hpsf.DocumentSummaryInformation;
 import org.apache.poi.hpsf.HPSFException;
-import org.apache.poi.hpsf.IllegalPropertySetDataException;
 import org.apache.poi.hpsf.NoFormatIDException;
 import org.apache.poi.hpsf.NoPropertySetStreamException;
 import org.apache.poi.hpsf.Property;
@@ -63,10 +62,9 @@ import org.apache.poi.poifs.eventfilesys
 import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
 import org.apache.poi.poifs.filesystem.DocumentNode;
-import org.apache.poi.poifs.filesystem.NDocumentInputStream;
-import org.apache.poi.poifs.filesystem.NDocumentOutputStream;
-import org.apache.poi.poifs.filesystem.NPOIFSDocument;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.DocumentInputStream;
+import org.apache.poi.poifs.filesystem.DocumentOutputStream;
+import org.apache.poi.poifs.filesystem.POIFSDocument;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.CodePageUtil;
 import org.apache.poi.util.IOUtils;
@@ -488,7 +486,7 @@ public class TestWrite {
      */
     @Test
     public void inPlaceNPOIFSWrite() throws Exception {
-        NPOIFSFileSystem fs;
+        POIFSFileSystem fs;
         DirectoryEntry root;
         DocumentNode sinfDoc;
         DocumentNode dinfDoc;
@@ -508,7 +506,7 @@ public class TestWrite {
         
         
         // Open the copy in read/write mode
-        fs = new NPOIFSFileSystem(copy, false);
+        fs = new POIFSFileSystem(copy, false);
         root = fs.getRoot();
         
         
@@ -516,12 +514,12 @@ public class TestWrite {
         sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
 
-        InputStream sinfStream = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream = new DocumentInputStream(sinfDoc);
         sinf = (SummaryInformation)PropertySetFactory.create(sinfStream);
         sinfStream.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        InputStream dinfStream = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream = new DocumentInputStream(dinfDoc);
         dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream);
         dinfStream.close();
         assertEquals(131077, dinf.getOSVersion());
@@ -540,20 +538,20 @@ public class TestWrite {
         assertNotNull(sinfDoc);
         assertNotNull(dinfDoc);
 
-        new NPOIFSDocument(sinfDoc).replaceContents(sinf.toInputStream());
-        new NPOIFSDocument(dinfDoc).replaceContents(dinf.toInputStream());
+        new POIFSDocument(sinfDoc).replaceContents(sinf.toInputStream());
+        new POIFSDocument(dinfDoc).replaceContents(dinf.toInputStream());
         
         
         // Check it didn't get changed
         sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
         
-        InputStream sinfStream2 = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream2 = new DocumentInputStream(sinfDoc);
         sinf = (SummaryInformation)PropertySetFactory.create(sinfStream2);
         sinfStream2.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        InputStream dinfStream2 = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream2 = new DocumentInputStream(dinfDoc);
         dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream2);
         dinfStream2.close();
         assertEquals(131077, dinf.getOSVersion());
@@ -567,29 +565,29 @@ public class TestWrite {
         inp.close();
         out.close();
         
-        fs = new NPOIFSFileSystem(copy, false);
+        fs = new POIFSFileSystem(copy, false);
         root = fs.getRoot();
         
         // Read the properties in once more
         sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
 
-        InputStream sinfStream3 = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream3 = new DocumentInputStream(sinfDoc);
         sinf = (SummaryInformation)PropertySetFactory.create(sinfStream3);
         sinfStream3.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        InputStream dinfStream3 = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream3 = new DocumentInputStream(dinfDoc);
         dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream3);
         dinfStream3.close();
         assertEquals(131077, dinf.getOSVersion());
         
         
         // Have them write themselves in-place with no changes, as an OutputStream
-        OutputStream soufStream = new NDocumentOutputStream(sinfDoc);
+        OutputStream soufStream = new DocumentOutputStream(sinfDoc);
         sinf.write(soufStream);
         soufStream.close();
-        OutputStream doufStream = new NDocumentOutputStream(dinfDoc);
+        OutputStream doufStream = new DocumentOutputStream(dinfDoc);
         dinf.write(doufStream);
         doufStream.close();
         
@@ -604,10 +602,10 @@ public class TestWrite {
         sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
         dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
 
-        InputStream sinfStream4 = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream4 = new DocumentInputStream(sinfDoc);
         byte[] sinfData = IOUtils.toByteArray(sinfStream4);
         sinfStream4.close();
-        InputStream dinfStream4 = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream4 = new DocumentInputStream(dinfDoc);
         byte[] dinfData = IOUtils.toByteArray(dinfStream4);
         dinfStream4.close();
         assertThat(sinfBytes.toByteArray(), equalTo(sinfData));
@@ -615,12 +613,12 @@ public class TestWrite {
 
         
         // Read back in as-is
-        InputStream sinfStream5 = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream5 = new DocumentInputStream(sinfDoc);
         sinf = (SummaryInformation)PropertySetFactory.create(sinfStream5);
         sinfStream5.close();
         assertEquals(131077, sinf.getOSVersion());
         
-        InputStream dinfStream5 = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream5 = new DocumentInputStream(dinfDoc);
         dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream5);
         dinfStream5.close();
         assertEquals(131077, dinf.getOSVersion());
@@ -640,23 +638,23 @@ public class TestWrite {
         
         
         // Save this into the filesystem
-        OutputStream soufStream2 = new NDocumentOutputStream(sinfDoc);
+        OutputStream soufStream2 = new DocumentOutputStream(sinfDoc);
         sinf.write(soufStream2);
         soufStream2.close();
-        OutputStream doufStream2 = new NDocumentOutputStream(dinfDoc);
+        OutputStream doufStream2 = new DocumentOutputStream(dinfDoc);
         dinf.write(doufStream2);
         doufStream2.close();
         
         
         // Read them back in again
         sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
-        InputStream sinfStream6 = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream6 = new DocumentInputStream(sinfDoc);
         sinf = (SummaryInformation)PropertySetFactory.create(sinfStream6);
         sinfStream6.close();
         assertEquals(131077, sinf.getOSVersion());
         
         dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
-        InputStream dinfStream6 = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream6 = new DocumentInputStream(dinfDoc);
         dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream6);
         dinfStream6.close();
         assertEquals(131077, dinf.getOSVersion());
@@ -673,18 +671,18 @@ public class TestWrite {
         fs.writeFilesystem();
         fs.close();
         
-        fs = new NPOIFSFileSystem(copy);
+        fs = new POIFSFileSystem(copy);
         root = fs.getRoot();
         
         // Re-check on load
         sinfDoc = (DocumentNode)root.getEntry(SummaryInformation.DEFAULT_STREAM_NAME);
-        InputStream sinfStream7 = new NDocumentInputStream(sinfDoc);
+        InputStream sinfStream7 = new DocumentInputStream(sinfDoc);
         sinf = (SummaryInformation)PropertySetFactory.create(sinfStream7);
         sinfStream7.close();
         assertEquals(131077, sinf.getOSVersion());
         
         dinfDoc = (DocumentNode)root.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
-        InputStream dinfStream7 = new NDocumentInputStream(dinfDoc);
+        InputStream dinfStream7 = new DocumentInputStream(dinfDoc);
         dinf = (DocumentSummaryInformation)PropertySetFactory.create(dinfStream7);
         dinfStream7.close();
         assertEquals(131077, dinf.getOSVersion());

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWriteWellKnown.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWriteWellKnown.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWriteWellKnown.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWriteWellKnown.java Fri Aug 31 00:25:50 2018
@@ -37,7 +37,6 @@ import org.apache.poi.POIDataSamples;
 import org.apache.poi.hpsf.CustomProperties;
 import org.apache.poi.hpsf.CustomProperty;
 import org.apache.poi.hpsf.DocumentSummaryInformation;
-import org.apache.poi.hpsf.MarkUnsupportedException;
 import org.apache.poi.hpsf.NoPropertySetStreamException;
 import org.apache.poi.hpsf.Property;
 import org.apache.poi.hpsf.PropertySet;
@@ -47,9 +46,8 @@ import org.apache.poi.hpsf.SummaryInform
 import org.apache.poi.hpsf.UnexpectedPropertySetTypeException;
 import org.apache.poi.hpsf.Variant;
 import org.apache.poi.hpsf.VariantSupport;
-import org.apache.poi.hpsf.WritingNotSupportedException;
 import org.apache.poi.poifs.filesystem.DocumentInputStream;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.TempFile;
@@ -69,55 +67,55 @@ public class TestWriteWellKnown {
         VariantSupport.setLogUnsupportedTypes(false);
     }
 
-    static final String P_APPLICATION_NAME = "ApplicationName";
-    static final String P_AUTHOR = "Author";
-    static final int    P_CHAR_COUNT = 4712;
-    static final String P_COMMENTS = "Comments";
-    static final Date   P_CREATE_DATE_TIME;
-    static final long   P_EDIT_TIME = 4713 * 1000 * 10;
-    static final String P_KEYWORDS = "Keywords";
-    static final String P_LAST_AUTHOR = "LastAuthor";
-    static final Date   P_LAST_PRINTED;
-    static final Date   P_LAST_SAVE_DATE_TIME;
-    static final int    P_PAGE_COUNT = 4714;
-    static final String P_REV_NUMBER = "RevNumber";
-    static final int    P_SECURITY = 1;
-    static final String P_SUBJECT = "Subject";
-    static final String P_TEMPLATE = "Template";
+    private static final String P_APPLICATION_NAME = "ApplicationName";
+    private static final String P_AUTHOR = "Author";
+    private static final int    P_CHAR_COUNT = 4712;
+    private static final String P_COMMENTS = "Comments";
+    private static final Date   P_CREATE_DATE_TIME;
+    private static final long   P_EDIT_TIME = 4713 * 1000 * 10;
+    private static final String P_KEYWORDS = "Keywords";
+    private static final String P_LAST_AUTHOR = "LastAuthor";
+    private static final Date   P_LAST_PRINTED;
+    private static final Date   P_LAST_SAVE_DATE_TIME;
+    private static final int    P_PAGE_COUNT = 4714;
+    private static final String P_REV_NUMBER = "RevNumber";
+    private static final int    P_SECURITY = 1;
+    private static final String P_SUBJECT = "Subject";
+    private static final String P_TEMPLATE = "Template";
     // FIXME (byte array properties not yet implemented): static final byte[] P_THUMBNAIL = new byte[123];
-    static final String P_TITLE = "Title";
-    static final int    P_WORD_COUNT = 4715;
+    private static final String P_TITLE = "Title";
+    private static final int    P_WORD_COUNT = 4715;
 
-    static final int     P_BYTE_COUNT = 4716;
-    static final String  P_CATEGORY = "Category";
-    static final String  P_COMPANY = "Company";
+    private static final int     P_BYTE_COUNT = 4716;
+    private static final String  P_CATEGORY = "Category";
+    private static final String  P_COMPANY = "Company";
     // FIXME (byte array properties not yet implemented): static final byte[]  P_DOCPARTS = new byte[123];
     // FIXME (byte array properties not yet implemented): static final byte[]  P_HEADING_PAIR = new byte[123];
-    static final int     P_HIDDEN_COUNT = 4717;
-    static final int     P_LINE_COUNT = 4718;
-    static final boolean P_LINKS_DIRTY = true;
-    static final String  P_MANAGER = "Manager";
-    static final int     P_MM_CLIP_COUNT = 4719;
-    static final int     P_NOTE_COUNT = 4720;
-    static final int     P_PAR_COUNT = 4721;
-    static final String  P_PRESENTATION_FORMAT = "PresentationFormat";
-    static final boolean P_SCALE = false;
-    static final int     P_SLIDE_COUNT = 4722;
-    static final Date    now = new Date();
-
-    static final Integer POSITIVE_INTEGER = new Integer(2222);
-    static final Long POSITIVE_LONG = new  Long(3333);
-    static final Double POSITIVE_DOUBLE = new  Double(4444);
-    static final Integer NEGATIVE_INTEGER = new Integer(2222);
-    static final Long NEGATIVE_LONG = new  Long(3333);
-    static final Double NEGATIVE_DOUBLE = new  Double(4444);
-
-    static final Integer MAX_INTEGER = new Integer(Integer.MAX_VALUE);
-    static final Integer MIN_INTEGER = new Integer(Integer.MIN_VALUE);
-    static final Long MAX_LONG = new Long(Long.MAX_VALUE);
-    static final Long MIN_LONG = new Long(Long.MIN_VALUE);
-    static final Double MAX_DOUBLE = new Double(Double.MAX_VALUE);
-    static final Double MIN_DOUBLE = new Double(Double.MIN_VALUE);
+    private static final int     P_HIDDEN_COUNT = 4717;
+    private static final int     P_LINE_COUNT = 4718;
+    private static final boolean P_LINKS_DIRTY = true;
+    private static final String  P_MANAGER = "Manager";
+    private static final int     P_MM_CLIP_COUNT = 4719;
+    private static final int     P_NOTE_COUNT = 4720;
+    private static final int     P_PAR_COUNT = 4721;
+    private static final String  P_PRESENTATION_FORMAT = "PresentationFormat";
+    private static final boolean P_SCALE = false;
+    private static final int     P_SLIDE_COUNT = 4722;
+    private static final Date    now = new Date();
+
+    private static final Integer POSITIVE_INTEGER = 2222;
+    private static final Long POSITIVE_LONG = 3333L;
+    private static final Double POSITIVE_DOUBLE = 4444d;
+    private static final Integer NEGATIVE_INTEGER = 2222;
+    private static final Long NEGATIVE_LONG = 3333L;
+    private static final Double NEGATIVE_DOUBLE = 4444d;
+
+    private static final Integer MAX_INTEGER = Integer.MAX_VALUE;
+    private static final Integer MIN_INTEGER = Integer.MIN_VALUE;
+    private static final Long MAX_LONG = Long.MAX_VALUE;
+    private static final Long MIN_LONG = Long.MIN_VALUE;
+    private static final Double MAX_DOUBLE = Double.MAX_VALUE;
+    private static final Double MIN_DOUBLE = Double.MIN_VALUE;
 
     static {
         Calendar cal = LocaleUtil.getLocaleCalendar(2000, 6, 6, 6, 6, 6);
@@ -170,10 +168,6 @@ public class TestWriteWellKnown {
      * be found in the property streams of <em>doc3</em>.</p></li> </ol>
      *
      * @throws IOException if some I/O error occurred.
-     * @throws MarkUnsupportedException
-     * @throws NoPropertySetStreamException
-     * @throws UnexpectedPropertySetTypeException
-     * @throws WritingNotSupportedException
      */
     @Test
     public void testWriteWellKnown() throws Exception {
@@ -191,7 +185,7 @@ public class TestWriteWellKnown {
         
         CustomProperties cps1 = write1stFile(doc1, doc2);
         CustomProperties cps2 = write2ndFile(doc2, doc3);
-        write3rdFile(doc3, null);
+        write3rdFile(doc3);
         
         assertEquals(cps1, cps2);
     }
@@ -203,7 +197,7 @@ public class TestWriteWellKnown {
      */
     private static CustomProperties write1stFile(File fileIn, File fileOut) throws Exception {
         /* Read a test document <em>doc1</em> into a POI filesystem. */
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(fileIn, false);
+        POIFSFileSystem poifs = new POIFSFileSystem(fileIn, false);
 
         /*
          * Read the summary information stream and the document summary
@@ -315,7 +309,7 @@ public class TestWriteWellKnown {
      * values.
      */
     private static CustomProperties write2ndFile(File fileIn, File fileOut) throws Exception {
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(fileIn, false);
+        POIFSFileSystem poifs = new POIFSFileSystem(fileIn, false);
         SummaryInformation si = getSummaryInformation(poifs);
         DocumentSummaryInformation dsi = getDocumentSummaryInformation(poifs);
 
@@ -434,8 +428,8 @@ public class TestWriteWellKnown {
      * and document summary information. All properties removed before must not
      * be found in the property streams of {@code doc3}.
      */
-    private static CustomProperties write3rdFile(File fileIn, File fileOut) throws Exception {
-        NPOIFSFileSystem poifs = new NPOIFSFileSystem(fileIn, false);
+    private static void write3rdFile(File fileIn) throws Exception {
+        POIFSFileSystem poifs = new POIFSFileSystem(fileIn, false);
         SummaryInformation si = getSummaryInformation(poifs);
         DocumentSummaryInformation dsi = getDocumentSummaryInformation(poifs);
 
@@ -488,11 +482,9 @@ public class TestWriteWellKnown {
         assertEquals(0, dsi.getSlideCount());
         assertTrue(dsi.wasNull());
         poifs.close();
-        
-        return dsi.getCustomProperties();
     }
 
-    private static SummaryInformation getSummaryInformation(NPOIFSFileSystem poifs) throws Exception {
+    private static SummaryInformation getSummaryInformation(POIFSFileSystem poifs) throws Exception {
         DocumentInputStream dis = poifs.createDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME);
         PropertySet ps = new PropertySet(dis);
         SummaryInformation si = new SummaryInformation(ps);
@@ -500,8 +492,8 @@ public class TestWriteWellKnown {
         return si;
     }
     
-    static DocumentSummaryInformation getDocumentSummaryInformation(NPOIFSFileSystem poifs)
-    throws IOException, NoPropertySetStreamException, UnexpectedPropertySetTypeException, MarkUnsupportedException  {
+    static DocumentSummaryInformation getDocumentSummaryInformation(POIFSFileSystem poifs)
+    throws IOException, NoPropertySetStreamException, UnexpectedPropertySetTypeException {
         if (!poifs.getRoot().hasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME)) {
             return null;
         }
@@ -586,7 +578,7 @@ public class TestWriteWellKnown {
         p.setType(Variant.VT_LPWSTR);
         p.setValue(VALUE_1);
         s.setProperty(p);
-        dictionary.put(Long.valueOf(ID_1), NAME_1);
+        dictionary.put((long) ID_1, NAME_1);
         s.setDictionary(dictionary);
         cps = dsi.getCustomProperties();
         assertEquals(1, cps.size());
@@ -594,7 +586,7 @@ public class TestWriteWellKnown {
 
         /* Add another custom property. */
         s.setProperty(ID_2, Variant.VT_LPWSTR, VALUE_1);
-        dictionary.put(Long.valueOf(ID_2), NAME_1);
+        dictionary.put((long) ID_2, NAME_1);
         s.setDictionary(dictionary);
         cps = dsi.getCustomProperties();
         assertEquals(1, cps.size());

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/extractor/TestHPSFPropertiesExtractor.java Fri Aug 31 00:25:50 2018
@@ -21,7 +21,6 @@ import static org.apache.poi.POITestCase
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 
@@ -30,7 +29,6 @@ import org.apache.poi.hpsf.*;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.extractor.ExcelExtractor;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 
@@ -39,72 +37,65 @@ public final class TestHPSFPropertiesExt
 
 	@Test
 	public void testNormalProperties() throws Exception {
-		POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestMickey.doc"));
-		HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
-		try {
-    		// Check each bit in turn
-    		String summary = ext.getSummaryInformationText();
-    		String docSummary = ext.getDocumentSummaryInformationText();
-
-    		assertContains(summary, "TEMPLATE = Normal");
-    		assertContains(summary, "SUBJECT = sample subject");
-    		assertContains(docSummary, "MANAGER = sample manager");
-    		assertContains(docSummary, "COMPANY = sample company");
-    
-    		// Now overall
-    		String text = ext.getText();
-    		assertContains(text, "TEMPLATE = Normal");
-    		assertContains(text, "SUBJECT = sample subject");
-    		assertContains(text, "MANAGER = sample manager");
-    		assertContains(text, "COMPANY = sample company");
-		} finally {
-		    ext.close();
+		try (InputStream is = _samples.openResourceAsStream("TestMickey.doc");
+			POIFSFileSystem fs = new POIFSFileSystem(is);
+			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+			// Check each bit in turn
+			String summary = ext.getSummaryInformationText();
+			String docSummary = ext.getDocumentSummaryInformationText();
+
+			assertContains(summary, "TEMPLATE = Normal");
+			assertContains(summary, "SUBJECT = sample subject");
+			assertContains(docSummary, "MANAGER = sample manager");
+			assertContains(docSummary, "COMPANY = sample company");
+
+			// Now overall
+			String text = ext.getText();
+			assertContains(text, "TEMPLATE = Normal");
+			assertContains(text, "SUBJECT = sample subject");
+			assertContains(text, "MANAGER = sample manager");
+			assertContains(text, "COMPANY = sample company");
 		}
 	}
 
 	@Test
 	public void testNormalUnicodeProperties() throws Exception {
-		POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestUnicode.xls"));
-		HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
-		try {
-    		// Check each bit in turn
-    		String summary = ext.getSummaryInformationText();
-    		String docSummary = ext.getDocumentSummaryInformationText();
-    
-    		assertContains(summary, "AUTHOR = marshall");
-    		assertContains(summary, "TITLE = Titel: \u00c4h");
-    		assertContains(docSummary, "COMPANY = Schreiner");
-    		assertContains(docSummary, "SCALE = false");
-    
-    		// Now overall
-    		String text = ext.getText();
-    		assertContains(text, "AUTHOR = marshall");
-    		assertContains(text, "TITLE = Titel: \u00c4h");
-    		assertContains(text, "COMPANY = Schreiner");
-    		assertContains(text, "SCALE = false");
-		} finally {
-		    ext.close();
+
+		try (InputStream is = _samples.openResourceAsStream("TestUnicode.xls");
+		 	POIFSFileSystem fs = new POIFSFileSystem(is);
+			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+			// Check each bit in turn
+			String summary = ext.getSummaryInformationText();
+			String docSummary = ext.getDocumentSummaryInformationText();
+
+			assertContains(summary, "AUTHOR = marshall");
+			assertContains(summary, "TITLE = Titel: \u00c4h");
+			assertContains(docSummary, "COMPANY = Schreiner");
+			assertContains(docSummary, "SCALE = false");
+
+			// Now overall
+			String text = ext.getText();
+			assertContains(text, "AUTHOR = marshall");
+			assertContains(text, "TITLE = Titel: \u00c4h");
+			assertContains(text, "COMPANY = Schreiner");
+			assertContains(text, "SCALE = false");
 		}
 	}
 
 	@Test
 	public void testCustomProperties() throws Exception {
-		POIFSFileSystem fs = new POIFSFileSystem(
-				_samples.openResourceAsStream("TestMickey.doc")
-		);
-		HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
-		try {
-    		// Custom properties are part of the document info stream
-    		String dinfText = ext.getDocumentSummaryInformationText();
-    		assertContains(dinfText, "Client = sample client");
-    		assertContains(dinfText, "Division = sample division");
-    
-    		String text = ext.getText();
-    		assertContains(text, "Client = sample client");
-    		assertContains(text, "Division = sample division");
-        } finally {
-            ext.close();
-        }
+		try (InputStream is = _samples.openResourceAsStream("TestMickey.doc");
+			 POIFSFileSystem fs = new POIFSFileSystem(is);
+			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+			// Custom properties are part of the document info stream
+			String dinfText = ext.getDocumentSummaryInformationText();
+			assertContains(dinfText, "Client = sample client");
+			assertContains(dinfText, "Division = sample division");
+
+			String text = ext.getText();
+			assertContains(text, "Client = sample client");
+			assertContains(text, "Division = sample division");
+		}
 	}
 
 	@Test
@@ -156,16 +147,14 @@ public final class TestHPSFPropertiesExt
 
 	@Test
 	public void test42726() throws IOException {
-		HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(HSSFTestDataSamples.openSampleWorkbook("42726.xls"));
-		try {
-    		String txt = ext.getText();
-    		assertContains(txt, "PID_AUTHOR");
-    		assertContains(txt, "PID_EDITTIME");
-    		assertContains(txt, "PID_REVNUMBER");
-    		assertContains(txt, "PID_THUMBNAIL");
-        } finally {
-            ext.close();
-        }
+		try (HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("42726.xls");
+				HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(wb)) {
+			String txt = ext.getText();
+			assertContains(txt, "PID_AUTHOR");
+			assertContains(txt, "PID_EDITTIME");
+			assertContains(txt, "PID_REVNUMBER");
+			assertContains(txt, "PID_THUMBNAIL");
+		}
 	}
 
 	@Test
@@ -181,22 +170,20 @@ public final class TestHPSFPropertiesExt
 
 	@Test
     public void test52258() throws Exception {
-        POIFSFileSystem fs = new POIFSFileSystem(_samples.openResourceAsStream("TestVisioWithCodepage.vsd"));
-        HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs);
-        try {
-            assertNotNull(ext.getDocSummaryInformation());
-            assertNotNull(ext.getDocumentSummaryInformationText());
-            assertNotNull(ext.getSummaryInformation());
-            assertNotNull(ext.getSummaryInformationText());
-            assertNotNull(ext.getText());
-        } finally {
-            ext.close();
-        }
+		try (InputStream is = _samples.openResourceAsStream("TestVisioWithCodepage.vsd");
+			 POIFSFileSystem fs = new POIFSFileSystem(is);
+			 HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(fs)) {
+			assertNotNull(ext.getDocSummaryInformation());
+			assertNotNull(ext.getDocumentSummaryInformationText());
+			assertNotNull(ext.getSummaryInformation());
+			assertNotNull(ext.getSummaryInformationText());
+			assertNotNull(ext.getText());
+		}
     }
 
 	@Test
-	public void test61300Extractor() throws NoPropertySetStreamException, MarkUnsupportedException, IOException {
-		try (NPOIFSFileSystem npoifs = new NPOIFSFileSystem(
+	public void test61300Extractor() throws IOException {
+		try (POIFSFileSystem npoifs = new POIFSFileSystem(
 				POIDataSamples.getPOIFSInstance().getFile("61300.bin"))) {
 			HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(npoifs);
 			assertContains(ext.getText(), "PID_CODEPAGE = 1252");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java Fri Aug 31 00:25:50 2018
@@ -26,7 +26,7 @@ import org.apache.poi.EncryptedDocumentE
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.OldExcelFormatException;
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LocaleUtil;
 import org.apache.poi.util.RecordFormatException;
 import org.junit.BeforeClass;
@@ -49,7 +49,6 @@ public class TestBiffViewer extends Base
         EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class);  // Biff 5 / Excel 5
         EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
         EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
-        EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
         EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class);  // HSSFWorkbook cannot open it as well
         // EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
         EXCLUDED.put("50833.xls", IllegalArgumentException.class);       // "Name is too long" when setting username
@@ -59,18 +58,11 @@ public class TestBiffViewer extends Base
 
     @Override
     void runOneFile(File fileIn) throws IOException {
-        NPOIFSFileSystem fs  = new NPOIFSFileSystem(fileIn, true);
-        try {
-            InputStream is = BiffViewer.getPOIFSInputStream(fs);
-            try {
-                // use a NullOutputStream to not write the bytes anywhere for best runtime
-                PrintWriter dummy = new PrintWriter(new OutputStreamWriter(NULL_OUTPUT_STREAM, LocaleUtil.CHARSET_1252));
-                BiffViewer.runBiffViewer(dummy, is, true, true, true, false);
-            } finally {
-                is.close();
-            }
-        } finally {
-            fs.close();
+        try (POIFSFileSystem fs = new POIFSFileSystem(fileIn, true);
+             InputStream is = BiffViewer.getPOIFSInputStream(fs)) {
+            // use a NullOutputStream to not write the bytes anywhere for best runtime
+            PrintWriter dummy = new PrintWriter(new OutputStreamWriter(NULL_OUTPUT_STREAM, LocaleUtil.CHARSET_1252));
+            BiffViewer.runBiffViewer(dummy, is, true, true, true, false);
         }
     }
 

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=1839709&r1=1839708&r2=1839709&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 Fri Aug 31 00:25:50 2018
@@ -35,7 +35,7 @@ import org.apache.poi.EmptyFileException
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.HSSFTestDataSamples;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
 import org.apache.poi.util.RecordFormatException;
 import org.junit.Ignore;
@@ -285,7 +285,7 @@ public final class TestOldExcelExtractor
     @Test
     public void testNPOIFSFileSystem() throws IOException {
         File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
-        try (NPOIFSFileSystem fs = new NPOIFSFileSystem(file)) {
+        try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
             OldExcelExtractor extractor = new OldExcelExtractor(fs);
             extractor.close();
         }
@@ -294,7 +294,7 @@ public final class TestOldExcelExtractor
     @Test
     public void testDirectoryNode() throws IOException {
         File file = HSSFTestDataSamples.getSampleFile("FormulaRefs.xls");
-        try (NPOIFSFileSystem fs = new NPOIFSFileSystem(file)) {
+        try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
             OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot());
             extractor.close();
         }
@@ -303,7 +303,7 @@ public final class TestOldExcelExtractor
     @Test
     public void testDirectoryNodeInvalidFile() throws IOException {
         File file = POIDataSamples.getDocumentInstance().getFile("test.doc");
-        try (NPOIFSFileSystem fs = new NPOIFSFileSystem(file)) {
+        try (POIFSFileSystem fs = new POIFSFileSystem(file)) {
             OldExcelExtractor extractor = new OldExcelExtractor(fs.getRoot());
             extractor.close();
             fail("Should catch exception here");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/model/TestRVA.java Fri Aug 31 00:25:50 2018
@@ -30,7 +30,7 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.ss.formula.ptg.AttrPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.usermodel.CellType;
@@ -50,12 +50,11 @@ import org.junit.runners.Parameterized.P
 public final class TestRVA {
 
 	private static final String NEW_LINE = System.getProperty("line.separator");
-	private static NPOIFSFileSystem poifs;
+	private static POIFSFileSystem poifs;
     private static HSSFWorkbook workbook;
-    private static HSSFSheet sheet;
 
-	
-    @Parameter(value = 0)
+
+	@Parameter(value = 0)
     public HSSFCell formulaCell;
     @Parameter(value = 1)
     public String formula;
@@ -68,9 +67,9 @@ public final class TestRVA {
 
     @Parameters(name="{1}")
     public static Collection<Object[]> data() throws Exception {
-        poifs = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("testRVA.xls"), true);
+        poifs = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("testRVA.xls"), true);
         workbook = new HSSFWorkbook(poifs);
-        sheet = workbook.getSheetAt(0);
+		HSSFSheet sheet = workbook.getSheetAt(0);
 
         List<Object[]> data = new ArrayList<>();
         
@@ -110,34 +109,27 @@ public final class TestRVA {
 			}
 		}
 		boolean hasMismatch = false;
-		StringBuffer sb = new StringBuffer();
+		StringBuilder sb = new StringBuilder();
 		for (int i = 0; i < nExcelTokens; i++) {
 			Ptg poiPtg = poiPtgs[i];
 			Ptg excelPtg = excelPtgs[i];
 			if (excelPtg.getClass() != poiPtg.getClass()) {
 				hasMismatch = true;
-				sb.append("  mismatch token type[" + i + "] " + getShortClassName(excelPtg) + " "
-						+ excelPtg.getRVAType() + " - " + getShortClassName(poiPtg) + " "
-						+ poiPtg.getRVAType());
+				sb.append("  mismatch token type[").append(i).append("] ").append(getShortClassName(excelPtg)).append(" ").append(excelPtg.getRVAType()).append(" - ").append(getShortClassName(poiPtg)).append(" ").append(poiPtg.getRVAType());
 				sb.append(NEW_LINE);
 				continue;
 			}
 			if (poiPtg.isBaseToken()) {
 				continue;
 			}
-			sb.append("  token[" + i + "] " + excelPtg + " "
-					+ excelPtg.getRVAType());
+			sb.append("  token[").append(i).append("] ").append(excelPtg).append(" ").append(excelPtg.getRVAType());
 
 			if (excelPtg.getPtgClass() != poiPtg.getPtgClass()) {
 				hasMismatch = true;
-				sb.append(" - was " + poiPtg.getRVAType());
+				sb.append(" - was ").append(poiPtg.getRVAType());
 			}
 			sb.append(NEW_LINE);
 		}
-//		if (false) { // set 'true' to see trace of RVA values
-//			System.out.println(formulaCell.getRowIndex() + " " + formula);
-//			System.out.println(sb.toString());
-//		}
 		assertFalse(hasMismatch);
 	}
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestChartTitleFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestChartTitleFormatRecord.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestChartTitleFormatRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/chart/TestChartTitleFormatRecord.java Fri Aug 31 00:25:50 2018
@@ -29,14 +29,14 @@ import org.apache.poi.hssf.eventusermode
 import org.apache.poi.hssf.eventusermodel.HSSFRequest;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.junit.Test;
 
 public final class TestChartTitleFormatRecord {
 
 	@Test
     public void testRecord() throws Exception {
-		NPOIFSFileSystem fs = new NPOIFSFileSystem(
+		POIFSFileSystem fs = new POIFSFileSystem(
 				HSSFTestDataSamples.getSampleFile("WithFormattedGraphTitle.xls"));
 		
 		// Check we can open the file via usermodel
@@ -66,7 +66,7 @@ public final class TestChartTitleFormatR
 	private static final class ChartTitleFormatRecordGrabber implements HSSFListener {
 		private final List<ChartTitleFormatRecord> chartTitleFormatRecords;
 		
-		public ChartTitleFormatRecordGrabber() {
+		ChartTitleFormatRecordGrabber() {
 			chartTitleFormatRecords = new ArrayList<>();
 		}
 



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