mocklib-checkins Mailing List for mocklib (Page 24)
Brought to you by:
bittwidler,
fastdragon
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(6) |
Jul
(1) |
Aug
(5) |
Sep
(3) |
Oct
|
Nov
|
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(54) |
Feb
(120) |
Mar
(31) |
Apr
(11) |
May
(8) |
Jun
(5) |
Jul
|
Aug
(22) |
Sep
(295) |
Oct
(6) |
Nov
(10) |
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
(2) |
Dec
(8) |
2008 |
Jan
|
Feb
(1) |
Mar
|
Apr
(8) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2009 |
Jan
|
Feb
(17) |
Mar
|
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Nobody <fas...@us...> - 2006-01-18 01:46:42
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4274/xsoftware/mock2/impl Modified Files: Tag: branchForOffice MockObjectImpl.java MockObjectSuperImpl.java Log Message: change back api to original api. api is agreed upon by C# and Java impl, and we should discuss if changes are needed. We are 90% sure no changes to the api are needed. Index: MockObjectImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectImpl.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** MockObjectImpl.java 17 Jan 2006 07:58:27 -0000 1.1.2.2 --- MockObjectImpl.java 18 Jan 2006 01:46:29 -0000 1.1.2.3 *************** *** 7,13 **** import java.util.Set; - import biz.xsoftware.mock2.CalledMethod; import biz.xsoftware.mock2.MockObject; - import biz.xsoftware.mock2.impl.MockObjectSuperImpl; /** --- 7,11 ---- Index: MockObjectSuperImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.3 diff -C2 -d -r1.3.2.2 -r1.3.2.3 *** MockObjectSuperImpl.java 17 Jan 2006 07:58:27 -0000 1.3.2.2 --- MockObjectSuperImpl.java 18 Jan 2006 01:46:29 -0000 1.3.2.3 *************** *** 62,73 **** return calledMethod; } ! ! private void waitForCalledMethod(String methodName,long timeout) { ! // TODO Auto-generated method stub ! ! CalledMethod calledMethod=methodsCalled.remove(0); ! ! ! } public CalledMethod expect(Object returnValue, String methodName, --- 62,73 ---- return calledMethod; } ! //This class shows eclipse warnings....commented out to keep eclipse warnings at zero ! // private void waitForCalledMethod(String methodName,long timeout) { ! // // TODO Auto-generated method stub ! // ! // CalledMethod calledMethod=methodsCalled.remove(0); ! // ! // ! // } public CalledMethod expect(Object returnValue, String methodName, *************** *** 89,93 **** } ! public void verify(String methodName,long timeout) { // TODO Auto-generated method stub --- 89,97 ---- } ! private void verify(String method, long timeout) { ! ! } ! ! public void verify() { // TODO Auto-generated method stub |
From: Nobody <fas...@us...> - 2006-01-18 01:37:29
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1638/input/javasrc/biz/xsoftware/mock2 Added Files: Tag: branchForOffice Messages.java Log Message: addition of commented out test for Jay to implement. --- NEW FILE: Messages.java --- package biz.xsoftware.mock2; public class Messages { private Messages() {} public static final String VERIFY_NOT_CALLED = "MockObject.verify() must be called before accessing and of the methods on CalledMethod object"; } |
From: Nobody <fas...@us...> - 2006-01-18 01:37:29
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1638/input/javasrc/biz/xsoftware/test/mock2 Modified Files: Tag: branchForOffice TestMockCreator.java Log Message: addition of commented out test for Jay to implement. Index: TestMockCreator.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2/Attic/TestMockCreator.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** TestMockCreator.java 17 Jan 2006 07:52:59 -0000 1.1.2.2 --- TestMockCreator.java 18 Jan 2006 01:37:20 -0000 1.1.2.3 *************** *** 2,5 **** --- 2,6 ---- import biz.xsoftware.mock2.CalledMethod; + import biz.xsoftware.mock2.Messages; import biz.xsoftware.mock2.MockObject; import biz.xsoftware.mock2.MockObjectFactory; *************** *** 27,30 **** --- 28,50 ---- assertEquals("param count should be 1", 1, method.getParameters().length); } + + // public void testFailure() throws Exception { + // MockObject m = MockObjectFactory.createMock(ListenerOne.class); + // ListenerOne l=(ListenerOne)m; + // + // String param="some params"; + // l.callMeSecond(param); + // + // String methodName="callMeSecond"; + // + // CalledMethod method=m.expect(methodName); + // + // try { + // assertEquals("params should equal", param, method.getParameters()[0]); + // fail("This should fail since m.verify() is not called"); + // } catch(IllegalStateException e) { + // assertEquals(Messages.VERIFY_NOT_CALLED, e.getMessage()); + // } + // } } |
From: Jay <ja...@us...> - 2006-01-17 07:59:41
|
Update of /cvsroot/mocklib/mocklib2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2543/bldfiles Modified Files: Tag: branchForOffice design.xml Log Message: changed to add the declare of package biz.xsoftware.mock2.impl Index: design.xml =================================================================== RCS file: /cvsroot/mocklib/mocklib2/bldfiles/design.xml,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** design.xml 1 Jan 2006 00:35:56 -0000 1.2 --- design.xml 17 Jan 2006 07:59:32 -0000 1.2.2.1 *************** *** 27,31 **** </package> ! <package name="impl2" package="biz.xsoftware.mock2"> <!-- is depending on junit a good idea???? it makes it easier to prevent people from forgetting to call verify but also locks us to use junit more --- 27,32 ---- </package> ! <package name="impl2" package="biz.xsoftware.mock2.impl" needdepends="false"/> ! <package name="api2" package="biz.xsoftware.mock2"> <!-- is depending on junit a good idea???? it makes it easier to prevent people from forgetting to call verify but also locks us to use junit more *************** *** 34,42 **** </package> <package name="testapi2" package="biz.xsoftware.test.mock2" subpackages="include"> ! <depends>impl2</depends> <depends>junit</depends> </package> <package name="examples2" package="biz.xsoftware.examples2" subpackages="include"> ! <depends>impl2</depends> <depends>junit</depends> </package> --- 35,43 ---- </package> <package name="testapi2" package="biz.xsoftware.test.mock2" subpackages="include"> ! <depends>api2</depends> <depends>junit</depends> </package> <package name="examples2" package="biz.xsoftware.examples2" subpackages="include"> ! <depends>api2</depends> <depends>junit</depends> </package> |
From: Jay <ja...@us...> - 2006-01-17 07:58:56
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2391/input/javasrc/biz/xsoftware/mock2 Removed Files: Tag: branchForOffice MockObjectImpl.java Log Message: --- MockObjectImpl.java DELETED --- |
From: Jay <ja...@us...> - 2006-01-17 07:58:36
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2300/input/javasrc/biz/xsoftware/mock2 Modified Files: Tag: branchForOffice MockObject.java Log Message: make the first test pass, but need to improve the code. the code checked in is really ungraceful Index: MockObject.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObject.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** MockObject.java 13 Jan 2006 16:33:18 -0000 1.2.2.1 --- MockObject.java 17 Jan 2006 07:58:27 -0000 1.2.2.2 *************** *** 144,148 **** * the time set for waitting the call */ ! public void verify(long timeout); /** --- 144,148 ---- * the time set for waitting the call */ ! public void verify(String methodName,long timeout); /** |
From: Jay <ja...@us...> - 2006-01-17 07:58:35
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2300/input/javasrc/biz/xsoftware/mock2/impl Modified Files: Tag: branchForOffice MockObjectImpl.java CalledMethodImpl.java MockObjectSuperImpl.java Log Message: make the first test pass, but need to improve the code. the code checked in is really ungraceful Index: CalledMethodImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/CalledMethodImpl.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** CalledMethodImpl.java 13 Jan 2006 16:33:54 -0000 1.1.2.1 --- CalledMethodImpl.java 17 Jan 2006 07:58:27 -0000 1.1.2.2 *************** *** 8,21 **** private String stackTrace; ! public void setMethodName(String methodName) { ! this.methodName = methodName; ! } ! ! public void setParameters(Object[] parameters) { ! this.parameters = parameters; ! } ! ! public void setStackTrace(String stackTrace) { ! this.stackTrace = stackTrace; } --- 8,20 ---- private String stackTrace; ! public CalledMethodImpl(String methodName, Object[]params,String stackTrace){ ! this.methodName=methodName; ! if(params==null){ ! this.parameters=new Object[0]; ! }else ! { ! this.parameters=params; ! } ! this.stackTrace=stackTrace; } Index: MockObjectImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectImpl.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** MockObjectImpl.java 13 Jan 2006 16:33:54 -0000 1.1.2.1 --- MockObjectImpl.java 17 Jan 2006 07:58:27 -0000 1.1.2.2 *************** *** 2,5 **** --- 2,6 ---- import java.lang.reflect.InvocationHandler; + import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashSet; *************** *** 48,57 **** return callSuperMethod(proxy,method,args); } ! return null; } ! private Object callSuperMethod(Object proxy, Method method, Object[] args) { ! // TODO Auto-generated method stub ! return null; } --- 49,79 ---- 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; ! } ! private Object callSuperMethod(Object proxy, Method method, Object[] args) throws Throwable{ ! try { ! if("equals".equals(method.getName())) ! return new Boolean(proxy == args[0]); ! else if("toString".equals(method.getName())) ! return ""+this; ! ! return method.invoke(this, args); ! } catch(InvocationTargetException e) { ! if(e.getCause() != null) ! throw e.getCause(); ! else ! throw e; ! } } *************** *** 60,77 **** } ! public CalledMethod expect(String methodName, Class... vargs) { ! // TODO Auto-generated method stub ! return null; ! } ! ! public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { ! // TODO Auto-generated method stub ! return null; ! } ! ! public CalledMethod expect(String methodName, long timeout, Class... vargs) { ! // TODO Auto-generated method stub ! return null; ! } } --- 82,86 ---- } ! } Index: MockObjectSuperImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -C2 -d -r1.3.2.1 -r1.3.2.2 *** MockObjectSuperImpl.java 13 Jan 2006 16:33:54 -0000 1.3.2.1 --- MockObjectSuperImpl.java 17 Jan 2006 07:58:27 -0000 1.3.2.2 *************** *** 1,4 **** --- 1,9 ---- package biz.xsoftware.mock2.impl; + import java.util.HashMap; + import java.util.LinkedList; + import java.util.List; + import java.util.Map; + import java.util.logging.Level; import java.util.logging.Logger; *************** *** 7,84 **** import biz.xsoftware.mock2.MockObject; ! public abstract class MockObjectSuperImpl implements MockObject{ ! ! ! private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); ! private static final long DEFAULT_TIME_OUT=10000; ! //private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); public CalledMethod expect(String methodName, Class... vargs) { ! return expect(methodName,DEFAULT_TIME_OUT,vargs); } - ! ! public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { ! return expect(returnValue,methodName,DEFAULT_TIME_OUT,vargs); } ! ! public CalledMethod expect(String methodName, Throwable throwable, Class... vargs) { ! ! return expect(methodName,throwable,DEFAULT_TIME_OUT,vargs); } ! public CalledMethod expect(String methodName, Behavior behavior, Class... params) { ! ! return expect(methodName,behavior,DEFAULT_TIME_OUT,params); ! } public CalledMethod expect(String methodName, long timeout, Class... vargs) { ! if(methodName==null) throw new IllegalArgumentException("methd name can not be null"); ! verify(timeout); ! return null; } ! public CalledMethod expect(Object returnValue, String methodName, long timeout, Class... vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Throwable throwable, long timeout, Class... vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Behavior behavior, long timeout, Class... params) { // TODO Auto-generated method stub return null; } ! public void verify(long timeout) { // TODO Auto-generated method stub ! } public void addIgnoreMethod(String methodName, Class... vargs) { // TODO Auto-generated method stub ! } public void removeIgnoreMethod(String methodName, Class... vargs) { // TODO Auto-generated method stub ! } ! public void setDefaultReturnValue(Object returnValue, String methodName, Class... vargs) { // TODO Auto-generated method stub ! } --- 12,111 ---- import biz.xsoftware.mock2.MockObject; ! public abstract class MockObjectSuperImpl implements MockObject { ! private static final Logger logger = Logger.getLogger(MockObjectSuperImpl.class.getName()); + private static final long DEFAULT_TIME_OUT = 10000; + /** + * List of the current methods that have been called. + */ + private List<CalledMethod> methodsCalled = new LinkedList<CalledMethod>(); + + /** + * A map of queues, containing objects to return when methods are called + */ + private Map<String, List<Object>> methodToReturnVal = new HashMap<String, List<Object>>(); + /** + * A map of default return values, which are used to return if the + * queue for the method is empty. + */ + private Map<String, Object> methodToDefaultRetVal = new HashMap<String, Object>(); public CalledMethod expect(String methodName, Class... vargs) { ! return expect(methodName, DEFAULT_TIME_OUT, vargs); } ! public CalledMethod expect(Object returnValue, String methodName, ! Class... vargs) { ! return expect(returnValue, methodName, DEFAULT_TIME_OUT, vargs); } ! public CalledMethod expect(String methodName, Throwable throwable, ! Class... vargs) { ! return expect(methodName, throwable, DEFAULT_TIME_OUT, vargs); } ! public CalledMethod expect(String methodName, Behavior behavior, ! Class... params) { + return expect(methodName, behavior, DEFAULT_TIME_OUT, params); + } public CalledMethod expect(String methodName, long timeout, Class... vargs) { ! if (methodName == null) throw new IllegalArgumentException("methd name can not be null"); ! verify(methodName,timeout); ! //waitForCalledMethod(methodName,DEFAULT_TIME_OUT); ! CalledMethod calledMethod=methodsCalled.remove(0); ! return calledMethod; } + private void waitForCalledMethod(String methodName,long timeout) { + // TODO Auto-generated method stub + + CalledMethod calledMethod=methodsCalled.remove(0); + + + } ! public CalledMethod expect(Object returnValue, String methodName, ! long timeout, Class... vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Throwable throwable, ! long timeout, Class... vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Behavior behavior, ! long timeout, Class... params) { // TODO Auto-generated method stub return null; } ! public void verify(String methodName,long timeout) { // TODO Auto-generated method stub ! } public void addIgnoreMethod(String methodName, Class... vargs) { // TODO Auto-generated method stub ! } public void removeIgnoreMethod(String methodName, Class... vargs) { // TODO Auto-generated method stub ! } ! public void setDefaultReturnValue(Object returnValue, String methodName, ! Class... vargs) { // TODO Auto-generated method stub ! } *************** *** 88,90 **** --- 115,157 ---- } + synchronized protected Object methodCalledImpl(String methodName, + Object[] parameters) { + + methodName = methodName.intern(); + String params = ""; + if (parameters == null) { + params = "no params"; + } else { + Object[] array = (Object[]) parameters; + for (int i = 0; i < array.length - 1; i++) { + params += array[i] + ", "; + } + params += array[array.length - 1]; + } + + if (logger.isLoggable(Level.FINE)) + logger.log(Level.FINE, "method called=" + methodName + "(" + params + + ") on obj=" + this); + String stackTrace="method Called="+methodName+"("+params+"on object"+this+")"; + methodsCalled.add(new CalledMethodImpl(methodName,parameters,stackTrace)); + this.notifyAll(); + + return getReturnValue(methodName); + } + + 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); + + + } + } |
From: Jay <ja...@us...> - 2006-01-17 07:53:34
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1426/input/javasrc/biz/xsoftware/test/mock2 Removed Files: Tag: branchForOffice MockOne.java Log Message: --- MockOne.java DELETED --- |
From: Jay <ja...@us...> - 2006-01-17 07:53:16
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1335/input/javasrc/biz/xsoftware/test/mock2 Modified Files: Tag: branchForOffice TestMockCreator.java Log Message: change to method.getMethodName() when assert Index: TestMockCreator.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2/Attic/TestMockCreator.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** TestMockCreator.java 13 Jan 2006 16:34:22 -0000 1.1.2.1 --- TestMockCreator.java 17 Jan 2006 07:52:59 -0000 1.1.2.2 *************** *** 23,27 **** CalledMethod method=m.expect(methodName); ! assertEquals("the methodName should be the same",methodName,method.getClass().getName()); assertEquals("params should equal", param, method.getParameters()[0]); assertEquals("param count should be 1", 1, method.getParameters().length); --- 23,27 ---- CalledMethod method=m.expect(methodName); ! assertEquals("the methodName should be the same",methodName,method.getMethodName()); assertEquals("params should equal", param, method.getParameters()[0]); assertEquals("param count should be 1", 1, method.getParameters().length); |
From: Nobody <fas...@us...> - 2006-01-16 15:23:28
|
Update of /cvsroot/mocklib/mocklib2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20565 Modified Files: build Log Message: test autobuild Index: build =================================================================== RCS file: /cvsroot/mocklib/mocklib2/build,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** build 21 Dec 2005 22:54:57 -0000 1.28 --- build 16 Jan 2006 15:23:17 -0000 1.29 *************** *** 1,2 **** --- 1,3 ---- + #************************************ # Generated file. Do not modify |
From: Jay <ja...@us...> - 2006-01-15 05:34:44
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25148/input/javasrc/biz/xsoftware/mock2 Modified Files: Tag: branchForOffice MockObjectFactory.java Log Message: fixing bug Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObjectFactory.java,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -C2 -d -r1.4.2.2 -r1.4.2.3 *** MockObjectFactory.java 15 Jan 2006 05:32:38 -0000 1.4.2.2 --- MockObjectFactory.java 15 Jan 2006 05:34:36 -0000 1.4.2.3 *************** *** 16,20 **** MockObjectFactory factory=null; try{ ! String className="biz.xsoftware.mock2.MockObjectFactoryImpl"; Class<? extends MockObjectFactory> c=Class.forName(className).asSubclass(MockObjectFactory.class); factory=c.newInstance(); --- 16,20 ---- MockObjectFactory factory=null; try{ ! String className="biz.xsoftware.mock2.impl.MockObjectFactoryImpl"; Class<? extends MockObjectFactory> c=Class.forName(className).asSubclass(MockObjectFactory.class); factory=c.newInstance(); |
From: Jay <ja...@us...> - 2006-01-15 05:32:46
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24795/input/javasrc/biz/xsoftware/mock2 Modified Files: Tag: branchForOffice MockObjectFactory.java Log Message: clean codes Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObjectFactory.java,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -C2 -d -r1.4.2.1 -r1.4.2.2 *** MockObjectFactory.java 14 Jan 2006 18:24:05 -0000 1.4.2.1 --- MockObjectFactory.java 15 Jan 2006 05:32:38 -0000 1.4.2.2 *************** *** 3,10 **** - import biz.xsoftware.mock2.impl.MockObjectFactoryImpl; - - - /** * The factory class that creates MockObjects --- 3,6 ---- *************** *** 15,25 **** public abstract class MockObjectFactory { ! private static MockObjectFactoryImpl instance=null; private static MockObjectFactory singleton() { ! //fix this using reflection.... ! if(instance==null){ ! return new MockObjectFactoryImpl(); ! } ! return instance; } --- 11,30 ---- public abstract class MockObjectFactory { ! private static MockObjectFactory singleton() { ! //fix this using reflection.... ClassLoader cl=MockObjectFactory.class.getClassLoader(); ! MockObjectFactory factory=null; ! try{ ! String className="biz.xsoftware.mock2.MockObjectFactoryImpl"; ! Class<? extends MockObjectFactory> c=Class.forName(className).asSubclass(MockObjectFactory.class); ! factory=c.newInstance(); ! }catch(ClassNotFoundException e){ ! throw new RuntimeException("create mockFactory failed", e); ! }catch(IllegalAccessException e){ ! throw new RuntimeException("create mockFactory failed", e); ! }catch(InstantiationException e){ ! throw new RuntimeException("create mockFactory failed", e); ! } ! return factory; } |
From: Jay <ja...@us...> - 2006-01-14 18:24:51
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31761/input/javasrc/biz/xsoftware/mock2/impl Modified Files: Tag: branchForOffice MockObjectFactoryImpl.java Log Message: change MockObjectFactory into MockOjectFactoryImpl Index: MockObjectFactoryImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectFactoryImpl.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** MockObjectFactoryImpl.java 13 Jan 2006 15:45:00 -0000 1.2 --- MockObjectFactoryImpl.java 14 Jan 2006 18:24:42 -0000 1.2.2.1 *************** *** 15,19 **** } ! ClassLoader cl = MockObjectFactory.class.getClassLoader(); MockObjectImpl impl = new MockObjectImpl(interfacesToMock); Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); --- 15,19 ---- } ! ClassLoader cl = MockObjectFactoryImpl.class.getClassLoader(); MockObjectImpl impl = new MockObjectImpl(interfacesToMock); Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); *************** *** 27,31 **** interfacePlusMock[0] = MockObject.class; ! ClassLoader cl = MockObjectFactory.class.getClassLoader(); MockObjectImpl impl = new MockObjectImpl(interfaceToMock, realObject); Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl); --- 27,31 ---- interfacePlusMock[0] = MockObject.class; ! ClassLoader cl = MockObjectFactoryImpl.class.getClassLoader(); MockObjectImpl impl = new MockObjectImpl(interfaceToMock, realObject); Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl); |
From: Jay <ja...@us...> - 2006-01-14 18:24:20
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31555/input/javasrc/biz/xsoftware/mock2 Modified Files: Tag: branchForOffice MockObjectFactory.java Log Message: check in to implements at office :) Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObjectFactory.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** MockObjectFactory.java 13 Jan 2006 15:45:00 -0000 1.4 --- MockObjectFactory.java 14 Jan 2006 18:24:05 -0000 1.4.2.1 *************** *** 3,6 **** --- 3,10 ---- + import biz.xsoftware.mock2.impl.MockObjectFactoryImpl; + + + /** * The factory class that creates MockObjects *************** *** 10,17 **** */ public abstract class MockObjectFactory { ! private static MockObjectFactory singleton() { //fix this using reflection.... ! return null; } --- 14,25 ---- */ public abstract class MockObjectFactory { ! ! private static MockObjectFactoryImpl instance=null; private static MockObjectFactory singleton() { //fix this using reflection.... ! if(instance==null){ ! return new MockObjectFactoryImpl(); ! } ! return instance; } |
From: Jay <ja...@us...> - 2006-01-13 16:34:30
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/test/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5168/input/javasrc/biz/xsoftware/test/mock2 Added Files: Tag: branchForOffice MockOne.java TestMockCreator.java Log Message: check in to implements at office :) --- NEW FILE: MockOne.java --- package biz.xsoftware.test.mock2; import java.io.IOException; import java.util.Map; import biz.xsoftware.mock2.impl.MockObjectSuperImpl; import biz.xsoftware.test.mock2.ListenerOne; public class MockOne extends MockObjectSuperImpl implements ListenerOne { public void callMeFirst(int s) { // TODO Auto-generated method stub } public void callMeSecond(String s) throws IOException { // TODO Auto-generated method stub } public void multipleParams(String x, Integer i) { // TODO Auto-generated method stub } public int respondTo(Map map) { // TODO Auto-generated method stub return 0; } public boolean responsd() { // TODO Auto-generated method stub return false; } public void noParams() { // TODO Auto-generated method stub } } --- NEW FILE: TestMockCreator.java --- package biz.xsoftware.test.mock2; import biz.xsoftware.mock2.CalledMethod; import biz.xsoftware.mock2.MockObject; import biz.xsoftware.mock2.MockObjectFactory; import junit.framework.TestCase; public class TestMockCreator extends TestCase { public TestMockCreator(String name){ super(name); } public void testMockCreator()throws Exception{ MockObject m = MockObjectFactory.createMock(ListenerOne.class); ListenerOne l=(ListenerOne)m; String param="some params"; l.callMeSecond(param); String methodName="callMeSecond"; CalledMethod method=m.expect(methodName); assertEquals("the methodName should be the same",methodName,method.getClass().getName()); assertEquals("params should equal", param, method.getParameters()[0]); assertEquals("param count should be 1", 1, method.getParameters().length); } } |
From: Jay <ja...@us...> - 2006-01-13 16:34:03
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5061/input/javasrc/biz/xsoftware/mock2/impl Modified Files: Tag: branchForOffice MockObjectImpl.java CalledMethodImpl.java MockObjectSuperImpl.java Log Message: check in to implements at office :) Index: CalledMethodImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/CalledMethodImpl.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** CalledMethodImpl.java 3 Jan 2006 13:29:54 -0000 1.1 --- CalledMethodImpl.java 13 Jan 2006 16:33:54 -0000 1.1.2.1 *************** *** 36,38 **** --- 36,40 ---- + + } Index: MockObjectImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectImpl.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** MockObjectImpl.java 13 Jan 2006 14:48:31 -0000 1.1 --- MockObjectImpl.java 13 Jan 2006 16:33:54 -0000 1.1.2.1 *************** *** 3,13 **** import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; public class MockObjectImpl extends MockObjectSuperImpl implements InvocationHandler { ! public MockObjectImpl(Class[] interfacesToMock) { ! // TODO Auto-generated constructor stub } --- 3,39 ---- import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; + import java.util.HashSet; + import java.util.Set; + import biz.xsoftware.mock2.CalledMethod; + import biz.xsoftware.mock2.MockObject; + import biz.xsoftware.mock2.impl.MockObjectSuperImpl; + /** + * this class implements the interface InvocationHandler,defind a + * certain MockObject and return a calledMethod instance to the + * test cases + * @author Jay + * + */ public class MockObjectImpl extends MockObjectSuperImpl implements InvocationHandler { ! private static Set<Method> isMethodInSuper=new HashSet<Method>(); ! Class[]classes; ! ! static { ! Class c=MockObject.class; ! Method[] m=c.getMethods(); ! for(int i=0;i<m.length;i++){ ! isMethodInSuper.add(m[i]); ! } ! c=Object.class; ! m=c.getMethods(); ! for(int i=0;i<m.length;i++){ ! isMethodInSuper.add(m[i]); ! } ! } public MockObjectImpl(Class[] interfacesToMock) { ! this.classes=interfacesToMock; } *************** *** 19,24 **** --- 45,78 ---- throws Throwable { // TODO Auto-generated method stub + if(isMethodInSuper.contains(method)){ + return callSuperMethod(proxy,method,args); + } + return null; + } + + private Object callSuperMethod(Object proxy, Method method, Object[] args) { + // TODO Auto-generated method stub + return null; + } + + public Class[] getClasses(){ + return this.classes; + } + + public CalledMethod expect(String methodName, Class... vargs) { + // TODO Auto-generated method stub + return null; + } + + public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { + // TODO Auto-generated method stub + return null; + } + + public CalledMethod expect(String methodName, long timeout, Class... vargs) { + // TODO Auto-generated method stub return null; } } + Index: MockObjectSuperImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** MockObjectSuperImpl.java 13 Jan 2006 14:48:31 -0000 1.3 --- MockObjectSuperImpl.java 13 Jan 2006 16:33:54 -0000 1.3.2.1 *************** *** 1,4 **** --- 1,6 ---- package biz.xsoftware.mock2.impl; + import java.util.logging.Logger; + import biz.xsoftware.mock2.Behavior; import biz.xsoftware.mock2.CalledMethod; *************** *** 7,36 **** public abstract class MockObjectSuperImpl implements MockObject{ //private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); ! private static final long NO_TIME_OUT=0; public CalledMethod expect(String methodName, Class... vargs) { ! return expect(methodName,NO_TIME_OUT,vargs); } public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { ! return expect(returnValue,methodName,NO_TIME_OUT,vargs); } public CalledMethod expect(String methodName, Throwable throwable, Class... vargs) { ! return expect(methodName,throwable,NO_TIME_OUT,vargs); } public CalledMethod expect(String methodName, Behavior behavior, Class... params) { ! return expect(methodName,behavior,NO_TIME_OUT,params); } public CalledMethod expect(String methodName, long timeout, Class... vargs) { ! return null; } public CalledMethod expect(Object returnValue, String methodName, long timeout, Class... vargs) { // TODO Auto-generated method stub --- 9,51 ---- public abstract class MockObjectSuperImpl implements MockObject{ + + private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); + private static final long DEFAULT_TIME_OUT=10000; + //private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); ! ! public CalledMethod expect(String methodName, Class... vargs) { ! return expect(methodName,DEFAULT_TIME_OUT,vargs); } + + public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { ! return expect(returnValue,methodName,DEFAULT_TIME_OUT,vargs); } + + public CalledMethod expect(String methodName, Throwable throwable, Class... vargs) { ! return expect(methodName,throwable,DEFAULT_TIME_OUT,vargs); } public CalledMethod expect(String methodName, Behavior behavior, Class... params) { ! return expect(methodName,behavior,DEFAULT_TIME_OUT,params); } + public CalledMethod expect(String methodName, long timeout, Class... vargs) { ! if(methodName==null) ! throw new IllegalArgumentException("methd name can not be null"); ! verify(timeout); return null; } + public CalledMethod expect(Object returnValue, String methodName, long timeout, Class... vargs) { // TODO Auto-generated method stub *************** *** 48,52 **** } ! public void verify() { // TODO Auto-generated method stub --- 63,67 ---- } ! public void verify(long timeout) { // TODO Auto-generated method stub |
From: Jay <ja...@us...> - 2006-01-13 16:34:02
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5061/input/javasrc/biz/xsoftware/mock2 Modified Files: Tag: branchForOffice MockObjectImpl.java Log Message: check in to implements at office :) Index: MockObjectImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/Attic/MockObjectImpl.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** MockObjectImpl.java 3 Jan 2006 15:37:37 -0000 1.1 --- MockObjectImpl.java 13 Jan 2006 16:33:55 -0000 1.1.2.1 *************** *** 3,14 **** import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import biz.xsoftware.mock2.impl.MockObjectSuperImpl; public class MockObjectImpl extends MockObjectSuperImpl implements InvocationHandler { ! public MockObjectImpl(Class[] interfacesToMock) { ! // TODO Auto-generated constructor stub } --- 3,37 ---- import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; + import java.util.HashSet; + import java.util.Set; import biz.xsoftware.mock2.impl.MockObjectSuperImpl; + /** + * this class implements the interface InvocationHandler,defind a + * certain MockObject and return a calledMethod instance to the + * test cases + * @author Jay + * + */ public class MockObjectImpl extends MockObjectSuperImpl implements InvocationHandler { ! private static Set<Method> isMethodInSuper=new HashSet<Method>(); ! Class[]classes; ! ! static { ! Class c=MockObject.class; ! Method[] m=c.getMethods(); ! for(int i=0;i<m.length;i++){ ! isMethodInSuper.add(m[i]); ! } ! c=Object.class; ! m=c.getMethods(); ! for(int i=0;i<m.length;i++){ ! isMethodInSuper.add(m[i]); ! } ! } public MockObjectImpl(Class[] interfacesToMock) { ! this.classes=interfacesToMock; } *************** *** 20,23 **** --- 43,73 ---- throws Throwable { // TODO Auto-generated method stub + if(isMethodInSuper.contains(method)){ + return callSuperMethod(proxy,method,args); + } + return null; + } + + private Object callSuperMethod(Object proxy, Method method, Object[] args) { + // TODO Auto-generated method stub + return null; + } + + public Class[] getClasses(){ + return this.classes; + } + + public CalledMethod expect(String methodName, Class... vargs) { + // TODO Auto-generated method stub + return null; + } + + public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { + // TODO Auto-generated method stub + return null; + } + + public CalledMethod expect(String methodName, long timeout, Class... vargs) { + // TODO Auto-generated method stub return null; } |
From: Jay <ja...@us...> - 2006-01-13 16:33:26
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4927/input/javasrc/biz/xsoftware/mock2 Modified Files: Tag: branchForOffice MockObject.java Log Message: check in to implements at office :) Index: MockObject.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObject.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** MockObject.java 7 Jan 2006 15:13:39 -0000 1.2 --- MockObject.java 13 Jan 2006 16:33:18 -0000 1.2.2.1 *************** *** 141,146 **** /** * Verifies that the expected methods are called within the timeout. */ ! public void verify(); /** --- 141,148 ---- /** * Verifies that the expected methods are called within the timeout. + * @param timeout + * the time set for waitting the call */ ! public void verify(long timeout); /** |
From: Nobody <fas...@us...> - 2006-01-13 15:45:14
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25903/input/javasrc/biz/xsoftware/mock Modified Files: ExpectFailedException.java Log Message: fix all the warnings in eclipse. Index: ExpectFailedException.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock/ExpectFailedException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExpectFailedException.java 26 Jun 2005 12:20:14 -0000 1.1 --- ExpectFailedException.java 13 Jan 2006 15:45:00 -0000 1.2 *************** *** 18,21 **** --- 18,25 ---- /** + * + */ + private static final long serialVersionUID = 1L; + /** * Expect failed because an event never came and waiting finally timed out. */ |
From: Nobody <fas...@us...> - 2006-01-13 15:45:14
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25903/input/javasrc/biz/xsoftware/mock2/impl Modified Files: MockObjectFactoryImpl.java Log Message: fix all the warnings in eclipse. Index: MockObjectFactoryImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectFactoryImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MockObjectFactoryImpl.java 13 Jan 2006 14:48:31 -0000 1.1 --- MockObjectFactoryImpl.java 13 Jan 2006 15:45:00 -0000 1.2 *************** *** 8,12 **** public class MockObjectFactoryImpl extends MockObjectFactory { ! public static MockObject createMock(Class[] interfacesToMock) { Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1]; interfacesPlusMock[0] = MockObject.class; --- 8,12 ---- public class MockObjectFactoryImpl extends MockObjectFactory { ! public MockObject createMockImpl(Class[] interfacesToMock) { Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1]; interfacesPlusMock[0] = MockObject.class; *************** *** 22,30 **** } ! public static MockObject createMock(Class interfaceToMock) { ! return createMock(new Class[] { interfaceToMock }); ! } ! ! public static MockObject createMock(Class interfaceToMock, Object realObject) { // TODO: Implement me! Class[] interfacePlusMock = new Class[1]; --- 22,26 ---- } ! public MockObject createMockImpl(Class interfaceToMock, Object realObject) { // TODO: Implement me! Class[] interfacePlusMock = new Class[1]; |
From: Nobody <fas...@us...> - 2006-01-13 15:45:14
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25903/input/javasrc/biz/xsoftware/mock2 Modified Files: MockObjectFactory.java Log Message: fix all the warnings in eclipse. Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObjectFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MockObjectFactory.java 13 Jan 2006 14:48:31 -0000 1.3 --- MockObjectFactory.java 13 Jan 2006 15:45:00 -0000 1.4 *************** *** 1,8 **** package biz.xsoftware.mock2; - import java.lang.reflect.Proxy; - import biz.xsoftware.mock2.MockObject; - import biz.xsoftware.mock2.impl.MockObjectImpl; /** --- 1,5 ---- *************** *** 20,24 **** public static MockObject createMock(Class[] interfacesToMock) { ! return singleton().createMock(interfacesToMock); } --- 17,21 ---- public static MockObject createMock(Class[] interfacesToMock) { ! return singleton().createMockImpl(interfacesToMock); } *************** *** 28,32 **** public static MockObject createMock(Class interfaceToMock, Object realObject) { ! return singleton().createMock(interfaceToMock, realObject); } } --- 25,33 ---- public static MockObject createMock(Class interfaceToMock, Object realObject) { ! return singleton().createMockImpl(interfaceToMock, realObject); } + + public abstract MockObject createMockImpl(Class[] interfacesToMock); + + public abstract MockObject createMockImpl(Class interfaceToMock, Object realObject); } |
From: Nobody <fas...@us...> - 2006-01-13 15:45:14
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/examples/basic In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25903/input/javasrc/biz/xsoftware/examples/basic Modified Files: PurchaseException.java Log Message: fix all the warnings in eclipse. Index: PurchaseException.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/examples/basic/PurchaseException.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PurchaseException.java 26 Jun 2005 12:02:25 -0000 1.1 --- PurchaseException.java 13 Jan 2006 15:44:59 -0000 1.2 *************** *** 15,18 **** --- 15,23 ---- /** + * + */ + private static final long serialVersionUID = 1L; + + /** * @param e */ |
From: Nobody <fas...@us...> - 2006-01-13 14:48:41
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13634/input/javasrc/biz/xsoftware/mock2/impl Modified Files: MockObjectSuperImpl.java Added Files: MockObjectFactoryImpl.java MockObjectImpl.java Log Message: get build passing again by modifying design slightly and in some cases modifying code to adhere to design. --- NEW FILE: MockObjectImpl.java --- package biz.xsoftware.mock2.impl; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; public class MockObjectImpl extends MockObjectSuperImpl implements InvocationHandler { public MockObjectImpl(Class[] interfacesToMock) { // TODO Auto-generated constructor stub } public MockObjectImpl(Class interfaceToMock, Object realObject) { // TODO Auto-generated constructor stub } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { // TODO Auto-generated method stub return null; } } --- NEW FILE: MockObjectFactoryImpl.java --- package biz.xsoftware.mock2.impl; import java.lang.reflect.Proxy; import biz.xsoftware.mock2.MockObject; import biz.xsoftware.mock2.MockObjectFactory; public class MockObjectFactoryImpl extends MockObjectFactory { public static MockObject createMock(Class[] interfacesToMock) { Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1]; interfacesPlusMock[0] = MockObject.class; for (int i = 1; i < interfacesPlusMock.length; i++) { interfacesPlusMock[i] = interfacesToMock[i - 1]; } ClassLoader cl = MockObjectFactory.class.getClassLoader(); MockObjectImpl impl = new MockObjectImpl(interfacesToMock); Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); MockObject m = (MockObject) o; return m; } public static MockObject createMock(Class interfaceToMock) { return createMock(new Class[] { interfaceToMock }); } public static MockObject createMock(Class interfaceToMock, Object realObject) { // TODO: Implement me! Class[] interfacePlusMock = new Class[1]; interfacePlusMock[0] = MockObject.class; ClassLoader cl = MockObjectFactory.class.getClassLoader(); MockObjectImpl impl = new MockObjectImpl(interfaceToMock, realObject); Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl); MockObject m = (MockObject) o; return m; } } Index: MockObjectSuperImpl.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/impl/MockObjectSuperImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockObjectSuperImpl.java 5 Jan 2006 15:09:59 -0000 1.2 --- MockObjectSuperImpl.java 13 Jan 2006 14:48:31 -0000 1.3 *************** *** 1,6 **** package biz.xsoftware.mock2.impl; - import java.util.logging.Logger; - import biz.xsoftware.mock2.Behavior; import biz.xsoftware.mock2.CalledMethod; --- 1,4 ---- *************** *** 9,49 **** public abstract class MockObjectSuperImpl implements MockObject{ ! private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); private static final long NO_TIME_OUT=0; ! public CalledMethod expect(String methodName, Class[] vargs) { return expect(methodName,NO_TIME_OUT,vargs); } ! public CalledMethod expect(Object returnValue, String methodName, Class[] vargs) { return expect(returnValue,methodName,NO_TIME_OUT,vargs); } ! public CalledMethod expect(String methodName, Throwable throwable, Class[] vargs) { return expect(methodName,throwable,NO_TIME_OUT,vargs); } ! public CalledMethod expect(String methodName, Behavior behavior, Class[] params) { return expect(methodName,behavior,NO_TIME_OUT,params); } ! public CalledMethod expect(String methodName, long timeout, Class[] vargs) { return null; } ! public CalledMethod expect(Object returnValue, String methodName, long timeout, Class[] vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Throwable throwable, long timeout, Class[] vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Behavior behavior, long timeout, Class[] params) { // TODO Auto-generated method stub return null; --- 7,47 ---- public abstract class MockObjectSuperImpl implements MockObject{ ! //private static final Logger logger=Logger.getLogger(MockObjectSuperImpl.class.getName()); private static final long NO_TIME_OUT=0; ! public CalledMethod expect(String methodName, Class... vargs) { return expect(methodName,NO_TIME_OUT,vargs); } ! public CalledMethod expect(Object returnValue, String methodName, Class... vargs) { return expect(returnValue,methodName,NO_TIME_OUT,vargs); } ! public CalledMethod expect(String methodName, Throwable throwable, Class... vargs) { return expect(methodName,throwable,NO_TIME_OUT,vargs); } ! public CalledMethod expect(String methodName, Behavior behavior, Class... params) { return expect(methodName,behavior,NO_TIME_OUT,params); } ! public CalledMethod expect(String methodName, long timeout, Class... vargs) { return null; } ! public CalledMethod expect(Object returnValue, String methodName, long timeout, Class... vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Throwable throwable, long timeout, Class... vargs) { // TODO Auto-generated method stub return null; } ! public CalledMethod expect(String methodName, Behavior behavior, long timeout, Class... params) { // TODO Auto-generated method stub return null; *************** *** 55,69 **** } ! public void addIgnoreMethod(String methodName, Class[] vargs) { // TODO Auto-generated method stub } ! public void removeIgnoreMethod(String methodName, Class[] vargs) { // TODO Auto-generated method stub } ! public void setDefaultReturnValue(Object returnValue, String methodName, Class[] vargs) { // TODO Auto-generated method stub --- 53,67 ---- } ! public void addIgnoreMethod(String methodName, Class... vargs) { // TODO Auto-generated method stub } ! public void removeIgnoreMethod(String methodName, Class... vargs) { // TODO Auto-generated method stub } ! public void setDefaultReturnValue(Object returnValue, String methodName, Class... vargs) { // TODO Auto-generated method stub |
From: Nobody <fas...@us...> - 2006-01-13 14:48:41
|
Update of /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13634/input/javasrc/biz/xsoftware/mock2 Modified Files: MockObjectFactory.java Removed Files: MockObjectImpl.java Log Message: get build passing again by modifying design slightly and in some cases modifying code to adhere to design. --- MockObjectImpl.java DELETED --- Index: MockObjectFactory.java =================================================================== RCS file: /cvsroot/mocklib/mocklib2/input/javasrc/biz/xsoftware/mock2/MockObjectFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockObjectFactory.java 3 Jan 2006 15:36:45 -0000 1.2 --- MockObjectFactory.java 13 Jan 2006 14:48:31 -0000 1.3 *************** *** 4,8 **** import biz.xsoftware.mock2.MockObject; ! import biz.xsoftware.mock2.MockObjectImpl; /** --- 4,8 ---- import biz.xsoftware.mock2.MockObject; ! import biz.xsoftware.mock2.impl.MockObjectImpl; /** *************** *** 13,28 **** */ public abstract class MockObjectFactory { public static MockObject createMock(Class[] interfacesToMock) { ! Class[] interfacesPlusMock = new Class[interfacesToMock.length + 1]; ! interfacesPlusMock[0] = MockObject.class; ! for (int i = 1; i < interfacesPlusMock.length; i++) { ! interfacesPlusMock[i] = interfacesToMock[i - 1]; ! } ! ! ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(interfacesToMock); ! Object o = Proxy.newProxyInstance(cl, interfacesPlusMock, impl); ! MockObject m = (MockObject) o; ! return m; } --- 13,24 ---- */ public abstract class MockObjectFactory { + + private static MockObjectFactory singleton() { + //fix this using reflection.... + return null; + } + public static MockObject createMock(Class[] interfacesToMock) { ! return singleton().createMock(interfacesToMock); } *************** *** 32,44 **** public static MockObject createMock(Class interfaceToMock, Object realObject) { ! // TODO: Implement me! ! Class[] interfacePlusMock = new Class[1]; ! interfacePlusMock[0] = MockObject.class; ! ! ClassLoader cl = MockObjectFactory.class.getClassLoader(); ! MockObjectImpl impl = new MockObjectImpl(interfaceToMock, realObject); ! Object o = Proxy.newProxyInstance(cl, interfacePlusMock, impl); ! MockObject m = (MockObject) o; ! return m; } } --- 28,32 ---- public static MockObject createMock(Class interfaceToMock, Object realObject) { ! return singleton().createMock(interfaceToMock, realObject); } } |
From: Nobody <fas...@us...> - 2006-01-13 14:48:41
|
Update of /cvsroot/mocklib/mocklib2/bldfiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13634/bldfiles Modified Files: design.xml Log Message: get build passing again by modifying design slightly and in some cases modifying code to adhere to design. Index: design.xml =================================================================== RCS file: /cvsroot/mocklib/mocklib2/bldfiles/design.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** design.xml 1 Jan 2006 00:35:56 -0000 1.2 --- design.xml 13 Jan 2006 14:48:31 -0000 1.3 *************** *** 27,31 **** </package> ! <package name="impl2" package="biz.xsoftware.mock2"> <!-- is depending on junit a good idea???? it makes it easier to prevent people from forgetting to call verify but also locks us to use junit more --- 27,31 ---- </package> ! <package name="api" package="biz.xsoftware.mock2"> <!-- is depending on junit a good idea???? it makes it easier to prevent people from forgetting to call verify but also locks us to use junit more *************** *** 33,36 **** --- 33,39 ---- <depends>junit</depends> </package> + <package name="impl2" package="biz.xsoftware.mock2.impl"> + <depends>api</depends> + </package> <package name="testapi2" package="biz.xsoftware.test.mock2" subpackages="include"> <depends>impl2</depends> *************** *** 44,46 **** ! </design> \ No newline at end of file --- 47,49 ---- ! </design> |