From: Jeff M. <cus...@us...> - 2003-04-10 10:37:42
|
Update of /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql In directory sc8-pr-cvs1:/tmp/cvs-serv25779/src/jdk/common/com/mockobjects/sql Modified Files: MockResultSet.java CommonMockMultiRowResultSet.java Log Message: Provided better error message for out of bounds values for getObject Index: MockResultSet.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/MockResultSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MockResultSet.java 31 Dec 2002 14:44:26 -0000 1.5 +++ MockResultSet.java 10 Apr 2003 10:37:39 -0000 1.6 @@ -25,6 +25,7 @@ private final ExpectationCounter myCloseCalls; protected final ExpectationCounter myNextCalls; + protected final String name; private final ReturnValue myMetaData = new ReturnValue("meta data"); private final ReturnValue myStatement = new ReturnValue("statement"); @@ -33,7 +34,11 @@ this(MockResultSet.class.getName()); } + /** + * @param name Label used to identify mock when it errors + */ public MockResultSet(String name) { + this.name = name; myCloseCalls = new ExpectationCounter(name + ".close"); myNextCalls = new ExpectationCounter(name + ".next"); } Index: CommonMockMultiRowResultSet.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/jdk/common/com/mockobjects/sql/CommonMockMultiRowResultSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CommonMockMultiRowResultSet.java 9 Dec 2002 18:20:12 -0000 1.3 +++ CommonMockMultiRowResultSet.java 10 Apr 2003 10:37:39 -0000 1.4 @@ -1,5 +1,7 @@ package com.mockobjects.sql; +import com.mockobjects.util.AssertMo; + import java.sql.SQLException; /** @@ -18,6 +20,9 @@ super(); } + /** + * @param name Label used to identify mock when it errors + */ public CommonMockMultiRowResultSet(String name) { super(name); } @@ -36,6 +41,9 @@ public Object getObject(int columnIndex) throws SQLException { throwGetExceptionIfAny(); + if (columnIndex > myRows[myRowOffset].length || columnIndex < 1) { + AssertMo.fail("Column " + columnIndex + " not found in " + name); + } return myRows[myRowOffset][columnIndex - 1]; } |