poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1053791 [10/18] - in /poi/branches/NIO_32_BRANCH: ./ src/contrib/src/org/apache/poi/contrib/poibrowser/ src/java/org/apache/poi/ src/java/org/apache/poi/hpsf/ src/java/org/apache/poi/hpsf/extractor/ src/java/org/apache/poi/hssf/record/ src...
Date Thu, 30 Dec 2010 02:35:11 GMT
Added: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java?rev=1053791&view=auto
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java (added)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestNPOIFSStream.java Thu Dec 30 02:35:06 2010
@@ -0,0 +1,641 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.poifs.filesystem;
+
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.POIDataSamples;
+import org.apache.poi.poifs.common.POIFSConstants;
+
+/**
+ * Tests {@link NPOIFSStream}
+ */
+public final class TestNPOIFSStream extends TestCase {
+   private static final POIDataSamples _inst = POIDataSamples.getPOIFSInstance();
+
+   /**
+    * Read a single block stream
+    */
+   public void testReadTinyStream() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+
+      // 98 is actually the last block in a two block stream...
+      NPOIFSStream stream = new NPOIFSStream(fs, 98);
+      Iterator<ByteBuffer> i = stream.getBlockIterator();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b = i.next();
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      
+      // Check the contents
+      assertEquals((byte)0x81, b.get());
+      assertEquals((byte)0x00, b.get());
+      assertEquals((byte)0x00, b.get());
+      assertEquals((byte)0x00, b.get());
+      assertEquals((byte)0x82, b.get());
+      assertEquals((byte)0x00, b.get());
+      assertEquals((byte)0x00, b.get());
+      assertEquals((byte)0x00, b.get());
+   }
+
+   /**
+    * Read a stream with only two blocks in it 
+    */
+   public void testReadShortStream() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      
+      // 97 -> 98 -> end
+      NPOIFSStream stream = new NPOIFSStream(fs, 97);
+      Iterator<ByteBuffer> i = stream.getBlockIterator();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b97 = i.next();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b98 = i.next();
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      
+      // Check the contents of the 1st block
+      assertEquals((byte)0x01, b97.get());
+      assertEquals((byte)0x00, b97.get());
+      assertEquals((byte)0x00, b97.get());
+      assertEquals((byte)0x00, b97.get());
+      assertEquals((byte)0x02, b97.get());
+      assertEquals((byte)0x00, b97.get());
+      assertEquals((byte)0x00, b97.get());
+      assertEquals((byte)0x00, b97.get());
+      
+      // Check the contents of the 2nd block
+      assertEquals((byte)0x81, b98.get());
+      assertEquals((byte)0x00, b98.get());
+      assertEquals((byte)0x00, b98.get());
+      assertEquals((byte)0x00, b98.get());
+      assertEquals((byte)0x82, b98.get());
+      assertEquals((byte)0x00, b98.get());
+      assertEquals((byte)0x00, b98.get());
+      assertEquals((byte)0x00, b98.get());
+   }
+   
+   /**
+    * Read a stream with many blocks 
+    */
+   public void testReadLongerStream() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      
+      ByteBuffer b0 = null;
+      ByteBuffer b1 = null;
+      ByteBuffer b22 = null;
+      
+      // The stream at 0 has 23 blocks in it
+      NPOIFSStream stream = new NPOIFSStream(fs, 0);
+      Iterator<ByteBuffer> i = stream.getBlockIterator();
+      int count = 0;
+      while(i.hasNext()) {
+         ByteBuffer b = i.next();
+         if(count == 0) {
+            b0 = b;
+         }
+         if(count == 1) {
+            b1 = b;
+         }
+         if(count == 22) {
+            b22 = b;
+         }
+         
+         count++;
+      }
+      assertEquals(23, count);
+      
+      // Check the contents
+      //  1st block is at 0
+      assertEquals((byte)0x9e, b0.get());
+      assertEquals((byte)0x75, b0.get());
+      assertEquals((byte)0x97, b0.get());
+      assertEquals((byte)0xf6, b0.get());
+            
+      //  2nd block is at 1
+      assertEquals((byte)0x86, b1.get());
+      assertEquals((byte)0x09, b1.get());
+      assertEquals((byte)0x22, b1.get());
+      assertEquals((byte)0xfb, b1.get());
+      
+      //  last block is at 89
+      assertEquals((byte)0xfe, b22.get());
+      assertEquals((byte)0xff, b22.get());
+      assertEquals((byte)0x00, b22.get());
+      assertEquals((byte)0x00, b22.get());
+      assertEquals((byte)0x05, b22.get());
+      assertEquals((byte)0x01, b22.get());
+      assertEquals((byte)0x02, b22.get());
+      assertEquals((byte)0x00, b22.get());
+   }
+
+   /**
+    * Read a stream with several blocks in a 4096 byte block file 
+    */
+   public void testReadStream4096() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize4096.zvi"));
+      
+      // 0 -> 1 -> 2 -> end
+      NPOIFSStream stream = new NPOIFSStream(fs, 0);
+      Iterator<ByteBuffer> i = stream.getBlockIterator();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b0 = i.next();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b1 = i.next();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b2 = i.next();
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      
+      // Check the contents of the 1st block
+      assertEquals((byte)0x9E, b0.get());
+      assertEquals((byte)0x75, b0.get());
+      assertEquals((byte)0x97, b0.get());
+      assertEquals((byte)0xF6, b0.get());
+      assertEquals((byte)0xFF, b0.get());
+      assertEquals((byte)0x21, b0.get());
+      assertEquals((byte)0xD2, b0.get());
+      assertEquals((byte)0x11, b0.get());
+      
+      // Check the contents of the 2nd block
+      assertEquals((byte)0x00, b1.get());
+      assertEquals((byte)0x00, b1.get());
+      assertEquals((byte)0x03, b1.get());
+      assertEquals((byte)0x00, b1.get());
+      assertEquals((byte)0x00, b1.get());
+      assertEquals((byte)0x00, b1.get());
+      assertEquals((byte)0x00, b1.get());
+      assertEquals((byte)0x00, b1.get());
+      
+      // Check the contents of the 3rd block
+      assertEquals((byte)0x6D, b2.get());
+      assertEquals((byte)0x00, b2.get());
+      assertEquals((byte)0x00, b2.get());
+      assertEquals((byte)0x00, b2.get());
+      assertEquals((byte)0x03, b2.get());
+      assertEquals((byte)0x00, b2.get());
+      assertEquals((byte)0x46, b2.get());
+      assertEquals((byte)0x00, b2.get());
+   }
+   
+   /**
+    * Craft a nasty file with a loop, and ensure we don't get stuck
+    */
+   public void testReadFailsOnLoop() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      
+      // Hack the FAT so that it goes 0->1->2->0
+      fs.setNextBlock(0, 1);
+      fs.setNextBlock(1, 2);
+      fs.setNextBlock(2, 0);
+      
+      // Now try to read
+      NPOIFSStream stream = new NPOIFSStream(fs, 0);
+      Iterator<ByteBuffer> i = stream.getBlockIterator();
+      assertEquals(true, i.hasNext());
+      
+      // 1st read works
+      i.next();
+      assertEquals(true, i.hasNext());
+      
+      // 2nd read works
+      i.next();
+      assertEquals(true, i.hasNext());
+      
+      // 3rd read works
+      i.next();
+      assertEquals(true, i.hasNext());
+      
+      // 4th read blows up as it loops back to 0
+      try {
+         i.next();
+         fail("Loop should have been detected but wasn't!");
+      } catch(RuntimeException e) {
+         // Good, it was detected
+      }
+      assertEquals(true, i.hasNext());
+   }
+
+   /**
+    * Tests that we can load some streams that are
+    *  stored in the mini stream.
+    */
+   public void testReadMiniStreams() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      NPOIFSMiniStore ministore = fs.getMiniStore();
+      
+      // 178 -> 179 -> 180 -> end
+      NPOIFSStream stream = new NPOIFSStream(ministore, 178);
+      Iterator<ByteBuffer> i = stream.getBlockIterator();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b178 = i.next();
+      assertEquals(true, i.hasNext());
+      assertEquals(true, i.hasNext());
+      ByteBuffer b179 = i.next();
+      assertEquals(true, i.hasNext());
+      ByteBuffer b180 = i.next();
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      assertEquals(false, i.hasNext());
+      
+      // Check the contents of the 1st block
+      assertEquals((byte)0xfe, b178.get());
+      assertEquals((byte)0xff, b178.get());
+      assertEquals((byte)0x00, b178.get());
+      assertEquals((byte)0x00, b178.get());
+      assertEquals((byte)0x05, b178.get());
+      assertEquals((byte)0x01, b178.get());
+      assertEquals((byte)0x02, b178.get());
+      assertEquals((byte)0x00, b178.get());
+      
+      // And the 2nd
+      assertEquals((byte)0x6c, b179.get());
+      assertEquals((byte)0x00, b179.get());
+      assertEquals((byte)0x00, b179.get());
+      assertEquals((byte)0x00, b179.get());
+      assertEquals((byte)0x28, b179.get());
+      assertEquals((byte)0x00, b179.get());
+      assertEquals((byte)0x00, b179.get());
+      assertEquals((byte)0x00, b179.get());
+      
+      // And the 3rd
+      assertEquals((byte)0x30, b180.get());
+      assertEquals((byte)0x00, b180.get());
+      assertEquals((byte)0x00, b180.get());
+      assertEquals((byte)0x00, b180.get());
+      assertEquals((byte)0x00, b180.get());
+      assertEquals((byte)0x00, b180.get());
+      assertEquals((byte)0x00, b180.get());
+      assertEquals((byte)0x80, b180.get());
+   }
+
+   /**
+    * Writing the same amount of data as before
+    */
+   public void testReplaceStream() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      
+      byte[] data = new byte[512];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      
+      // 98 is actually the last block in a two block stream...
+      NPOIFSStream stream = new NPOIFSStream(fs, 98);
+      stream.updateContents(data);
+      
+      // Check the reading of blocks
+      Iterator<ByteBuffer> it = stream.getBlockIterator();
+      assertEquals(true, it.hasNext());
+      ByteBuffer b = it.next();
+      assertEquals(false, it.hasNext());
+      
+      // Now check the contents
+      data = new byte[512];
+      b.get(data);
+      for(int i=0; i<data.length; i++) {
+         byte exp = (byte)(i%256);
+         assertEquals(exp, data[i]);
+      }
+   }
+   
+   /**
+    * Writes less data than before, some blocks will need
+    *  to be freed
+    */
+   public void testReplaceStreamWithLess() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      
+      byte[] data = new byte[512];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      
+      // 97 -> 98 -> end
+      assertEquals(98, fs.getNextBlock(97));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(98));
+      
+      // Create a 2 block stream, will become a 1 block one
+      NPOIFSStream stream = new NPOIFSStream(fs, 97);
+      stream.updateContents(data);
+      
+      // 97 should now be the end, and 98 free
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(97));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(98));
+      
+      // Check the reading of blocks
+      Iterator<ByteBuffer> it = stream.getBlockIterator();
+      assertEquals(true, it.hasNext());
+      ByteBuffer b = it.next();
+      assertEquals(false, it.hasNext());
+      
+      // Now check the contents
+      data = new byte[512];
+      b.get(data);
+      for(int i=0; i<data.length; i++) {
+         byte exp = (byte)(i%256);
+         assertEquals(exp, data[i]);
+      }
+   }
+   
+   /**
+    * Writes more data than before, new blocks will be needed
+    */
+   public void testReplaceStreamWithMore() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      
+      byte[] data = new byte[512*3];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      
+      // 97 -> 98 -> end
+      assertEquals(98, fs.getNextBlock(97));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(98));
+      
+      // 100 is our first free one
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(99));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(100));
+      
+      // Create a 2 block stream, will become a 3 block one
+      NPOIFSStream stream = new NPOIFSStream(fs, 97);
+      stream.updateContents(data);
+      
+      // 97 -> 98 -> 100 -> end
+      assertEquals(98, fs.getNextBlock(97));
+      assertEquals(100, fs.getNextBlock(98));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(100));
+      
+      // Check the reading of blocks
+      Iterator<ByteBuffer> it = stream.getBlockIterator();
+      int count = 0;
+      while(it.hasNext()) {
+         ByteBuffer b = it.next();
+         data = new byte[512];
+         b.get(data);
+         for(int i=0; i<data.length; i++) {
+            byte exp = (byte)(i%256);
+            assertEquals(exp, data[i]);
+         }
+         count++;
+      }
+      assertEquals(3, count);
+   }
+   
+   /**
+    * Writes to a new stream in the file
+    */
+   public void testWriteNewStream() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      
+      // 100 is our first free one
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(99));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(100));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(101));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
+      
+      
+      // Add a single block one
+      byte[] data = new byte[512];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      
+      NPOIFSStream stream = new NPOIFSStream(fs);
+      stream.updateContents(data);
+      
+      // Check it was allocated properly
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(99));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(100));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(101));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
+      
+      // And check the contents
+      Iterator<ByteBuffer> it = stream.getBlockIterator();
+      int count = 0;
+      while(it.hasNext()) {
+         ByteBuffer b = it.next();
+         data = new byte[512];
+         b.get(data);
+         for(int i=0; i<data.length; i++) {
+            byte exp = (byte)(i%256);
+            assertEquals(exp, data[i]);
+         }
+         count++;
+      }
+      assertEquals(1, count);
+      
+      
+      // And a multi block one
+      data = new byte[512*3];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      
+      stream = new NPOIFSStream(fs);
+      stream.updateContents(data);
+      
+      // Check it was allocated properly
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(99));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(100));
+      assertEquals(102,                         fs.getNextBlock(101));
+      assertEquals(103,                         fs.getNextBlock(102));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(103));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
+      
+      // And check the contents
+      it = stream.getBlockIterator();
+      count = 0;
+      while(it.hasNext()) {
+         ByteBuffer b = it.next();
+         data = new byte[512];
+         b.get(data);
+         for(int i=0; i<data.length; i++) {
+            byte exp = (byte)(i%256);
+            assertEquals(exp, data[i]);
+         }
+         count++;
+      }
+      assertEquals(3, count);
+      
+      // Free it
+      stream.free();
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(99));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(100));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(101));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(102));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(103));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(104));
+   }
+   
+   /**
+    * Writes to a new stream in the file, where we've not enough
+    *  free blocks so new FAT segments will need to be allocated
+    *  to support this
+    */
+   public void testWriteNewStreamExtraFATs() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      
+      // Allocate almost all the blocks
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(99));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(100));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(127));
+      for(int i=100; i<127; i++) {
+         fs.setNextBlock(i, POIFSConstants.END_OF_CHAIN);
+      }
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(127));
+      assertEquals(true, fs.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
+
+      
+      // Write a 3 block stream
+      byte[] data = new byte[512*3];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      NPOIFSStream stream = new NPOIFSStream(fs);
+      stream.updateContents(data);
+      
+      // Check we got another BAT
+      assertEquals(false, fs.getBATBlockAndIndex(0).getBlock().hasFreeSectors());
+      assertEquals(true,  fs.getBATBlockAndIndex(128).getBlock().hasFreeSectors());
+      
+      // the BAT will be in the first spot of the new block
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(126));
+      assertEquals(129,                         fs.getNextBlock(127));
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(128));
+      assertEquals(130,                         fs.getNextBlock(129));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(130));
+      assertEquals(POIFSConstants.UNUSED_BLOCK, fs.getNextBlock(131));
+   }
+   
+   /**
+    * Replaces data in an existing stream, with a bit
+    *  more data than before, in a 4096 byte block file
+    */
+   public void testWriteStream4096() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize4096.zvi"));
+      
+      // 0 -> 1 -> 2 -> end
+      assertEquals(1, fs.getNextBlock(0));
+      assertEquals(2, fs.getNextBlock(1));
+      assertEquals(POIFSConstants.END_OF_CHAIN, fs.getNextBlock(2));
+      assertEquals(4, fs.getNextBlock(3));
+      
+      // First free one is at 15
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(14));
+      assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(15));
+      
+      
+      // Write a 5 block file 
+      byte[] data = new byte[4096*5];
+      for(int i=0; i<data.length; i++) {
+         data[i] = (byte)(i%256);
+      }
+      NPOIFSStream stream = new NPOIFSStream(fs, 0);
+      stream.updateContents(data);
+      
+      
+      // Check it
+      assertEquals(1, fs.getNextBlock(0));
+      assertEquals(2, fs.getNextBlock(1));
+      assertEquals(15, fs.getNextBlock(2)); // Jumps
+      assertEquals(4, fs.getNextBlock(3));  // Next stream
+      assertEquals(POIFSConstants.FAT_SECTOR_BLOCK, fs.getNextBlock(14));
+      assertEquals(16,                              fs.getNextBlock(15)); // Continues
+      assertEquals(POIFSConstants.END_OF_CHAIN,     fs.getNextBlock(16)); // Ends
+      assertEquals(POIFSConstants.UNUSED_BLOCK,     fs.getNextBlock(17)); // Free
+
+      // Check the contents too
+      Iterator<ByteBuffer> it = stream.getBlockIterator();
+      int count = 0;
+      while(it.hasNext()) {
+         ByteBuffer b = it.next();
+         data = new byte[512];
+         b.get(data);
+         for(int i=0; i<data.length; i++) {
+            byte exp = (byte)(i%256);
+            assertEquals(exp, data[i]);
+         }
+         count++;
+      }
+      assertEquals(5, count);
+   }
+   
+   /**
+    * Tests that we can write into the mini stream
+    */
+   public void testWriteMiniStreams() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.openResourceAsStream("BlockSize512.zvi"));
+      
+      // TODO
+   }
+
+   /**
+    * Craft a nasty file with a loop, and ensure we don't get stuck
+    */
+   public void testWriteFailsOnLoop() throws Exception {
+      NPOIFSFileSystem fs = new NPOIFSFileSystem(_inst.getFile("BlockSize512.zvi"));
+      
+      // Hack the FAT so that it goes 0->1->2->0
+      fs.setNextBlock(0, 1);
+      fs.setNextBlock(1, 2);
+      fs.setNextBlock(2, 0);
+      
+      // Try to write a large amount, should fail on the write
+      byte[] data = new byte[512*4];
+      NPOIFSStream stream = new NPOIFSStream(fs, 0);
+      try {
+         stream.updateContents(data);
+         fail("Loop should have been detected but wasn't!");
+      } catch(IllegalStateException e) {}
+      
+      // Now reset, and try on a small bit
+      // Should fail during the freeing set
+      fs.setNextBlock(0, 1);
+      fs.setNextBlock(1, 2);
+      fs.setNextBlock(2, 0);
+      
+      data = new byte[512];
+      stream = new NPOIFSStream(fs, 0);
+      try {
+         stream.updateContents(data);
+         fail("Loop should have been detected but wasn't!");
+      } catch(IllegalStateException e) {}
+   }
+}

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOffice2007XMLException.java Thu Dec 30 02:35:06 2010
@@ -41,7 +41,8 @@ public class TestOffice2007XMLException 
 			fail("expected exception was not thrown");
 		} catch(OfficeXmlFileException e) {
 			// expected during successful test
-			assertTrue(e.getMessage().indexOf("POI only supports OLE2 Office documents") > 0);
+			assertTrue(e.getMessage().indexOf("The supplied data appears to be in the Office 2007+ XML") > -1);
+			assertTrue(e.getMessage().indexOf("You are calling the part of POI that deals with OLE2 Office Documents") > -1);
 		}
 	}
 	

