2

我正在尝试在 SwitchYard 应用程序中实现 Junit。我正在使用 JPA ,而不使用 Camel。我有带有以下详细信息的 persistence.xml。我正在使用资源生产者模式来公开 EntityManager。

但是当我测试服务时,我在 DAO 层中得到了 EntityManager 的空调用。

有什么办法,我可以在 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