Skip to content

chore: migrate tests from JMock to Mockito#1814

Merged
jeanouii merged 2 commits intoapache:mainfrom
jbonofre:jmock-to-mockito-migration
Mar 23, 2026
Merged

chore: migrate tests from JMock to Mockito#1814
jeanouii merged 2 commits intoapache:mainfrom
jbonofre:jmock-to-mockito-migration

Conversation

@jbonofre
Copy link
Member

Replace JMock with Mockito in activemq-ra, activemq-unit-tests, and activemq-kahadb-store modules. Remove JMock dependencies from POMs.

Replace JMock with Mockito in activemq-ra, activemq-unit-tests, and
activemq-kahadb-store modules. Remove JMock dependencies from POMs.
@jbonofre jbonofre requested a review from jeanouii March 20, 2026 15:24
jeanouii
jeanouii previously approved these changes Mar 23, 2026
Copy link
Contributor

@jeanouii jeanouii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to get rid of JMock and only rely on one mocking framework.
Some very very minimal details. Nothing to block the merge

}});

setupExpectRelease();
doThrow(new ResourceException()).when(mockEndpointAndListener).beforeDelivery(any(Method.class));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few checks not ported here I believe

  • the 2 never in the checking block

    verify(mockEndpointAndListener, never()).onMessage(any());
    verify(mockEndpointAndListener, never()).afterDelivery();

  • the release in the setupExpectRelease() method
    verify(mockEndpointAndListener).release();


@Test(timeout = 60000)
public void testSuccessfulCallSequence() throws Exception {
setupBeforeDeliverySuccessful();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing equivalents for this?

verify(mockEndpointAndListener).beforeDelivery(any(Method.class));
verify(mockEndpointAndListener).onMessage(stubMessage);
verify(mockEndpointAndListener).afterDelivery();

}});
doBeforeDeliveryExpectSuccess();

setupAfterDeliverySuccessful();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the verify for Mockito

import static org.mockito.Mockito.*;
import static org.mockito.ArgumentMatchers.*;

@Ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of the scope of this PR. This test is @ignore, so you could have also remove it
Or fix it.

But that's fully equivalent

- Replace star imports with explicit imports in MessageEndpointProxyTest
- Add missing Mockito verify calls for all test methods to match
  original JMock expectations (never, release, successful calls)
- Extract common mock setup into setupCommonMocks() helper in
  ServerSessionImplTest
- Remove unused XAResource import
@jbonofre
Copy link
Member Author

@jeanouii I think I addressed your comments.

@jeanouii jeanouii merged commit 0c1eabd into apache:main Mar 23, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants