Camunda Process Engine 配置与 MockExpressionManager for wildfly

Camunda Process Engine configuration with MockExpressionManager for wildfly

我们已将 Camunda 安装为 Wildfly8 的模块。 一切正常,但我需要一种方法来模拟 java 委托进行单元测试(使用 Arquillian)。 据我了解,org.camunda.bpm.engine.test.mock.Mocks 可用于提供模拟委托。 根据 JavaDoc,我应该在我的流程引擎配置中注册 MockExpressionManager。 我在这里找到了一些与 MockExpressingManager 类似的配置 https://github.com/camunda/camunda-bpm-assert/blob/master/camunda-bpm-assert-examples/src/test/resources/camunda.cfg.xml

但是 wildfly 的 camunda 模块是独立配置的-full.xml:

        <subsystem xmlns="urn:org.camunda.bpm.jboss:1.1">
        <process-engines>
            <process-engine name="default" default="true">
                <datasource>
                    java:jboss/datasources/ProcessEngine
                </datasource>
                <history-level>
                    full
                </history-level>
                <configuration>
                    org.camunda.bpm.engine.cdi.CdiJtaProcessEngineConfiguration
                </configuration>
                <properties>
                    <property name="jobExecutorAcquisitionName">
                        default
                    </property>
                    <property name="isAutoSchemaUpdate">
                        true
                    </property>
                    <property name="authorizationEnabled">
                        true
                    </property>
                    <property name="jobExecutorDeploymentAware">
                        true
                    </property>
                    <property name="expressionManager">
                        org.camunda.bpm.engine.test.mock.MockExpressionManager
                    </property>                     
                </properties>

但这不起作用,在 wildfly 启动时我看到了

16:45:31,930 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 61) MSC000001: Failed to start service org.camunda.bpm.platform.process-engine.default: org.jboss.msc.service.StartException in service org.camunda.bpm.platform.process-engine.default: org.camunda.bpm.engine.ProcessEngineException: Could not set value for property 'expressionManager' on class org.camunda.bpm.engine.cdi.CdiJtaProcessEngineConfiguration
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.run(MscManagedProcessEngineController.java:97)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_11]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_11]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_11]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_11]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_11]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final.jar:2.1.1.Final]
Caused by: org.camunda.bpm.engine.ProcessEngineException: Could not set value for property 'expressionManager' on class org.camunda.bpm.engine.cdi.CdiJtaProcessEngineConfiguration
    at org.camunda.bpm.container.impl.metadata.PropertyHelper.applyProperty(PropertyHelper.java:76)
    at org.camunda.bpm.container.impl.metadata.PropertyHelper.applyProperties(PropertyHelper.java:94)
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startProcessEngine(MscManagedProcessEngineController.java:173)
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.run(MscManagedProcessEngineController.java:131)
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.run(MscManagedProcessEngineController.java:129)
    at org.camunda.bpm.container.impl.jboss.util.Tccl.runWithTccl(Tccl.java:53)
    at org.camunda.bpm.container.impl.jboss.util.Tccl.runUnderClassloader(Tccl.java:45)
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.startInternal(MscManagedProcessEngineController.java:129)
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController.run(MscManagedProcessEngineController.java:90)
    ... 6 more
Caused by: java.lang.IllegalArgumentException: argument type mismatch
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_11]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_11]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_11]
    at java.lang.reflect.Method.invoke(Method.java:483) [rt.jar:1.8.0_11]
    at org.camunda.bpm.container.impl.metadata.PropertyHelper.applyProperty(PropertyHelper.java:74)
    ... 14 more

如何正确设置这个MockExpressionManager的配置?

或者可能有一些其他方法来模拟 java 代表?

通过查看 Camunda 代码,他们期望传入对表达式管理器的引用。如果我不得不猜测的话,这是作为字符串传入的。我能想到的一种肮脏的处理方法是创建 CdiJtaProcessEngineConfiguration 的子类,它配置适当的表达式管理器,将该 JAR 部署到他们的模块并将其连接到

就我个人而言,我发现他们的配置对我来说在直接的 wildfly 集成中有点过于紧张,因此选择直接在我的应用程序中配置他们的库。