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
This commit is contained in:
parent
213aa1559b
commit
8e89cbca3a
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
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.AssertionFailedError;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.poi.util.HexDump;
|
||||||
|
import org.apache.poi.util.HexRead;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Josh Micich
|
* @author Josh Micich
|
||||||
@ -68,6 +68,8 @@ public final class TestExternalNameRecord extends TestCase {
|
|||||||
throw new AssertionFailedError("Identified bug 44695");
|
throw new AssertionFailedError("Identified bug 44695");
|
||||||
}
|
}
|
||||||
assertEquals(17, enr.getRecordSize());
|
assertEquals(17, enr.getRecordSize());
|
||||||
|
|
||||||
|
assertNotNull(enr.serialize());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAutoStdDocName() {
|
public void testAutoStdDocName() {
|
||||||
@ -172,4 +174,18 @@ public final class TestExternalNameRecord extends TestCase {
|
|||||||
byte[] ser = enr.serialize();
|
byte[] ser = enr.serialize();
|
||||||
assertEquals(HexDump.toHex(data), HexDump.toHex(ser));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user