Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] synchroniser and expectations

Scott Levey

2011-05-15


Author LoginPost Reply

I've been playing around with the synchroniser... so far, it's working really
good.. but I'm wondering if I might be using it a bit wrong.

Here's a simple test.

@Test(timeout=1000)
public void testAddImmediateCommandOperation() {
 final States scheduling = context.states("scheduling");
 context.checking(new Expectations() {{
   oneOf(listener).beginTransaction(with(any(String.class)));
     when(scheduling.isNot("finished"));
     
   oneOf(listener).executeCommand(with(any(StipCommand.class)));
     will(returnValue(commandResponse));
     when(scheduling.isNot("finished"));
     
   oneOf(listener).commitTransaction(with(any(String.class)));
     then(scheduling.is("finished"));
 }});
 
 transactionScheduler.addCommandOperation(immediateDeleteUserCO);
 
 try {
   synchroniser.waitUntil(scheduling.is("finished"));
 } catch (InterruptedException e) {
   // TODO Auto-generated catch block
   fail("Thread Fail");
 }
   context.assertIsSatisfied();
}

If a call gets made to one of my mocked objects, and it's not in the
expectation list, I get the following exception thrown.

Exception in thread "TransactionRunner" java.lang.NoSuchMethodError:
 org.jmock.internal.
ParametersMatcher.describeMismatch(Ljava/lang/Object;
 Lorg/hamcrest/Description;)V
at org.jmock.internal.InvocationExpectation.describeMismatch
 (InvtionExpectation.java:90)
at org.jmock.internal.InvocationDispatcher$1$1$1.describeTo
 (InvocationDispatcher.java:44)
at org.hamcrest.BaseDescription.appendDescriptionOf (BaseDescription.java:21)
at org.hamcrest.BaseDescription.appendList (BaseDescription.java:78)
at org.hamcrest.BaseDescription.appendList (BaseDescription.java:69)
at org.jmock.internal.InvocationDispatcher.describe
 (InvocationDispatcher.java:61)
at org.jmock.internal.InvocationDispatcher.describeMismatch
 (InvocationDispatcher.java:32)
at org.jmock.Mockery.describeMismatch(Mockery.java:229)
at org.jmock.Mockery.access$000(Mockery.java:46)
at org.jmock.Mockery$1.describeTo(Mockery.java:268)
at org.jmock.api.ExpectationError.describeTo(ExpectationError.java:43)
at org.hamcrest.BaseDescription.appendDescriptionOf
 (BaseDescription.java:21)
at org.hamcrest.StringDescription.toString (StringDescription.java:28)
at org.jmock.lib.AssertionErrorTranslator.translate
 (AssertionErrorTranslator.java:20)
at org.jmock.Mockery.dispatch(Mockery.java:255)
at org.jmock.Mockery.access$100(Mockery.java:46)
at org.jmock.Mockery$MockObject.invoke(Mockery.java:290)
at org.jmock.internal.InvocationDiverter.invoke(InvocationDiverter.java:27)
at org.jmock.internal.FakeObjectMethods.invoke(FakeObjectMethods.java:38)
at org.jmock.lib.concurrent.Synchroniser.synchroniseInvocation
 (Synchroniser.java:82)
at org.jmock.lib.concurrent.Synchroniser.access$000(Synchroniser.java:23)
at org.jmock.lib.concurrent.Synchroniser$1.invoke(Synchroniser.java:74)
at org.jmock.lib.JavaReflectionImposteriser$1.invoke
 (JavaReflectionImposteriser.java:33)
at $Proxy11.submitTransaction(Unknown Source)
at gov.tsa.stip.api.transactions.TransactionRunner.
saveSuccessfullTransactionInDatabase(TransactionRunner.java:301)
at gov.tsa.stip.api.transactions.TransactionRunner.run
 (TransactionRunner.java:240)
at java.lang.Thread.run (Thread.java:662)

Now it's easy enough from this exception to see that it's complaining that
dataService.submitTransaction was not in the expectations list, but the junit
test passes. If I don't use the synchroniser, the junit tests fail as they
should.

Is there anything I can do, or is it a limitation of synchroniser?

thanks for your help


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


©2008 gg3721.com - Jax Systems, LLC, U.S.A.