Clean-up in POIFS unit tests - compacted raw data declaration
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@784316 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
818492c6a2
commit
fa914b75ee
@ -24,6 +24,8 @@ import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.poifs.storage.RawDataUtil;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
@ -260,64 +262,32 @@ public final class TestDirectoryProperty extends TestCase {
|
||||
assertTrue(_property.changeName(p1, originalName));
|
||||
}
|
||||
|
||||
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 static 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());
|
||||
|
@ -20,6 +20,8 @@ package org.apache.poi.poifs.property;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.poifs.storage.RawDataUtil;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
@ -44,140 +46,25 @@ public final class TestDocumentProperty extends TestCase {
|
||||
}
|
||||
|
||||
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
|
||||
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");
|
||||
@ -185,7 +72,7 @@ public final class TestDocumentProperty extends TestCase {
|
||||
}
|
||||
|
||||
private void verifyReadingProperty(int index, byte[] input, int offset, String name)
|
||||
throws IOException {
|
||||
throws IOException {
|
||||
DocumentProperty property = new DocumentProperty(index, input,
|
||||
offset);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,7 @@ import java.io.IOException;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.poifs.common.POIFSConstants;
|
||||
import org.apache.poi.poifs.storage.RawDataUtil;
|
||||
|
||||
/**
|
||||
* Class to test RootProperty functionality
|
||||
@ -30,141 +31,101 @@ import org.apache.poi.poifs.common.POIFSConstants;
|
||||
* @author Marc Johnson
|
||||
*/
|
||||
public final class TestRootProperty extends TestCase {
|
||||
private RootProperty _property;
|
||||
private byte[] _testblock;
|
||||
private RootProperty _property;
|
||||
private byte[] _testblock;
|
||||
|
||||
public void testConstructor() throws IOException {
|
||||
createBasicRootProperty();
|
||||
verifyProperty();
|
||||
}
|
||||
|
||||
public void testConstructor() throws IOException {
|
||||
createBasicRootProperty();
|
||||
verifyProperty();
|
||||
}
|
||||
private void createBasicRootProperty() {
|
||||
_property = new RootProperty();
|
||||
_testblock = new byte[128];
|
||||
int index = 0;
|
||||
|
||||
private void createBasicRootProperty()
|
||||
{
|
||||
_property = new RootProperty();
|
||||
_testblock = new byte[ 128 ];
|
||||
int index = 0;
|
||||
for (; index < 0x40; index++) {
|
||||
_testblock[index] = (byte) 0;
|
||||
}
|
||||
String name = "Root Entry";
|
||||
int limit = Math.min(31, name.length());
|
||||
|
||||
for (; index < 0x40; index++)
|
||||
{
|
||||
_testblock[ index ] = ( byte ) 0;
|
||||
}
|
||||
String name = "Root Entry";
|
||||
int limit = Math.min(31, name.length());
|
||||
_testblock[index++] = (byte) (2 * (limit + 1));
|
||||
_testblock[index++] = (byte) 0;
|
||||
_testblock[index++] = (byte) 5;
|
||||
_testblock[index++] = (byte) 1;
|
||||
for (; index < 0x50; index++) {
|
||||
_testblock[index] = (byte) 0xff;
|
||||
}
|
||||
for (; index < 0x74; index++) {
|
||||
_testblock[index] = (byte) 0;
|
||||
}
|
||||
_testblock[index++] = (byte) POIFSConstants.END_OF_CHAIN;
|
||||
for (; index < 0x78; index++) {
|
||||
_testblock[index] = (byte) 0xff;
|
||||
}
|
||||
for (; index < 0x80; index++) {
|
||||
_testblock[index] = (byte) 0;
|
||||
}
|
||||
byte[] name_bytes = name.getBytes();
|
||||
|
||||
_testblock[ index++ ] = ( byte ) (2 * (limit + 1));
|
||||
_testblock[ index++ ] = ( byte ) 0;
|
||||
_testblock[ index++ ] = ( byte ) 5;
|
||||
_testblock[ index++ ] = ( byte ) 1;
|
||||
for (; index < 0x50; index++)
|
||||
{
|
||||
_testblock[ index ] = ( byte ) 0xff;
|
||||
}
|
||||
for (; index < 0x74; index++)
|
||||
{
|
||||
_testblock[ index ] = ( byte ) 0;
|
||||
}
|
||||
_testblock[ index++ ] = ( byte ) POIFSConstants.END_OF_CHAIN;
|
||||
for (; index < 0x78; index++)
|
||||
{
|
||||
_testblock[ index ] = ( byte ) 0xff;
|
||||
}
|
||||
for (; index < 0x80; index++)
|
||||
{
|
||||
_testblock[ index ] = ( byte ) 0;
|
||||
}
|
||||
byte[] name_bytes = name.getBytes();
|
||||
for (index = 0; index < limit; index++) {
|
||||
_testblock[index * 2] = name_bytes[index];
|
||||
}
|
||||
}
|
||||
|
||||
for (index = 0; index < limit; index++)
|
||||
{
|
||||
_testblock[ index * 2 ] = name_bytes[ index ];
|
||||
}
|
||||
}
|
||||
private void verifyProperty() throws IOException {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
||||
|
||||
private void verifyProperty() throws IOException {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(512);
|
||||
_property.writeData(stream);
|
||||
byte[] output = stream.toByteArray();
|
||||
|
||||
_property.writeData(stream);
|
||||
byte[] output = stream.toByteArray();
|
||||
assertEquals(_testblock.length, output.length);
|
||||
for (int j = 0; j < _testblock.length; j++) {
|
||||
assertEquals("mismatch at offset " + j, _testblock[j], output[j]);
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(_testblock.length, output.length);
|
||||
for (int j = 0; j < _testblock.length; j++)
|
||||
{
|
||||
assertEquals("mismatch at offset " + j, _testblock[ j ],
|
||||
output[ j ]);
|
||||
}
|
||||
}
|
||||
public void testSetSize() {
|
||||
for (int j = 0; j < 10; j++) {
|
||||
createBasicRootProperty();
|
||||
_property.setSize(j);
|
||||
assertEquals("trying block count of " + j, j * 64, _property.getSize());
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetSize() {
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
createBasicRootProperty();
|
||||
_property.setSize(j);
|
||||
assertEquals("trying block count of " + j, j * 64,
|
||||
_property.getSize());
|
||||
}
|
||||
}
|
||||
public void testReadingConstructor() {
|
||||
String[] input = {
|
||||
"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",
|
||||
};
|
||||
verifyReadingProperty(0, RawDataUtil.decode(input), 0, "Root Entry",
|
||||
"{00020820-0000-0000-C000-000000000046}");
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
private void verifyReadingProperty(int index, byte[] input, int offset, String name,
|
||||
String sClsId) {
|
||||
RootProperty property = new RootProperty(index, input, offset);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
||||
byte[] expected = new byte[128];
|
||||
|
||||
verifyReadingProperty(0, input, 0, "Root Entry", "{00020820-0000-0000-C000-000000000046}");
|
||||
}
|
||||
System.arraycopy(input, offset, expected, 0, 128);
|
||||
try {
|
||||
property.writeData(stream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
byte[] output = stream.toByteArray();
|
||||
|
||||
private void verifyReadingProperty(int index, byte[] input, int offset, String name,
|
||||
String sClsId) throws IOException {
|
||||
RootProperty property = new RootProperty(index, input,
|
||||
offset);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream(128);
|
||||
byte[] expected = new byte[ 128 ];
|
||||
|
||||
System.arraycopy(input, offset, expected, 0, 128);
|
||||
property.writeData(stream);
|
||||
byte[] output = stream.toByteArray();
|
||||
|
||||
assertEquals(128, output.length);
|
||||
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());
|
||||
assertEquals(property.getStorageClsid().toString(), sClsId);
|
||||
}
|
||||
assertEquals(128, output.length);
|
||||
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());
|
||||
assertEquals(property.getStorageClsid().toString(), sClsId);
|
||||
}
|
||||
}
|
||||
|
70
src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java
Normal file
70
src/testcases/org/apache/poi/poifs/storage/RawDataUtil.java
Normal file
@ -0,0 +1,70 @@
|
||||
package org.apache.poi.poifs.storage;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.util.HexRead;
|
||||
|
||||
/**
|
||||
* Test utility class.<br/>
|
||||
*
|
||||
* Creates raw <code>byte[]</code> data from hex-dump String arrays.
|
||||
*
|
||||
* @author Josh Micich
|
||||
*/
|
||||
public final class RawDataUtil {
|
||||
|
||||
public static byte[] decode(String[] hexDataLines) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(hexDataLines.length * 32 + 32);
|
||||
|
||||
for (int i = 0; i < hexDataLines.length; i++) {
|
||||
byte[] lineData = HexRead.readFromString(hexDataLines[i]);
|
||||
baos.write(lineData, 0, lineData.length);
|
||||
}
|
||||
return baos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Development time utility method.<br/>
|
||||
* Transforms a byte array into hex-dump String lines in java source code format.
|
||||
*/
|
||||
public static void dumpData(byte[] data) {
|
||||
int i=0;
|
||||
System.out.println("String[] hexDataLines = {");
|
||||
System.out.print("\t\"");
|
||||
while(true) {
|
||||
char[] cc = HexDump.byteToHex(data[i]);
|
||||
System.out.print(cc[2]);
|
||||
System.out.print(cc[3]);
|
||||
i++;
|
||||
if (i>=data.length) {
|
||||
break;
|
||||
}
|
||||
if (i % 32 == 0) {
|
||||
System.out.println("\",");
|
||||
System.out.print("\t\"");
|
||||
} else {
|
||||
System.out.print(" ");
|
||||
}
|
||||
}
|
||||
System.out.println("\",");
|
||||
System.out.println("};");
|
||||
}
|
||||
|
||||
/**
|
||||
* Development time utility method.<br/>
|
||||
* Confirms that the specified byte array is equivalent to the hex-dump String lines.
|
||||
*/
|
||||
public static void confirmEqual(byte[] expected, String[] hexDataLines) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(hexDataLines.length * 32 + 32);
|
||||
|
||||
for (int i = 0; i < hexDataLines.length; i++) {
|
||||
byte[] lineData = HexRead.readFromString(hexDataLines[i]);
|
||||
baos.write(lineData, 0, lineData.length);
|
||||
}
|
||||
if (!Arrays.equals(expected, baos.toByteArray())) {
|
||||
throw new RuntimeException("different");
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -29,178 +29,55 @@ import junit.framework.TestCase;
|
||||
*/
|
||||
public final class TestHeaderBlockReader extends TestCase {
|
||||
|
||||
public void testConstructors() throws IOException {
|
||||
byte[] content =
|
||||
{
|
||||
( byte ) 0xD0, ( byte ) 0xCF, ( byte ) 0x11, ( byte ) 0xE0,
|
||||
( byte ) 0xA1, ( byte ) 0xB1, ( byte ) 0x1A, ( byte ) 0xE1,
|
||||
( 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 ) 0x3B, ( byte ) 0x00, ( byte ) 0x03, ( byte ) 0x00,
|
||||
( byte ) 0xFE, ( byte ) 0xFF, ( byte ) 0x09, ( byte ) 0x00,
|
||||
( byte ) 0x06, ( 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 ) 0xFE, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||
( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
|
||||
( byte ) 0x00, ( byte ) 0x10, ( byte ) 0x00, ( byte ) 0x00,
|
||||
( byte ) 0xFE, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||
( byte ) 0x01, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
|
||||
( byte ) 0xFE, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||
( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00, ( byte ) 0x00,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF, ( 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 ) 0xFF,
|
||||
( 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 ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF,
|
||||
( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF, ( byte ) 0xFF
|
||||
};
|
||||
HeaderBlockReader block =
|
||||
new HeaderBlockReader(new ByteArrayInputStream(content));
|
||||
public void testConstructors() throws IOException {
|
||||
String[] hexData = {
|
||||
"D0 CF 11 E0 A1 B1 1A E1 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3B 00 03 00 FE FF 09 00",
|
||||
"06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FE FF FF FF 00 00 00 00 00 10 00 00 FE FF FF FF",
|
||||
"01 00 00 00 FE FF FF FF 00 00 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
"FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF",
|
||||
};
|
||||
byte[] content = RawDataUtil.decode(hexData);
|
||||
HeaderBlockReader block = new HeaderBlockReader(new ByteArrayInputStream(content));
|
||||
|
||||
assertEquals(-2, block.getPropertyStart());
|
||||
assertEquals(-2, block.getPropertyStart());
|
||||
|
||||
// verify we can't read a short block
|
||||
byte[] shortblock = new byte[ 511 ];
|
||||
// verify we can't read a short block
|
||||
byte[] shortblock = new byte[511];
|
||||
|
||||
System.arraycopy(content, 0, shortblock, 0, 511);
|
||||
try
|
||||
{
|
||||
block =
|
||||
new HeaderBlockReader(new ByteArrayInputStream(shortblock));
|
||||
fail("Should have caught IOException reading a short block");
|
||||
}
|
||||
catch (IOException ignored)
|
||||
{
|
||||
System.arraycopy(content, 0, shortblock, 0, 511);
|
||||
try {
|
||||
block = new HeaderBlockReader(new ByteArrayInputStream(shortblock));
|
||||
fail("Should have caught IOException reading a short block");
|
||||
} catch (IOException ignored) {
|
||||
|
||||
// as expected
|
||||
}
|
||||
// as expected
|
||||
}
|
||||
|
||||
// try various forms of corruption
|
||||
for (int index = 0; index < 8; index++)
|
||||
{
|
||||
content[ index ] = ( byte ) (content[ index ] - 1);
|
||||
try
|
||||
{
|
||||
block =
|
||||
new HeaderBlockReader(new ByteArrayInputStream(content));
|
||||
fail("Should have caught IOException corrupting byte "
|
||||
+ index);
|
||||
}
|
||||
catch (IOException ignored)
|
||||
{
|
||||
// try various forms of corruption
|
||||
for (int index = 0; index < 8; index++) {
|
||||
content[index] = (byte) (content[index] - 1);
|
||||
try {
|
||||
block = new HeaderBlockReader(new ByteArrayInputStream(content));
|
||||
fail("Should have caught IOException corrupting byte " + index);
|
||||
} catch (IOException ignored) {
|
||||
|
||||
// as expected
|
||||
}
|
||||
// as expected
|
||||
}
|
||||
|
||||
// restore byte value
|
||||
content[ index ] = ( byte ) (content[ index ] + 1);
|
||||
}
|
||||
}
|
||||
// restore byte value
|
||||
content[index] = (byte) (content[index] + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user