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
This commit is contained in:
Dominik Stadler 2015-05-12 06:27:11 +00:00
parent c4a26a18f4
commit cbd315d441
3 changed files with 12 additions and 5 deletions

View File

@ -65,7 +65,7 @@ public final class RowRecord extends StandardRecord {
public RowRecord(int rowNumber) { public RowRecord(int rowNumber) {
if(rowNumber < 0) { if(rowNumber < 0) {
throw new IllegalArgumentException("Invalid row number " + rowNumber + " specified"); throw new IllegalArgumentException("Invalid row number (" + rowNumber + ")");
} }
field_1_row_number = rowNumber; field_1_row_number = rowNumber;
field_4_height = (short)0xFF; field_4_height = (short)0xFF;

View File

@ -17,6 +17,8 @@
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import java.io.IOException;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFITestDataProvider;
@ -71,7 +73,7 @@ public final class TestHSSFRow extends BaseTestRow {
assertEquals(-1, row.getLastCellNum()); assertEquals(-1, row.getLastCellNum());
} }
public void testMoveCell() { public void testMoveCell() throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet(); HSSFSheet sheet = workbook.createSheet();
HSSFRow row = sheet.createRow(0); HSSFRow row = sheet.createRow(0);
@ -115,9 +117,11 @@ public final class TestHSSFRow extends BaseTestRow {
assertEquals(5, cellB2.getColumnIndex()); assertEquals(5, cellB2.getColumnIndex());
assertEquals(2, row.getFirstCellNum()); assertEquals(2, row.getFirstCellNum());
assertEquals(6, row.getLastCellNum()); assertEquals(6, row.getLastCellNum());
workbook.close();
} }
public void testRowHeight(){ public void testRowHeight() throws IOException{
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet(); HSSFSheet sheet = workbook.createSheet();
HSSFRow row = sheet.createRow(0); HSSFRow row = sheet.createRow(0);
@ -132,5 +136,7 @@ public final class TestHSSFRow extends BaseTestRow {
row.setHeight((short) -1); row.setHeight((short) -1);
assertEquals(row.getHeight(), sheet.getDefaultRowHeight()); assertEquals(row.getHeight(), sheet.getDefaultRowHeight());
assertEquals(row.getRowRecord().getBadFontHeight(), false); assertEquals(row.getRowRecord().getBadFontHeight(), false);
workbook.close();
} }
} }

View File

@ -17,6 +17,7 @@
package org.apache.poi.ss.usermodel; package org.apache.poi.ss.usermodel;
import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -138,7 +139,7 @@ public abstract class BaseTestRow extends TestCase {
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
// expected during successful test // expected during successful test
assertTrue("Did not find expected error message, had: " + e, 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 //Test high row bound
@ -285,7 +286,7 @@ public abstract class BaseTestRow extends TestCase {
assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType()); assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5).getCellType());
} }
public void testRowHeight() { public void testRowHeight() throws IOException {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
Row row1 = sheet.createRow(0); Row row1 = sheet.createRow(0);