You can easily set this up by definining your own MockCall
implementation. To meet your use case, it's as simple as:
final Map lookupData = new HashMap();
lookupData.add(OrderUtil.ORDER_LOCALHOME, orderLocalHome);
lookupData.add(JNDINames.QUEUE_ORDER, queue);
lookupData.add(JNDINames.QUEUE_CONNECTION_FACTORY,
queueConnectionFactory);
mockContext.setup("lookup", new MockCall() {
public Object call(Object[] args) {
return lookupData.get(args[0]);
}
});
Adding a CallGroup class would be a good idea as this is something I've
come across lots although it might be tricky as it seems coupled to the
fact that the first argument is a keyed value.
cheers
-Joe
Vincent Massol wrote:
>Hi,
>
>I have the following use case:
>
>1/ I have a lookup() method
>2/ The first time the code under test is executed, the lookup method is
>called 3 times
>3/ The second time (and all time thereafter) the code under test is
>executed, the lookup method is only called twice (because a static flag
>has been set)
>4/ I can't remove the static flag (because I'm writing a tutorial which
>needs this static flag)
>5/ I would much much prefer not to have to order my testXXX() methods
>
>My question is: how can I set this up using Dyna Mocks?
>
>If I write:
>
> CallSequence sequence = new CallSequence();
> sequence.expectReturn(OrderUtil.ORDER_LOCALHOME,
>orderLocalHome);
> sequence.expectReturn(JNDINames.QUEUE_ORDER, queue);
> sequence.expectReturn(JNDINames.QUEUE_CONNECTION_FACTORY,
> queueConnectionFactory);
> mockContext.setup("lookup", sequence);
>
>Then, it does not work the second time as the first lookup is skipped in
>the execution code (because of the flag).
>
>Does anyone have a "CallGroup" java class that would perform the same as
>CallSequence but with no ordering nor expectation on the calls?
>
>Thanks
>-Vincent
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>http://thinkgeek.com/sf
>_______________________________________________
>Mockobjects-java-dev mailing list
>Moc...@li...
>https://lists.sourceforge.net/lists/listinfo/mockobjects-java-dev
>
>
|