From c9506f0f3911c5710a8e8c4c0945d0a6e227d308 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 7 Nov 2023 12:00:57 +0000 Subject: [PATCH] fix broken HSSFWorkbook test git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913648 13f79535-47bb-0310-9956-ffa450edef68 --- build.gradle | 6 +++--- .../poi/hssf/usermodel/TestHSSFWorkbook.java | 14 +++++++++----- .../apache/poi/ss/usermodel/BaseTestWorkbook.java | 12 ++++++++++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 7d8a34aeb6..366d661a81 100644 --- a/build.gradle +++ b/build.gradle @@ -43,7 +43,7 @@ plugins { repositories { mavenCentral() - //maven { url 'https://repository.apache.org/content/repositories/staging' } + maven { url 'https://repository.apache.org/content/repositories/staging' } } // Only add the plugin for Sonar if enabled @@ -127,7 +127,7 @@ subprojects { log4jVersion = '2.21.1' mockitoVersion = '4.11.0' hamcrestVersion = '2.2' - xmlbeansVersion = '5.1.1' + xmlbeansVersion = '5.2.0' batikVersion = '1.17' graphics2dVersion = '0.43' pdfboxVersion = '2.0.29' @@ -177,7 +177,7 @@ subprojects { repositories { mavenCentral() - //maven { url 'https://repository.apache.org/content/repositories/staging' } + maven { url 'https://repository.apache.org/content/repositories/staging' } } dependencies { diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java index 9cba23ff82..9d99627674 100644 --- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java +++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -99,6 +99,15 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { return wb.getWorkbook(); } + @Override + protected int getDrawingSizeForCreateDrawing1() { + return 225; + } + @Override + protected int getDrawingSizeForCreateDrawing2() { + return 171; + } + /** * Tests for {@link HSSFWorkbook#isHidden()} etc */ @@ -1217,11 +1226,6 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook { } } - @Disabled - void createDrawing() { - // the dimensions for this image are different than for XSSF and SXSSF - } - @Test void writeInvalidFile() throws Exception { try (Workbook wb = WorkbookFactory.create( diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java index 0dc0bafbf6..7e16d69df6 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestWorkbook.java @@ -872,6 +872,14 @@ public abstract class BaseTestWorkbook { } } + // these 2 values are overridden in TestHSSFWorkbook + protected int getDrawingSizeForCreateDrawing1() { + return 1609725; + } + protected int getDrawingSizeForCreateDrawing2() { + return 1114425; + } + // bug 51233 and 55075: correctly size image if added to a row with a custom height @Test void createDrawing() throws Exception { @@ -906,13 +914,13 @@ public abstract class BaseTestWorkbook { assertEquals(0, anchor.getRow1()); assertEquals(0, anchor.getRow2()); assertEquals(0, anchor.getDy1()); - assertEquals(1609725, anchor.getDy2()); //HSSF: 225 + assertEquals(getDrawingSizeForCreateDrawing1(), anchor.getDy2()); // Check drawing width assertEquals(0, anchor.getCol1()); assertEquals(0, anchor.getCol2()); assertEquals(0, anchor.getDx1()); - assertEquals(1114425, anchor.getDx2()); //HSSF: 171 + assertEquals(getDrawingSizeForCreateDrawing2(), anchor.getDx2()); } }