aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2019-12-27 23:00:13 +0000
committerAndreas Beeker <kiwiwings@apache.org>2019-12-27 23:00:13 +0000
commitc66575c1e7059ed403b74b76e699200fdee507b4 (patch)
tree0fe96421471b53e9f72a2370ce76d61b49a659bc /src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
parent37282aae8f25970b157c40ae0888684f974ba666 (diff)
downloadpoi-c66575c1e7059ed403b74b76e699200fdee507b4.tar.gz
poi-c66575c1e7059ed403b74b76e699200fdee507b4.zip
Migrate all junit tests to Junit 4
get rid of references to junit.framework don't throw AssertionFailedErrors, but use Assert.fail instead add try-with-resources where it was missing git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1872041 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java')
-rw-r--r--src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java34
1 files changed, 14 insertions, 20 deletions
diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
index 1f222b6b27..2dd5737bd9 100644
--- a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
+++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java
@@ -16,40 +16,34 @@
==================================================================== */
package org.apache.poi.hwpf.usermodel;
-import junit.framework.TestCase;
+import static org.apache.poi.hwpf.HWPFTestDataSamples.openSampleFile;
+import static org.junit.Assert.assertEquals;
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;
import org.apache.poi.util.StringUtil;
+import org.junit.Test;
/**
* Test cases for {@link OfficeDrawing} and {@link OfficeDrawingsImpl} classes.
- *
- * @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/
-public class TestOfficeDrawings extends TestCase
-{
+public class TestOfficeDrawings {
/**
* Tests watermark text extraction
*/
- public void testWatermark() throws Exception
- {
- HWPFDocument hwpfDocument = HWPFTestDataSamples
- .openSampleFile( "watermark.doc" );
- OfficeDrawing drawing = hwpfDocument.getOfficeDrawingsHeaders()
- .getOfficeDrawings().iterator().next();
- EscherContainerRecord escherContainerRecord = drawing
- .getOfficeArtSpContainer();
+ @Test
+ public void testWatermark() throws Exception {
+ try (HWPFDocument hwpfDocument = openSampleFile("watermark.doc")) {
+ OfficeDrawing drawing = hwpfDocument.getOfficeDrawingsHeaders().getOfficeDrawings().iterator().next();
+ EscherContainerRecord escherContainerRecord = drawing.getOfficeArtSpContainer();
- EscherOptRecord officeArtFOPT = escherContainerRecord
- .getChildById( (short) 0xF00B );
- EscherComplexProperty gtextUNICODE = officeArtFOPT
- .lookup( 0x00c0 );
+ EscherOptRecord officeArtFOPT = escherContainerRecord.getChildById((short) 0xF00B);
+ EscherComplexProperty gtextUNICODE = officeArtFOPT.lookup(0x00c0);
- String text = StringUtil.getFromUnicodeLE(gtextUNICODE.getComplexData());
- assertEquals( "DRAFT CONTRACT\0", text );
+ String text = StringUtil.getFromUnicodeLE(gtextUNICODE.getComplexData());
+ assertEquals("DRAFT CONTRACT\0", text);
+ }
}
}