Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12903/input/javasrc/biz/xsoftware/mock2/impl
Modified Files:
MockObjectImpl.java MockObjectFactoryImpl.java
MockObjectSuperImpl.java
Log Message:
add log to mocklib2 , add ID to mocklib2 , correct wait time to mocklib2
Index: MockObjectImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectImpl.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** MockObjectImpl.java 21 Mar 2006 15:01:25 -0000 1.5
--- MockObjectImpl.java 5 Apr 2006 15:27:08 -0000 1.6
***************
*** 35,43 ****
}
}
! public MockObjectImpl(Class[] interfacesToMock) {
this.classes=interfacesToMock;
}
! public MockObjectImpl(Class interfaceToMock, Object realObject) {
this.c=interfaceToMock;
this.realObject=realObject;
--- 35,45 ----
}
}
! public MockObjectImpl(String id,Class[] interfacesToMock) {
! super(id);
this.classes=interfacesToMock;
}
! public MockObjectImpl( String id,Class interfaceToMock, Object realObject) {
! super(id);
this.c=interfaceToMock;
this.realObject=realObject;
***************
*** 51,55 ****
}
Object o=methodCalledImpl(method.getName(),args);
! return o;
}
--- 53,57 ----
}
Object o=methodCalledImpl(method.getName(),args);
! return o;
}
Index: MockObjectFactoryImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectFactoryImpl.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MockObjectFactoryImpl.java 21 Mar 2006 09:25:32 -0000 1.4
--- MockObjectFactoryImpl.java 5 Apr 2006 15:27:08 -0000 1.5
***************
*** 8,12 ****
public class MockObjectFactoryImpl extends MockObjectFactory {
! public MockObject createMockImpl(Class[] interfacesToMock) {
Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1];
interfacesPlusMock[0] = MockObject.class;
--- 8,12 ----
public class MockObjectFactoryImpl extends MockObjectFactory {
! public MockObject createMockImpl( String id,Class[] interfacesToMock) {
Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1];
interfacesPlusMock[0] = MockObject.class;
***************
*** 16,20 ****
ClassLoader cl = MockObjectFactoryImpl.class.getClassLoader();
! MockObjectImpl impl = new MockObjectImpl(interfacesToMock);
Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl);
MockObject m = (MockObject) o;
--- 16,20 ----
ClassLoader cl = MockObjectFactoryImpl.class.getClassLoader();
! MockObjectImpl impl = new MockObjectImpl(id,interfacesToMock);
Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl);
MockObject m = (MockObject) o;
***************
*** 22,26 ****
}
! public MockObject createMockImpl(Class interfaceToMock, Object realObject) {
Class[] interfacePlusMock = new Class[1];
--- 22,26 ----
}
! public MockObject createMockImpl(String id,Class interfaceToMock, Object realObject) {
Class[] interfacePlusMock = new Class[1];
***************
*** 28,32 ****
ClassLoader cl = MockObjectFactoryImpl.class.getClassLoader();
! MockObjectImpl impl = new MockObjectImpl(interfaceToMock, realObject);
Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl);
MockObject m = (MockObject) o;
--- 28,32 ----
ClassLoader cl = MockObjectFactoryImpl.class.getClassLoader();
! MockObjectImpl impl = new MockObjectImpl(id,interfaceToMock, realObject);
Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl);
MockObject m = (MockObject) o;
Index: MockObjectSuperImpl.java
===================================================================
RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** MockObjectSuperImpl.java 27 Mar 2006 15:44:31 -0000 1.11
--- MockObjectSuperImpl.java 5 Apr 2006 15:27:08 -0000 1.12
***************
*** 7,10 ****
--- 7,12 ----
import java.util.List;
import java.util.Map;
+ import java.util.logging.Logger;
+ import java.util.logging.Level;
import biz.xsoftware.mock2.Behavior;
***************
*** 20,24 ****
public abstract class MockObjectSuperImpl implements MockObject {
!
private static final long DEFAULT_TIME_OUT = 10000;
--- 22,29 ----
public abstract class MockObjectSuperImpl implements MockObject {
! private static final Logger log=Logger.getLogger(MockObjectSuperImpl.class.getName());
!
! private String id;
! private long delayTime=0;
private static final long DEFAULT_TIME_OUT = 10000;
***************
*** 59,63 ****
! public CalledMethod expect(String methodName, Class... vargs) {
return expect(methodName, DEFAULT_TIME_OUT, vargs);
}
--- 64,72 ----
! public MockObjectSuperImpl(String id) {
! this.id=id;
! }
!
! public CalledMethod expect(String methodName, Class... vargs) {
return expect(methodName, DEFAULT_TIME_OUT, vargs);
}
***************
*** 83,89 ****
--- 92,103 ----
if (methodName == null)
throw new IllegalArgumentException(Messages.METHOD_NAME_CANT_BE_NULL);
+ delayTime=timeout;
CalledMethod calledMethod = new CalledMethodImpl(methodName);
if(!methodsIgnored.containsKey(methodName))
methodsExpected.add(calledMethod);
+
+ if(log.isLoggable(Level.FINE)){
+ log.log(Level.FINE,"ID="+id+" "+methodName+"is expected");
+ }
return calledMethod;
}
***************
*** 93,96 ****
--- 107,111 ----
if (methodName == null)
throw new IllegalArgumentException(Messages.METHOD_NAME_CANT_BE_NULL);
+ delayTime=timeout;
CalledMethod calledMethod = new CalledMethodImpl(methodName);
if(!methodsIgnored.containsKey(methodName)){
***************
*** 98,101 ****
--- 113,119 ----
retVal.put(methodName, returnValue);
}
+ if(log.isLoggable(Level.FINE)){
+ log.log(Level.FINE,"ID="+id+" "+methodName+" is expected with return value="+returnValue.toString());
+ }
return calledMethod;
}
***************
*** 105,108 ****
--- 123,127 ----
if (methodName == null)
throw new IllegalArgumentException(Messages.METHOD_NAME_CANT_BE_NULL);
+ delayTime=timeout;
CalledMethod calledMethod = new CalledMethodImpl(methodName);
if(!methodsIgnored.containsKey(methodName)){
***************
*** 110,113 ****
--- 129,137 ----
methodWithException.put(methodName, throwable);
}
+
+ if(log.isLoggable(Level.FINE)){
+ log.log(Level.FINE,"ID="+id+" "+methodName+" is expected and expect this method to throw exception="+throwable.toString());
+ }
+
return calledMethod;
}
***************
*** 117,125 ****
if(methodName==null)
throw new IllegalArgumentException(Messages.METHOD_NAME_CANT_BE_NULL);
CalledMethod calledMethod=new CalledMethodImpl(methodName);
if(!methodsIgnored.containsKey(methodName)){
methodsExpected.add(calledMethod);
behaviorMap.put(methodName,behavior);
-
try {
--- 141,149 ----
if(methodName==null)
throw new IllegalArgumentException(Messages.METHOD_NAME_CANT_BE_NULL);
+ delayTime=timeout;
CalledMethod calledMethod=new CalledMethodImpl(methodName);
if(!methodsIgnored.containsKey(methodName)){
methodsExpected.add(calledMethod);
behaviorMap.put(methodName,behavior);
try {
***************
*** 134,137 ****
--- 158,165 ----
}
+ if(log.isLoggable(Level.FINE)){
+ log.log(Level.FINE,"ID="+id+" "+methodName+" is expected with behavior="+behavior.toString());
+ }
+
return calledMethod;
}
***************
*** 142,149 ****
if (methodsCalled.size() == 0) {
synchronized (this) {
-
try {
! this.wait(DEFAULT_TIME_OUT);
} catch (InterruptedException e) {
e.getMessage();
--- 170,181 ----
if (methodsCalled.size() == 0) {
+
+ if(log.isLoggable(Level.FINE)){
+ log.log(Level.FINE,"called methods may be delayed,waitting methods to call...");
+ }
synchronized (this) {
try {
!
! this.wait(delayTime);
} catch (InterruptedException e) {
e.getMessage();
***************
*** 182,188 ****
}
! String stackTrace = "method Called=" + methodName + "(" + params
! + "on object" + this + ")";
!
CalledMethod calledMethod = new CalledMethodImpl(methodName,
parameters, stackTrace);
--- 214,223 ----
}
! String stackTrace = "method Called=" + methodName + ",params=" + params
! + " on object" + this + ")";
! if(log.isLoggable(Level.FINE)){
!
! log.log(Level.FINE,"ID="+id+" "+stackTrace);
! }
CalledMethod calledMethod = new CalledMethodImpl(methodName,
parameters, stackTrace);
|