fix broken HSSFWorkbook test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1913648 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2023-11-07 12:00:57 +00:00
parent a57344e585
commit c9506f0f39
3 changed files with 22 additions and 10 deletions

View File

@ -43,7 +43,7 @@ plugins {
repositories { repositories {
mavenCentral() 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 // Only add the plugin for Sonar if enabled
@ -127,7 +127,7 @@ subprojects {
log4jVersion = '2.21.1' log4jVersion = '2.21.1'
mockitoVersion = '4.11.0' mockitoVersion = '4.11.0'
hamcrestVersion = '2.2' hamcrestVersion = '2.2'
xmlbeansVersion = '5.1.1' xmlbeansVersion = '5.2.0'
batikVersion = '1.17' batikVersion = '1.17'
graphics2dVersion = '0.43' graphics2dVersion = '0.43'
pdfboxVersion = '2.0.29' pdfboxVersion = '2.0.29'
@ -177,7 +177,7 @@ subprojects {
repositories { repositories {
mavenCentral() mavenCentral()
//maven { url 'https://repository.apache.org/content/repositories/staging' } maven { url 'https://repository.apache.org/content/repositories/staging' }
} }
dependencies { dependencies {

View File

@ -99,6 +99,15 @@ public final class TestHSSFWorkbook extends BaseTestWorkbook {
return wb.getWorkbook(); return wb.getWorkbook();
} }
@Override
protected int getDrawingSizeForCreateDrawing1() {
return 225;
}
@Override
protected int getDrawingSizeForCreateDrawing2() {
return 171;
}
/** /**
* Tests for {@link HSSFWorkbook#isHidden()} etc * 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 @Test
void writeInvalidFile() throws Exception { void writeInvalidFile() throws Exception {
try (Workbook wb = WorkbookFactory.create( try (Workbook wb = WorkbookFactory.create(

View File

@ -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 // bug 51233 and 55075: correctly size image if added to a row with a custom height
@Test @Test
void createDrawing() throws Exception { void createDrawing() throws Exception {
@ -906,13 +914,13 @@ public abstract class BaseTestWorkbook {
assertEquals(0, anchor.getRow1()); assertEquals(0, anchor.getRow1());
assertEquals(0, anchor.getRow2()); assertEquals(0, anchor.getRow2());
assertEquals(0, anchor.getDy1()); assertEquals(0, anchor.getDy1());
assertEquals(1609725, anchor.getDy2()); //HSSF: 225 assertEquals(getDrawingSizeForCreateDrawing1(), anchor.getDy2());
// Check drawing width // Check drawing width
assertEquals(0, anchor.getCol1()); assertEquals(0, anchor.getCol1());
assertEquals(0, anchor.getCol2()); assertEquals(0, anchor.getCol2());
assertEquals(0, anchor.getDx1()); assertEquals(0, anchor.getDx1());
assertEquals(1114425, anchor.getDx2()); //HSSF: 171 assertEquals(getDrawingSizeForCreateDrawing2(), anchor.getDx2());
} }
} }