How to configure the Demoiselle 2.4.2 Junit component to inject EJB dependencies

Asked

Viewed 105 times

1

I have a Demoiselle 2.4.2/JSF/Hibernate application that presents several test cases in full operation. The Bcs operated by these test cases undergo several dependency injections without any problem. Now I needed the injection of an EJB client, as shown in the code below:

@BusinessController
public class MeuBC implements Serializable {
    private static final long serialVersionUID = 1L;

    @Inject
    private SecurityServices securityServices;
    @Inject
    private TipoVinculoBC tipoVinculoBC;

    @EJB(lookup=Constantes.EXTERNAL_SERVICE_JNDI)
    private ExternalService EXTERNALService; // <=== Preciso desta injeção!!!

    // Restante da classe
}

In the example, we have TipoVinculoBC being injected without problem. However, during the tests only (works in the execution of the application) ExternalService is not injected, remaining with the value null during execution, resulting in error.

Rebound that is not about integration test, ExternalService is not in test, is only one service of which the MeuBC depends (like any other API), so it is a unit test of MeuBC.

What is missing so that the DemoiselleRunner or another participant may provide the customer with ExternalService?

1 answer

1


Browser other questions tagged

You are not signed in. Login or sign up in order to post.