add watermark test case (as example)

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1160745 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Sergey Vladimirov 2011-08-23 15:35:07 +00:00
parent ebe0c65b9a
commit 4813799df7
2 changed files with 32 additions and 0 deletions

View File

@ -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 );
}
}

Binary file not shown.