Update of /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv2881/input/javasrc/biz/xsoftware/impl/mock
Modified Files:
MockSuperclass.java BehaviorInfo.java
Log Message:
basic example with behavior.
Index: MockSuperclass.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/MockSuperclass.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MockSuperclass.java 1 Oct 2006 03:18:44 -0000 1.4
--- MockSuperclass.java 1 Oct 2006 04:02:00 -0000 1.5
***************
*** 16,19 ****
--- 16,20 ----
import biz.xsoftware.mock.ExpectFailedException;
import biz.xsoftware.mock.MockObject;
+ import biz.xsoftware.mock.NoCloneBehavior;
***************
*** 558,561 ****
--- 559,565 ----
try {
+ if(behavior instanceof NoCloneBehavior)
+ return;
+
Method clonerMethod = clazz.getMethod(m.getName()+"Cloner", (Class[])m.getParameterTypes());
action.setClonerMethod(clonerMethod);
***************
*** 621,625 ****
if(action instanceof BehaviorInfo) {
BehaviorInfo behavior = (BehaviorInfo)action;
! return behavior.runClonerMethod(params);
}
--- 625,630 ----
if(action instanceof BehaviorInfo) {
BehaviorInfo behavior = (BehaviorInfo)action;
! if(behavior.hasClonerMethod())
! return behavior.runClonerMethod(params);
}
Index: BehaviorInfo.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib3/input/javasrc/biz/xsoftware/impl/mock/BehaviorInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BehaviorInfo.java 1 Oct 2006 03:18:44 -0000 1.2
--- BehaviorInfo.java 1 Oct 2006 04:02:00 -0000 1.3
***************
*** 1,4 ****
--- 1,5 ----
package biz.xsoftware.impl.mock;
+ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
***************
*** 16,20 ****
public Object execute(Object[] args) throws Throwable {
! return behaviorMethod.invoke(behavior, args);
}
--- 17,28 ----
public Object execute(Object[] args) throws Throwable {
! try {
! return behaviorMethod.invoke(behavior, args);
! } catch(InvocationTargetException e) {
! if(e.getCause() != null)
! throw e.getCause();
! else
! throw e;
! }
}
***************
*** 30,33 ****
--- 38,47 ----
this.clonerMethod = clonerMethod;
}
+
+ public boolean hasClonerMethod() {
+ if(clonerMethod == null)
+ return false;
+ return true;
+ }
// private Method method;
|