Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/mock
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv10986/input/javasrc/biz/xsoftware/mock
Modified Files:
MockObject.java
Log Message:
added some convenience methods to the interface
Index: MockObject.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/mock/MockObject.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MockObject.java 11 Sep 2006 15:03:59 -0000 1.5
--- MockObject.java 12 Sep 2006 15:02:11 -0000 1.6
***************
*** 31,35 ****
* @return An array of params that were passed to the methods called
*/
! public CalledMethod expect(String method); //, Class ... argTypes);
/**
--- 31,35 ----
* @return An array of params that were passed to the methods called
*/
! public CalledMethod expect(String method);
/**
***************
*** 45,59 ****
*/
public CalledMethod[] expect(String ... methods);
/**
* Set the DefaultReturnValue for a 'method'
*
* @param method The method name to set the default return value for
* @param argTypes Optionally specify the type of parameters of the method
*/
! public void setDefaultReturnValue(Object o, String method, Class... argTypes);
!
public void setDefaultBehavior(Behavior b, String method, Class ... argTypes);
/**
--- 45,89 ----
*/
public CalledMethod[] expect(String ... methods);
+
+ /**
+ * Set the DefaultReturnValue for a 'method'
+ *
+ * @param returnValue
+ * @param method The method name to set the default return value for
+ */
+ public void setDefaultReturnValue(Object returnValue, String method);
/**
* Set the DefaultReturnValue for a 'method'
*
+ * @param returnValue
* @param method The method name to set the default return value for
* @param argTypes Optionally specify the type of parameters of the method
*/
! public void setDefaultReturnValue(Object returnValue, String method, Class... argTypes);
+ public void setDefaultBehavior(Behavior b, String method);
public void setDefaultBehavior(Behavior b, String method, Class ... argTypes);
+
+ /**
+ * Add an exception to throw when a method on the mockObject is called.
+ * <br/<br/>
+ * This can be called many times where each time it is called, the
+ * exception is added to a queue. Each time 'method' is called, it
+ * checks the queue, if empty, it does not throw an exception.
+ * <br/<br/>
+ * Should only pass the type of Throwable that the 'method'
+ * can throw. If you pass IOException in for a method that
+ * doesn't have a signature of 'throws IOException', then
+ * one of the following exceptions will be thrown into
+ * the sysUnderTest
+ * <ol>
+ * <li> UndeclaredThrowableException for MockObjects created with MockCreator</li>
+ * <li> RuntimeException for Subclasses of MockSuperclass</li>
+ * </ol>
+ * @param e The exception to throw on method.
+ * @param method The method to throw the exception on when it is called.
+ */
+ public void addThrowException(Throwable e, String method);
/**
***************
*** 78,81 ****
--- 108,127 ----
*/
public void addThrowException(Throwable e, String method, Class... argTypes);
+
+ /**
+ * Add a return value to return when 'method' is called.
+ * <br></br>
+ * This can be called multiple times and each call will add
+ * to a queue. When 'method' is called, it will return
+ * the first value on the queue. If the queue is null,
+ * 'method' will return the defaultvalue which is null unless
+ * setDefaultReturnValue is called on MockObject.
+ * <br></br>
+ * Use Integer to return int, Long for long, etc.
+ * @param o The object to return that is added to the queue
+ * @param method The method that when called returns first value on queue
+ */
+ public void addReturnValue(Object o, String method);
+
/**
* Add a return value to return when 'method' is called.
***************
*** 93,98 ****
*/
public void addReturnValue(Object o, String method, Class... argTypes);
!
! public void addBehavior(Behavior behavior, String string, Class... argTypes);
/**
--- 139,154 ----
*/
public void addReturnValue(Object o, String method, Class... argTypes);
!
! public void addBehavior(Behavior behavior, String method);
! public void addBehavior(Behavior behavior, String method, Class... argTypes);
!
! /**
! * When calling expect, the MockObject will ignore the methods
! * in 'methods' variable so if one of the methods in this array is
! * called, it will not result in an exception.
! *
! * @param method The name of the method to ignore
! */
! public void addIgnore(String method);
/**
***************
*** 110,113 ****
--- 166,176 ----
*
* @param method The name of the method to not ignore
+ */
+ public void removeIgnore(String method);
+
+ /**
+ * Removes the method from the ignored methods set.
+ *
+ * @param method The name of the method to not ignore
* @param argTypes Optionally specify the type of parameters of the method
*/
|