Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28877/input/javasrc/biz/xsoftware/mock2/impl
Modified Files:
Tag: branchForOffice
MockObjectSuperImpl.java
Log Message:
Index: MockObjectSuperImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v
retrieving revision 1.3.2.6
retrieving revision 1.3.2.7
diff -C2 -d -r1.3.2.6 -r1.3.2.7
*** MockObjectSuperImpl.java 6 Feb 2006 16:02:54 -0000 1.3.2.6
--- MockObjectSuperImpl.java 15 Feb 2006 14:44:57 -0000 1.3.2.7
***************
*** 29,34 ****
* List of the methods been called ,and store them
*/
! // private List<CalledMethod> calledMethodsStore=new
! // LinkedList<CalledMethod>();
/**
* List of the methods that have been expected
--- 29,33 ----
* List of the methods been called ,and store them
*/
! Map retVal=new HashMap();
/**
* List of the methods that have been expected
***************
*** 78,83 ****
public CalledMethod expect(Object returnValue, String methodName,
long timeout, Class... vargs) {
! // TODO Auto-generated method stub
! return null;
}
--- 77,86 ----
public CalledMethod expect(Object returnValue, String methodName,
long timeout, Class... vargs) {
! if(methodName==null)
! throw new IllegalArgumentException("method name can not be null");
! CalledMethod calledMethod=new CalledMethodImpl(methodName);
! methodsExpected.add(calledMethod);
! retVal.put(methodName,returnValue);
! return calledMethod;
}
***************
*** 113,116 ****
--- 116,120 ----
m.setParameters(calledMethod.getParameters());
m.setStackTrace(calledMethod.getStackTrace());
+
}
***************
*** 129,133 ****
public void setDefaultReturnValue(Object returnValue, String methodName,
Class... vargs) {
! // TODO Auto-generated method stub
}
--- 133,137 ----
public void setDefaultReturnValue(Object returnValue, String methodName,
Class... vargs) {
!
}
***************
*** 158,161 ****
--- 162,166 ----
CalledMethod calledMethod = new CalledMethodImpl(methodName,
parameters, stackTrace);
+
methodsCalled.add(calledMethod);
***************
*** 166,180 ****
private Object getReturnValue(String methodName) {
!
! List l = (List) methodToReturnVal.get(methodName);
! if (l != null) {
! Object retVal = l.remove(0);
! if (l.size() <= 0)
! methodToReturnVal.remove(methodName);
! return retVal;
}
! // next line returns null if setDefaultReturnValue not called by test
! // case...
! return methodToDefaultRetVal.get(methodName);
}
--- 171,184 ----
private Object getReturnValue(String methodName) {
! if(retVal.size()==0){
! String returnValue="No return value is set";
! setDefaultReturnValue(returnValue,methodName);
}
! if(retVal.containsKey(methodName)){
! return retVal.get(methodName);
! }
!
! return null;
!
}
|