aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/poifs/storage
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2010-12-19 05:54:11 +0000
committerNick Burch <nick@apache.org>2010-12-19 05:54:11 +0000
commit6703ad1c9367738d08e53a974a849c0a0a7479c6 (patch)
tree4a0a0f4f1f23e986a4e7545c5cb76b29d563877b /src/testcases/org/apache/poi/poifs/storage
parent4b8e5f61c18bc0d178aeb161fc36e8b5645da055 (diff)
downloadpoi-6703ad1c9367738d08e53a974a849c0a0a7479c6.tar.gz
poi-6703ad1c9367738d08e53a974a849c0a0a7479c6.zip
Start to merge the POIFS classes HeaderBlockReader and HeaderBlockWriter into a common HeaderBlock class
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1050764 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/poifs/storage')
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java4
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java10
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReading.java (renamed from src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReader.java)8
-rw-r--r--src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriting.java (renamed from src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriter.java)6
4 files changed, 16 insertions, 12 deletions
diff --git a/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java b/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
index b589922587..46011916ee 100644
--- a/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
+++ b/src/testcases/org/apache/poi/poifs/storage/AllPOIFSStorageTests.java
@@ -33,8 +33,8 @@ public final class AllPOIFSStorageTests {
result.addTestSuite(TestBlockAllocationTableWriter.class);
result.addTestSuite(TestBlockListImpl.class);
result.addTestSuite(TestDocumentBlock.class);
- result.addTestSuite(TestHeaderBlockReader.class);
- result.addTestSuite(TestHeaderBlockWriter.class);
+ result.addTestSuite(TestHeaderBlockReading.class);
+ result.addTestSuite(TestHeaderBlockWriting.class);
result.addTestSuite(TestPropertyBlock.class);
result.addTestSuite(TestRawDataBlock.class);
result.addTestSuite(TestRawDataBlockList.class);
diff --git a/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java b/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java
index 45dd34c26e..79f7bd76de 100644
--- a/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java
+++ b/src/testcases/org/apache/poi/poifs/storage/TestBlockAllocationTableReader.java
@@ -405,10 +405,10 @@ public final class TestBlockAllocationTableReader extends TestCase {
// similar code to POIFSFileSystem.<init>:
InputStream stream = new ByteArrayInputStream(data);
- HeaderBlockReader hb;
+ HeaderBlock hb;
RawDataBlockList dataBlocks;
try {
- hb = new HeaderBlockReader(stream);
+ hb = new HeaderBlock(stream);
dataBlocks = new RawDataBlockList(stream, bigBlockSize);
} catch (IOException e) {
throw new RuntimeException(e);
@@ -419,7 +419,11 @@ public final class TestBlockAllocationTableReader extends TestCase {
hb.getXBATIndex(), dataBlocks);
} catch (IOException e) {
// expected during successful test
- assertEquals("Block count 538976257 is too high. POI maximum is 65535.", e.getMessage());
+ assertEquals(
+ "Your file contains 0 sectors, but the initial DIFAT array at index 0 referenced block # 538976288. This isn't allowed and your file is corrupt",
+ e.getMessage()
+ );
+// assertEquals("Block count 538976257 is too high. POI maximum is 65535.", e.getMessage());
} catch (OutOfMemoryError e) {
if (e.getStackTrace()[1].getMethodName().equals("testBadSectorAllocationTableSize")) {
throw new AssertionFailedError("Identified bug 48085");
diff --git a/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReader.java b/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReading.java
index f49ef12322..15077c4fba 100644
--- a/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReader.java
+++ b/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockReading.java
@@ -27,7 +27,7 @@ import junit.framework.TestCase;
*
* @author Marc Johnson
*/
-public final class TestHeaderBlockReader extends TestCase {
+public final class TestHeaderBlockReading extends TestCase {
public void testConstructors() throws IOException {
String[] hexData = {
@@ -49,7 +49,7 @@ public final class TestHeaderBlockReader extends TestCase {
"FF FF FF FF FF FF FF FF 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));
+ HeaderBlock block = new HeaderBlock(new ByteArrayInputStream(content));
assertEquals(-2, block.getPropertyStart());
@@ -58,7 +58,7 @@ public final class TestHeaderBlockReader extends TestCase {
System.arraycopy(content, 0, shortblock, 0, 511);
try {
- block = new HeaderBlockReader(new ByteArrayInputStream(shortblock));
+ block = new HeaderBlock(new ByteArrayInputStream(shortblock));
fail("Should have caught IOException reading a short block");
} catch (IOException ignored) {
@@ -69,7 +69,7 @@ public final class TestHeaderBlockReader extends TestCase {
for (int index = 0; index < 8; index++) {
content[index] = (byte) (content[index] - 1);
try {
- block = new HeaderBlockReader(new ByteArrayInputStream(content));
+ block = new HeaderBlock(new ByteArrayInputStream(content));
fail("Should have caught IOException corrupting byte " + index);
} catch (IOException ignored) {
diff --git a/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriter.java b/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriting.java
index 456d30c52e..e01c7885be 100644
--- a/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriter.java
+++ b/src/testcases/org/apache/poi/poifs/storage/TestHeaderBlockWriting.java
@@ -32,7 +32,7 @@ import org.apache.poi.util.LittleEndianConsts;
*
* @author Marc Johnson
*/
-public final class TestHeaderBlockWriter extends TestCase {
+public final class TestHeaderBlockWriting extends TestCase {
private static void confirmEqual(String[] expectedDataHexDumpLines, byte[] actual) {
byte[] expected = RawDataUtil.decode(expectedDataHexDumpLines);
@@ -78,8 +78,8 @@ public final class TestHeaderBlockWriter extends TestCase {
block.setPropertyStart(0x87654321);
output = new ByteArrayOutputStream(512);
block.writeBlocks(output);
- assertEquals(0x87654321, new HeaderBlockReader(new ByteArrayInputStream(output
- .toByteArray())).getPropertyStart());
+ assertEquals(0x87654321, new HeaderBlock(
+ new ByteArrayInputStream(output.toByteArray())).getPropertyStart());
}
/**