Hello,
I just migrate a working code from 3.3.2 to 3.4.0 and when I change my tests to use the new @MockitoSpyBean
I got exceptions with Mockito telling me that there is not the expected interaction with my mock. I cannot produce code easily, but here the exception :
Wanted but not invoked:
clientInitiator.start();
-> at quickfix.ThreadedSocketInitiator.start(ThreadedSocketInitiator.java:112)
However, there were exactly 3 interactions with this mock:
clientInitiator.startInitiators();
-> at quickfix.ThreadedSocketInitiator.start(ThreadedSocketInitiator.java:114)
clientInitiator.startSessionTimer();
-> at quickfix.mina.initiator.AbstractSocketInitiator.startInitiators(AbstractSocketInitiator.java:317)
clientInitiator.isLoggedOn();
-> at com.pictet.trading.gateway.FixToHttpIT.should_send_message_in_http(FixToHttpIT.java:133)
Here an extract of the code the producing the exception :
@MockitoSpyBean(name = "clientInitiator")
private Initiator initiator;
...
then(initiator).should().start();
The actual class on Github : https://github.com/quickfix-j/quickfixj/blob/QFJ_RELEASE_2_3_1/quickfixj-core/src/main/java/quickfix/ThreadedSocketInitiator.java#L111
As you can see you cannot call startInitiators()
without calling start()
.
If I put back @SpyBean
then everything works !
Thank you in advance for your help ππ»
Comment From: quaff
It may be duplicate of https://github.com/spring-projects/spring-framework/issues/33941.
Comment From: sbrannen
Hi @McKratt,
Congratulations on submitting your first issue for the Spring Framework! π
Like @quaff, I also assumed this was a duplicate of #33941, but I wanted to verify that.
So, I created an integration test specific to @MockitoSpyBean
in 51956fad89bc19abd33f5406ad246226c791435a. That fails with 6.2.0 but passes with 6.2.1 snapshots.
In light of that, I am closing this issue.
In any case, if you get a chance please try out 6.2.1-SNAPSHOT builds and let us know if your issue is resolved.
Cheers,
Sam
Comment From: McKratt
Hi @sbrannen,
Great news ! Thanks a lot. I'll wait the next version then π