]> source.dussan.org Git - poi.git/commitdiff
add watermark test case (as example)
authorSergey Vladimirov <sergey@apache.org>
Tue, 23 Aug 2011 15:35:07 +0000 (15:35 +0000)
committerSergey Vladimirov <sergey@apache.org>
Tue, 23 Aug 2011 15:35:07 +0000 (15:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1160745 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java [new file with mode: 0644]
test-data/document/watermark.doc [new file with mode: 0644]

diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
new file mode 100644 (file)
index 0000000..64f8e58
--- /dev/null
@@ -0,0 +1,32 @@
+package org.apache.poi.hwpf.usermodel;
+
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.ddf.EscherComplexProperty;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherOptRecord;
+import org.apache.poi.hwpf.HWPFDocument;
+import org.apache.poi.hwpf.HWPFTestDataSamples;
+
+public class TestOfficeDrawings extends TestCase
+{
+    public void testWatermark() throws UnsupportedEncodingException
+    {
+        HWPFDocument hwpfDocument = HWPFTestDataSamples
+                .openSampleFile( "watermark.doc" );
+        OfficeDrawing drawing = hwpfDocument.getOfficeDrawingsHeaders()
+                .getOfficeDrawings().iterator().next();
+        EscherContainerRecord escherContainerRecord = drawing
+                .getOfficeArtSpContainer();
+
+        EscherOptRecord officeArtFOPT = escherContainerRecord
+                .getChildById( (short) 0xF00B );
+        EscherComplexProperty gtextUNICODE = (EscherComplexProperty) officeArtFOPT
+                .lookup( 0x00c0 );
+
+        String text = new String( gtextUNICODE.getComplexData(), "UTF-16LE" );
+        assertEquals( "DRAFT CONTRACT\0", text );
+    }
+}
diff --git a/test-data/document/watermark.doc b/test-data/document/watermark.doc
new file mode 100644 (file)
index 0000000..7e9d586
Binary files /dev/null and b/test-data/document/watermark.doc differ