jeudi 30 juillet 2015

Rebind an stateless ejb

The stateless bean works fine when deployed to app server,

@Stateless(name = "UtilitiesPersonClient")
@Loggable
public class UtilitiesPersonClient {

And the output of log shows created correctly :

java:global/my-app/UtilitiesPersonClient
java:app/my-app/UtilitiesPersonClient
java:module/UtilitiesPersonClient

However in my tests when I try to rebind this bean to a mock, it just doesn't get rebound and no error is thrown :

ejbContainer = EJBContainer.createEJBContainer(p);

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    UtilitiesPersonClient mockService = mock(UtilitiesPersonClient.class);
    when(mockService.getMyMap(anyCollection())).thenReturn(mockedMap());
    ejbContainer
            .getContext()
            .rebind("java:module/UtilitiesPersonClient", mockService);
}

How do I rebind a stateless bean using ejbcontainer ?

Aucun commentaire:

Enregistrer un commentaire