Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20450/input/javasrc/biz/xsoftware/mock
Modified Files:
MockObjectImpl.java
Log Message:
add nice exception for when a null is returned and a primitive is needed.
Index: MockObjectImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock/MockObjectImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MockObjectImpl.java 27 Jun 2005 03:40:32 -0000 1.4
--- MockObjectImpl.java 18 Sep 2005 17:10:24 -0000 1.5
***************
*** 51,56 ****
if(isMethodInSuper.contains(method))
return callSuperMethod(proxy, method, args);
! return methodCalledImpl(method.getName(), args);
}
/**
--- 51,64 ----
if(isMethodInSuper.contains(method))
return callSuperMethod(proxy, method, args);
+
+ Object o = methodCalledImpl(method.getName(), args);
! if(o == null) {
! Class c = method.getReturnType();
! if(!Object.class.isAssignableFrom(c) && !"void".equals(c.getName())) {
! throw new RuntimeException("Must call addReturnValue and specify a non-null value as method="+method.getName()+" returns a primitive value");
! }
! }
! return o;
}
/**
|