diff options
author | Yegor Kozlov <yegor@apache.org> | 2008-01-10 18:04:38 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2008-01-10 18:04:38 +0000 |
commit | f13f164e72fe6a3c53302d1f015d098426848829 (patch) | |
tree | 5dc7ade188aceea9fa130fa93beb268642c0df43 /src/testcases/org | |
parent | 7ad30758812963137fe648cb07eacabcddbaec56 (diff) | |
download | poi-f13f164e72fe6a3c53302d1f015d098426848829.tar.gz poi-f13f164e72fe6a3c53302d1f015d098426848829.zip |
fixed bug 44200: Sheet not cloneable when Note added to excel cell
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@610855 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org')
-rwxr-xr-x | src/testcases/org/apache/poi/hssf/data/44200.xls | bin | 0 -> 13824 bytes | |||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls | bin | 21504 -> 21504 bytes | |||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java | 23 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java | 12 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java | 40 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 22 |
6 files changed, 96 insertions, 1 deletions
diff --git a/src/testcases/org/apache/poi/hssf/data/44200.xls b/src/testcases/org/apache/poi/hssf/data/44200.xls Binary files differnew file mode 100755 index 0000000000..691afedb80 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/data/44200.xls diff --git a/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls b/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls Binary files differindex 556ea81927..6b71a77f2d 100644 --- a/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls +++ b/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls diff --git a/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java index 5d45094924..2f967b66e6 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestNoteRecord.java @@ -79,4 +79,27 @@ public class TestNoteRecord System.arraycopy(ser, 4, recdata, 0, recdata.length); assertTrue(Arrays.equals(data, recdata)); } + + public void testClone() + { + NoteRecord record = new NoteRecord(); + + record.setRow((short)1); + record.setColumn((short)2); + record.setFlags(NoteRecord.NOTE_VISIBLE); + record.setShapeId((short)1026); + record.setAuthor("Apache Software Foundation"); + + NoteRecord cloned = (NoteRecord)record.clone(); + assertEquals(record.getRow(), cloned.getRow()); + assertEquals(record.getColumn(), cloned.getColumn()); + assertEquals(record.getFlags(), cloned.getFlags()); + assertEquals(record.getShapeId(), cloned.getShapeId()); + assertEquals(record.getAuthor(), cloned.getAuthor()); + + //finally check that the serialized data is the same + byte[] src = record.serialize(); + byte[] cln = cloned.serialize(); + assertTrue(Arrays.equals(src, cln)); + } } diff --git a/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java b/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java index 833aa66128..d6b5a64766 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestNoteStructureSubRecord.java @@ -65,4 +65,16 @@ public class TestNoteStructureSubRecord assertEquals(ser.length - 4, data.length); } + + public void testClone() + { + NoteStructureSubRecord record = new NoteStructureSubRecord(); + byte[] src = record.serialize(); + + NoteStructureSubRecord cloned = (NoteStructureSubRecord)record.clone(); + byte[] cln = cloned.serialize(); + + assertEquals(record.getRecordSize(), cloned.getRecordSize()); + assertTrue(Arrays.equals(src, cln)); + } } diff --git a/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java b/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java index 63b9db356f..64e087a554 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestTextObjectRecord.java @@ -117,4 +117,44 @@ public class TestTextObjectRecord extends TestCase { }
}
+
+ /**
+ * Test cloning
+ */
+ public void testClone() {
+ String text = "Hello, World";
+ HSSFRichTextString str = new HSSFRichTextString(text);
+
+ TextObjectRecord obj = new TextObjectRecord();
+ int frLength = ( str.numFormattingRuns() + 1 ) * 8;
+ obj.setFormattingRunLength( (short) frLength );
+ obj.setTextLength( (short) str.length() );
+ obj.setReserved1(true);
+ obj.setReserved2((short)2);
+ obj.setReserved3((short)3);
+ obj.setReserved4((short)4);
+ obj.setReserved5((short)5);
+ obj.setReserved6((short)6);
+ obj.setReserved7((short)7);
+ obj.setStr( str );
+
+
+ TextObjectRecord cloned = (TextObjectRecord)obj.clone();
+ assertEquals(obj.getReserved2(), cloned.getReserved2());
+ assertEquals(obj.getReserved3(), cloned.getReserved3());
+ assertEquals(obj.getReserved4(), cloned.getReserved4());
+ assertEquals(obj.getReserved5(), cloned.getReserved5());
+ assertEquals(obj.getReserved6(), cloned.getReserved6());
+ assertEquals(obj.getReserved7(), cloned.getReserved7());
+ assertEquals(obj.getRecordSize(), cloned.getRecordSize());
+ assertEquals(obj.getOptions(), cloned.getOptions());
+ assertEquals(obj.getHorizontalTextAlignment(), cloned.getHorizontalTextAlignment());
+ assertEquals(obj.getFormattingRunLength(), cloned.getFormattingRunLength());
+ assertEquals(obj.getStr().getString(), cloned.getStr().getString());
+
+ //finally check that the serialized data is the same
+ byte[] src = obj.serialize();
+ byte[] cln = cloned.serialize();
+ assertTrue(Arrays.equals(src, cln));
+ }
}
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 75ec3fee60..a3154e3063 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -913,7 +913,27 @@ extends TestCase { } - + /** + * Bug 44200: Sheet not cloneable when Note added to excel cell + */ + public void test44200() throws Exception { + FileInputStream in = new FileInputStream(new File(cwd, "44200.xls")); + HSSFWorkbook wb = new HSSFWorkbook(in); + in.close(); + + wb.cloneSheet(0); + assertTrue("No Exceptions while cloning sheet", true); + + //serialize and read again + ByteArrayOutputStream out = new ByteArrayOutputStream(); + wb.write(out); + out.close(); + + wb = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); + assertTrue("No Exceptions while reading file", true); + + } + } |