poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kiwiwi...@apache.org
Subject svn commit: r1839709 [5/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...
Date Fri, 31 Aug 2018 00:25:51 GMT
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Fri Aug 31 00:25:50 2018
@@ -67,7 +67,6 @@ import org.apache.poi.hssf.record.common
 import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
 import org.apache.poi.poifs.filesystem.DocumentEntry;
 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.ss.formula.ptg.Area3DPtg;
 import org.apache.poi.ss.formula.ptg.DeletedArea3DPtg;
@@ -1625,7 +1624,7 @@ public final class TestBugs extends Base
             ));
         }
         try {
-            try (NPOIFSFileSystem fs = new NPOIFSFileSystem(
+            try (POIFSFileSystem fs = new POIFSFileSystem(
                     HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"))) {
                 new HSSFWorkbook(fs.getRoot(), false).close();
                 fail("Should catch exception here");
@@ -2340,7 +2339,7 @@ public final class TestBugs extends Base
 
         HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(
                 new ByteArrayInputStream(data)).getRoot(), false);
-        HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem(
+        HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new POIFSFileSystem(
                 new ByteArrayInputStream(data)).getRoot(), false);
 
         assertEquals(2, wbPOIFS.getNumberOfSheets());
@@ -2357,7 +2356,7 @@ public final class TestBugs extends Base
 
         HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem(
                 new ByteArrayInputStream(data)).getRoot(), false);
-        HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new NPOIFSFileSystem(
+        HSSFWorkbook wbNPOIFS = new HSSFWorkbook(new POIFSFileSystem(
                 new ByteArrayInputStream(data)).getRoot(), false);
 
         for (HSSFWorkbook wb : new HSSFWorkbook[]{wbPOIFS, wbNPOIFS}) {
@@ -3100,7 +3099,7 @@ public final class TestBugs extends Base
 
     @Test(expected = RuntimeException.class)
     public void test61300() throws Exception {
-        NPOIFSFileSystem npoifs = new NPOIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls"));
+        POIFSFileSystem npoifs = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("61300.xls"));
 
         DocumentEntry entry =
                 (DocumentEntry) npoifs.getRoot().getEntry(SummaryInformation.DEFAULT_STREAM_NAME);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java Fri Aug 31 00:25:50 2018
@@ -53,7 +53,6 @@ import org.apache.poi.hssf.record.Record
 import org.apache.poi.hssf.record.WindowOneRecord;
 import org.apache.poi.poifs.filesystem.DirectoryEntry;
 import org.apache.poi.poifs.filesystem.DirectoryNode;
-import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.ss.formula.ptg.Area3DPtg;
 import org.apache.poi.ss.usermodel.BaseTestWorkbook;
@@ -614,7 +613,7 @@ public final class TestHSSFWorkbook exte
 
     /**
      * Tests that we can work with both {@link POIFSFileSystem}
-     *  and {@link NPOIFSFileSystem}
+     *  and {@link POIFSFileSystem}
      */
     @Test
     public void differentPOIFS() throws Exception {
@@ -622,7 +621,7 @@ public final class TestHSSFWorkbook exte
        DirectoryNode[] files = new DirectoryNode[2];
         try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("Simple.xls"))) {
             files[0] = poifsFileSystem.getRoot();
-            try (NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))) {
+            try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("Simple.xls"))) {
                 files[1] = npoifsFileSystem.getRoot();
 
                 // Open without preserving nodes
@@ -654,7 +653,7 @@ public final class TestHSSFWorkbook exte
        DirectoryNode[] files = new DirectoryNode[2];
         try (POIFSFileSystem poifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls"))) {
             files[0] = poifsFileSystem.getRoot();
-            try (NPOIFSFileSystem npoifsFileSystem = new NPOIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))) {
+            try (POIFSFileSystem npoifsFileSystem = new POIFSFileSystem(HSSFTestDataSamples.getSampleFile("WithEmbeddedObjects.xls"))) {
                 files[1] = npoifsFileSystem.getRoot();
 
                 // Check the embedded parts
@@ -689,7 +688,7 @@ public final class TestHSSFWorkbook exte
     @Test
     public void writeWorkbookFromNPOIFS() throws IOException {
         try (InputStream is = HSSFTestDataSamples.openSampleFileStream("WithEmbeddedObjects.xls");
-             NPOIFSFileSystem fs = new NPOIFSFileSystem(is)) {
+             POIFSFileSystem fs = new POIFSFileSystem(is)) {
             // Start as NPOIFS
             HSSFWorkbook wb = new HSSFWorkbook(fs.getRoot(), true);
             assertEquals(3, wb.getNumberOfSheets());
@@ -1116,7 +1115,7 @@ public final class TestHSSFWorkbook exte
     
             // edit the workbook
             {
-                try (NPOIFSFileSystem fs = new NPOIFSFileSystem(file, false)) {
+                try (POIFSFileSystem fs = new POIFSFileSystem(file, false)) {
                     DirectoryNode root = fs.getRoot();
                     final Workbook workbook = new HSSFWorkbook(root, true);
                     final Sheet sheet = workbook.getSheet("foo");
@@ -1157,7 +1156,7 @@ public final class TestHSSFWorkbook exte
         assertCloseDoesNotModifyFile(filename, wb);
         
         // File via NPOIFileStream (java.nio)
-        wb = new HSSFWorkbook(new NPOIFSFileSystem(file));
+        wb = new HSSFWorkbook(new POIFSFileSystem(file));
         assertCloseDoesNotModifyFile(filename, wb);
         
         // InputStream
@@ -1204,7 +1203,7 @@ public final class TestHSSFWorkbook exte
         wb.close();
         
         // Can't work for Read-Only files
-        NPOIFSFileSystem fs = new NPOIFSFileSystem(
+        POIFSFileSystem fs = new POIFSFileSystem(
                 POIDataSamples.getSpreadSheetInstance().getFile("SampleSS.xls"), true);
         wb = new HSSFWorkbook(fs);
         try {
@@ -1226,7 +1225,7 @@ public final class TestHSSFWorkbook exte
         }
         
         // Open from the temp file in read-write mode
-        HSSFWorkbook wb = new HSSFWorkbook(new NPOIFSFileSystem(file, false));
+        HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(file, false));
         assertEquals(3, wb.getNumberOfSheets());
         
         // Change
@@ -1238,7 +1237,7 @@ public final class TestHSSFWorkbook exte
         wb.write();
         wb.close();
         
-        wb = new HSSFWorkbook(new NPOIFSFileSystem(file));
+        wb = new HSSFWorkbook(new POIFSFileSystem(file));
         assertEquals(1, wb.getNumberOfSheets());
         assertEquals("Changed!", wb.getSheetAt(0).getRow(0).getCell(0).toString());
 
@@ -1257,7 +1256,7 @@ public final class TestHSSFWorkbook exte
         wb.close();
         
         // Read and check
-        wb = new HSSFWorkbook(new NPOIFSFileSystem(file));
+        wb = new HSSFWorkbook(new POIFSFileSystem(file));
         assertEquals(3, wb.getNumberOfSheets());
         wb.close();
     }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/crypt/TestXorEncryption.java Fri Aug 31 00:25:50 2018
@@ -21,16 +21,19 @@ import static org.hamcrest.core.IsEqual.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 
 import org.apache.poi.hssf.HSSFTestDataSamples;
+import org.apache.poi.hssf.record.FilePassRecord;
 import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey;
 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.util.HexRead;
-import org.junit.After;
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestXorEncryption {
@@ -38,7 +41,7 @@ public class TestXorEncryption {
     private static final HSSFTestDataSamples samples = new HSSFTestDataSamples();
     
     @Test
-    public void testXorEncryption() throws IOException {
+    public void testXorEncryption() {
         // Xor-Password: abc
         // 2.5.343 XORObfuscation
         // key = 20810
@@ -58,7 +61,7 @@ public class TestXorEncryption {
     public void testUserFile() throws IOException {
         File f = samples.getSampleFile("xor-encryption-abc.xls");
         Biff8EncryptionKey.setCurrentUserPassword("abc");
-        try (NPOIFSFileSystem fs = new NPOIFSFileSystem(f, true);
+        try (POIFSFileSystem fs = new POIFSFileSystem(f, true);
              HSSFWorkbook hwb = new HSSFWorkbook(fs.getRoot(), true)) {
             HSSFSheet sh = hwb.getSheetAt(0);
             assertEquals(1.0, sh.getRow(0).getCell(0).getNumericCellValue(), 0.0);
@@ -67,5 +70,24 @@ public class TestXorEncryption {
         } finally {
             Biff8EncryptionKey.setCurrentUserPassword(null);
         }
+    }
+
+    @Test
+    @Ignore("currently not supported")
+    public void encrypt() throws IOException {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        try {
+            try (HSSFWorkbook hwb = HSSFTestDataSamples.openSampleWorkbook("SampleSS.xls")) {
+                Biff8EncryptionKey.setCurrentUserPassword("abc");
+                hwb.getInternalWorkbook().getWorkbookRecordList()
+                    .add(1, new FilePassRecord(EncryptionMode.xor));
+                hwb.write(bos);
+            }
+            try (HSSFWorkbook hwb = new HSSFWorkbook(new ByteArrayInputStream(bos.toByteArray()))) {
+                assertEquals(3, hwb.getNumberOfSheets());
+            }
+        } finally {
+            Biff8EncryptionKey.setCurrentUserPassword(null);
+        }
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/dev/TestPOIFSDump.java Fri Aug 31 00:25:50 2018
@@ -17,10 +17,10 @@
 package org.apache.poi.poifs.dev;
 
 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.NotOLE2FileException;
 import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
-import org.apache.poi.poifs.property.NPropertyTable;
+import org.apache.poi.poifs.property.PropertyTable;
 import org.apache.poi.util.TempFile;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -40,7 +40,7 @@ public class TestPOIFSDump {
         SYSTEM = System.out;
         System.setOut(new PrintStream(new OutputStream() {
             @Override
-            public void write(int b) throws IOException {
+            public void write(int b) {
 
             }
         }, false, "UTF-8"));
@@ -85,7 +85,7 @@ public class TestPOIFSDump {
         }
     }
 
-    public static void cleanDirectory(File directory) throws IOException {
+    private static void cleanDirectory(File directory) throws IOException {
         if (!directory.isDirectory()) {
             String message = directory + " is not a directory";
             throw new IllegalArgumentException(message);
@@ -110,7 +110,7 @@ public class TestPOIFSDump {
         }
     }
 
-    public static void forceDelete(File file) throws IOException {
+    private static void forceDelete(File file) throws IOException {
         if (file.isDirectory()) {
             deleteDirectory(file);
         } else {
@@ -196,10 +196,10 @@ public class TestPOIFSDump {
         assertTrue("Had: " + dir, dir.mkdirs());
 
         FileInputStream is = new FileInputStream(TEST_FILE);
-        NPOIFSFileSystem fs = new NPOIFSFileSystem(is);
+        POIFSFileSystem fs = new POIFSFileSystem(is);
         is.close();
 
-        NPropertyTable props = fs.getPropertyTable();
+        PropertyTable props = fs.getPropertyTable();
         assertNotNull(props);
 
         // try with an invalid startBlock to trigger an exception

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/AllPOIFSFileSystemTests.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/AllPOIFSFileSystemTests.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/AllPOIFSFileSystemTests.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/AllPOIFSFileSystemTests.java Fri Aug 31 00:25:50 2018
@@ -35,7 +35,6 @@ import org.junit.runners.Suite;
     , TestOfficeXMLException.class
     , TestPOIFSDocumentPath.class
     , TestPOIFSFileSystem.class
-    , TestNPOIFSFileSystem.class
     , TestPropertySorter.class
     , TestOle10Native.class
 })

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocument.java Fri Aug 31 00:25:50 2018
@@ -45,7 +45,7 @@ public class TestDocument {
     @Test
     public void testNPOIFSDocument() throws IOException {
 
-        try (NPOIFSFileSystem poifs = new NPOIFSFileSystem()) {
+        try (POIFSFileSystem poifs = new POIFSFileSystem()) {
 
             // verify correct number of blocks get created for document
             // that is exact multiple of block size
@@ -65,7 +65,7 @@ public class TestDocument {
 
 
             // verify that output is correct
-            NPOIFSDocument document = checkDocument(poifs, LARGER_BIG_BLOCK_SIZE + 1);
+            POIFSDocument document = checkDocument(poifs, LARGER_BIG_BLOCK_SIZE + 1);
             DocumentProperty property = document.getDocumentProperty();
             ByteArrayOutputStream stream = new ByteArrayOutputStream();
 
@@ -77,11 +77,11 @@ public class TestDocument {
         }
     }
 
-    private static NPOIFSDocument checkDocument(final NPOIFSFileSystem poifs, final int size) throws IOException {
+    private static POIFSDocument checkDocument(final POIFSFileSystem poifs, final int size) throws IOException {
         final byte[] input = new byte[size];
         IntStream.range(0, size).forEach(i -> input[i] = (byte)i);
 
-        NPOIFSDocument document = ((DocumentNode)poifs.createDocument(
+        POIFSDocument document = ((DocumentNode)poifs.createDocument(
             new SlowInputStream(new ByteArrayInputStream(input)),
         "entry"+poifs.getRoot().getEntryCount())).getDocument();
 
@@ -89,15 +89,15 @@ public class TestDocument {
         final int blockCount = (size + (blockSize-1)) / blockSize;
 
         final byte[] bytCpy = checkValues(blockCount, document, input);
-        final NPOIFSDocument copied = makeCopy(document,bytCpy);
+        final POIFSDocument copied = makeCopy(document,bytCpy);
 
         checkValues(blockCount, copied, input);
 
         return document;
     }
 
-    private static NPOIFSDocument makeCopy(NPOIFSDocument document, byte[] input) throws IOException {
-        NPOIFSFileSystem poifs = document.getFileSystem();
+    private static POIFSDocument makeCopy(POIFSDocument document, byte[] input) throws IOException {
+        POIFSFileSystem poifs = document.getFileSystem();
         String name = "test" + input.length;
         DirectoryNode root = poifs.getRoot();
         if (root.hasEntry(name)) {
@@ -108,7 +108,7 @@ public class TestDocument {
             .getDocument();
     }
 
-    private static byte[] checkValues(final int blockCountExp, NPOIFSDocument document, byte[] input) throws IOException {
+    private static byte[] checkValues(final int blockCountExp, POIFSDocument document, byte[] input) throws IOException {
         assertNotNull(document);
         assertNotNull(document.getDocumentProperty().getDocument());
         assertEquals(document, document.getDocumentProperty().getDocument());

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentInputStream.java Fri Aug 31 00:25:50 2018
@@ -59,7 +59,7 @@ public final class TestDocumentInputStre
         byte[] _workbook_data_only = new byte[_workbook_size];
         System.arraycopy(_workbook_data, 0, _workbook_data_only, 0, _workbook_size);
 
-        NPOIFSFileSystem npoifs = new NPOIFSFileSystem();
+        POIFSFileSystem npoifs = new POIFSFileSystem();
         // Make it easy when debugging to see what isn't the doc
         byte[] minus1 = new byte[512];
         Arrays.fill(minus1, (byte) -1);
@@ -79,7 +79,7 @@ public final class TestDocumentInputStre
      */
     @Test
     public void testConstructor() throws IOException {
-        try (DocumentInputStream nstream = new NDocumentInputStream(_workbook_n)) {
+        try (DocumentInputStream nstream = new DocumentInputStream(_workbook_n)) {
             assertEquals(_workbook_size, _workbook_n.getSize());
             assertEquals(_workbook_size, available(nstream));
         }
@@ -90,7 +90,7 @@ public final class TestDocumentInputStre
      */
     @Test(expected = IllegalStateException.class)
     public void testAvailable() throws IOException {
-        DocumentInputStream nstream = new NDocumentInputStream(_workbook_n);
+        DocumentInputStream nstream = new DocumentInputStream(_workbook_n);
         assertEquals(_workbook_size, available(nstream));
         nstream.close();
 
@@ -106,7 +106,7 @@ public final class TestDocumentInputStre
         byte[] buffer = new byte[_workbook_size / 5];
         byte[] small_buffer = new byte[212];
 
-        DocumentInputStream stream = new NDocumentInputStream(_workbook_n);
+        DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         // Read a fifth of it, and check all's correct
         stream.read(buffer);
         for (int j = 0; j < buffer.length; j++) {
@@ -184,7 +184,7 @@ public final class TestDocumentInputStre
         }
 
         // Now repeat it with spanning multiple blocks
-        stream = new NDocumentInputStream(_workbook_n);
+        stream = new DocumentInputStream(_workbook_n);
         // Read several blocks work
         buffer = new byte[_workbook_size / 5];
         stream.read(buffer);
@@ -239,7 +239,7 @@ public final class TestDocumentInputStre
     @SuppressWarnings("ResultOfMethodCallIgnored")
     @Test(expected = IOException.class)
     public void testReadSingleByte() throws IOException {
-        DocumentInputStream stream = new NDocumentInputStream(_workbook_n);
+        DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         int remaining = _workbook_size;
 
         // Try and read each byte in turn
@@ -267,7 +267,7 @@ public final class TestDocumentInputStre
     @SuppressWarnings("ResultOfMethodCallIgnored")
     @Test
     public void testBufferRead() throws IOException {
-        DocumentInputStream stream = new NDocumentInputStream(_workbook_n);
+        DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         // Need to give a byte array to read
         try {
             stream.read(null);
@@ -322,7 +322,7 @@ public final class TestDocumentInputStre
     @SuppressWarnings("ResultOfMethodCallIgnored")
     @Test
     public void testComplexBufferRead() throws IOException {
-        DocumentInputStream stream = new NDocumentInputStream(_workbook_n);
+        DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         try {
             stream.read(null, 0, 1);
             fail("Should have caught NullPointerException");
@@ -407,7 +407,7 @@ public final class TestDocumentInputStre
      */
     @Test
     public void testSkip() throws IOException {
-        DocumentInputStream stream = new NDocumentInputStream(_workbook_n);
+        DocumentInputStream stream = new DocumentInputStream(_workbook_n);
         assertEquals(_workbook_size, available(stream));
         int count = available(stream);
 
@@ -440,7 +440,7 @@ public final class TestDocumentInputStre
 
         DocumentInputStream stream;
 
-        try (NPOIFSFileSystem npoifs = new NPOIFSFileSystem(sample)) {
+        try (POIFSFileSystem npoifs = new POIFSFileSystem(sample)) {
             // Ensure we have what we expect on the root
             assertEquals(npoifs, npoifs.getRoot().getNFileSystem());
             assertEquals(npoifs, npoifs.getRoot().getFileSystem());

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDocumentOutputStream.java Fri Aug 31 00:25:50 2018
@@ -18,13 +18,13 @@
 
 package org.apache.poi.poifs.filesystem;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.fail;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.Arrays;
 
+import org.apache.poi.util.IOUtils;
 import org.junit.Test;
 
 /**
@@ -37,30 +37,28 @@ public final class TestDocumentOutputStr
      */
     @Test
     public void testWrite1() throws IOException {
-        ByteArrayOutputStream stream  = new ByteArrayOutputStream();
-        DocumentOutputStream  dstream = new DocumentOutputStream(stream, 25);
+        final byte[] expected = data(25);
 
-        for (int j = 0; j < 25; j++)
-        {
-            dstream.write(j);
-        }
-        try
-        {
-            dstream.write(0);
-            fail("Should have caught IOException");
-        }
-        catch (IOException ignored)
-        {
-        }
-        byte[] output = stream.toByteArray();
+        POIFSWriterListener l = (event) -> {
+            DocumentOutputStream dstream = event.getStream();
 
-        assertEquals(25, output.length);
-        for (int j = 0; j < 25; j++)
-        {
-            assertEquals(( byte ) j, output[ j ]);
-        }
-        dstream.close();
-        stream.close();
+            try {
+                for (byte b : expected) {
+                    dstream.write((int)b);
+                }
+            } catch (IOException ignored) {
+                fail("stream exhausted too early");
+            }
+
+            try {
+                dstream.write(0);
+                fail("Should have caught IOException");
+            }
+            catch (IOException ignored) {
+            }
+        };
+
+        compare(l, expected);
     }
 
     /**
@@ -68,40 +66,25 @@ public final class TestDocumentOutputStr
      */
     @Test
     public void testWrite2() throws IOException {
-        ByteArrayOutputStream stream  = new ByteArrayOutputStream();
-        DocumentOutputStream  dstream = new DocumentOutputStream(stream, 25);
+        final byte[] expected = data(24);
 
-        for (int j = 0; j < 6; j++)
-        {
-            byte[] array = new byte[ 4 ];
+        POIFSWriterListener l = (event) -> {
+            DocumentOutputStream dstream = event.getStream();
 
-            Arrays.fill(array, ( byte ) j);
-            dstream.write(array);
-        }
-        try
-        {
-            byte[] array = new byte[ 4 ];
-
-            Arrays.fill(array, ( byte ) 7);
-            dstream.write(array);
-            fail("Should have caught IOException");
-        }
-        catch (IOException ignored)
-        {
-        }
-        byte[] output = stream.toByteArray();
+            try {
+                dstream.write(expected);
+            } catch (IOException ignored) {
+                fail("stream exhausted too early");
+            }
 
-        assertEquals(24, output.length);
-        for (int j = 0; j < 6; j++)
-        {
-            for (int k = 0; k < 4; k++)
-            {
-                assertEquals(String.valueOf((j * 4) + k), ( byte ) j,
-                             output[ (j * 4) + k ]);
+            try {
+                dstream.write(new byte[]{'7','7','7','7'});
+                fail("Should have caught IOException");
+            } catch (IOException ignored) {
             }
-        }
-        dstream.close();
-        stream.close();
+        };
+
+        compare(l, expected);
     }
 
     /**
@@ -109,67 +92,45 @@ public final class TestDocumentOutputStr
      */
     @Test
     public void testWrite3() throws IOException {
-        ByteArrayOutputStream stream  = new ByteArrayOutputStream();
-        DocumentOutputStream  dstream = new DocumentOutputStream(stream, 25);
-        byte[]                array   = new byte[ 50 ];
-
-        for (int j = 0; j < 50; j++)
-        {
-            array[ j ] = ( byte ) j;
-        }
-        dstream.write(array, 1, 25);
-        try
-        {
-            dstream.write(array, 0, 1);
-            fail("Should have caught IOException");
-        }
-        catch (IOException ignored)
-        {
-        }
-        byte[] output = stream.toByteArray();
+        byte[] input = data(50);
+        byte[] expected = new byte[25];
+        System.arraycopy(input, 1, expected, 0, 25);
+
+        POIFSWriterListener l = (event) -> {
+            DocumentOutputStream dstream = event.getStream();
+            try {
+                dstream.write(input, 1, 25);
+            } catch (IOException ignored) {
+                fail("stream exhausted too early");
+            }
+            try {
+                dstream.write(input, 0, 1);
+                fail("Should have caught IOException");
+            }
+            catch (IOException ignored) {}
+        };
 
-        assertEquals(25, output.length);
-        for (int j = 0; j < 25; j++)
-        {
-            assertEquals(( byte ) (j + 1), output[ j ]);
-        }
-        dstream.close();
-        stream.close();
+        compare(l, expected);
     }
 
-    /**
-     * test writeFiller()
-     */
-    @Test
-    public void testWriteFiller() throws IOException {
-        ByteArrayOutputStream stream  = new ByteArrayOutputStream();
-        DocumentOutputStream  dstream = new DocumentOutputStream(stream, 25);
-
-        for (int j = 0; j < 25; j++)
-        {
-            dstream.write(j);
-        }
-        try
-        {
-            dstream.write(0);
-            fail("Should have caught IOException");
-        }
-        catch (IOException ignored)
-        {
+    private static byte[] data(int len) {
+        byte[] input = new byte[len];
+        for (int i = 0; i < len; i++) {
+            input[i] = (byte)('0' + (i%10));
         }
-        dstream.writeFiller(100, ( byte ) 0xff);
-        byte[] output = stream.toByteArray();
+        return input;
+    }
 
-        assertEquals(100, output.length);
-        for (int j = 0; j < 25; j++)
-        {
-            assertEquals(( byte ) j, output[ j ]);
-        }
-        for (int j = 25; j < 100; j++)
-        {
-            assertEquals(String.valueOf(j), ( byte ) 0xff, output[ j ]);
+    private void compare(POIFSWriterListener l, byte[] expected) throws IOException {
+        try (POIFSFileSystem poifs = new POIFSFileSystem()) {
+            DirectoryNode root = poifs.getRoot();
+            root.createDocument("foo", expected.length, l);
+
+            try (DocumentInputStream is = root.createDocumentInputStream("foo")) {
+                final ByteArrayOutputStream bos = new ByteArrayOutputStream(expected.length);
+                IOUtils.copy(is, bos);
+                assertArrayEquals(expected, bos.toByteArray());
+            }
         }
-        dstream.close();
-        stream.close();
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestEntryUtils.java Fri Aug 31 00:25:50 2018
@@ -18,7 +18,10 @@
 package org.apache.poi.poifs.filesystem;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -109,15 +112,15 @@ public class TestEntryUtils {
        
        
        // Names must match
-       assertEquals(false, entryA1.getName().equals(entryA1b.getName()));
-       assertEquals(false, EntryUtils.areDocumentsIdentical(entryA1, entryA1b));
+       assertNotEquals(entryA1.getName(), entryA1b.getName());
+       assertFalse(EntryUtils.areDocumentsIdentical(entryA1, entryA1b));
        
        // Contents must match
-       assertEquals(false, EntryUtils.areDocumentsIdentical(entryA1, entryA2));
+       assertFalse(EntryUtils.areDocumentsIdentical(entryA1, entryA2));
        
        // Parents don't matter if contents + names are the same
-       assertEquals(false, entryA1.getParent().equals(entryB1.getParent()));
-       assertEquals(true, EntryUtils.areDocumentsIdentical(entryA1, entryB1));
+       assertNotEquals(entryA1.getParent(), entryB1.getParent());
+       assertTrue(EntryUtils.areDocumentsIdentical(entryA1, entryB1));
        
        
        // Can work with NPOIFS + POIFS
@@ -125,22 +128,22 @@ public class TestEntryUtils {
        fs.writeFilesystem(tmpO);
        
        ByteArrayInputStream tmpI = new ByteArrayInputStream(tmpO.toByteArray());
-       NPOIFSFileSystem nfs = new NPOIFSFileSystem(tmpI);
+       POIFSFileSystem nfs = new POIFSFileSystem(tmpI);
        
        DirectoryEntry dN1 = (DirectoryEntry)nfs.getRoot().getEntry("DirA");
        DirectoryEntry dN2 = (DirectoryEntry)nfs.getRoot().getEntry("DirB");
        DocumentEntry eNA1 = (DocumentEntry)dN1.getEntry(entryA1.getName());
        DocumentEntry eNA2 = (DocumentEntry)dN1.getEntry(entryA2.getName());
        DocumentEntry eNB1 = (DocumentEntry)dN2.getEntry(entryB1.getName());
-       
-       assertEquals(false, EntryUtils.areDocumentsIdentical(eNA1, eNA2));
-       assertEquals(true, EntryUtils.areDocumentsIdentical(eNA1, eNB1));
-       
-       assertEquals(false, EntryUtils.areDocumentsIdentical(eNA1, entryA1b));
-       assertEquals(false, EntryUtils.areDocumentsIdentical(eNA1, entryA2));
-       
-       assertEquals(true, EntryUtils.areDocumentsIdentical(eNA1, entryA1));
-       assertEquals(true, EntryUtils.areDocumentsIdentical(eNA1, entryB1));
+
+       assertFalse(EntryUtils.areDocumentsIdentical(eNA1, eNA2));
+       assertTrue(EntryUtils.areDocumentsIdentical(eNA1, eNB1));
+
+       assertFalse(EntryUtils.areDocumentsIdentical(eNA1, entryA1b));
+       assertFalse(EntryUtils.areDocumentsIdentical(eNA1, entryA2));
+
+       assertTrue(EntryUtils.areDocumentsIdentical(eNA1, entryA1));
+       assertTrue(EntryUtils.areDocumentsIdentical(eNA1, entryB1));
        nfs.close();
        fs.close();
     }
@@ -152,56 +155,56 @@ public class TestEntryUtils {
        DirectoryEntry dirB = fs.createDirectory("DirB");
        
        // Names must match
-       assertEquals(false, EntryUtils.areDirectoriesIdentical(dirA, dirB));
+       assertFalse(EntryUtils.areDirectoriesIdentical(dirA, dirB));
        
        // Empty dirs are fine
        DirectoryEntry dirA1 = dirA.createDirectory("TheDir"); 
        DirectoryEntry dirB1 = dirB.createDirectory("TheDir");
        assertEquals(0, dirA1.getEntryCount());
        assertEquals(0, dirB1.getEntryCount());
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
+       assertTrue(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
        
        // Otherwise children must match
        dirA1.createDocument("Entry1", new ByteArrayInputStream(dataSmallA));
-       assertEquals(false, EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
+       assertFalse(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
        
        dirB1.createDocument("Entry1", new ByteArrayInputStream(dataSmallA));
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
+       assertTrue(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
        
        dirA1.createDirectory("DD");
-       assertEquals(false, EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
+       assertFalse(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
        dirB1.createDirectory("DD");
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
+       assertTrue(EntryUtils.areDirectoriesIdentical(dirA1, dirB1));
        
        
        // Excludes support
-       List<String> excl = Arrays.asList(new String[] {"Ignore1", "IgnDir/Ign2"});
+       List<String> excl = Arrays.asList("Ignore1", "IgnDir/Ign2");
        FilteringDirectoryNode fdA = new FilteringDirectoryNode(dirA1, excl);
        FilteringDirectoryNode fdB = new FilteringDirectoryNode(dirB1, excl);
-       
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+
+       assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        // Add an ignored doc, no notice is taken
        fdA.createDocument("Ignore1", new ByteArrayInputStream(dataSmallA));
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+       assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        // Add a directory with filtered contents, not the same
        DirectoryEntry dirAI = dirA1.createDirectory("IgnDir");
-       assertEquals(false, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+       assertFalse(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        DirectoryEntry dirBI = dirB1.createDirectory("IgnDir");
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+       assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        // Add something to the filtered subdir that gets ignored
        dirAI.createDocument("Ign2", new ByteArrayInputStream(dataSmallA));
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+       assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        // And something that doesn't
        dirAI.createDocument("IgnZZ", new ByteArrayInputStream(dataSmallA));
-       assertEquals(false, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+       assertFalse(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        dirBI.createDocument("IgnZZ", new ByteArrayInputStream(dataSmallA));
-       assertEquals(true, EntryUtils.areDirectoriesIdentical(fdA, fdB));
+       assertTrue(EntryUtils.areDirectoriesIdentical(fdA, fdB));
        
        fs.close();
     }

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestFileSystemBugs.java Fri Aug 31 00:25:50 2018
@@ -40,12 +40,12 @@ public final class TestFileSystemBugs {
     private static POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
     private static POIDataSamples _ssSamples = POIDataSamples.getSpreadSheetInstance();
 
-    private List<NPOIFSFileSystem> openedFSs;
+    private List<POIFSFileSystem> openedFSs;
 
     @After
     public void tearDown() {
         if (openedFSs != null && !openedFSs.isEmpty()) {
-            for (NPOIFSFileSystem fs : openedFSs) {
+            for (POIFSFileSystem fs : openedFSs) {
                 try {
                     fs.close();
                 } catch (Exception e) {
@@ -70,7 +70,7 @@ public final class TestFileSystemBugs {
     }
 
     private DirectoryNode openSample(InputStream inps) throws Exception {
-        NPOIFSFileSystem nfs = new NPOIFSFileSystem(inps);
+        POIFSFileSystem nfs = new POIFSFileSystem(inps);
         if (openedFSs == null) {
             openedFSs = new ArrayList<>();
         }
@@ -135,7 +135,7 @@ public final class TestFileSystemBugs {
         fetchSizes("/", root, entries);
 
         // Prepare to copy
-        DirectoryNode dest = new NPOIFSFileSystem().getRoot();
+        DirectoryNode dest = new POIFSFileSystem().getRoot();
 
         // Copy over
         EntryUtils.copyNodes(root, dest);
@@ -144,7 +144,7 @@ public final class TestFileSystemBugs {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         root.getNFileSystem().writeFilesystem(baos);
 
-        NPOIFSFileSystem read = new NPOIFSFileSystem(
+        POIFSFileSystem read = new POIFSFileSystem(
                 new ByteArrayInputStream(baos.toByteArray()));
 
         // Check the structure matches

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java Fri Aug 31 00:25:50 2018
@@ -17,12 +17,11 @@
 
 package org.apache.poi.poifs.filesystem;
 
+import static org.apache.poi.POITestCase.assertContains;
 import static org.hamcrest.core.IsEqual.equalTo;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.apache.poi.POITestCase.assertContains;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -34,7 +33,6 @@ import java.util.List;
 
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.util.IOUtils;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class TestOle10Native {
@@ -63,9 +61,9 @@ public class TestOle10Native {
         };
         
         for (File f : files) {
-            NPOIFSFileSystem fs = new NPOIFSFileSystem(f, true);
+            POIFSFileSystem fs = new POIFSFileSystem(f, true);
             List<Entry> entries = new ArrayList<>();
-            findOle10(entries, fs.getRoot(), "/", "");
+            findOle10(entries, fs.getRoot(), "/");
             
             for (Entry e : entries) {
                 ByteArrayOutputStream bosExp = new ByteArrayOutputStream();
@@ -85,21 +83,7 @@ public class TestOle10Native {
         }
     }
 
-    /*
-    void searchOle10Files() throws Exception {
-        File dir = new File("test-data/document");
-        for (File file : dir.listFiles(new FileFilter(){
-            public boolean accept(File pathname) {
-                return pathname.getName().endsWith("doc");
-            }
-        })) {
-            NPOIFSFileSystem fs = new NPOIFSFileSystem(file, true);
-            findOle10(null, fs.getRoot(), "/", file.getName());
-            fs.close();
-        }
-    }*/
-    
-    void findOle10(List<Entry> entries, DirectoryNode dn, String path, String filename) {
+    private void findOle10(List<Entry> entries, DirectoryNode dn, String path) {
         Iterator<Entry> iter = dn.getEntries();
         while (iter.hasNext()) {
             Entry e = iter.next();
@@ -107,13 +91,13 @@ public class TestOle10Native {
                 if (entries != null) entries.add(e);
                 // System.out.println(filename+" : "+path);
             } else if (e.isDirectoryEntry()) {
-                findOle10(entries, (DirectoryNode)e, path+e.getName()+"/", filename);
+                findOle10(entries, (DirectoryNode)e, path+e.getName()+"/");
             }
         }
     }
 
     @Test
-    public void testOleNativeOOM() throws IOException, Ole10NativeException {
+    public void testOleNativeOOM() throws IOException {
         POIFSFileSystem fs = new POIFSFileSystem(dataSamples.openResourceAsStream("60256.bin"));
         try {
             Ole10Native.createFromEmbeddedOleObject(fs);

Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java?rev=1839709&r1=1839708&r2=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java Fri Aug 31 00:25:50 2018
@@ -32,9 +32,7 @@ import org.apache.poi.hssf.HSSFTestDataS
 import org.apache.poi.poifs.common.POIFSBigBlockSize;
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.poifs.storage.BATBlock;
-import org.apache.poi.poifs.storage.BlockAllocationTableReader;
 import org.apache.poi.poifs.storage.HeaderBlock;
-import org.apache.poi.poifs.storage.RawDataBlockList;
 import org.apache.poi.util.IOUtils;
 import org.junit.Rule;
 import org.junit.Test;
@@ -113,13 +111,13 @@ public final class TestPOIFSFileSystem {
 
 		// Normal case - read until EOF and close
 		testIS = new TestIS(openSampleStream("13224.xls"), -1);
-		try (NPOIFSFileSystem ignored = new NPOIFSFileSystem(testIS)){
+		try (POIFSFileSystem ignored = new POIFSFileSystem(testIS)){
 			assertTrue("input stream was not closed", testIS.isClosed());
 		}
 
 		// intended to crash after reading 10000 bytes
 		testIS = new TestIS(openSampleStream("13224.xls"), 10000);
-		try (NPOIFSFileSystem ignored = new NPOIFSFileSystem(testIS)){
+		try (POIFSFileSystem ignored = new POIFSFileSystem(testIS)){
 			fail("ex should have been thrown");
 		} catch (MyEx e) {
 			// expected
@@ -148,7 +146,7 @@ public final class TestPOIFSFileSystem {
 
 		for (String file : files) {
 			// Open the file up
-			NPOIFSFileSystem fs = new NPOIFSFileSystem(
+			POIFSFileSystem fs = new POIFSFileSystem(
 			    _samples.openResourceAsStream(file)
 			);
 
@@ -174,7 +172,7 @@ public final class TestPOIFSFileSystem {
 		expectedEx.expect(IndexOutOfBoundsException.class);
 		expectedEx.expectMessage("Block 1148 not found");
 		try (InputStream stream = _samples.openResourceAsStream("ReferencesInvalidSectors.mpp")) {
-			new NPOIFSFileSystem(stream);
+			new POIFSFileSystem(stream);
 			fail("File is corrupt and shouldn't have been opened");
 		}
 	}
@@ -188,7 +186,7 @@ public final class TestPOIFSFileSystem {
 	@Test
 	public void testBATandXBAT() throws Exception {
 	   byte[] hugeStream = new byte[8*1024*1024];
-	   NPOIFSFileSystem fs = new NPOIFSFileSystem();
+	   POIFSFileSystem fs = new POIFSFileSystem();
 	   fs.getRoot().createDocument(
 	         "BIG", new ByteArrayInputStream(hugeStream)
 	   );
@@ -219,19 +217,8 @@ public final class TestPOIFSFileSystem {
 	   assertEquals(POIFSConstants.END_OF_CHAIN, xbat.getValueAt(127));
 	   
 	   
-	   // Load the blocks and check with that
-	   RawDataBlockList blockList = new RawDataBlockList(inp, POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS);
-	   assertEquals(fsData.length / 512, blockList.blockCount() + 1); // Header not counted
-	   new BlockAllocationTableReader(header.getBigBlockSize(),
-            header.getBATCount(),
-            header.getBATArray(),
-            header.getXBATCount(),
-            header.getXBATIndex(),
-            blockList);
-      assertEquals(fsData.length / 512, blockList.blockCount() + 1); // Header not counted
-      
 	   // Now load it and check
-	   fs = new NPOIFSFileSystem(
+	   fs = new POIFSFileSystem(
 	         new ByteArrayInputStream(fsData)
 	   );
 	   
@@ -259,13 +246,8 @@ public final class TestPOIFSFileSystem {
 			assertEquals(1, header_block.getBATCount());
 			assertEquals(0, header_block.getXBATCount());
 
-			// Now check we can get the basic fat
-			RawDataBlockList data_blocks = new RawDataBlockList(inp,
-					bigBlockSize);
-			assertEquals(15, data_blocks.blockCount());
-
 			// Now try and open properly
-			NPOIFSFileSystem fs = new NPOIFSFileSystem(
+			POIFSFileSystem fs = new POIFSFileSystem(
 					_samples.openResourceAsStream("BlockSize4096.zvi"));
 			assertTrue(fs.getRoot().getEntryCount() > 3);
 
@@ -273,7 +255,7 @@ public final class TestPOIFSFileSystem {
 			checkAllDirectoryContents(fs.getRoot());
 
 			// Finally, check we can do a similar 512byte one too
-			fs = new NPOIFSFileSystem(
+			fs = new POIFSFileSystem(
 					_samples.openResourceAsStream("BlockSize512.zvi"));
 			assertTrue(fs.getRoot().getEntryCount() > 3);
 			checkAllDirectoryContents(fs.getRoot());

Copied: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java (from r1839708, poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java)
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java?p2=poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java&p1=poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java&r1=1839708&r2=1839709&rev=1839709&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSMiniStore.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSMiniStore.java Fri Aug 31 00:25:50 2018
@@ -19,6 +19,8 @@ package org.apache.poi.poifs.filesystem;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
@@ -33,7 +35,8 @@ import org.junit.Test;
 /**
  * Tests for the Mini Store in the NIO POIFS
  */
-public final class TestNPOIFSMiniStore {
+@SuppressWarnings("CatchMayIgnoreException")
+public final class TestPOIFSMiniStore {
    private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
    
    /**
@@ -43,12 +46,12 @@ public final class TestNPOIFSMiniStore {
    @Test
    public void testNextBlock() throws Exception {
       // It's the same on 512 byte and 4096 byte block files!
-      NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
-      NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
-      NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
-      NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
-      for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB,fsC,fsD}) {
-         NPOIFSMiniStore ministore = fs.getMiniStore();
+      POIFSFileSystem fsA = new POIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      POIFSFileSystem fsB = new POIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      POIFSFileSystem fsC = new POIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
+      POIFSFileSystem fsD = new POIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
+      for(POIFSFileSystem fs : new POIFSFileSystem[] {fsA,fsB,fsC,fsD}) {
+         POIFSMiniStore ministore = fs.getMiniStore();
          
          // 0 -> 51 is one stream
          for(int i=0; i<50; i++) {
@@ -121,16 +124,16 @@ public final class TestNPOIFSMiniStore {
    @Test
    public void testGetBlock() throws Exception {
       // It's the same on 512 byte and 4096 byte block files!
-      NPOIFSFileSystem fsA = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
-      NPOIFSFileSystem fsB = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
-      NPOIFSFileSystem fsC = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
-      NPOIFSFileSystem fsD = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
-      for(NPOIFSFileSystem fs : new NPOIFSFileSystem[] {fsA,fsB,fsC,fsD}) {
+      POIFSFileSystem fsA = new POIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      POIFSFileSystem fsB = new POIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      POIFSFileSystem fsC = new POIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
+      POIFSFileSystem fsD = new POIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
+      for(POIFSFileSystem fs : new POIFSFileSystem[] {fsA,fsB,fsC,fsD}) {
          // Mini stream should be at big block zero
          assertEquals(0, fs._get_property_table().getRoot().getStartBlock());
          
          // Grab the ministore
-         NPOIFSMiniStore ministore = fs.getMiniStore();
+         POIFSMiniStore ministore = fs.getMiniStore();
          ByteBuffer b;
          
          // Runs from the start of the data section in 64 byte chungs
@@ -191,12 +194,12 @@ public final class TestNPOIFSMiniStore {
     */
    @Test
    public void testGetFreeBlockWithSpare() throws Exception {
-      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
-      NPOIFSMiniStore ministore = fs.getMiniStore();
+      POIFSFileSystem fs = new POIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      POIFSMiniStore ministore = fs.getMiniStore();
       
       // Our 2nd SBAT block has spares
-      assertEquals(false, ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
-      assertEquals(true,  ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
+      assertFalse(ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
+      assertTrue(ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
       
       // First free one at 181
       assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(181));
@@ -223,8 +226,8 @@ public final class TestNPOIFSMiniStore {
     */
    @Test
    public void testGetFreeBlockWithNoneSpare() throws Exception {
-      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
-      NPOIFSMiniStore ministore = fs.getMiniStore();
+      POIFSFileSystem fs = new POIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      POIFSMiniStore ministore = fs.getMiniStore();
       
       // We've spare ones from 181 to 255
       for(int i=181; i<256; i++) {
@@ -232,8 +235,8 @@ public final class TestNPOIFSMiniStore {
       }
       
       // Check our SBAT free stuff is correct
-      assertEquals(false, ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
-      assertEquals(true,  ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
+      assertFalse(ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
+      assertTrue(ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
       
       // Allocate all the spare ones
       for(int i=181; i<256; i++) {
@@ -241,19 +244,19 @@ public final class TestNPOIFSMiniStore {
       }
       
       // SBAT are now full, but there's only the two
-      assertEquals(false, ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
-      assertEquals(false, ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
+      assertFalse(ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
+      assertFalse(ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
       try {
-         assertEquals(false, ministore.getBATBlockAndIndex(256).getBlock().hasFreeSectors());
+         assertFalse(ministore.getBATBlockAndIndex(256).getBlock().hasFreeSectors());
          fail("Should only be two SBATs");
       } catch(IndexOutOfBoundsException e) {}
       
       // Now ask for a free one, will need to extend the SBAT chain
       assertEquals(256, ministore.getFreeBlock());
-      
-      assertEquals(false, ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
-      assertEquals(false, ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
-      assertEquals(true, ministore.getBATBlockAndIndex(256).getBlock().hasFreeSectors());
+
+      assertFalse(ministore.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
+      assertFalse(ministore.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
+      assertTrue(ministore.getBATBlockAndIndex(256).getBlock().hasFreeSectors());
       assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(254)); // 2nd SBAT 
       assertEquals(POIFSConstants.END_OF_CHAIN, ministore.getNextBlock(255)); // 2nd SBAT
       assertEquals(POIFSConstants.UNUSED_BLOCK, ministore.getNextBlock(256)); // 3rd SBAT
@@ -268,8 +271,8 @@ public final class TestNPOIFSMiniStore {
     */
    @Test
    public void testCreateBlockIfNeeded() throws Exception {
-      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
-      NPOIFSMiniStore ministore = fs.getMiniStore();
+      POIFSFileSystem fs = new POIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      POIFSMiniStore ministore = fs.getMiniStore();
       
       // 178 -> 179 -> 180, 181+ is free
       assertEquals(179                        , ministore.getNextBlock(178));
@@ -289,7 +292,7 @@ public final class TestNPOIFSMiniStore {
       } catch(IndexOutOfBoundsException e) {}
       
       // The ministore itself is made up of 23 big blocks
-      Iterator<ByteBuffer> it = new NPOIFSStream(fs, fs.getRoot().getProperty().getStartBlock()).getBlockIterator();
+      Iterator<ByteBuffer> it = new POIFSStream(fs, fs.getRoot().getProperty().getStartBlock()).getBlockIterator();
       int count = 0;
       while(it.hasNext()) {
          count++;
@@ -301,7 +304,7 @@ public final class TestNPOIFSMiniStore {
       ministore.createBlockIfNeeded(184);
       
       // The ministore should be one big block bigger now
-      it = new NPOIFSStream(fs, fs.getRoot().getProperty().getStartBlock()).getBlockIterator();
+      it = new POIFSStream(fs, fs.getRoot().getProperty().getStartBlock()).getBlockIterator();
       count = 0;
       while(it.hasNext()) {
          count++;
@@ -321,7 +324,7 @@ public final class TestNPOIFSMiniStore {
       
       // Now try writing through to 192, check that the SBAT and blocks are there
       byte[] data = new byte[15*64];
-      NPOIFSStream stream = new NPOIFSStream(ministore, 178);
+      POIFSStream stream = new POIFSStream(ministore, 178);
       stream.updateContents(data);
       
       // Check now
@@ -349,8 +352,8 @@ public final class TestNPOIFSMiniStore {
    
    @Test
    public void testCreateMiniStoreFirst() throws Exception {
-       NPOIFSFileSystem fs = new NPOIFSFileSystem();
-       NPOIFSMiniStore ministore = fs.getMiniStore();
+       POIFSFileSystem fs = new POIFSFileSystem();
+       POIFSMiniStore ministore = fs.getMiniStore();
        DocumentInputStream dis;
        DocumentEntry entry;
 
@@ -426,8 +429,7 @@ public final class TestNPOIFSMiniStore {
        }
        
        // New filesystem and store to use
-       NPOIFSFileSystem fs = new NPOIFSFileSystem();
-       NPOIFSMiniStore ministore = fs.getMiniStore();
+       POIFSFileSystem fs = new POIFSFileSystem();
 
        // Initially has Properties + BAT but nothing else
        assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(0));
@@ -436,7 +438,7 @@ public final class TestNPOIFSMiniStore {
        
        // Store the 2 block one, should use 2 mini blocks, and request
        // the use of 2 big blocks
-       ministore = fs.getMiniStore();
+       POIFSMiniStore ministore = fs.getMiniStore();
        fs.getRoot().createDocument("mini2", new ByteArrayInputStream(data2B));
        
        // Check



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


Mime
View raw message