]> source.dussan.org Git - poi.git/commitdiff
Add a test for spreadsheet/49219.xls which previously failed with NullPointerExceptio...
authorDominik Stadler <centic@apache.org>
Sun, 21 Dec 2014 21:07:25 +0000 (21:07 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 21 Dec 2014 21:07:25 +0000 (21:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647212 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java

index 1b6e4a1212d3d6c633f16973421734013cf34b3a..54042ba00611e6ed1d72818442654253f4650275 100644 (file)
 
 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));
+    }
 }