Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31048/input/javasrc/biz/xsoftware/mock
Modified Files:
MockObjectImpl.java MockSuperclass.java
ExpectFailedException.java MockObjectFactory.java
Log Message:
add findbugs, checkstyle to mocklib.
Index: ExpectFailedException.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock/ExpectFailedException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ExpectFailedException.java 13 Jan 2006 15:45:00 -0000 1.2
--- ExpectFailedException.java 19 Feb 2006 19:20:52 -0000 1.3
***************
*** 29,38 ****
* all your expected methods were called.
*/
! public static final String UNEXPECTED_CALL_AFTER = "Another method that was not expected nor ignored was called after all the expected method calls";
/**
* Expect failed because a method you did not list in expected methods was called
* before or during the other methods you did expect.
*/
! public static final String UNEXPECTED_CALL_BEFORE ="Another method that was not expected nor ignored was called before all the expected method calls were called";
/**
* Expect failed because you expected no methods to be called, but a method was called.
--- 29,40 ----
* all your expected methods were called.
*/
! public static final String UNEXPECTED_CALL_AFTER =
! "Another method that was not expected nor ignored was called after all the expected method calls";
/**
* Expect failed because a method you did not list in expected methods was called
* before or during the other methods you did expect.
*/
! public static final String UNEXPECTED_CALL_BEFORE =
! "Another method that was not expected nor ignored was called before all the expected method calls were called";
/**
* Expect failed because you expected no methods to be called, but a method was called.
Index: MockSuperclass.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock/MockSuperclass.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MockSuperclass.java 24 Sep 2005 05:41:22 -0000 1.5
--- MockSuperclass.java 19 Feb 2006 19:20:52 -0000 1.6
***************
*** 78,82 ****
private String[] ignoredMethods = new String[0];
! protected Cloner cloner;
/**
--- 78,82 ----
private String[] ignoredMethods = new String[0];
! private Cloner cloner;
/**
***************
*** 84,88 ****
* called.
*/
! public final static int DEFAULT_WAIT_TIME = 10000;
private int waitTime = DEFAULT_WAIT_TIME;
--- 84,88 ----
* called.
*/
! public static final int DEFAULT_WAIT_TIME = 10000;
private int waitTime = DEFAULT_WAIT_TIME;
***************
*** 145,153 ****
if(e instanceof RuntimeException)
throw (RuntimeException)e;
! throw new RuntimeException("Sorry, must wrap exception, unwrap in your mockobject, or have mockObject call methodCalledImpl instead", e);
}
}
! synchronized protected Object methodCalledImpl(String method, Object[] parameters) throws Throwable {
method = method.intern();
String params = "";
--- 145,154 ----
if(e instanceof RuntimeException)
throw (RuntimeException)e;
! throw new RuntimeException("Sorry, must wrap exception, unwrap in " +
! "your mockobject, or have mockObject call methodCalledImpl instead", e);
}
}
! protected synchronized Object methodCalledImpl(String method, Object[] parameters) throws Throwable {
method = method.intern();
String params = "";
***************
*** 211,215 ****
* @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[])
*/
! synchronized public CalledMethod[] expectUnorderedCalls(String[] methods) {
if(methods == null)
throw new IllegalArgumentException("methods cannot be null");
--- 212,216 ----
* @see biz.xsoftware.mock.MockObject#expectUnorderedCalls(java.lang.String[])
*/
! public synchronized CalledMethod[] expectUnorderedCalls(String[] methods) {
if(methods == null)
throw new IllegalArgumentException("methods cannot be null");
***************
*** 218,222 ****
for(int i = 0; i < methods.length; i++) {
if(methods[i] == null)
! throw new IllegalArgumentException("None of values in methods can be null, yet methods["+i+"] was null");
}
--- 219,224 ----
for(int i = 0; i < methods.length; i++) {
if(methods[i] == null)
! throw new IllegalArgumentException("None of values in methods " +
! "can be null, yet methods["+i+"] was null");
}
***************
*** 232,241 ****
for(int i = 0; i < methods.length; i++) {
if(ANY.equals(methods[i]))
! throw new IllegalArgumentException("The parameter 'methods' in expectUnorderedCalls cannot contain MockSuperclass.ANY(use expectOrderedCalls instead)");
CalledMethod o = expectUnignoredCall(ANY, ignorables, methodsCalledList);
if(o == null) {
! String reason = putTogetherReason(methods, ignorables, methodsCalledList, "timed out on next expected method\n");
! throw new ExpectFailedException("Timed out waiting for a method call\n"+reason, retVal, ExpectFailedException.TIMED_OUT);
}
Integer index = (Integer)expectedMethods.remove(o.getMethodName());
--- 234,246 ----
for(int i = 0; i < methods.length; i++) {
if(ANY.equals(methods[i]))
! throw new IllegalArgumentException("The parameter 'methods' in " +
! "expectUnorderedCalls cannot contain MockSuperclass.ANY(use expectOrderedCalls instead)");
CalledMethod o = expectUnignoredCall(ANY, ignorables, methodsCalledList);
if(o == null) {
! String reason = putTogetherReason(methods, ignorables, methodsCalledList,
! "timed out on next expected method\n");
! throw new ExpectFailedException("Timed out waiting for a method call\n"
! +reason, retVal, ExpectFailedException.TIMED_OUT);
}
Integer index = (Integer)expectedMethods.remove(o.getMethodName());
***************
*** 290,294 ****
* @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[])
*/
! synchronized public CalledMethod[] expectOrderedCalls(String[] methods) {
if(methods == null)
throw new IllegalArgumentException("methods cannot be null");
--- 295,299 ----
* @see biz.xsoftware.mock.MockObject#expectOrderedCalls(java.lang.String[])
*/
! public synchronized CalledMethod[] expectOrderedCalls(String[] methods) {
if(methods == null)
throw new IllegalArgumentException("methods cannot be null");
***************
*** 321,326 ****
}
if(o == null) {
! String reason = putTogetherReason(methods, ignorables, methodsCalledList, "timed out on next expected method\n");
! throw new ExpectFailedException("Timed out waiting for call="+method+"\n"+reason, cleanup(retVal, i), ExpectFailedException.TIMED_OUT);
}
retVal[i] = o;
--- 326,333 ----
}
if(o == null) {
! String reason = putTogetherReason(methods, ignorables, methodsCalledList,
! "timed out on next expected method\n");
! throw new ExpectFailedException("Timed out waiting for call="
! +method+"\n"+reason, cleanup(retVal, i), ExpectFailedException.TIMED_OUT);
}
retVal[i] = o;
***************
*** 411,415 ****
}
! synchronized protected CalledMethod expectUnignoredCall(String method, Set<String> ignorables, List<CalledMethod> calledMethods) {
if(method == null)
--- 418,422 ----
}
! protected synchronized CalledMethod expectUnignoredCall(String method, Set<String> ignorables, List<CalledMethod> calledMethods) {
if(method == null)
***************
*** 440,444 ****
}
! private CalledMethod waitForUnignoredCall(String logM, Set<String> ignorables, List<CalledMethod> calledMethods) throws InterruptedException {
long waitTime2 = waitTime+50;
--- 447,452 ----
}
! private CalledMethod waitForUnignoredCall(
! String logM, Set<String> ignorables, List<CalledMethod> calledMethods) throws InterruptedException {
long waitTime2 = waitTime+50;
***************
*** 522,526 ****
* @see biz.xsoftware.mock.MockObject#addThrowException(java.lang.String, java.lang.Throwable)
*/
! synchronized public void addThrowException(String method, Throwable e) {
if(method == null)
throw new IllegalArgumentException("method parameter cannot be null");
--- 530,534 ----
* @see biz.xsoftware.mock.MockObject#addThrowException(java.lang.String, java.lang.Throwable)
*/
! public synchronized void addThrowException(String method, Throwable e) {
if(method == null)
throw new IllegalArgumentException("method parameter cannot be null");
***************
*** 538,542 ****
* @see biz.xsoftware.mock.MockObject#addReturnValue(java.lang.String, java.lang.Object)
*/
! synchronized public void addReturnValue(String method, Object o) {
if(method == null)
throw new IllegalArgumentException("method parameter cannot be null");
--- 546,550 ----
* @see biz.xsoftware.mock.MockObject#addReturnValue(java.lang.String, java.lang.Object)
*/
! public synchronized void addReturnValue(String method, Object o) {
if(method == null)
throw new IllegalArgumentException("method parameter cannot be null");
Index: MockObjectImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock/MockObjectImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MockObjectImpl.java 18 Sep 2005 17:10:24 -0000 1.5
--- MockObjectImpl.java 19 Feb 2006 19:20:52 -0000 1.6
***************
*** 57,61 ****
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");
}
}
--- 57,62 ----
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");
}
}
Index: MockObjectFactory.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock/MockObjectFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** MockObjectFactory.java 27 Jun 2005 03:40:32 -0000 1.2
--- MockObjectFactory.java 19 Feb 2006 19:20:52 -0000 1.3
***************
*** 16,19 ****
--- 16,21 ----
public abstract class MockObjectFactory {
+ private MockObjectFactory() {}
+
/**
* Creates a MockObject based on your interface. One way to use it
|