diff --git a/src/scratchpad/testcases/org/apache/poi/hemf/hemfplus/extractor/HemfPlusExtractorTest.java b/src/scratchpad/testcases/org/apache/poi/hemf/hemfplus/extractor/HemfPlusExtractorTest.java index b42bac7d5d..afd255591c 100644 --- a/src/scratchpad/testcases/org/apache/poi/hemf/hemfplus/extractor/HemfPlusExtractorTest.java +++ b/src/scratchpad/testcases/org/apache/poi/hemf/hemfplus/extractor/HemfPlusExtractorTest.java @@ -73,20 +73,16 @@ public class HemfPlusExtractorTest { private EmfCommentDataPlus getCommentRecord(String testFileName, int recordIndex) throws Exception { - EmfCommentDataPlus returnRecord = null; - try (InputStream is = POIDataSamples.getSpreadSheetInstance().openResourceAsStream(testFileName)) { HemfPicture ex = new HemfPicture(is); int i = 0; for (HemfRecord record : ex) { - if (i == recordIndex) { - EmfComment commentRecord = ((EmfComment) record); - returnRecord = (EmfCommentDataPlus) commentRecord.getCommentData(); - break; + if (record instanceof EmfComment && i++ == recordIndex) { + EmfComment commentRecord = (EmfComment)record; + return (EmfCommentDataPlus) commentRecord.getCommentData(); } - i++; } } - return returnRecord; + return null; } } diff --git a/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java b/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java index 8ff4742be6..5f630b563e 100644 --- a/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java +++ b/src/scratchpad/testcases/org/apache/poi/hemf/usermodel/HemfPictureTest.java @@ -207,8 +207,8 @@ public class HemfPictureTest { assertEquals(27864, header.getBytes()); assertEquals(31, header.getRecords()); assertEquals(3, header.getHandles()); - assertEquals(346000, header.getMicroDimension().getWidth()); - assertEquals(194000, header.getMicroDimension().getHeight()); + assertEquals(346000, header.getMicroDimension().getWidth(), 0); + assertEquals(194000, header.getMicroDimension().getHeight(), 0); List records = pic.getRecords();