aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases/org/apache/poi/hdgf
diff options
context:
space:
mode:
authorJosh Micich <josh@apache.org>2009-05-21 18:12:22 +0000
committerJosh Micich <josh@apache.org>2009-05-21 18:12:22 +0000
commit852e34bfea1affa39f4c89ed5edf2442b13708ab (patch)
treed0889907e5bd8eb66f27115444367eb49060c93a /src/scratchpad/testcases/org/apache/poi/hdgf
parent6e9212e8a2057badf8c0bc88433be602d8cc3ccd (diff)
downloadpoi-852e34bfea1affa39f4c89ed5edf2442b13708ab.tar.gz
poi-852e34bfea1affa39f4c89ed5edf2442b13708ab.zip
Changed CRLF to LF in scratchpad. Minor fixes for compiler warnings and formatting
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@777204 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi/hdgf')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java21
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java177
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/chunks/TestChunks.java167
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java37
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java35
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java1
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java123
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java23
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java101
9 files changed, 347 insertions, 338 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java b/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java
index 85f64df220..e98c8110a0 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFCore.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf;
import java.io.FileInputStream;
@@ -24,35 +25,35 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import junit.framework.TestCase;
-public class TestHDGFCore extends TestCase {
+public final class TestHDGFCore extends TestCase {
private POIFSFileSystem fs;
private String dirname;
private String filename;
-
+
protected void setUp() throws Exception {
dirname = System.getProperty("HDGF.testdata.path");
filename = dirname + "/Test_Visio-Some_Random_Text.vsd";
fs = new POIFSFileSystem(new FileInputStream(filename));
}
-
+
public void testCreate() throws Exception {
new HDGFDiagram(fs);
}
-
+
public void testTrailer() throws Exception {
HDGFDiagram hdgf = new HDGFDiagram(fs);
assertNotNull(hdgf);
assertNotNull(hdgf.getTrailerStream());
-
+
// Check it has what we'd expect
TrailerStream trailer = hdgf.getTrailerStream();
assertEquals(0x8a94, trailer.getPointer().getOffset());
-
+
assertNotNull(trailer.getPointedToStreams());
assertEquals(20, trailer.getPointedToStreams().length);
-
+
assertEquals(20, hdgf.getTopLevelStreams().length);
-
+
// 9th one should have children
assertNotNull(trailer.getPointedToStreams()[8]);
assertNotNull(trailer.getPointedToStreams()[8].getPointer());
@@ -61,7 +62,7 @@ public class TestHDGFCore extends TestCase {
assertNotNull(ps8.getPointedToStreams());
assertEquals(8, ps8.getPointedToStreams().length);
}
-
+
/**
* Tests that we can open a problematic file, that initially
* appears to have a negative chunk length
@@ -69,7 +70,7 @@ public class TestHDGFCore extends TestCase {
public void DISABLEDtestNegativeChunkLength() throws Exception {
filename = dirname + "/NegativeChunkLength.vsd";
fs = new POIFSFileSystem(new FileInputStream(filename));
-
+
HDGFDiagram hdgf = new HDGFDiagram(fs);
assertNotNull(hdgf);
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java b/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java
index f8f0f25558..bbdeadad09 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/TestHDGFLZW.java
@@ -13,173 +13,174 @@
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.hdgf;
import java.io.ByteArrayInputStream;
import junit.framework.TestCase;
-public class TestHDGFLZW extends TestCase {
+public final class TestHDGFLZW extends TestCase {
public static final byte[] testTrailerComp = new byte[] {
123, // *mask bit*
- -60, 2,
+ -60, 2,
-21, -16, // 3 @ 4093
- 1, 0, 0, -72,
+ 1, 0, 0, -72,
-13, -16, // 3 @ 5
78, // *mask bit*
- -32, -5, // 14 @ 4082
- 1, 0, 3,
+ -32, -5, // 14 @ 4082
+ 1, 0, 3,
-21, -16, // 3 @ 4093
10, 5, // 8 @ 28
- 4,
+ 4,
+ -21, -16, // 3 @ 4093
+ 21, // *mask bit*
+ 9,
-21, -16, // 3 @ 4093
- 21, // *mask bit*
- 9,
- -21, -16, // 3 @ 4093
- 103, -21, -16, 34,
+ 103, -21, -16, 34,
-36, -1, // 18 @ 4078
- 52, 15, // 18 @ 70
- 70, 15, // 18 @ 88
+ 52, 15, // 18 @ 70
+ 70, 15, // 18 @ 88
120, // *mask bit*
- 88, 15, // 18 @ 106
- -7, -2, // 17 @ 11
+ 88, 15, // 18 @ 106
+ -7, -2, // 17 @ 11
-28, -9, // 10 @ 4086
- -123, 21, 0, 44,
- -122, 1, // 4 @ 152
- -4, // *mask bit*
- 104, 15, // 18 @ 122
- -24, -13, 40, -98, 32,
- 78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
- -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
- -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
- -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
- -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
- -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
- -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
- -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
- 17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
- -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
- 0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
- 125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
- -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
- 17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
- 85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
- -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
- 1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
- 85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
+ -123, 21, 0, 44,
+ -122, 1, // 4 @ 152
+ -4, // *mask bit*
+ 104, 15, // 18 @ 122
+ -24, -13, 40, -98, 32,
+ 78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
+ -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
+ -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
+ -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
+ -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
+ -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
+ -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
+ -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
+ 17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
+ -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
+ 0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
+ 125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
+ -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
+ 17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
+ 85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
+ -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
+ 1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
+ 85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
85, 1, 102, -119, 72, 37, 0, 97, 33 };
public static final byte[] testTrailerDecomp = new byte[] {
- -60, 2, 0, 0, 0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
- 0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
- -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
- 123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
- 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
- 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
- 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
- -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
- 0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
- 0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
- -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
- 50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
- 36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0,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0, 0,
+ -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
+ -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
+ 123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
+ 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
+ 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
+ -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
+ 0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
+ -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
+ 50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
+ 36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100,
+ -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4,
+ 79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79,
+ 1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85,
+ 1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119,
+ 0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127,
+ 0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120,
+ 0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119,
0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
};
-
+
public void testFromToInt() throws Exception {
byte b255 = -1;
assertEquals(255, HDGFLZW.fromByte(b255));
assertEquals(-1, HDGFLZW.fromInt( HDGFLZW.fromByte(b255) ));
assertEquals(-1, HDGFLZW.fromInt( 255 ));
-
+
byte b11 = 11;
assertEquals(11, HDGFLZW.fromByte(b11));
assertEquals(11, HDGFLZW.fromInt( HDGFLZW.fromByte(b11) ));
assertEquals(11, HDGFLZW.fromInt( 11 ));
-
+
byte b0 = 0;
assertEquals(0, HDGFLZW.fromByte(b0));
assertEquals(0, HDGFLZW.fromInt( HDGFLZW.fromByte(b0) ));
assertEquals(0, HDGFLZW.fromInt( 0 ));
-
+
byte b127 = 127;
assertEquals(127, HDGFLZW.fromByte(b127));
assertEquals(127, HDGFLZW.fromInt( HDGFLZW.fromByte(b127) ));
assertEquals(127, HDGFLZW.fromInt( 127 ));
-
+
byte b128 = -128;
assertEquals(128, HDGFLZW.fromByte(b128));
assertEquals(-128, HDGFLZW.fromInt( HDGFLZW.fromByte(b128) ));
assertEquals(-128, HDGFLZW.fromInt( 128 ));
}
-
+
public void testCounts() throws Exception {
assertEquals(339, testTrailerComp.length);
assertEquals(632, testTrailerDecomp.length);
-
+
// Decode it using our engine
HDGFLZW lzw = new HDGFLZW();
byte[] dec = lzw.decode(new ByteArrayInputStream(testTrailerComp));
-
+
// Check it's of the right size
assertEquals(632, dec.length);
-/*
+/*
// Encode it again using our engine
byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
-
+
// Check it's of the right size
assertEquals(339, comp.length);
*/
}
-
+
public void testDecompress() throws Exception {
assertEquals(339, testTrailerComp.length);
assertEquals(632, testTrailerDecomp.length);
-
+
// Decode it using our engine
HDGFLZW lzw = new HDGFLZW();
byte[] dec = lzw.decode(new ByteArrayInputStream(testTrailerComp));
-
+
// Now check it's the right data
assertEquals(632, dec.length);
for(int i=0; i<dec.length; i++) {
- if(dec[i] != testTrailerDecomp[i])
+ if(dec[i] != testTrailerDecomp[i])
System.err.println(i + "\t" + dec[i] + "\t" + testTrailerDecomp[i]);
}
}
-
+
public void DISABLEDtestCompress() throws Exception {
assertEquals(339, testTrailerComp.length);
assertEquals(632, testTrailerDecomp.length);
-
+
// Compress it using our engine
HDGFLZW lzw = new HDGFLZW();
byte[] comp = lzw.compress(new ByteArrayInputStream(testTrailerDecomp));
-
+
// Now check it's the right data
assertEquals(339, comp.length);
for(int i=0; i<comp.length; i++) {
- if(comp[i] != testTrailerComp[i])
+ if(comp[i] != testTrailerComp[i])
System.err.println(i + "\t" + comp[i] + "\t" + testTrailerComp[i]);
}
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/chunks/TestChunks.java b/src/scratchpad/testcases/org/apache/poi/hdgf/chunks/TestChunks.java
index fabe9cd8bf..f4107c8e3a 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/chunks/TestChunks.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/chunks/TestChunks.java
@@ -14,208 +14,209 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.chunks;
import junit.framework.TestCase;
-public class TestChunks extends TestCase {
+public final class TestChunks extends TestCase {
public static final byte[] data_a = new byte[] { 70, 0, 0, 0,
- -1, -1, -1, -1, 2, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0,
- 0, 0, 2, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, -1, -1, -1, -1, 0, 0, 0,
- 0, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
- 0, 36, 0, 0, 0, 1, 0, 84, 24, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
- 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, -110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -124, 0, 0, 0, 2, 0, 85, 73, 0, 0, 0, 0, 0, 0, -56, 63, 73, 0, 0, 0,
- 0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0, -64, 63, 63, 0, 0, 0, 0, 0, 0,
- -64, -65, 73, 0, 0, 0, 0, 0, 0, -16, 63, 73, 0, 0, 0, 0, 0, 0, -16, 63,
- 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -16, 63, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 2, 0,
+ 85, 5, 0, 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, -55, 0, 0, 0, 2, 0, 0, 0,
+ 0, 0, 0, 0, -122, 0, 0, 0, 1, 0, 80, 1, 0, 0, 0, 60, 0, 0, 0, 60, 0, 0,
+ 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0
};
public void testChunkHeaderA() throws Exception {
ChunkFactory cf = new ChunkFactory(11);
- ChunkHeader h =
+ ChunkHeader h =
ChunkHeader.createChunkHeader(11, data_a, 0);
-
+
assertTrue(h instanceof ChunkHeaderV11);
ChunkHeaderV11 header = (ChunkHeaderV11)h;
-
+
assertEquals(70, header.getType());
assertEquals(-1, header.getId());
assertEquals(2, header.getUnknown1());
assertEquals(68, header.getLength());
assertEquals(0, header.getUnknown2());
assertEquals(0, header.getUnknown3());
-
+
assertTrue(header.hasTrailer());
assertTrue(header.hasSeparator());
}
public void testChunkHeaderB() throws Exception {
ChunkFactory cf = new ChunkFactory(11);
- ChunkHeader h =
+ ChunkHeader h =
ChunkHeader.createChunkHeader(11, data_b, 0);
-
+
assertTrue(h instanceof ChunkHeaderV11);
ChunkHeaderV11 header = (ChunkHeaderV11)h;
-
+
assertEquals(70, header.getType());
assertEquals(-1, header.getId());
assertEquals(3, header.getUnknown1());
assertEquals(68, header.getLength());
assertEquals(0, header.getUnknown2());
assertEquals(0, header.getUnknown3());
-
+
assertTrue(header.hasTrailer());
assertTrue(header.hasSeparator());
}
-
+
public void testOneChunk() throws Exception {
ChunkFactory cf = new ChunkFactory(11);
cf.createChunk(data_a, 0);
cf.createChunk(data_b, 0);
-
+
Chunk chunk = cf.createChunk(data_a, 0);
assertNotNull(chunk.getHeader());
assertNotNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator());
-
+
// Should be 19 + length + 8 + 4 big
assertEquals(68, chunk.getHeader().getLength());
assertEquals(68+19+8+4, chunk.getOnDiskSize());
-
+
// Type is 70, or 0x46
assertEquals(70, chunk.getHeader().getType());
assertEquals(0x46, chunk.getHeader().getType());
-
+
// Should have two virtual chunk commands, a
// 10 (page sheet) and an 18
assertEquals(2, chunk.commandDefinitions.length);
assertEquals(0, chunk.getCommands().length);
-
+
assertEquals(10, chunk.commandDefinitions[0].getType());
assertEquals(0, chunk.commandDefinitions[0].getOffset());
assertEquals("PageSheet", chunk.commandDefinitions[0].getName());
-
+
assertEquals(18, chunk.commandDefinitions[1].getType());
assertEquals(0, chunk.commandDefinitions[1].getOffset());
assertEquals("0", chunk.commandDefinitions[1].getName());
}
-
+
public void testAnotherChunk() throws Exception {
ChunkFactory cf = new ChunkFactory(11);
-
+
// Go for the 2nd chunk in the stream
int offset = 0;
Chunk chunk = cf.createChunk(data_b, offset);
offset += chunk.getOnDiskSize();
chunk = cf.createChunk(data_b, offset);
-
+
assertNotNull(chunk.getHeader());
assertNotNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator());
-
+
// Should be 19 + length + 8 + 4 big
assertEquals(32, chunk.getHeader().getLength());
assertEquals(32+19+8+4, chunk.getOnDiskSize());
-
+
// Type is 104, or 0x68
assertEquals(104, chunk.getHeader().getType());
assertEquals(0x68, chunk.getHeader().getType());
-
+
// Should have two virtual chunk commands, a
// 10 (Unknown) and an 18
assertEquals(2, chunk.commandDefinitions.length);
assertEquals(0, chunk.getCommands().length);
-
+
assertEquals(10, chunk.commandDefinitions[0].getType());
assertEquals(0, chunk.commandDefinitions[0].getOffset());
assertEquals("PropList", chunk.commandDefinitions[0].getName());
-
+
assertEquals(18, chunk.commandDefinitions[1].getType());
assertEquals(0, chunk.commandDefinitions[1].getOffset());
assertEquals("0", chunk.commandDefinitions[1].getName());
}
-
+
public void testManyChunks() throws Exception {
ChunkFactory cf = new ChunkFactory(11);
Chunk chunk;
int offset = 0;
-
+
chunk = cf.createChunk(data_a, offset);
assertNotNull(chunk.getHeader());
assertNotNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator());
offset += chunk.getOnDiskSize();
-
+
chunk = cf.createChunk(data_a, offset);
assertNotNull(chunk.getHeader());
assertNotNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator());
offset += chunk.getOnDiskSize();
-
+
// Has a separator but no trailer
chunk = cf.createChunk(data_a, offset);
assertNotNull(chunk.getHeader());
assertNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator());
offset += chunk.getOnDiskSize();
-
+
chunk = cf.createChunk(data_a, offset);
assertNotNull(chunk.getHeader());
assertNull(chunk.getTrailer());
assertNotNull(chunk.getSeparator());
offset += chunk.getOnDiskSize();
-
+
chunk = cf.createChunk(data_a, offset);
assertNotNull(chunk.getHeader());
assertNull(chunk.getTrailer());
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java b/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
index 8f890db3aa..a24733c919 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/extractor/TestVisioExtractor.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.extractor;
import java.io.ByteArrayOutputStream;
@@ -26,25 +27,25 @@ import junit.framework.TestCase;
import org.apache.poi.hdgf.HDGFDiagram;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-public class TestVisioExtractor extends TestCase {
+public final class TestVisioExtractor extends TestCase {
private String dirname;
private String defFilename;
protected void setUp() throws Exception {
dirname = System.getProperty("HDGF.testdata.path");
defFilename = dirname + "/Test_Visio-Some_Random_Text.vsd";
}
-
+
/**
* Test the 3 different ways of creating one
*/
public void testCreation() throws Exception {
VisioTextExtractor extractor;
-
+
extractor = new VisioTextExtractor(new FileInputStream(defFilename));
assertNotNull(extractor);
assertNotNull(extractor.getAllText());
assertEquals(3, extractor.getAllText().length);
-
+
extractor = new VisioTextExtractor(
new POIFSFileSystem(
new FileInputStream(defFilename)
@@ -53,7 +54,7 @@ public class TestVisioExtractor extends TestCase {
assertNotNull(extractor);
assertNotNull(extractor.getAllText());
assertEquals(3, extractor.getAllText().length);
-
+
extractor = new VisioTextExtractor(
new HDGFDiagram(
new POIFSFileSystem(
@@ -65,53 +66,53 @@ public class TestVisioExtractor extends TestCase {
assertNotNull(extractor.getAllText());
assertEquals(3, extractor.getAllText().length);
}
-
+
public void testExtraction() throws Exception {
VisioTextExtractor extractor =
new VisioTextExtractor(new FileInputStream(defFilename));
-
+
// Check the array fetch
String[] text = extractor.getAllText();
assertNotNull(text);
assertEquals(3, text.length);
-
+
assertEquals("Test View\n", text[0]);
assertEquals("I am a test view\n", text[1]);
assertEquals("Some random text, on a page\n", text[2]);
-
+
// And the all-in fetch
String textS = extractor.getText();
assertEquals("Test View\nI am a test view\nSome random text, on a page\n", textS);
}
-
+
public void testProblemFiles() throws Exception {
File a = new File(dirname, "44594.vsd");
VisioTextExtractor.main(new String[] {a.toString()});
-
+
File b = new File(dirname, "44594-2.vsd");
VisioTextExtractor.main(new String[] {b.toString()});
-
+
File c = new File(dirname, "ShortChunk1.vsd");
VisioTextExtractor.main(new String[] {c.toString()});
-
+
File d = new File(dirname, "ShortChunk2.vsd");
VisioTextExtractor.main(new String[] {d.toString()});
-
+
File e = new File(dirname, "ShortChunk3.vsd");
VisioTextExtractor.main(new String[] {e.toString()});
}
-
+
public void testMain() throws Exception {
PrintStream oldOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream capture = new PrintStream(baos);
System.setOut(capture);
-
+
VisioTextExtractor.main(new String[] {defFilename});
-
+
// Put things back
System.setOut(oldOut);
-
+
// Check
capture.flush();
String text = baos.toString();
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java b/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java
index 25316b39b8..aaed0fd6f8 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/pointers/TestPointerFactory.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.pointers;
import junit.framework.TestCase;
@@ -21,14 +22,14 @@ import junit.framework.TestCase;
/**
* Tests for the pointer factory, and the pointers themselves
*/
-public class TestPointerFactory extends TestCase {
+public final class TestPointerFactory extends TestCase {
// Type: 16 Addr: 0143aff4 Offset: 80 Len: 54 Format: 46 From: 8a94
private static byte[] vp6_a = new byte[] {
22, 0, 0, 0, -12, -81, 67, 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0
};
// Type: 17 Addr: 014fd84c Offset: d4 Len: 20 Format: 54 From: 8a94
private static byte[] vp6_b = new byte[] {
- 23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0
+ 23, 0, 0, 0, 76, -40, 79, 1, -44, 0, 0, 0, 32, 0, 0, 0, 84, 0
};
// Type: 17 Addr: 014fd8bc Offset: f8 Len: 20 Format: 54 From: 8a94
private static byte[] vp6_c = new byte[] {
@@ -38,7 +39,7 @@ public class TestPointerFactory extends TestCase {
private static byte[] vp6_d = new byte[] {
-1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0
};
-
+
public void testCreateV4() throws Exception {
PointerFactory pf = new PointerFactory(4);
try {
@@ -48,7 +49,7 @@ public class TestPointerFactory extends TestCase {
// As expected
}
}
-
+
public void testCreateV5() throws Exception {
PointerFactory pf = new PointerFactory(5);
try {
@@ -62,46 +63,46 @@ public class TestPointerFactory extends TestCase {
public void testCreateV6() throws Exception {
PointerFactory pf = new PointerFactory(6);
-
+
Pointer a = pf.createPointer(vp6_a, 0);
assertEquals(0x16, a.getType());
assertEquals(0x0143aff4, a.getAddress());
assertEquals(0x80, a.getOffset());
assertEquals(0x54, a.getLength());
assertEquals(0x46, a.getFormat());
-
+
assertTrue(a.destinationCompressed());
assertTrue(a.destinationHasStrings());
assertFalse(a.destinationHasChunks());
assertFalse(a.destinationHasPointers());
-
+
assertEquals(18, a.getSizeInBytes());
-
-
+
+
Pointer b = pf.createPointer(vp6_b, 0);
assertEquals(0x17, b.getType());
assertEquals(0x014fd84c, b.getAddress());
assertEquals(0xd4, b.getOffset());
assertEquals(0x20, b.getLength());
assertEquals(0x54, b.getFormat());
-
+
assertFalse(b.destinationCompressed());
assertFalse(b.destinationHasStrings());
assertFalse(b.destinationHasChunks());
assertTrue(b.destinationHasPointers());
-
+
Pointer c = pf.createPointer(vp6_c, 0);
assertEquals(0x17, c.getType());
assertEquals(0x014fd8bc, c.getAddress());
assertEquals(0xf8, c.getOffset());
assertEquals(0x20, c.getLength());
assertEquals(0x54, c.getFormat());
-
+
assertFalse(c.destinationCompressed());
assertFalse(c.destinationHasStrings());
assertFalse(c.destinationHasChunks());
assertTrue(c.destinationHasPointers());
-
+
// Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
Pointer d = pf.createPointer(vp6_d, 0);
assertEquals(0xff, d.getType());
@@ -109,7 +110,7 @@ public class TestPointerFactory extends TestCase {
assertEquals(0x00, d.getOffset());
assertEquals(0x00, d.getLength());
assertEquals(0x60, d.getFormat());
-
+
assertFalse(d.destinationCompressed());
assertFalse(d.destinationHasStrings());
assertFalse(d.destinationHasChunks());
@@ -118,19 +119,19 @@ public class TestPointerFactory extends TestCase {
public void testCreateV6FromMid() throws Exception {
PointerFactory pf = new PointerFactory(11);
-
+
// Create a from part way down the byte stream
byte[] bytes = new byte[28];
System.arraycopy(vp6_b, 0, bytes, 0, 10);
System.arraycopy(vp6_a, 0, bytes, 10, 18);
-
+
Pointer a = pf.createPointer(bytes, 10);
assertEquals(0x16, a.getType());
assertEquals(0x0143aff4, a.getAddress());
assertEquals(0x80, a.getOffset());
assertEquals(0x54, a.getLength());
assertEquals(0x46, a.getFormat());
-
+
assertTrue(a.destinationCompressed());
assertTrue(a.destinationHasStrings());
assertFalse(a.destinationHasChunks());
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java
index f71af640ed..41d1132782 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/StreamTest.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import org.apache.poi.hdgf.pointers.Pointer;
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java
index 6c4024db9d..26c91d0d19 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBasics.java
@@ -14,72 +14,73 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import org.apache.poi.hdgf.pointers.Pointer;
-public class TestStreamBasics extends StreamTest {
+public final class TestStreamBasics extends StreamTest {
/** The header from when compressedStream is decompressed */
public static final byte[] compressedStreamDCHeader = new byte[] {
-60, 2, 0, 0
};
public static final byte[] compressedStream = new byte[] {
- 123, -60, 2, -21, -16, 1, 0, 0, -72, -13, -16, 78, -32, -5, 1,
- 0, 3, -21, -16, 10, 5, 4, -21, -16, 21, 9, -21, -16, 103, -21,
- -16, 34, -36, -1, 52, 15, 70, 15, 120, 88, 15, -7, -2, -28, -9,
- -123, 21, 0, 44, -122, 1, -4, 104, 15, -24, -13, 40, -98, 32,
- 78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
- -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
- -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
- -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
- -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
- -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
- -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
- -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
- 17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
- -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
- 0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
- 125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
- -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
- 17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
- 85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
- -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
- 1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
- 85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
+ 123, -60, 2, -21, -16, 1, 0, 0, -72, -13, -16, 78, -32, -5, 1,
+ 0, 3, -21, -16, 10, 5, 4, -21, -16, 21, 9, -21, -16, 103, -21,
+ -16, 34, -36, -1, 52, 15, 70, 15, 120, 88, 15, -7, -2, -28, -9,
+ -123, 21, 0, 44, -122, 1, -4, 104, 15, -24, -13, 40, -98, 32,
+ 78, 102, -67, -1, -2, -30, 64, 40, -67, -113, -73, 116, -98,
+ -85, 2, 66, 123, 9, 109, -85, 2, -89, 14, -56, -69, -83, -79,
+ -34, -3, 120, 110, 75, -9, -10, 20, -6, -25, -12, 22, -21, -16,
+ -12, -81, 67, 1, -128, -70, -21, -16, 84, -21, -16, 70, 0, 23,
+ -21, -16, 76, 47, -40, 79, 1, -44, -21, -16, 32, 3, 18, 12, 17,
+ -43, -68, 17, 16, -8, 21, 22, -1, -21, -16, -84, -1, -35, 79,
+ -9, -10, 96, 0, 46, -21, -16, 44, -39, -41, 79, 1, 119, -13,
+ -16, -106, -13, -16, 84, 0, 125, 26, -21, -16, 68, -38, 79, 1,
+ 17, 10, 0, -97, 50, 10, 0, 0, -42, -108, 15, 118, 31, 0, -3, 29,
+ -21, -16, -100, -25, 79, 1, -18, 97, -36, 76, 16, -21, -16, 86,
+ 0, 36, -5, 1, -5, 79, 63, 1, -124, 98, 0, 0, 28, 3, 20, -34, -3,
+ 125, 33, -21, -16, 100, -4, 79, 1, -92, -91, 16, -22, 24, 19, 41,
+ -21, -16, -44, -59, 16, 108, 100, 0, -21, 0, 71, -105, 18, 39, 85,
+ 17, -3, 79, 1, 95, -108, 113, 0, 0, 104, 3, 18, 49, 49, 17, -1, 64,
+ 85, 1, 0, 114, 0, 0, -93, -36, -21, -16, 100, 31, 0, 0, -40, -21,
+ -16, -92, 66, 127, 85, 1, 98, 119, 0, 0, -48, 79, 18, -3, 50, -17,
+ 1, 67, 85, 1, 81, -127, 0, -41, 0, 14, 6, 4, 17, 63, -63, 17, 68,
+ 85, -65, 1, 30, -120, 0, 0, 42, 79, 18, 68, 126, -21, -16, -76, 69,
85, 1, 102, -119, 72, 37, 0, 97, 33 };
public static final byte[] uncompressedStream = new byte[] {
- 0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
- 0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
- -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
- 123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
- 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
- 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
- 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
- -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
- 0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
- 0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
- -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
- 50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
- 36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100,
- -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4,
- 79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79,
- 1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85,
- 1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119,
- 0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127,
- 0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120,
- 0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119,
+ 0, 1, 0, 0, -72, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0,
+ 0, 9, 0, 0, 0, 103, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ -123, 21, 0, 44, -123, 21, 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, -98, 32, 78, 102, -67,
+ -2, -30, 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, 40, 66,
+ 123, 9, 109, -67, -2, -30, 64, 40, -98, 32, 78, 102, -67, -2, -30,
+ 64, 40, -67, -113, -73, 116, -67, -2, -30, 64, -56, -83, -79, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 110, 75, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 22, 0, 0, 0, -12, -81, 67,
+ 1, -128, 0, 0, 0, 84, 0, 0, 0, 70, 0, 23, 0, 0, 0, 76, -40, 79, 1,
+ -44, 0, 0, 0, 32, 0, 0, 0, 84, 0, 23, 0, 0, 0, -68, -40, 79, 1, -8,
+ 0, 0, 0, 32, 0, 0, 0, 84, 0, -1, 0, 0, 0, -84, -1, 79, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 96, 0, 46, 0, 0, 0, 44, -39, 79, 1, 119, 1, 0, 0,
+ -106, 1, 0, 0, 84, 0, 26, 0, 0, 0, 68, -38, 79, 1, 17, 3, 0, 0,
+ 50, 10, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 0, 0, 0, -100, -25, 79, 1, -18, 97, 0, 0, -106, 0, 0, 0, 86, 0,
+ 36, 0, 0, 0, -12, -5, 79, 1, -124, 98, 0, 0, 28, 0, 0, 0, 84, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 0, 0, 0, 100,
+ -4, 79, 1, -92, 98, 0, 0, 32, 0, 0, 0, 84, 0, 41, 0, 0, 0, -44, -4,
+ 79, 1, 108, 100, 0, 0, 71, 0, 0, 0, 86, 0, 39, 0, 0, 0, 68, -3, 79,
+ 1, -108, 113, 0, 0, 104, 0, 0, 0, 84, 0, 49, 0, 0, 0, -84, 64, 85,
+ 1, 0, 114, 0, 0, -93, 0, 0, 0, -42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, -40, 0, 0, 0, -92, 66, 85, 1, 98, 119,
+ 0, 0, -48, 1, 0, 0, 84, 0, 50, 0, 0, 0, 20, 67, 85, 1, 81, -127,
+ 0, 0, 14, 6, 0, 0, 84, 0, 63, 0, 0, 0, 100, 68, 85, 1, 30, -120,
+ 0, 0, 42, 1, 0, 0, 84, 0, 68, 0, 0, 0, -76, 69, 85, 1, 102, -119,
0, 0, 42, 1, 0, 0, 84, 0, 0, 0, 0, 0
};
@@ -88,31 +89,31 @@ public class TestStreamBasics extends StreamTest {
Pointer ptr = new TestPointer(true, 0, compressedStream.length, -1, (short)-1);
// Now the stream
Stream stream = Stream.createStream(ptr, compressedStream, null, null);
-
+
// Check
assertNotNull(stream.getPointer());
assertNotNull(stream.getStore());
assertTrue(stream.getStore() instanceof StreamStore);
assertTrue(stream.getStore() instanceof CompressedStreamStore);
assertTrue(stream instanceof UnknownStream);
-
+
// Check the stream store
CompressedStreamStore ss = (CompressedStreamStore)stream.getStore();
assertEquals(4, ss._getBlockHeader().length);
assertEquals(compressedStream.length, ss._getCompressedContents().length);
assertEquals(uncompressedStream.length, ss.getContents().length);
-
+
for(int i=0; i<uncompressedStream.length; i++) {
assertEquals(uncompressedStream[i], ss.getContents()[i]);
}
}
-
+
public void testUncompressedStream() {
// Create a fake pointer
Pointer ptr = new TestPointer(false, 0, uncompressedStream.length, -1, (short)-1);
// Now the stream
Stream stream = Stream.createStream(ptr, uncompressedStream, null, null);
-
+
// Check
assertNotNull(stream.getPointer());
assertNotNull(stream.getStore());
@@ -120,4 +121,4 @@ public class TestStreamBasics extends StreamTest {
assertFalse(stream.getStore() instanceof CompressedStreamStore);
assertTrue(stream instanceof UnknownStream);
}
-} \ No newline at end of file
+}
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
index 9d4cac1689..507c2e9579 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamBugs.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import java.io.FileInputStream;
@@ -28,7 +29,7 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
/**
* Tests for bugs with streams
*/
-public class TestStreamBugs extends StreamTest {
+public final class TestStreamBugs extends StreamTest {
private byte[] contents;
private ChunkFactory chunkFactory;
private PointerFactory ptrFactory;
@@ -42,7 +43,7 @@ public class TestStreamBugs extends StreamTest {
FileInputStream fin = new FileInputStream(filename);
filesystem = new POIFSFileSystem(fin);
-
+
DocumentEntry docProps =
(DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
@@ -50,41 +51,41 @@ public class TestStreamBugs extends StreamTest {
contents = new byte[docProps.getSize()];
filesystem.createDocumentInputStream("VisioDocument").read(contents);
}
-
+
public void testGetTrailer() throws Exception {
Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
}
-
+
public void TOIMPLEMENTtestGetCertainChunks() throws Exception {
int offsetA = 3708;
int offsetB = 3744;
}
-
+
public void testGetChildren() throws Exception {
Pointer trailerPointer = ptrFactory.createPointer(contents, 0x24);
TrailerStream trailer = (TrailerStream)
Stream.createStream(trailerPointer, contents, chunkFactory, ptrFactory);
-
+
// Get without recursing
Pointer[] ptrs = trailer.getChildPointers();
for(int i=0; i<ptrs.length; i++) {
Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
}
-
+
// Get with recursing into chunks
for(int i=0; i<ptrs.length; i++) {
- Stream stream =
+ Stream stream =
Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
if(stream instanceof ChunkStream) {
ChunkStream cStream = (ChunkStream)stream;
cStream.findChunks();
}
}
-
+
// Get with recursing into chunks and pointers
for(int i=0; i<ptrs.length; i++) {
- Stream stream =
+ Stream stream =
Stream.createStream(ptrs[i], contents, chunkFactory, ptrFactory);
if(stream instanceof PointerContainingStream) {
PointerContainingStream pStream =
@@ -92,7 +93,7 @@ public class TestStreamBugs extends StreamTest {
pStream.findChildren(contents);
}
}
-
+
trailer.findChildren(contents);
}
diff --git a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
index 5ea21d1a1c..8f1897e00e 100644
--- a/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
+++ b/src/scratchpad/testcases/org/apache/poi/hdgf/streams/TestStreamComplex.java
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hdgf.streams;
import java.io.FileInputStream;
@@ -25,7 +26,7 @@ import org.apache.poi.hdgf.pointers.PointerFactory;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-public class TestStreamComplex extends StreamTest {
+public final class TestStreamComplex extends StreamTest {
private byte[] contents;
private int trailerPointerAt = 0x24;
private int trailerDataAt = 0x8a94;
@@ -40,7 +41,7 @@ public class TestStreamComplex extends StreamTest {
FileInputStream fin = new FileInputStream(filename);
POIFSFileSystem filesystem = new POIFSFileSystem(fin);
-
+
DocumentEntry docProps =
(DocumentEntry)filesystem.getRoot().getEntry("VisioDocument");
@@ -55,71 +56,71 @@ public class TestStreamComplex extends StreamTest {
public void testTrailer() {
// Find the trailer
Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
-
+
assertEquals(20, trailerPtr.getType());
assertEquals(trailerDataAt, trailerPtr.getOffset());
-
+
Stream stream = Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
assertTrue(stream instanceof TrailerStream);
TrailerStream ts = (TrailerStream)stream;
-
+
assertNotNull(ts.getChildPointers());
assertNull(ts.getPointedToStreams());
-
+
assertEquals(20, ts.getChildPointers().length);
assertEquals(0x16, ts.getChildPointers()[0].getType());
assertEquals(0x17, ts.getChildPointers()[1].getType());
assertEquals(0x17, ts.getChildPointers()[2].getType());
assertEquals(0xff, ts.getChildPointers()[3].getType());
}
-
+
public void testChunks() {
Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
TrailerStream ts = (TrailerStream)
Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
+
// Should be 7th one
Pointer chunkPtr = ts.getChildPointers()[5];
assertFalse(chunkPtr.destinationHasStrings());
assertTrue(chunkPtr.destinationHasChunks());
assertFalse(chunkPtr.destinationHasPointers());
-
+
Stream stream = Stream.createStream(chunkPtr, contents, chunkFactory, ptrFactory);
assertNotNull(stream);
assertTrue(stream instanceof ChunkStream);
-
+
// Now find the chunks within it
ChunkStream cs = (ChunkStream)stream;
cs.findChunks();
}
-
+
public void testStrings() {
Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
TrailerStream ts = (TrailerStream)
Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
+
// Should be the 1st one
Pointer stringPtr = ts.getChildPointers()[0];
assertTrue(stringPtr.destinationHasStrings());
assertFalse(stringPtr.destinationHasChunks());
assertFalse(stringPtr.destinationHasPointers());
-
+
Stream stream = Stream.createStream(stringPtr, contents, chunkFactory, ptrFactory);
assertNotNull(stream);
assertTrue(stream instanceof StringsStream);
}
-
+
public void testPointerToStrings() {
// The stream at 0x347f has strings
// The stream at 0x4312 has a pointer to 0x347f
// The stream at 0x44d3 has a pointer to 0x4312
// (it's the 2nd one of 3, and the block is compressed)
-
+
TestPointer ptr44d3 = new TestPointer(true, 0x44d3, 0x51, 0x4e, (short)0x56);
ptr44d3.hasPointers = true;
PointerContainingStream s44d3 = (PointerContainingStream)
Stream.createStream(ptr44d3, contents, chunkFactory, ptrFactory);
-
+
// Type: 0d Addr: 014ff644 Offset: 4312 Len: 48 Format: 54 From: 44d3
Pointer ptr4312 = s44d3.getChildPointers()[1];
assertEquals(0x0d, ptr4312.getType());
@@ -128,10 +129,10 @@ public class TestStreamComplex extends StreamTest {
assertEquals(0x54, ptr4312.getFormat());
assertTrue(ptr4312.destinationHasPointers());
assertFalse(ptr4312.destinationHasStrings());
-
+
PointerContainingStream s4312 = (PointerContainingStream)
Stream.createStream(ptr4312, contents, chunkFactory, ptrFactory);
-
+
// Check it has 0x347f
// Type: 1f Addr: 01540004 Offset: 347f Len: 8e8 Format: 46 From: 4312
assertEquals(2, s4312.getChildPointers().length);
@@ -142,7 +143,7 @@ public class TestStreamComplex extends StreamTest {
assertEquals(0x46, ptr347f.getFormat());
assertFalse(ptr347f.destinationHasPointers());
assertTrue(ptr347f.destinationHasStrings());
-
+
// Find the children of 0x4312
assertNull(s4312.getPointedToStreams());
s4312.findChildren(contents);
@@ -152,89 +153,89 @@ public class TestStreamComplex extends StreamTest {
assertTrue(s4312.getPointedToStreams()[0] instanceof StringsStream);
assertTrue(s4312.getPointedToStreams()[1] instanceof StringsStream);
}
-
+
public void testTrailerContents() {
Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
TrailerStream ts = (TrailerStream)
Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
+
assertNotNull(ts.getChildPointers());
assertNull(ts.getPointedToStreams());
assertEquals(20, ts.getChildPointers().length);
-
+
ts.findChildren(contents);
-
+
assertNotNull(ts.getChildPointers());
assertNotNull(ts.getPointedToStreams());
assertEquals(20, ts.getChildPointers().length);
assertEquals(20, ts.getPointedToStreams().length);
-
+
// Step down:
// 8 -> 4 -> 5 -> 1 -> 0 == String
assertNotNull(ts.getPointedToStreams()[8]);
assertTrue(ts.getPointedToStreams()[8] instanceof PointerContainingStream);
-
- PointerContainingStream s8 =
+
+ PointerContainingStream s8 =
(PointerContainingStream)ts.getPointedToStreams()[8];
assertNotNull(s8.getPointedToStreams());
-
+
assertNotNull(s8.getPointedToStreams()[4]);
assertTrue(s8.getPointedToStreams()[4] instanceof PointerContainingStream);
-
- PointerContainingStream s84 =
+
+ PointerContainingStream s84 =
(PointerContainingStream)s8.getPointedToStreams()[4];
assertNotNull(s84.getPointedToStreams());
-
+
assertNotNull(s84.getPointedToStreams()[5]);
assertTrue(s84.getPointedToStreams()[5] instanceof PointerContainingStream);
-
- PointerContainingStream s845 =
+
+ PointerContainingStream s845 =
(PointerContainingStream)s84.getPointedToStreams()[5];
assertNotNull(s845.getPointedToStreams());
-
+
assertNotNull(s845.getPointedToStreams()[1]);
assertTrue(s845.getPointedToStreams()[1] instanceof PointerContainingStream);
-
- PointerContainingStream s8451 =
+
+ PointerContainingStream s8451 =
(PointerContainingStream)s845.getPointedToStreams()[1];
assertNotNull(s8451.getPointedToStreams());
-
+
assertNotNull(s8451.getPointedToStreams()[0]);
assertTrue(s8451.getPointedToStreams()[0] instanceof StringsStream);
assertTrue(s8451.getPointedToStreams()[1] instanceof StringsStream);
}
-
+
public void testChunkWithText() throws Exception {
// Parent ChunkStream is at 0x7194
// This is one of the last children of the trailer
Pointer trailerPtr = ptrFactory.createPointer(contents, trailerPointerAt);
TrailerStream ts = (TrailerStream)
Stream.createStream(trailerPtr, contents, chunkFactory, ptrFactory);
-
+
ts.findChildren(contents);
-
+
assertNotNull(ts.getChildPointers());
assertNotNull(ts.getPointedToStreams());
assertEquals(20, ts.getChildPointers().length);
assertEquals(20, ts.getPointedToStreams().length);
-
+
assertEquals(0x7194, ts.getChildPointers()[13].getOffset());
assertEquals(0x7194, ts.getPointedToStreams()[13].getPointer().getOffset());
-
+
PointerContainingStream ps7194 = (PointerContainingStream)
ts.getPointedToStreams()[13];
-
+
// First child is at 0x64b3
assertEquals(0x64b3, ps7194.getChildPointers()[0].getOffset());
assertEquals(0x64b3, ps7194.getPointedToStreams()[0].getPointer().getOffset());
-
+
ChunkStream cs = (ChunkStream)ps7194.getPointedToStreams()[0];
-
+
// Should be 26bc bytes un-compressed
assertEquals(0x26bc, cs.getStore().getContents().length);
// And should have lots of children
assertEquals(131, cs.getChunks().length);
-
+
// One of which is Text
boolean hasText = false;
for(int i=0; i<cs.getChunks().length; i++) {
@@ -245,20 +246,20 @@ public class TestStreamComplex extends StreamTest {
assertTrue(hasText);
// Which is the 72nd command
assertEquals("Text", cs.getChunks()[72].getName());
-
+
Chunk text = cs.getChunks()[72];
assertEquals("Text", text.getName());
-
+
// Which contains our text
assertEquals(1, text.getCommands().length);
assertEquals("Test View\n", text.getCommands()[0].getValue());
-
-
+
+
// Almost at the end is some more text
assertEquals("Text", cs.getChunks()[128].getName());
text = cs.getChunks()[128];
assertEquals("Text", text.getName());
-
+
assertEquals(1, text.getCommands().length);
assertEquals("Some random text, on a page\n", text.getCommands()[0].getValue());
}