Inject EntityManager in SwitchYard Junit implementation

174 views Asked by At

I am trying to implement Junit in SwitchYard Application. i am using JPA , without using Camel. i have persistence.xml with the following details. And i am using resource producer pattern to expose EntityManager.

But when i am testing a service, i am getting null Invocation for EntityManager in DAO layer.

Is there any way , i can mock or inject EntityManager in SwitchYard Junit

@RunWith(SwitchYardRunner.class)
@SwitchYardTestCaseConfig(config = SwitchYardTestCaseConfig.SWITCHYARD_XML, mixins = {
        CDIMixIn.class, HTTPMixIn.class, NamingMixIn.class })
public class SalesModuleServiceTest {

    private SwitchYardTestKit testKit;
    private CDIMixIn cdiMixIn;
    private HTTPMixIn httpMixIn;
    private static NamingMixIn namingMixIn;
    private TransformerRegistry transformerRegistry;

    @ServiceOperation("SalesModuleService")
    private Invoker service;

    //------ JUnit test with REST binding fails if no resteasy properties defined ------
        @BeforeDeploy
        public void setProperties()
        { 
            System.setProperty("org.switchyard.component.resteasy.standalone.port", "8081"); 
            System.setProperty("org.switchyard.component.resteasy.standalone.path", ""); 
        }

    @Test
    public void testUpdateCustomerStatus() throws Exception {

        SalesDetailsRequest message = null;
        BudgetResponse<?> result = service.operation("updateCustomerStatus")
                .sendInOut(message).getContent(SalesResponse.class);

        // validate the results
        Assert.assertTrue("Implement me", false);
    }
    }
0

There are 0 answers