You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2017/06/06 22:21:41 UTC

svn commit: r1797838 - in /poi/trunk/src/scratchpad: src/org/apache/poi/hwpf/model/ src/org/apache/poi/hwpf/model/io/ testcases/org/apache/poi/hwpf/model/ testcases/org/apache/poi/hwpf/usermodel/

Author: kiwiwings
Date: Tue Jun  6 22:21:40 2017
New Revision: 1797838

URL: http://svn.apache.org/viewvc?rev=1797838&view=rev
Log:
Replace HWPFOutputStream with ByteArrayOutputStream - it doesn't add any new features

Removed:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFOutputStream.java
Modified:
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/BookmarksTables.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/LFOData.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NotesTables.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SttbUtils.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestBugs.java

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/BookmarksTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/BookmarksTables.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/BookmarksTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/BookmarksTables.java Tue Jun  6 22:21:40 2017
@@ -16,12 +16,12 @@
 ==================================================================== */
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -148,7 +148,7 @@ public class BookmarksTables
     }
 
     public void writePlcfBkmkf( FileInformationBlock fib,
-            HWPFOutputStream tableStream ) throws IOException
+            ByteArrayOutputStream tableStream ) throws IOException
     {
         if ( descriptorsFirst == null || descriptorsFirst.length() == 0 )
         {
@@ -157,16 +157,16 @@ public class BookmarksTables
             return;
         }
 
-        int start = tableStream.getOffset();
+        int start = tableStream.size();
         tableStream.write( descriptorsFirst.toByteArray() );
-        int end = tableStream.getOffset();
+        int end = tableStream.size();
 
         fib.setFcPlcfbkf( start );
         fib.setLcbPlcfbkf( end - start );
     }
 
     public void writePlcfBkmkl( FileInformationBlock fib,
-            HWPFOutputStream tableStream ) throws IOException
+            ByteArrayOutputStream tableStream ) throws IOException
     {
         if ( descriptorsLim == null || descriptorsLim.length() == 0 )
         {
@@ -175,16 +175,16 @@ public class BookmarksTables
             return;
         }
 
-        int start = tableStream.getOffset();
+        int start = tableStream.size();
         tableStream.write( descriptorsLim.toByteArray() );
-        int end = tableStream.getOffset();
+        int end = tableStream.size();
 
         fib.setFcPlcfbkl( start );
         fib.setLcbPlcfbkl( end - start );
     }
 
     public void writeSttbfBkmk( FileInformationBlock fib,
-            HWPFOutputStream tableStream ) throws IOException
+            ByteArrayOutputStream tableStream ) throws IOException
     {
         if ( names == null || names.isEmpty() )
         {
@@ -193,10 +193,10 @@ public class BookmarksTables
             return;
         }
 
-        int start = tableStream.getOffset();
+        int start = tableStream.size();
         SttbUtils.writeSttbfBkmk( names.toArray( new String[names.size()] ),
                 tableStream );
-        int end = tableStream.getOffset();
+        int end = tableStream.size();
 
         fib.setFcSttbfbkmk( start );
         fib.setLcbSttbfbkmk( end - start );

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/CHPBinTable.java Tue Jun  6 22:21:40 2017
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -31,7 +32,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 import org.apache.poi.hwpf.sprm.SprmIterator;
 import org.apache.poi.hwpf.sprm.SprmOperation;
@@ -448,14 +448,14 @@ public class CHPBinTable
     public void writeTo( HWPFFileSystem sys, int fcMin,
             CharIndexTranslator translator ) throws IOException
     {
-        HWPFOutputStream docStream = sys.getStream( "WordDocument" );
-        HWPFOutputStream tableStream = sys.getStream( "1Table" );
+        ByteArrayOutputStream docStream = sys.getStream( "WordDocument" );
+        ByteArrayOutputStream tableStream = sys.getStream( "1Table" );
 
         writeTo( docStream, tableStream, fcMin, translator );
     }
 
-    public void writeTo( HWPFOutputStream wordDocumentStream,
-            HWPFOutputStream tableStream, int fcMin,
+    public void writeTo( ByteArrayOutputStream wordDocumentStream,
+            ByteArrayOutputStream tableStream, int fcMin,
             CharIndexTranslator translator ) throws IOException
     {
 
@@ -470,7 +470,7 @@ public class CHPBinTable
         PlexOfCps bte = new PlexOfCps( 4 );
 
     // each FKP must start on a 512 byte page.
-    int docOffset = wordDocumentStream.getOffset();
+    int docOffset = wordDocumentStream.size();
     int mod = docOffset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
     if (mod != 0)
     {
@@ -479,7 +479,7 @@ public class CHPBinTable
     }
 
     // get the page number for the first fkp
-    docOffset = wordDocumentStream.getOffset();
+    docOffset = wordDocumentStream.size();
     int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
 
         // get the ending fc

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java Tue Jun  6 22:21:40 2017
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.charset.Charset;
 import java.util.LinkedList;
 import java.util.List;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
@@ -82,14 +82,14 @@ public class ComplexFileTable {
 
     @Deprecated
     public void writeTo(HWPFFileSystem sys) throws IOException {
-        HWPFOutputStream docStream = sys.getStream("WordDocument");
-        HWPFOutputStream tableStream = sys.getStream("1Table");
+        ByteArrayOutputStream docStream = sys.getStream("WordDocument");
+        ByteArrayOutputStream tableStream = sys.getStream("1Table");
 
         writeTo(docStream, tableStream);
     }
 
-    public void writeTo(HWPFOutputStream wordDocumentStream,
-                        HWPFOutputStream tableStream) throws IOException {
+    public void writeTo(ByteArrayOutputStream wordDocumentStream,
+                        ByteArrayOutputStream tableStream) throws IOException {
         tableStream.write(TEXT_PIECE_TABLE_TYPE);
 
         byte[] table = _tpt.writeTo(wordDocumentStream);

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/DocumentProperties.java Tue Jun  6 22:21:40 2017
@@ -17,9 +17,9 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.hwpf.model.types.DOPAbstractType;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
@@ -65,7 +65,7 @@ public final class DocumentProperties ex
         super.serialize( data, offset );
     }
 
-    public void writeTo( HWPFOutputStream tableStream ) throws IOException
+    public void writeTo( ByteArrayOutputStream tableStream ) throws IOException
     {
         byte[] supported = new byte[getSize()];
         serialize( supported, 0 );

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java Tue Jun  6 22:21:40 2017
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
@@ -223,7 +223,7 @@ public final class FIBFieldHandler
       return _fields.length / 2;
   }
   
-  void writeTo(byte[] mainStream, int offset, HWPFOutputStream tableStream)
+  void writeTo(byte[] mainStream, int offset, ByteArrayOutputStream tableStream)
     throws IOException
   {
     for (int x = 0; x < _fields.length/2; x++)
@@ -231,8 +231,8 @@ public final class FIBFieldHandler
       UnhandledDataStructure ds = _unknownMap.get(Integer.valueOf(x));
       if (ds != null)
       {
-        _fields[x * 2] = tableStream.getOffset();
-        LittleEndian.putInt(mainStream, offset, tableStream.getOffset());
+        _fields[x * 2] = tableStream.size();
+        LittleEndian.putInt(mainStream, offset, tableStream.size());
         offset += LittleEndian.INT_SIZE;
 
         byte[] buf = ds.getBuf();

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FieldsTables.java Tue Jun  6 22:21:40 2017
@@ -19,12 +19,12 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 
 /**
@@ -131,19 +131,19 @@ public class FieldsTables
     }
 
     private int savePlex( FileInformationBlock fib, FieldsDocumentPart part,
-            PlexOfCps plexOfCps, HWPFOutputStream outputStream )
+            PlexOfCps plexOfCps, ByteArrayOutputStream outputStream )
             throws IOException
     {
         if ( plexOfCps == null || plexOfCps.length() == 0 )
         {
-            fib.setFieldsPlcfOffset( part, outputStream.getOffset() );
+            fib.setFieldsPlcfOffset( part, outputStream.size() );
             fib.setFieldsPlcfLength( part, 0 );
             return 0;
         }
 
         byte[] data = plexOfCps.toByteArray();
 
-        int start = outputStream.getOffset();
+        int start = outputStream.size();
         int length = data.length;
 
         outputStream.write( data );
@@ -154,7 +154,7 @@ public class FieldsTables
         return length;
     }
 
-    public void write( FileInformationBlock fib, HWPFOutputStream tableStream )
+    public void write( FileInformationBlock fib, ByteArrayOutputStream tableStream )
             throws IOException
     {
         for ( FieldsDocumentPart part : FieldsDocumentPart.values() )

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FileInformationBlock.java Tue Jun  6 22:21:40 2017
@@ -17,14 +17,13 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.HashSet;
 import java.util.Locale;
 
-import org.apache.poi.EncryptedDocumentException;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
@@ -67,12 +66,6 @@ public final class FileInformationBlock
         offset = FibBase.getSize();
         assert offset == 32;
 
-        if ( _fibBase.isFEncrypted() )
-        {
-            throw new EncryptedDocumentException(
-                    "Cannot process encrypted word file" );
-        }
-
         _csw = LittleEndian.getUShort( mainDocument, offset );
         offset += LittleEndian.SHORT_SIZE;
         assert offset == 34;
@@ -1074,7 +1067,7 @@ public final class FileInformationBlock
                 offset );
     }
 
-    public void writeTo( byte[] mainStream, HWPFOutputStream tableStream )
+    public void writeTo( byte[] mainStream, ByteArrayOutputStream tableStream )
             throws IOException
     {
         _cbRgFcLcb = _fieldHandler.getFieldsCount();

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FontTable.java Tue Jun  6 22:21:40 2017
@@ -17,10 +17,10 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
@@ -118,11 +118,11 @@ public final class FontTable
     @Deprecated
     public void writeTo( HWPFFileSystem sys ) throws IOException
     {
-        HWPFOutputStream tableStream = sys.getStream( "1Table" );
+        ByteArrayOutputStream tableStream = sys.getStream( "1Table" );
         writeTo( tableStream );
     }
 
-    public void writeTo( HWPFOutputStream tableStream ) throws IOException
+    public void writeTo( ByteArrayOutputStream tableStream ) throws IOException
     {
         byte[] buf = new byte[LittleEndian.SHORT_SIZE];
         LittleEndian.putShort(buf, 0, _stringCount);

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/LFOData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/LFOData.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/LFOData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/LFOData.java Tue Jun  6 22:21:40 2017
@@ -18,10 +18,10 @@
  */
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 
@@ -80,7 +80,7 @@ public class LFOData
         return result;
     }
 
-    void writeTo( HWPFOutputStream tableStream ) throws IOException
+    void writeTo( ByteArrayOutputStream tableStream ) throws IOException
     {
         LittleEndian.putInt( _cp, tableStream );
         for ( ListFormatOverrideLevel lfolvl : _rgLfoLvl )

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java Tue Jun  6 22:21:40 2017
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.util.LinkedHashMap;
 import java.util.NoSuchElementException;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
@@ -81,9 +80,9 @@ public final class ListTables
     }
 
     public void writeListDataTo( FileInformationBlock fib,
-            HWPFOutputStream tableStream ) throws IOException
+            ByteArrayOutputStream tableStream ) throws IOException
     {
-        final int startOffset = tableStream.getOffset();
+        final int startOffset = tableStream.size();
         fib.setFcPlfLst( startOffset );
 
     int listSize = _listMap.size();
@@ -109,12 +108,12 @@ public final class ListTables
          * account for the array of LVLs. -- Page 76 of 621 -- [MS-DOC] --
          * v20110315 Word (.doc) Binary File Format
          */
-        fib.setLcbPlfLst( tableStream.getOffset() - startOffset );
+        fib.setLcbPlfLst( tableStream.size() - startOffset );
         tableStream.write( levelBuf.toByteArray() );
     }
 
     public void writeListOverridesTo( FileInformationBlock fib,
-            HWPFOutputStream tableStream ) throws IOException
+            ByteArrayOutputStream tableStream ) throws IOException
     {
         _plfLfo.writeTo( fib, tableStream );
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NotesTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NotesTables.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NotesTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NotesTables.java Tue Jun  6 22:21:40 2017
@@ -16,9 +16,9 @@
 ==================================================================== */
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 
 /**
@@ -82,37 +82,37 @@ public class NotesTables
                     textPositionsStart, textPositionsLength, 0 );
     }
 
-    public void writeRef( FileInformationBlock fib, HWPFOutputStream tableStream )
+    public void writeRef( FileInformationBlock fib, ByteArrayOutputStream tableStream )
             throws IOException
     {
         if ( descriptors == null || descriptors.length() == 0 )
         {
-            fib.setNotesDescriptorsOffset( noteType, tableStream.getOffset() );
+            fib.setNotesDescriptorsOffset( noteType, tableStream.size() );
             fib.setNotesDescriptorsSize( noteType, 0 );
             return;
         }
 
-        int start = tableStream.getOffset();
+        int start = tableStream.size();
         tableStream.write( descriptors.toByteArray() );
-        int end = tableStream.getOffset();
+        int end = tableStream.size();
 
         fib.setNotesDescriptorsOffset( noteType, start );
         fib.setNotesDescriptorsSize( noteType, end - start );
     }
 
-    public void writeTxt( FileInformationBlock fib, HWPFOutputStream tableStream )
+    public void writeTxt( FileInformationBlock fib, ByteArrayOutputStream tableStream )
             throws IOException
     {
         if ( textPositions == null || textPositions.length() == 0 )
         {
-            fib.setNotesTextPositionsOffset( noteType, tableStream.getOffset() );
+            fib.setNotesTextPositionsOffset( noteType, tableStream.size() );
             fib.setNotesTextPositionsSize( noteType, 0 );
             return;
         }
 
-        int start = tableStream.getOffset();
+        int start = tableStream.size();
         tableStream.write( textPositions.toByteArray() );
-        int end = tableStream.getOffset();
+        int end = tableStream.size();
 
         fib.setNotesTextPositionsOffset( noteType, start );
         fib.setNotesTextPositionsSize( noteType, end - start );

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java Tue Jun  6 22:21:40 2017
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -26,7 +27,6 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
 import org.apache.poi.hwpf.sprm.SprmIterator;
 import org.apache.poi.hwpf.sprm.SprmOperation;
@@ -386,15 +386,15 @@ public class PAPBinTable
         return _paragraphs;
     }
 
-    public void writeTo( HWPFOutputStream wordDocumentStream,
-            HWPFOutputStream tableStream, CharIndexTranslator translator )
+    public void writeTo( ByteArrayOutputStream wordDocumentStream,
+            ByteArrayOutputStream tableStream, CharIndexTranslator translator )
             throws IOException
     {
 
         PlexOfCps binTable = new PlexOfCps(4);
     
         // each FKP must start on a 512 byte page.
-        int docOffset = wordDocumentStream.getOffset();
+        int docOffset = wordDocumentStream.size();
         int mod = docOffset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
         if (mod != 0)
         {
@@ -403,7 +403,7 @@ public class PAPBinTable
         }
     
         // get the page number for the first fkp
-        docOffset = wordDocumentStream.getOffset();
+        docOffset = wordDocumentStream.size();
         int pageNum = docOffset/POIFSConstants.SMALLER_BIG_BLOCK_SIZE;
     
         // get the ending fc

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PAPFormattedDiskPage.java Tue Jun  6 22:21:40 2017
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 
@@ -182,7 +182,7 @@ public final class PAPFormattedDiskPage
      * @throws IOException
      *             if an I/O error occurs.
      */
-    protected byte[] toByteArray( HWPFOutputStream dataStream,
+    protected byte[] toByteArray( ByteArrayOutputStream dataStream,
             CharIndexTranslator translator ) throws IOException
     {
         byte[] buf = new byte[512];
@@ -296,7 +296,7 @@ public final class PAPFormattedDiskPage
 
                 byte[] hugePapx = new byte[grpprl.length - 2];
                 System.arraycopy( grpprl, 2, hugePapx, 0, grpprl.length - 2 );
-                int dataStreamOffset = dataStream.getOffset();
+                int dataStreamOffset = dataStream.size();
                 dataStream.write( hugePapx );
 
                 // grpprl = grpprl containing only a sprmPHugePapx2

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java Tue Jun  6 22:21:40 2017
@@ -18,11 +18,11 @@
  */
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.NoSuchElementException;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -202,10 +202,10 @@ public class PlfLfo
         return result;
     }
 
-    void writeTo( FileInformationBlock fib, HWPFOutputStream outputStream )
+    void writeTo( FileInformationBlock fib, ByteArrayOutputStream outputStream )
             throws IOException
     {
-        final int offset = outputStream.getOffset();
+        final int offset = outputStream.size();
         fib.setFcPlfLfo( offset );
 
         LittleEndian.putUInt( _lfoMac, outputStream );
@@ -221,6 +221,6 @@ public class PlfLfo
         {
             _rgLfoData[i].writeTo( outputStream );
         }
-        fib.setLcbPlfLfo( outputStream.getOffset() - offset );
+        fib.setLcbPlfLfo( outputStream.size() - offset );
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/RevisionMarkAuthorTable.java Tue Jun  6 22:21:40 2017
@@ -17,12 +17,12 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 
 /**
@@ -88,7 +88,7 @@ public final class RevisionMarkAuthorTab
 	 * @param tableStream  the table stream to write to.
 	 * @throws IOException  if an error occurs while writing.
 	 */
-    public void writeTo( HWPFOutputStream tableStream ) throws IOException
+    public void writeTo( ByteArrayOutputStream tableStream ) throws IOException
     {
         SttbUtils.writeSttbfRMark( entries, tableStream );
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SavedByTable.java Tue Jun  6 22:21:40 2017
@@ -16,12 +16,12 @@
 ==================================================================== */
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 
 /**
@@ -77,7 +77,7 @@ public final class SavedByTable
      * @throws IOException
      *             if an error occurs while writing.
      */
-    public void writeTo( HWPFOutputStream tableStream ) throws IOException
+    public void writeTo( ByteArrayOutputStream tableStream ) throws IOException
     {
         String[] toSave = new String[entries.length * 2];
         int counter = 0;

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SectionTable.java Tue Jun  6 22:21:40 2017
@@ -17,13 +17,13 @@
 
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
@@ -168,18 +168,18 @@ public class SectionTable
     @Deprecated
     public void writeTo( HWPFFileSystem sys, int fcMin ) throws IOException
     {
-        HWPFOutputStream docStream = sys.getStream( "WordDocument" );
-        HWPFOutputStream tableStream = sys.getStream( "1Table" );
+        ByteArrayOutputStream docStream = sys.getStream( "WordDocument" );
+        ByteArrayOutputStream tableStream = sys.getStream( "1Table" );
 
         writeTo( docStream, tableStream );
     }
 
     public void writeTo(
-            HWPFOutputStream wordDocumentStream,
-            HWPFOutputStream tableStream ) throws IOException
+            ByteArrayOutputStream wordDocumentStream,
+            ByteArrayOutputStream tableStream ) throws IOException
     {
 
-        int offset = wordDocumentStream.getOffset();
+        int offset = wordDocumentStream.size();
         int len = _sections.size();
         PlexOfCps plex = new PlexOfCps(SED_SIZE);
 
@@ -220,7 +220,7 @@ public class SectionTable
 
             plex.addProperty(property);
 
-            offset = wordDocumentStream.getOffset();
+            offset = wordDocumentStream.size();
         }
         tableStream.write(plex.toByteArray());
     }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SttbUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SttbUtils.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SttbUtils.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/SttbUtils.java Tue Jun  6 22:21:40 2017
@@ -17,8 +17,8 @@
 package org.apache.poi.hwpf.model;
 
 import java.io.IOException;
+import java.io.OutputStream;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.util.Internal;
 
 /**
@@ -53,24 +53,22 @@ class SttbUtils
                 .getData();
     }
 
-    static void writeSttbfBkmk( String[] data, HWPFOutputStream tableStream )
+    static void writeSttbfBkmk( String[] data, OutputStream tableStream )
             throws IOException
     {
         tableStream.write( new Sttb( CDATA_SIZE_STTBF_BKMK, data ).serialize() );
     }
 
-    static void writeSttbfRMark( String[] data, HWPFOutputStream tableStream )
+    static void writeSttbfRMark( String[] data, OutputStream tableStream )
             throws IOException
     {
-        tableStream.write( new Sttb( CDATA_SIZE_STTBF_R_MARK, data )
-                .serialize() );
+        tableStream.write( new Sttb( CDATA_SIZE_STTBF_R_MARK, data ).serialize() );
     }
 
-    static void writeSttbSavedBy( String[] data, HWPFOutputStream tableStream )
+    static void writeSttbSavedBy( String[] data, OutputStream tableStream )
             throws IOException
     {
-        tableStream.write( new Sttb( CDATA_SIZE_STTB_SAVED_BY, data )
-                .serialize() );
+        tableStream.write( new Sttb( CDATA_SIZE_STTB_SAVED_BY, data ).serialize() );
     }
 
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java Tue Jun  6 22:21:40 2017
@@ -18,8 +18,8 @@
 package org.apache.poi.hwpf.model;
 
 import java.io.IOException;
+import java.io.OutputStream;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.hwpf.sprm.CharacterSprmUncompressor;
 import org.apache.poi.hwpf.sprm.ParagraphSprmUncompressor;
 import org.apache.poi.hwpf.usermodel.CharacterProperties;
@@ -123,7 +123,7 @@ public final class StyleSheet implements
       }
   }
 
-  public void writeTo(HWPFOutputStream out)
+  public void writeTo(OutputStream out)
     throws IOException
   {
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/TextPieceTable.java Tue Jun  6 22:21:40 2017
@@ -16,6 +16,7 @@
 ==================================================================== */
 package org.apache.poi.hwpf.model;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -24,7 +25,6 @@ import java.util.Comparator;
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.POILogFactory;
@@ -413,14 +413,14 @@ public class TextPieceTable implements C
         return _textPiecesFCOrder.get(low + 1).getPieceDescriptor().getFilePosition();
     }
 
-    public byte[] writeTo(HWPFOutputStream docStream) throws IOException {
+    public byte[] writeTo(ByteArrayOutputStream docStream) throws IOException {
         PlexOfCps textPlex = new PlexOfCps(PieceDescriptor.getSizeInBytes());
         // int fcMin = docStream.getOffset();
 
         for (TextPiece next : _textPieces) {
             PieceDescriptor pd = next.getPieceDescriptor();
 
-            int offset = docStream.getOffset();
+            int offset = docStream.size();
             int mod = (offset % POIFSConstants.SMALLER_BIG_BLOCK_SIZE);
             if (mod != 0) {
                 mod = POIFSConstants.SMALLER_BIG_BLOCK_SIZE - mod;
@@ -429,7 +429,7 @@ public class TextPieceTable implements C
             }
 
             // set the text piece position to the current docStream offset.
-            pd.setFilePosition(docStream.getOffset());
+            pd.setFilePosition(docStream.size());
 
             // write the text to the docstream and save the piece descriptor to
             // the

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/io/HWPFFileSystem.java Tue Jun  6 22:21:40 2017
@@ -18,6 +18,7 @@
 package org.apache.poi.hwpf.model.io;
 
 
+import java.io.ByteArrayOutputStream;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -26,16 +27,16 @@ import org.apache.poi.util.Internal;
 @Internal
 public final class HWPFFileSystem
 {
-  Map<String, HWPFOutputStream> _streams = new HashMap<String, HWPFOutputStream>();
+  private Map<String, ByteArrayOutputStream> _streams = new HashMap<String, ByteArrayOutputStream>();
 
   public HWPFFileSystem()
   {
-    _streams.put("WordDocument", new HWPFOutputStream());
-    _streams.put("1Table", new HWPFOutputStream());
-    _streams.put("Data", new HWPFOutputStream());
+    _streams.put("WordDocument", new ByteArrayOutputStream());
+    _streams.put("1Table", new ByteArrayOutputStream());
+    _streams.put("Data", new ByteArrayOutputStream());
   }
 
-  public HWPFOutputStream getStream(String name)
+  public ByteArrayOutputStream getStream(String name)
   {
     return _streams.get(name);
   }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestFontTable.java Tue Jun  6 22:21:40 2017
@@ -17,19 +17,23 @@
 
 package org.apache.poi.hwpf.model;
 
-import junit.framework.*;
-import org.apache.poi.hwpf.*;
-import org.apache.poi.hwpf.model.io.*;
-
-public final class TestFontTable
-  extends TestCase
-{
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.apache.poi.hwpf.HWPFDocFixture;
+import org.apache.poi.hwpf.model.io.HWPFFileSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public final class TestFontTable {
   private FontTable _fontTable = null;
   private HWPFDocFixture _hWPFDocFixture;
 
-  public void testReadWrite()
-    throws Exception
-  {
+  @Test
+  public void testReadWrite() throws IOException {
     FileInformationBlock fib = _hWPFDocFixture._fib;
     byte[] tableStream = _hWPFDocFixture._tableStream;
 
@@ -41,7 +45,7 @@ public final class TestFontTable
     HWPFFileSystem fileSys = new HWPFFileSystem();
 
     _fontTable.writeTo(fileSys);
-    HWPFOutputStream  tableOut = fileSys.getStream("1Table");
+    ByteArrayOutputStream  tableOut = fileSys.getStream("1Table");
 
 
     byte[] newTableStream = tableOut.toByteArray();
@@ -53,25 +57,15 @@ public final class TestFontTable
 
   }
 
-  @Override
-protected void setUp()
-    throws Exception
-  {
-    super.setUp();
-    /**@todo verify the constructors*/
+  @Before
+  public void setUp() throws IOException {
     _hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
-
     _hWPFDocFixture.setUp();
   }
 
-  @Override
-protected void tearDown()
-    throws Exception
-  {
+  @After
+  public void tearDown() throws IOException  {
     _hWPFDocFixture.tearDown();
-
-    _hWPFDocFixture = null;
-    super.tearDown();
   }
 
 }

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestListTables.java Tue Jun  6 22:21:40 2017
@@ -19,11 +19,11 @@ package org.apache.poi.hwpf.model;
 
 import static org.junit.Assert.assertEquals;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
 import org.apache.poi.hwpf.HWPFTestCase;
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.junit.Test;
 
 public final class TestListTables extends HWPFTestCase {
@@ -43,7 +43,7 @@ public final class TestListTables extend
             ListTables listTables = new ListTables(tableStream, listOffset, lfoOffset, bLfoOffset);
             HWPFFileSystem fileSys = new HWPFFileSystem();
     
-            HWPFOutputStream tableOut = fileSys.getStream("1Table");
+            ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
     
             listTables.writeListDataTo(fib, tableOut);
             listTables.writeListOverridesTo(fib, tableOut);

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestPAPBinTable.java Tue Jun  6 22:21:40 2017
@@ -17,29 +17,30 @@
 
 package org.apache.poi.hwpf.model;
 
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.TestCase;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
 
 import org.apache.poi.hwpf.HWPFDocFixture;
 import org.apache.poi.hwpf.HWPFTestDataSamples;
 import org.apache.poi.hwpf.model.io.HWPFFileSystem;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
+import org.junit.Test;
 
-public final class TestPAPBinTable extends TestCase
-{
+public final class TestPAPBinTable {
 
-    public void testObIs()
-    {
+    @Test
+    public void testObIs() throws IOException {
         // shall not fail with assertions on
-        HWPFTestDataSamples.openSampleFile( "ob_is.doc" );
+        HWPFTestDataSamples.openSampleFile( "ob_is.doc" ).close();;
     }
 
-    public void testReadWrite() throws Exception
-    {
+    @Test
+    public void testReadWrite() throws IOException {
         /** @todo verify the constructors */
-        HWPFDocFixture _hWPFDocFixture = new HWPFDocFixture( this,
-                HWPFDocFixture.DEFAULT_TEST_FILE );
+        HWPFDocFixture _hWPFDocFixture = new HWPFDocFixture( this, HWPFDocFixture.DEFAULT_TEST_FILE );
 
         _hWPFDocFixture.setUp();
         TextPieceTable fakeTPT = new TextPieceTable();
@@ -52,8 +53,8 @@ public final class TestPAPBinTable exten
                 null, fib.getFcPlcfbtePapx(), fib.getLcbPlcfbtePapx(), fakeTPT );
 
         HWPFFileSystem fileSys = new HWPFFileSystem();
-        HWPFOutputStream tableOut = fileSys.getStream( "1Table" );
-        HWPFOutputStream mainOut = fileSys.getStream( "WordDocument" );
+        ByteArrayOutputStream tableOut = fileSys.getStream( "1Table" );
+        ByteArrayOutputStream mainOut = fileSys.getStream( "WordDocument" );
         _pAPBinTable.writeTo( mainOut, tableOut, fakeTPT );
 
         byte[] newTableStream = tableOut.toByteArray();

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java?rev=1797838&r1=1797837&r2=1797838&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java Tue Jun  6 22:21:40 2017
@@ -17,25 +17,29 @@
 
 package org.apache.poi.hwpf.model;
 
-import junit.framework.*;
+import static org.junit.Assert.assertEquals;
 
-import org.apache.poi.hwpf.*;
-import org.apache.poi.hwpf.model.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 
-public final class TestStyleSheet
-  extends TestCase
-{
+import org.apache.poi.hwpf.HWPFDocFixture;
+import org.apache.poi.hwpf.model.io.HWPFFileSystem;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public final class TestStyleSheet {
   private StyleSheet _styleSheet = null;
   private HWPFDocFixture _hWPFDocFixture;
 
-  public void testReadWrite()
-    throws Exception
+  @Test
+  public void testReadWrite() throws IOException
   {
     HWPFFileSystem fileSys = new HWPFFileSystem();
 
 
-    HWPFOutputStream tableOut = fileSys.getStream("1Table");
-    HWPFOutputStream mainOut =  fileSys.getStream("WordDocument");
+    ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
+    ByteArrayOutputStream mainOut =  fileSys.getStream("WordDocument");
 
     _styleSheet.writeTo(tableOut);
 
@@ -43,14 +47,13 @@ public final class TestStyleSheet
 
     StyleSheet newStyleSheet = new StyleSheet(newTableStream, 0);
     assertEquals(newStyleSheet, _styleSheet);
-
   }
 
-  public void testReadWriteFromNonZeroOffset()
-    throws Exception
+  @Test
+  public void testReadWriteFromNonZeroOffset() throws IOException
   {
     HWPFFileSystem fileSys = new HWPFFileSystem();
-    HWPFOutputStream tableOut = fileSys.getStream("1Table");
+    ByteArrayOutputStream tableOut = fileSys.getStream("1Table");
 
     tableOut.write(new byte[20]); // 20 bytes of whatever at the front.
     _styleSheet.writeTo(tableOut);
@@ -61,11 +64,8 @@ public final class TestStyleSheet
     assertEquals(newStyleSheet, _styleSheet);
   }
 
-  @Override
-protected void setUp()
-    throws Exception
-  {
-    super.setUp();
+  @Before
+  public void setUp() throws IOException {
     /**@todo verify the constructors*/
     _hWPFDocFixture = new HWPFDocFixture(this, HWPFDocFixture.DEFAULT_TEST_FILE);
     _hWPFDocFixture.setUp();
@@ -77,15 +77,11 @@ protected void setUp()
     _styleSheet = new StyleSheet(tableStream, fib.getFcStshf());
   }
 
-  @Override
-protected void tearDown()
-    throws Exception
-  {
+  @After
+  public void tearDown() throws Exception {
     _styleSheet = null;
     _hWPFDocFixture.tearDown();
 
     _hWPFDocFixture = null;
-    super.tearDown();
   }
-
 }

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=1797838&r1=1797837&r2=1797838&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 Tue Jun  6 22:21:40 2017
@@ -16,10 +16,10 @@
 ==================================================================== */
 package org.apache.poi.hwpf.usermodel;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.apache.poi.POITestCase.assertContains;
 import static org.apache.poi.POITestCase.assertNotContained;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -29,7 +29,6 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
-import junit.framework.TestCase;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.poi.POIDataSamples;
 import org.apache.poi.hwpf.HWPFDocument;
@@ -43,7 +42,6 @@ import org.apache.poi.hwpf.model.FieldsD
 import org.apache.poi.hwpf.model.FileInformationBlock;
 import org.apache.poi.hwpf.model.PlexOfField;
 import org.apache.poi.hwpf.model.SubdocumentType;
-import org.apache.poi.hwpf.model.io.HWPFOutputStream;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.IOUtils;
@@ -51,6 +49,8 @@ import org.apache.poi.util.POILogFactory
 import org.apache.poi.util.POILogger;
 import org.junit.Test;
 
+import junit.framework.TestCase;
+
 /**
  * Test different problems reported in the Apache Bugzilla
  *  against HWPF
@@ -607,7 +607,7 @@ public class TestBugs{
         System.arraycopy(doc.getTableStream(), doc.getFileInformationBlock()
                 .getFcDop(), originalData, 0, originalData.length);
 
-        HWPFOutputStream outputStream = new HWPFOutputStream();
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         doc.getDocProperties().writeTo(outputStream);
         final byte[] oldData = outputStream.toByteArray();
 
@@ -620,7 +620,7 @@ public class TestBugs{
 
         doc = HWPFTestDataSamples.writeOutAndReadBack(doc);
 
-        outputStream = new HWPFOutputStream();
+        outputStream = new ByteArrayOutputStream();
         doc.getDocProperties().writeTo(outputStream);
         final byte[] newData = outputStream.toByteArray();
 



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