Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32291/input/javasrc/biz/xsoftware/mock2/impl
Modified Files:
MockObjectSuperImpl.java
Log Message:
check in for further modify , the build is successful , but the test is not totally right right now
Index: MockObjectSuperImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MockObjectSuperImpl.java 23 Feb 2006 11:36:32 -0000 1.7
--- MockObjectSuperImpl.java 20 Mar 2006 15:01:20 -0000 1.8
***************
*** 2,5 ****
--- 2,6 ----
+ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.LinkedList;
***************
*** 11,14 ****
--- 12,16 ----
import biz.xsoftware.mock2.MockObject;
+
public abstract class MockObjectSuperImpl implements MockObject {
***************
*** 26,30 ****
/**
! * List of the methods been called ,and store them
*/
private Map<String, Object> retVal = new HashMap<String, Object>();
--- 28,32 ----
/**
! * a Map of return value which the method with return value has
*/
private Map<String, Object> retVal = new HashMap<String, Object>();
***************
*** 39,48 ****
*/
private Map<String, Throwable> methodWithException = new HashMap<String, Throwable>();
!
/**
! * a with the ignore method
*/
! // private Map<String, Object> methodToDefaultRetVal = new HashMap<String, Object>();
!
public CalledMethod expect(String methodName, Class... vargs) {
return expect(methodName, DEFAULT_TIME_OUT, vargs);
--- 41,55 ----
*/
private Map<String, Throwable> methodWithException = new HashMap<String, Throwable>();
!
/**
! * A List of Method
*/
! private List<Method> methodList=new LinkedList<Method>();
!
! /**
! * a Map of behavior impl which is passed in by expect method
! */
! private Map<String,Behavior> behaviorMap=new HashMap<String,Behavior>();
!
public CalledMethod expect(String methodName, Class... vargs) {
return expect(methodName, DEFAULT_TIME_OUT, vargs);
***************
*** 61,65 ****
public CalledMethod expect(String methodName, Behavior behavior,
! Class... params) {
return expect(methodName, behavior, DEFAULT_TIME_OUT, params);
--- 68,72 ----
public CalledMethod expect(String methodName, Behavior behavior,
! Class... params){
return expect(methodName, behavior, DEFAULT_TIME_OUT, params);
***************
*** 95,103 ****
public CalledMethod expect(String methodName, Behavior behavior,
! long timeout, Class... params) {
! // TODO Auto-generated method stub
! return null;
}
public void verify(){
--- 102,129 ----
public CalledMethod expect(String methodName, Behavior behavior,
! long timeout, Class... params){
! if(methodName==null)
! throw new IllegalArgumentException("method name can not be null");
! CalledMethod calledMethod=new CalledMethodImpl(methodName);
! methodsExpected.add(calledMethod);
! behaviorMap.put(methodName,behavior);
!
!
! try {
! Class c=behavior.getClass();
! Method method = c.getMethod(methodName,params);
! methodList.add(method);
! } catch (SecurityException e) {
! // TODO Auto-generated catch block
! e.printStackTrace();
! } catch (NoSuchMethodException e) {
! throw new IllegalArgumentException("method:"+methodName+"is not defined in your Behvior Implemetation");
! }
!
! return calledMethod;
}
+
+
public void verify(){
***************
*** 118,122 ****
CalledMethod calledMethod = methodsCalled.remove(0);
CalledMethodImpl m = (CalledMethodImpl) methodsExpected.remove(0);
-
m.setParameters(calledMethod.getParameters());
m.setStackTrace(calledMethod.getStackTrace());
--- 144,147 ----
***************
*** 172,178 ****
throw t;
}
!
!
! return getReturnValue(methodName);
}
--- 197,212 ----
throw t;
}
!
! for(int i=0;i<methodList.size();i++){
! if(methodList.get(i).getName()==calledMethod.getMethodName()){
! Method m=methodList.get(i);
! Behavior b=behaviorMap.get(calledMethod.getMethodName());
! // m.setAccessible(true);
! Object retValue=m.invoke(b,calledMethod.getParameters());
! retVal.put(methodName,retValue);
! }
! }
!
! return getReturnValue(methodName);
}
***************
*** 180,184 ****
if (retVal.size() == 0) {
String returnValue = "No return value is set";
! setDefaultReturnValue(returnValue, methodName);
}
if (retVal.containsKey(methodName)) {
--- 214,220 ----
if (retVal.size() == 0) {
String returnValue = "No return value is set";
! // setDefaultReturnValue(returnValue, methodName);
!
! return returnValue;
}
if (retVal.containsKey(methodName)) {
|