diff options
author | Dominik Stadler <centic@apache.org> | 2014-12-21 21:07:25 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2014-12-21 21:07:25 +0000 |
commit | 920c7d59888a19ebe689c4ed7e960b4289c1ff8c (patch) | |
tree | dea1bee85eeeef8bb4b706f045d04be9a4757793 /src/testcases/org/apache | |
parent | e67b008ce8da523864eb52aa50e44e4be5240552 (diff) | |
download | poi-920c7d59888a19ebe689c4ed7e960b4289c1ff8c.tar.gz poi-920c7d59888a19ebe689c4ed7e960b4289c1ff8c.zip |
Add a test for spreadsheet/49219.xls which previously failed with NullPointerException because we did not handle serializing ExternalNameRecords without actual data
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647212 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java b/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java index 1b6e4a1212..54042ba006 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java @@ -17,11 +17,11 @@ package org.apache.poi.hssf.record; -import org.apache.poi.util.HexRead; -import org.apache.poi.util.HexDump; - import junit.framework.AssertionFailedError; import junit.framework.TestCase; + +import org.apache.poi.util.HexDump; +import org.apache.poi.util.HexRead; /** * * @author Josh Micich @@ -68,6 +68,8 @@ public final class TestExternalNameRecord extends TestCase { throw new AssertionFailedError("Identified bug 44695"); } assertEquals(17, enr.getRecordSize()); + + assertNotNull(enr.serialize()); } public void testAutoStdDocName() { @@ -172,4 +174,18 @@ public final class TestExternalNameRecord extends TestCase { byte[] ser = enr.serialize(); assertEquals(HexDump.toHex(data), HexDump.toHex(ser)); } + + public void testNPEWithFileFrom49219() { + // the file at test-data/spreadsheet/49219.xls has ExternalNameRecords without actual data, + // we did handle this during reading, but failed during serializing this out, ensure it works now + byte[] data = new byte[] { + 2, 127, 0, 0, 0, 0, + 9, 0, 82, 97, 116, 101, 95, 68, 97, 116, 101}; + + ExternalNameRecord enr = createSimpleENR(data); + + byte[] ser = enr.serialize(); + assertEquals("[23, 00, 11, 00, 02, 7F, 00, 00, 00, 00, 09, 00, 52, 61, 74, 65, 5F, 44, 61, 74, 65]", + HexDump.toHex(ser)); + } } |