Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20088/input/javasrc/biz/xsoftware/impl/mock
Modified Files:
MessageHelper.java ReturnValue.java MockSuperclass.java
BehaviorInfo.java ThrowException.java Action.java
Removed Files:
GenericAction.java
Log Message:
refactor mocklib3 a bit.
Index: ReturnValue.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/ReturnValue.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ReturnValue.java 12 Sep 2006 02:20:59 -0000 1.1
--- ReturnValue.java 1 Oct 2006 03:18:44 -0000 1.2
***************
*** 1,5 ****
package biz.xsoftware.impl.mock;
! public class ReturnValue extends GenericAction implements Action {
private Object retVal;
--- 1,5 ----
package biz.xsoftware.impl.mock;
! public class ReturnValue implements Action {
private Object retVal;
--- GenericAction.java DELETED ---
Index: ThrowException.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/ThrowException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ThrowException.java 12 Sep 2006 02:20:59 -0000 1.1
--- ThrowException.java 1 Oct 2006 03:18:44 -0000 1.2
***************
*** 1,5 ****
package biz.xsoftware.impl.mock;
! public class ThrowException extends GenericAction implements Action {
private Throwable e;
--- 1,5 ----
package biz.xsoftware.impl.mock;
! public class ThrowException implements Action {
private Throwable e;
Index: BehaviorInfo.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/BehaviorInfo.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BehaviorInfo.java 12 Sep 2006 02:20:58 -0000 1.1
--- BehaviorInfo.java 1 Oct 2006 03:18:44 -0000 1.2
***************
*** 5,9 ****
import biz.xsoftware.mock.Behavior;
! public class BehaviorInfo extends GenericAction implements Action {
private Behavior behavior;
--- 5,9 ----
import biz.xsoftware.mock.Behavior;
! public class BehaviorInfo implements Action {
private Behavior behavior;
***************
*** 30,32 ****
--- 30,42 ----
this.clonerMethod = clonerMethod;
}
+
+ // private Method method;
+ //
+ // public Method getMethod() {
+ // return method;
+ // }
+ //
+ // public void setMethod(Method method) {
+ // this.method = method;
+ // }
}
Index: Action.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/Action.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Action.java 12 Sep 2006 02:20:58 -0000 1.1
--- Action.java 1 Oct 2006 03:18:45 -0000 1.2
***************
*** 1,5 ****
package biz.xsoftware.impl.mock;
- import java.lang.reflect.Method;
public interface Action {
--- 1,4 ----
***************
*** 7,11 ****
public Object execute(Object[] args) throws Throwable;
- public void setMethod(Method m);
- public Method getMethod();
}
--- 6,8 ----
Index: MockSuperclass.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/MockSuperclass.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** MockSuperclass.java 13 Sep 2006 03:09:00 -0000 1.3
--- MockSuperclass.java 1 Oct 2006 03:18:44 -0000 1.4
***************
*** 85,89 ****
* called.
*/
! public static final int DEFAULT_WAIT_TIME = 10000;
private int waitTime = DEFAULT_WAIT_TIME;
--- 85,89 ----
* called.
*/
! public static final int DEFAULT_WAIT_TIME = 5000;
private int waitTime = DEFAULT_WAIT_TIME;
***************
*** 539,546 ****
if(behavior == null)
throw new IllegalArgumentException("behavior parameter cannot be null");
BehaviorInfo action = new BehaviorInfo(behavior);
addToActionList(action, method, argTypes);
- Method m = action.getMethod();
//verify behavior has correct methods
Class clazz = behavior.getClass();
--- 539,546 ----
if(behavior == null)
throw new IllegalArgumentException("behavior parameter cannot be null");
+ Method m = checkMethod(method, argTypes);
BehaviorInfo action = new BehaviorInfo(behavior);
addToActionList(action, method, argTypes);
//verify behavior has correct methods
Class clazz = behavior.getClass();
***************
*** 574,607 ****
public void addThrowException(String method, Throwable e)
{
! addThrowException(method, e, new Class[] {});
! }
!
! /**
! * @see biz.xsoftware.mock.MockObject#addThrowException(java.lang.String, java.lang.Throwable, Class...)
! */
! public synchronized void addThrowException(String method, Throwable e, Class... argTypes) {
! if(e == null)
! throw new IllegalArgumentException("e parameter to this method cannot be null");
Action action = new ThrowException(e);
! addToActionList(action, method, argTypes);
}
-
public void addReturnValue(String method, Object o)
{
! addReturnValue(method, o, new Class[] {});
! }
!
! /**
! * @see biz.xsoftware.mock.MockObject#addReturnValue(java.lang.String, java.lang.Object, Class...)
! */
! public synchronized void addReturnValue(String method, Object o, Class... argTypes) {
Action action = new ReturnValue(o);
! addToActionList(action, method, argTypes);
}
private void addToActionList(Action action, String method, Class... argTypes) {
! Method m = checkMethod(method, argTypes);
! action.setMethod(m);
List<Action> l = methodToReturnVal.get(method);
if(l == null) {
--- 574,591 ----
public void addThrowException(String method, Throwable e)
{
! verityMethodExists(method);
Action action = new ThrowException(e);
! addToActionList(action, method);
}
public void addReturnValue(String method, Object o)
{
! verityMethodExists(method);
Action action = new ReturnValue(o);
! addToActionList(action, method);
}
private void addToActionList(Action action, String method, Class... argTypes) {
!
List<Action> l = methodToReturnVal.get(method);
if(l == null) {
***************
*** 649,656 ****
private void verifyMethodsExist(String[] methods) {
for(int i = 0; i < methods.length; i++) {
! MethodVerifier.getMethod(getClasses(), false, methods[i]);
}
}
private Method checkMethod(String method, Class[] argTypes) {
return MethodVerifier.getMethod(getClasses(), true, method, argTypes);
--- 633,644 ----
private void verifyMethodsExist(String[] methods) {
for(int i = 0; i < methods.length; i++) {
! verityMethodExists(methods[i]);
}
}
+ private void verityMethodExists(String method) {
+ MethodVerifier.getMethod(getClasses(), false, method);
+ }
+
private Method checkMethod(String method, Class[] argTypes) {
return MethodVerifier.getMethod(getClasses(), true, method, argTypes);
Index: MessageHelper.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/MessageHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MessageHelper.java 14 Sep 2006 22:36:53 -0000 1.2
--- MessageHelper.java 1 Oct 2006 03:18:44 -0000 1.3
***************
*** 28,32 ****
}
! public static String putTogetherReason(String[] methods, Set<String> ignorables, List methodsCalled, String lastLine) {
String reason = "\nMethods you expected...\n";
for(int i = 0; i < methods.length; i++) {
--- 28,32 ----
}
! public static String putTogetherReason(String[] methods, Set<String> ignorables, List<CalledMethod> methodsCalled, String lastLine) {
String reason = "\nMethods you expected...\n";
for(int i = 0; i < methods.length; i++) {
|