2

SwitchYard アプリケーションに Junit を実装しようとしています。Camelを使用せずに JPA を使用しています。次の詳細を含むpersistence.xmlがあります。そして、リソース プロデューサー パターンを使用して EntityManager を公開しています。

しかし、サービスをテストしているとき、DAO レイヤーで EntityManager の呼び出しが null になっています。

方法はありますか、SwitchYard Junit で EntityManager をモックまたは注入できます

@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);
    }
    }
4

0 に答える 0