From cbd315d441e7d4c8917738ead00aef94b051550a Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Tue, 12 May 2015 06:27:11 +0000 Subject: [PATCH] Adjust error message to have the same error across different types of Workbook and revert test to check on common error message again git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1678874 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/record/RowRecord.java | 2 +- .../org/apache/poi/hssf/usermodel/TestHSSFRow.java | 10 ++++++++-- .../org/apache/poi/ss/usermodel/BaseTestRow.java | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java index 7a9026dc5..ffbf9c753 100644 --- a/src/java/org/apache/poi/hssf/record/RowRecord.java +++ b/src/java/org/apache/poi/hssf/record/RowRecord.java @@ -65,7 +65,7 @@ public final class RowRecord extends StandardRecord { public RowRecord(int rowNumber) { if(rowNumber < 0) { - throw new IllegalArgumentException("Invalid row number " + rowNumber + " specified"); + throw new IllegalArgumentException("Invalid row number (" + rowNumber + ")"); } field_1_row_number = rowNumber; field_4_height = (short)0xFF; diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java index 654db6aa0..dafb481d3 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java @@ -17,6 +17,8 @@ package org.apache.poi.hssf.usermodel; +import java.io.IOException; + import junit.framework.AssertionFailedError; import org.apache.poi.hssf.HSSFITestDataProvider; @@ -71,7 +73,7 @@ public final class TestHSSFRow extends BaseTestRow { assertEquals(-1, row.getLastCellNum()); } - public void testMoveCell() { + public void testMoveCell() throws IOException { HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); HSSFRow row = sheet.createRow(0); @@ -115,9 +117,11 @@ public final class TestHSSFRow extends BaseTestRow { assertEquals(5, cellB2.getColumnIndex()); assertEquals(2, row.getFirstCellNum()); assertEquals(6, row.getLastCellNum()); + + workbook.close(); } - public void testRowHeight(){ + public void testRowHeight() throws IOException{ HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); HSSFRow row = sheet.createRow(0); @@ -132,5 +136,7 @@ public final class TestHSSFRow extends BaseTestRow { row.setHeight((short) -1); assertEquals(row.getHeight(), sheet.getDefaultRowHeight()); assertEquals(row.getRowRecord().getBadFontHeight(), false); + + workbook.close(); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index ca59fa7f7..2ae096aa1 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.usermodel; +import java.io.IOException; import java.util.Iterator; import junit.framework.TestCase; @@ -138,7 +139,7 @@ public abstract class BaseTestRow extends TestCase { } catch (IllegalArgumentException e) { // expected during successful test assertTrue("Did not find expected error message, had: " + e, - e.getMessage().startsWith("Invalid row number -1")); + e.getMessage().startsWith("Invalid row number (-1)")); } //Test high row bound @@ -285,7 +286,7 @@ public abstract class BaseTestRow extends TestCase { assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType()); } - public void testRowHeight() { + public void testRowHeight() throws IOException { Workbook workbook = _testDataProvider.createWorkbook(); Sheet sheet = workbook.createSheet(); Row row1 = sheet.createRow(0);