From: <sea...@ce...> - 2003-07-28 01:56:08
|
Hi all I have just started using Dynamic Mocks in MockObjects v0.09. On the MockObjects wiki (http://mockobjects.com/wiki/CallableDecorators) there is a discussion about writing a custom stub when you want to mock a method that has side-effects. The example given is: // Note: final so they can be used by the anonymous inner class final ResultSetHandler resultSetHandler = .... final Mock mockResultSet = new Mock(ResultSet.class); Mock mockSQLExecuter = new Mock(SQLExecuter.class); mockSQLExecuter.add( new CallOnceExpectation( new CallSignature( "execute", C.eq( expectedSQL, expectedBindVariables, resultSetHandler ) ), new VoidStub() { public void getDescription() { return super.getDescription() + " [calls back to resultSetHandler]"; } public Object call( String methodName, Object[] args ) { resultSetHandler.handle( (ResultSet)mockResultSet.proxy() ); return super.call( methodName, args ); // stubs the void result } } ) ) ); I need to do something similar, but this approach does not seem to be supported. For example, there is no Mock.add method, or any means to supply a custom CallStub. What is the currently recommended approach, or am I missing something? Thanks Sean. Important: This e-mail is intended for the use of the addressee and may contain information that is confidential, commercially valuable or subject to legal or parliamentary privilege. If you are not the intended recipient you are notified that any review, re-transmission, disclosure, use or dissemination of this communication is strictly prohibited by several Commonwealth Acts of Parliament. If you have received this communication in error please notify the sender immediately and delete all copies of this transmission together with any attachments. |