Added: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java?rev=1053791&view=auto
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java (added)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestOle10Native.java Thu Dec 30 02:35:06 2010
@@ -0,0 +1,36 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.poifs.filesystem;
+
+import junit.framework.TestCase;
+import org.apache.poi.POIDataSamples;
+
+import java.io.IOException;
+
+public class TestOle10Native extends TestCase {
+    private static final POIDataSamples dataSamples = POIDataSamples.getPOIFSInstance();
+
+    public void testOleNative() throws IOException, Ole10NativeException {
+        POIFSFileSystem fs = new POIFSFileSystem(dataSamples.openResourceAsStream("oleObject1.bin"));
+
+        Ole10Native ole = Ole10Native.createFromEmbeddedOleObject(fs);
+
+        assertEquals("File1.svg", ole.getLabel());
+        assertEquals("D:\\Documents and Settings\\rsc\\My Documents\\file1.svg", ole.getCommand());
+    }
+}

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java Thu Dec 30 02:35:06 2010
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,39 +14,23 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.filesystem;
 
-import junit.framework.*;
+import junit.framework.TestCase;
 
 /**
  * Class to test POIFSDocumentPath functionality
  *
  * @author Marc Johnson
  */
+public final class TestPOIFSDocumentPath extends TestCase {
 
-public class TestPOIFSDocumentPath
-    extends TestCase
-{
-
-    /**
-     * Constructor TestPOIFSDocumentPath
-     *
-     * @param name
-     */
-
-    public TestPOIFSDocumentPath(String name)
-    {
-        super(name);
-    }
 
     /**
      * Test default constructor
      */
-
-    public void testDefaultConstructor()
-    {
+    public void testDefaultConstructor() {
         POIFSDocumentPath path = new POIFSDocumentPath();
 
         assertEquals(0, path.length());
@@ -56,9 +39,7 @@ public class TestPOIFSDocumentPath
     /**
      * Test full path constructor
      */
-
-    public void testFullPathConstructor()
-    {
+    public void testFullPathConstructor() {
         String[] components =
         {
             "foo", "bar", "foobar", "fubar"
@@ -125,9 +106,7 @@ public class TestPOIFSDocumentPath
     /**
      * Test relative path constructor
      */
-
-    public void testRelativePathConstructor()
-    {
+    public void testRelativePathConstructor() {
         String[] initialComponents =
         {
             "a", "b", "c"
@@ -186,24 +165,40 @@ public class TestPOIFSDocumentPath
                 }
             }
 
-            // test weird variants
+            // Test weird variants
+            
+            // This one is allowed, even if it's really odd
             assertEquals(n, new POIFSDocumentPath(base, null).length());
+            new POIFSDocumentPath(base, new String[]
+            {
+                 "fu", ""
+            });
+            
+            // This one is allowed too
+            new POIFSDocumentPath(base, new String[]
+            {
+                 "", "fu"
+            });
+            
+            // This one shouldn't be allowed
             try
             {
                 new POIFSDocumentPath(base, new String[]
                 {
-                    "fu", ""
+                    "fu", null
                 });
                 fail("should have caught IllegalArgumentException");
             }
             catch (IllegalArgumentException ignored)
             {
             }
+            
+            // Ditto
             try
             {
                 new POIFSDocumentPath(base, new String[]
                 {
-                    "fu", null
+                    null, "fu"
                 });
                 fail("should have caught IllegalArgumentException");
             }
@@ -216,9 +211,7 @@ public class TestPOIFSDocumentPath
     /**
      * test equality
      */
-
-    public void testEquality()
-    {
+    public void testEquality() {
         POIFSDocumentPath   a1    = new POIFSDocumentPath();
         POIFSDocumentPath   a2    = new POIFSDocumentPath(null);
         POIFSDocumentPath   a3    = new POIFSDocumentPath(new String[ 0 ]);
@@ -318,17 +311,4 @@ public class TestPOIFSDocumentPath
             }
         }
     }
-
-    /**
-     * main method to run the unit tests
-     *
-     * @param ignored_args
-     */
-
-    public static void main(String [] ignored_args)
-    {
-        System.out.println(
-            "Testing org.apache.poi.poifs.eventfilesystem.POIFSDocumentPath");
-        junit.textui.TestRunner.run(TestPOIFSDocumentPath.class);
-    }
 }

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSFileSystem.java Thu Dec 30 02:35:06 2010
@@ -17,22 +17,32 @@
 
 package org.apache.poi.poifs.filesystem;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
 
 import junit.framework.TestCase;
 
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hssf.HSSFTestDataSamples;
+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;
 
 /**
  * Tests for POIFSFileSystem
- * 
+ *
  * @author Josh Micich
  */
 public final class TestPOIFSFileSystem extends TestCase {
+   private POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
+   
 
 	/**
 	 * Mock exception used to ensure correct error handling
@@ -44,7 +54,7 @@ public final class TestPOIFSFileSystem e
 	}
 	/**
 	 * Helps facilitate testing. Keeps track of whether close() was called.
-	 * Also can throw an exception at a specific point in the stream. 
+	 * Also can throw an exception at a specific point in the stream.
 	 */
 	private static final class TestIS extends InputStream {
 
@@ -87,15 +97,14 @@ public final class TestPOIFSFileSystem e
 			return _isClosed;
 		}
 	}
-	
+
 	/**
 	 * Test for undesired behaviour observable as of svn revision 618865 (5-Feb-2008).
 	 * POIFSFileSystem was not closing the input stream.
 	 */
 	public void testAlwaysClose() {
-		
 		TestIS testIS;
-	
+
 		// Normal case - read until EOF and close
 		testIS = new TestIS(openSampleStream("13224.xls"), -1);
 		try {
@@ -104,7 +113,7 @@ public final class TestPOIFSFileSystem e
 			throw new RuntimeException(e);
 		}
 		assertTrue("input stream was not closed", testIS.isClosed());
-		
+
 		// intended to crash after reading 10000 bytes
 		testIS = new TestIS(openSampleStream("13224.xls"), 10000);
 		try {
@@ -116,14 +125,13 @@ public final class TestPOIFSFileSystem e
 			// expected
 		}
 		assertTrue("input stream was not closed", testIS.isClosed()); // but still should close
-		
 	}
-	
+
 	/**
 	 * Test for bug # 48898 - problem opening an OLE2
 	 *  file where the last block is short (i.e. not a full
 	 *  multiple of 512 bytes)
-	 *  
+	 *
 	 * As yet, this problem remains. One school of thought is
 	 *  not not issue an EOF when we discover the last block
 	 *  is short, but this seems a bit wrong.
@@ -132,26 +140,192 @@ public final class TestPOIFSFileSystem e
 	 */
 	public void testShortLastBlock() throws Exception {
 		String[] files = new String[] {
-			"ShortLastBlock.qwp", "ShortLastBlock.wps"	
+			"ShortLastBlock.qwp", "ShortLastBlock.wps"
 		};
-		String pdirname = System.getProperty("POIFS.testdata.path");
 
 		for(int i=0; i<files.length; i++) {
-			File f = new File(pdirname, files[i]);
-			assertTrue(f.exists());
-			
 			// Open the file up
 			POIFSFileSystem fs = new POIFSFileSystem(
-					new FileInputStream(f)
+			    _samples.openResourceAsStream(files[i])
 			);
-			
+
 			// Write it into a temp output array
 			ByteArrayOutputStream baos = new ByteArrayOutputStream();
 			fs.writeFilesystem(baos);
-			
+
 			// Check sizes
 		}
 	}
+	
+	/**
+	 * Check that we do the right thing when the list of which
+	 *  sectors are BAT blocks points off the list of
+	 *  sectors that exist in the file.
+	 */
+	public void testFATandDIFATsectors() throws Exception {
+      // Open the file up
+      try {
+         POIFSFileSystem fs = new POIFSFileSystem(
+             _samples.openResourceAsStream("ReferencesInvalidSectors.mpp")
+         );
+         fail("File is corrupt and shouldn't have been opened");
+      } catch(IOException e) {
+         String msg = e.getMessage();
+         assertTrue(msg.startsWith("Your file contains 695 sectors"));
+      }
+	}
+	
+	/**
+	 * Tests that we can write and read a file that contains XBATs
+	 *  as well as regular BATs.
+	 * However, because a file needs to be at least 6.875mb big
+	 *  to have an XBAT in it, we don't have a test one. So, generate it.
+	 */
+	public void testBATandXBAT() throws Exception {
+	   byte[] hugeStream = new byte[8*1024*1024];
+	   POIFSFileSystem fs = new POIFSFileSystem();
+	   fs.getRoot().createDocument(
+	         "BIG", new ByteArrayInputStream(hugeStream)
+	   );
+	   
+	   ByteArrayOutputStream baos = new ByteArrayOutputStream();
+	   fs.writeFilesystem(baos);
+	   byte[] fsData = baos.toByteArray();
+	   
+	   
+	   // Check the header was written properly
+	   InputStream inp = new ByteArrayInputStream(fsData); 
+	   HeaderBlock header = new HeaderBlock(inp);
+	   assertEquals(109+21, header.getBATCount());
+	   assertEquals(1, header.getXBATCount());
+	   
+	   
+	   // We should have 21 BATs in the XBAT
+	   ByteBuffer xbatData = ByteBuffer.allocate(512);
+	   xbatData.put(fsData, (1+header.getXBATIndex())*512, 512);
+	   xbatData.position(0);
+	   BATBlock xbat = BATBlock.createBATBlock(POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS, xbatData);
+	   for(int i=0; i<21; i++) {
+	      assertTrue(xbat.getValueAt(i) != POIFSConstants.UNUSED_BLOCK);
+	   }
+	   for(int i=21; i<127; i++) {
+	      assertEquals(POIFSConstants.UNUSED_BLOCK, xbat.getValueAt(i));
+	   }
+	   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 = null;
+	   fs = new POIFSFileSystem(
+	         new ByteArrayInputStream(fsData)
+	   );
+	   
+	   DirectoryNode root = fs.getRoot();
+	   assertEquals(1, root.getEntryCount());
+	   DocumentNode big = (DocumentNode)root.getEntry("BIG");
+	   assertEquals(hugeStream.length, big.getSize());
+	}
+	
+	/**
+	 * Most OLE2 files use 512byte blocks. However, a small number
+	 *  use 4k blocks. Check that we can open these.
+	 */
+	public void test4KBlocks() throws Exception {
+      POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
+	   InputStream inp = _samples.openResourceAsStream("BlockSize4096.zvi");
+	   
+	   // First up, check that we can process the header properly
+      HeaderBlock header_block = new HeaderBlock(inp);
+      POIFSBigBlockSize bigBlockSize = header_block.getBigBlockSize();
+      assertEquals(4096, bigBlockSize.getBigBlockSize());
+      
+      // Check the fat info looks sane
+      assertEquals(1, header_block.getBATArray().length);
+      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);
+
+	   
+	   // Now try and open properly
+	   POIFSFileSystem fs = new POIFSFileSystem(
+	         _samples.openResourceAsStream("BlockSize4096.zvi")
+	   );
+	   assertTrue(fs.getRoot().getEntryCount() > 3);
+	   
+	   // Check we can get at all the contents
+	   checkAllDirectoryContents(fs.getRoot());
+	   
+	   
+	   // Finally, check we can do a similar 512byte one too
+	   fs = new POIFSFileSystem(
+            _samples.openResourceAsStream("BlockSize512.zvi")
+      );
+      assertTrue(fs.getRoot().getEntryCount() > 3);
+      checkAllDirectoryContents(fs.getRoot());
+	}
+	private void checkAllDirectoryContents(DirectoryEntry dir) throws IOException {
+	   for(Entry entry : dir) {
+	      if(entry instanceof DirectoryEntry) {
+	         checkAllDirectoryContents((DirectoryEntry)entry);
+	      } else {
+	         DocumentNode doc = (DocumentNode) entry;
+	         DocumentInputStream dis = new DocumentInputStream(doc);
+	         int numBytes = dis.available();
+	         byte[] data = new byte [numBytes];
+            dis.read(data);
+	      }
+	   }
+	}
+	
+	/**
+	 * Test that we can open files that come via Lotus notes.
+	 * These have a top level directory without a name....
+	 */
+	public void testNotesOLE2Files() throws Exception {
+      POIDataSamples _samples = POIDataSamples.getPOIFSInstance();
+      
+      // Open the file up
+      POIFSFileSystem fs = new POIFSFileSystem(
+          _samples.openResourceAsStream("Notes.ole2")
+      );
+      
+      // Check the contents
+      assertEquals(1, fs.getRoot().getEntryCount());
+      
+      Entry entry = fs.getRoot().getEntries().next();
+      assertTrue(entry.isDirectoryEntry());
+      assertTrue(entry instanceof DirectoryEntry);
+      
+      // The directory lacks a name!
+      DirectoryEntry dir = (DirectoryEntry)entry;
+      assertEquals("", dir.getName());
+      
+      // Has two children
+      assertEquals(2, dir.getEntryCount());
+      
+      // Check them
+      Iterator<Entry> it = dir.getEntries();
+      entry = it.next();
+      assertEquals(true, entry.isDocumentEntry());
+      assertEquals("\u0001Ole10Native", entry.getName());
+      
+      entry = it.next();
+      assertEquals(true, entry.isDocumentEntry());
+      assertEquals("\u0001CompObj", entry.getName());
+	}
 
 	private static InputStream openSampleStream(String sampleFileName) {
 		return HSSFTestDataSamples.openSampleFileStream(sampleFileName);

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/filesystem/TestPropertySorter.java Thu Dec 30 02:35:06 2010
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -20,14 +19,13 @@ package org.apache.poi.poifs.filesystem;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Iterator;
+import java.util.List;
 
 import junit.framework.ComparisonFailure;
 import junit.framework.TestCase;
@@ -62,7 +60,7 @@ public final class TestPropertySorter ex
             throw new RuntimeException(e);
         }
     }
-    
+
     /**
      * Test sorting of properties in <code>DirectoryProperty</code>
      */
@@ -125,22 +123,22 @@ public final class TestPropertySorter ex
         DirectoryNode vba = (DirectoryNode)vba_project.getEntry(VBA);
         DirectoryProperty  p = (DirectoryProperty)vba.getProperty();
 
-        ArrayList lst = new ArrayList();
-        for (Iterator it = p.getChildren(); it.hasNext();){
-            Property ch = (Property)it.next();
+        List<Property> lst = new ArrayList<Property>();
+        for (Iterator<Property> it = p.getChildren(); it.hasNext();){
+            Property ch = it.next();
             lst.add(ch);
         }
-        return (Property [])lst.toArray(new Property[ 0 ]);
+        return lst.toArray(new Property[ 0 ]);
     }
 
     /**
      * Old version of case-sensitive PropertyComparator to demonstrate the problem
      */
-    private static final Comparator OldCaseSensitivePropertyComparator = new Comparator() {
+    private static final Comparator<Property> OldCaseSensitivePropertyComparator = new Comparator<Property>() {
 
-        public int compare(Object o1, Object o2) {
-            String name1  = (( Property ) o1).getName();
-            String name2  = (( Property ) o2).getName();
+        public int compare(Property o1, Property o2) {
+            String name1  = o1.getName();
+            String name2  = o2.getName();
             int result = name1.length() - name2.length();
 
             if (result == 0) {

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/AllPOIFSPropertyTests.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/AllPOIFSPropertyTests.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/AllPOIFSPropertyTests.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/AllPOIFSPropertyTests.java Thu Dec 30 02:35:06 2010
@@ -1,3 +1,20 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
 package org.apache.poi.poifs.property;
 
 import junit.framework.Test;
@@ -11,7 +28,7 @@ import junit.framework.TestSuite;
 public final class AllPOIFSPropertyTests {
 
     public static Test suite() {
-        TestSuite result = new TestSuite("Tests for org.apache.poi.poifs.property");
+        TestSuite result = new TestSuite(AllPOIFSPropertyTests.class.getName());
         result.addTestSuite(TestDirectoryProperty.class);
         result.addTestSuite(TestDocumentProperty.class);
         result.addTestSuite(TestPropertyFactory.class);

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDirectoryProperty.java Thu Dec 30 02:35:06 2010
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,63 +14,41 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.property;
 
-import java.io.*;
-
-import java.util.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
 
-import junit.framework.*;
+import org.apache.poi.poifs.storage.RawDataUtil;
 
-import org.apache.poi.poifs.common.POIFSConstants;
+import junit.framework.TestCase;
 
 /**
  * Class to test DirectoryProperty functionality
  *
  * @author Marc Johnson
  */
-
-public class TestDirectoryProperty
-    extends TestCase
-{
+public final class TestDirectoryProperty extends TestCase {
     private DirectoryProperty _property;
     private byte[]            _testblock;
 
     /**
-     * Constructor TestDirectoryProperty
-     *
-     * @param name
-     */
-
-    public TestDirectoryProperty(String name)
-    {
-        super(name);
-    }
-
-    /**
      * Test constructing DirectoryProperty
-     *
-     * @exception IOException
      */
-
-    public void testConstructor()
-        throws IOException
-    {
+    public void testConstructor() throws IOException {
         createBasicDirectoryProperty();
         verifyProperty();
     }
 
     /**
      * Test pre-write functionality
-     *
-     * @exception IOException
      */
-
-    public void testPreWrite()
-        throws IOException
-    {
+    public void testPreWrite() throws IOException {
         createBasicDirectoryProperty();
         _property.preWrite();
 
@@ -119,9 +96,7 @@ public class TestDirectoryProperty
         }
     }
 
-    private void verifyChildren(int count)
-        throws IOException
-    {
+    private void verifyChildren(int count) {
         Iterator iter     = _property.getChildren();
         List     children = new ArrayList();
 
@@ -175,8 +150,7 @@ public class TestDirectoryProperty
         }
     }
 
-    private void createBasicDirectoryProperty()
-    {
+    private void createBasicDirectoryProperty() {
         String name = "MyDirectory";
 
         _property  = new DirectoryProperty(name);
@@ -209,9 +183,7 @@ public class TestDirectoryProperty
         }
     }
 
-    private void verifyProperty()
-        throws IOException
-    {
+    private void verifyProperty() throws IOException {
         ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
 
         _property.writeData(stream);
@@ -225,15 +197,7 @@ public class TestDirectoryProperty
         }
     }
 
-    /**
-     * Test addChild
-     *
-     * @exception IOException
-     */
-
-    public void testAddChild()
-        throws IOException
-    {
+    public void testAddChild() throws IOException {
         createBasicDirectoryProperty();
         _property.addChild(new LocalProperty(1));
         _property.addChild(new LocalProperty(2));
@@ -260,15 +224,7 @@ public class TestDirectoryProperty
         _property.addChild(new LocalProperty(3));
     }
 
-    /**
-     * Test deleteChild
-     *
-     * @exception IOException
-     */
-
-    public void testDeleteChild()
-        throws IOException
-    {
+    public void testDeleteChild() throws IOException {
         createBasicDirectoryProperty();
         Property p1 = new LocalProperty(1);
 
@@ -288,15 +244,7 @@ public class TestDirectoryProperty
         _property.addChild(new LocalProperty(1));
     }
 
-    /**
-     * Test changeName
-     *
-     * @exception IOException
-     */
-
-    public void testChangeName()
-        throws IOException
-    {
+    public void testChangeName() throws IOException {
         createBasicDirectoryProperty();
         Property p1           = new LocalProperty(1);
         String   originalName = p1.getName();
@@ -314,88 +262,35 @@ public class TestDirectoryProperty
         assertTrue(_property.changeName(p1, originalName));
     }
 
-    /**
-     * Test reading constructor
-     *
-     * @exception IOException
-     */
-
-    public void testReadingConstructor()
-        throws IOException
-    {
-        byte[] input =
-        {
-            ( byte ) 0x42, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x6F, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
-            ( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00,
-            ( byte ) 0x6E, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x79, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x16, ( byte ) 0x00, ( byte ) 0x01, ( byte ) 0x01,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x02, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x20, ( byte ) 0x08, ( byte ) 0x02, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0xC0, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x46,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0xC0, ( byte ) 0x5C, ( byte ) 0xE8, ( byte ) 0x23,
-            ( byte ) 0x9E, ( byte ) 0x6B, ( byte ) 0xC1, ( byte ) 0x01,
-            ( byte ) 0xFE, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00
+    public void testReadingConstructor() {
+        String[] input = {
+            "42 00 6F 00 6F 00 74 00 20 00 45 00 6E 00 74 00 72 00 79 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "16 00 01 01 FF FF FF FF FF FF FF FF 02 00 00 00 20 08 02 00 00 00 00 00 C0 00 00 00 00 00 00 46",
+            "00 00 00 00 00 00 00 00 00 00 00 00 C0 5C E8 23 9E 6B C1 01 FE FF FF FF 00 00 00 00 00 00 00 00",
         };
-
-        verifyReadingProperty(0, input, 0, "Boot Entry");
+        verifyReadingProperty(0, RawDataUtil.decode(input), 0, "Boot Entry");
     }
 
-    private void verifyReadingProperty(int index, byte [] input, int offset,
-                                       String name)
-        throws IOException
-    {
-        DirectoryProperty     property = new DirectoryProperty(index, input,
-                                             offset);
-        ByteArrayOutputStream stream   = new ByteArrayOutputStream(128);
-        byte[]                expected = new byte[ 128 ];
+    private static void verifyReadingProperty(int index, byte[] input, int offset, String name) {
+        DirectoryProperty property = new DirectoryProperty(index, input, offset);
+        ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
+        byte[] expected = new byte[128];
 
         System.arraycopy(input, offset, expected, 0, 128);
-        property.writeData(stream);
+        try {
+            property.writeData(stream);
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
         byte[] output = stream.toByteArray();
 
         assertEquals(128, output.length);
-        for (int j = 0; j < 128; j++)
-        {
-            assertEquals("mismatch at offset " + j, expected[ j ],
-                         output[ j ]);
+        for (int j = 0; j < 128; j++) {
+            assertEquals("mismatch at offset " + j, expected[j], output[j]);
         }
         assertEquals(index, property.getIndex());
         assertEquals(name, property.getName());
         assertTrue(!property.getChildren().hasNext());
     }
-
-    /**
-     * main method to run the unit tests
-     *
-     * @param ignored_args
-     */
-
-    public static void main(String [] ignored_args)
-    {
-        System.out.println(
-            "Testing org.apache.poi.poifs.property.DirectoryProperty");
-        junit.textui.TestRunner.run(TestDirectoryProperty.class);
-    }
 }

Modified: poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java
URL: http://svn.apache.org/viewvc/poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java?rev=1053791&r1=1053790&r2=1053791&view=diff
==============================================================================
--- poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java (original)
+++ poi/branches/NIO_32_BRANCH/src/testcases/org/apache/poi/poifs/property/TestDocumentProperty.java Thu Dec 30 02:35:06 2010
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,49 +14,24 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.poifs.property;
 
-import java.io.*;
-
-import java.util.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 
-import junit.framework.*;
+import org.apache.poi.poifs.storage.RawDataUtil;
 
-import org.apache.poi.poifs.property.DocumentProperty;
+import junit.framework.TestCase;
 
 /**
  * Class to test DocumentProperty functionality
  *
  * @author Marc Johnson
  */
+public final class TestDocumentProperty extends TestCase {
 
-public class TestDocumentProperty
-    extends TestCase
-{
-
-    /**
-     * Constructor TestDocumentProperty
-     *
-     * @param name
-     */
-
-    public TestDocumentProperty(String name)
-    {
-        super(name);
-    }
-
-    /**
-     * Test constructing DocumentPropertys
-     *
-     * @exception IOException
-     */
-
-    public void testConstructor()
-        throws IOException
-    {
-
+    public void testConstructor() throws IOException {
         // test with short name, small file
         verifyProperty("foo", 1234);
 
@@ -71,160 +45,34 @@ public class TestDocumentProperty
         verifyProperty("A.really.long.long.long.name123", 4096);
     }
 
-    /**
-     * Test reading constructor
-     *
-     * @exception IOException
-     */
-
-    public void testReadingConstructor()
-        throws IOException
-    {
-        byte[] input =
-        {
-            ( byte ) 0x52, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x6F, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
-            ( byte ) 0x20, ( byte ) 0x00, ( byte ) 0x45, ( byte ) 0x00,
-            ( byte ) 0x6E, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x79, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x16, ( byte ) 0x00, ( byte ) 0x05, ( byte ) 0x01,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x02, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x20, ( byte ) 0x08, ( byte ) 0x02, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0xC0, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x46,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0xC0, ( byte ) 0x5C, ( byte ) 0xE8, ( byte ) 0x23,
-            ( byte ) 0x9E, ( byte ) 0x6B, ( byte ) 0xC1, ( byte ) 0x01,
-            ( byte ) 0xFE, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-
-            ( byte ) 0x57, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x6B, ( byte ) 0x00,
-            ( byte ) 0x62, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x6F, ( byte ) 0x00, ( byte ) 0x6B, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x12, ( byte ) 0x00, ( byte ) 0x02, ( byte ) 0x01,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x10, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-
-            ( byte ) 0x05, ( byte ) 0x00, ( byte ) 0x53, ( byte ) 0x00,
-            ( byte ) 0x75, ( byte ) 0x00, ( byte ) 0x6D, ( byte ) 0x00,
-            ( byte ) 0x6D, ( byte ) 0x00, ( byte ) 0x61, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x79, ( byte ) 0x00,
-            ( byte ) 0x49, ( byte ) 0x00, ( byte ) 0x6E, ( byte ) 0x00,
-            ( byte ) 0x66, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x6D, ( byte ) 0x00,
-            ( byte ) 0x61, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
-            ( byte ) 0x69, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x6E, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x28, ( byte ) 0x00, ( byte ) 0x02, ( byte ) 0x01,
-            ( byte ) 0x01, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x03, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x08, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x10, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-
-            ( byte ) 0x05, ( byte ) 0x00, ( byte ) 0x44, ( byte ) 0x00,
-            ( byte ) 0x6F, ( byte ) 0x00, ( byte ) 0x63, ( byte ) 0x00,
-            ( byte ) 0x75, ( byte ) 0x00, ( byte ) 0x6D, ( byte ) 0x00,
-            ( byte ) 0x65, ( byte ) 0x00, ( byte ) 0x6E, ( byte ) 0x00,
-            ( byte ) 0x74, ( byte ) 0x00, ( byte ) 0x53, ( byte ) 0x00,
-            ( byte ) 0x75, ( byte ) 0x00, ( byte ) 0x6D, ( byte ) 0x00,
-            ( byte ) 0x6D, ( byte ) 0x00, ( byte ) 0x61, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x79, ( byte ) 0x00,
-            ( byte ) 0x49, ( byte ) 0x00, ( byte ) 0x6E, ( byte ) 0x00,
-            ( byte ) 0x66, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x72, ( byte ) 0x00, ( byte ) 0x6D, ( byte ) 0x00,
-            ( byte ) 0x61, ( byte ) 0x00, ( byte ) 0x74, ( byte ) 0x00,
-            ( byte ) 0x69, ( byte ) 0x00, ( byte ) 0x6F, ( byte ) 0x00,
-            ( byte ) 0x6E, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x38, ( byte ) 0x00, ( byte ) 0x02, ( byte ) 0x01,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x10, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x10, ( byte ) 0x00, ( byte ) 0x00,
-            ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00
+    public void testReadingConstructor() throws IOException {
+        String[] hexData = {
+            "52 00 6F 00 6F 00 74 00 20 00 45 00 6E 00 74 00 72 00 79 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "16 00 05 01 FF FF FF FF FF FF FF FF 02 00 00 00 20 08 02 00 00 00 00 00 C0 00 00 00 00 00 00 46",
+            "00 00 00 00 00 00 00 00 00 00 00 00 C0 5C E8 23 9E 6B C1 01 FE FF FF FF 00 00 00 00 00 00 00 00",
+            "57 00 6F 00 72 00 6B 00 62 00 6F 00 6F 00 6B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "12 00 02 01 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00",
+            "05 00 53 00 75 00 6D 00 6D 00 61 00 72 00 79 00 49 00 6E 00 66 00 6F 00 72 00 6D 00 61 00 74 00",
+            "69 00 6F 00 6E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "28 00 02 01 01 00 00 00 03 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 00 10 00 00 00 00 00 00",
+            "05 00 44 00 6F 00 63 00 75 00 6D 00 65 00 6E 00 74 00 53 00 75 00 6D 00 6D 00 61 00 72 00 79 00",
+            "49 00 6E 00 66 00 6F 00 72 00 6D 00 61 00 74 00 69 00 6F 00 6E 00 00 00 00 00 00 00 00 00 00 00",
+            "38 00 02 01 FF FF FF FF FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
+            "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 10 00 00 00 00 00 00",
         };
+        byte[] input = RawDataUtil.decode(hexData);
 
         verifyReadingProperty(1, input, 128, "Workbook");
         verifyReadingProperty(2, input, 256, "\005SummaryInformation");
-        verifyReadingProperty(3, input, 384,
-                              "\005DocumentSummaryInformation");
+        verifyReadingProperty(3, input, 384, "\005DocumentSummaryInformation");
     }
 
-    private void verifyReadingProperty(int index, byte [] input, int offset,
-                                       String name)
-        throws IOException
-    {
+    private void verifyReadingProperty(int index, byte[] input, int offset, String name)
+            throws IOException {
         DocumentProperty      property = new DocumentProperty(index, input,
                                              offset);
         ByteArrayOutputStream stream   = new ByteArrayOutputStream(128);
@@ -244,9 +92,7 @@ public class TestDocumentProperty
         assertEquals(name, property.getName());
     }
 
-    private void verifyProperty(String name, int size)
-        throws IOException
-    {
+    private void verifyProperty(String name, int size) throws IOException {
         DocumentProperty property = new DocumentProperty(name, size);
 
         if (size >= 4096)
@@ -309,17 +155,4 @@ public class TestDocumentProperty
                          output[ j ]);
         }
     }
-
-    /**
-     * main method to run the unit tests
-     *
-     * @param ignored_args
-     */
-
-    public static void main(String [] ignored_args)
-    {
-        System.out.println(
-            "Testing org.apache.poi.poifs.property.DocumentProperty");
-        junit.textui.TestRunner.run(TestDocumentProperty.class);
-    }
 }



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


Mime
View raw message