1

我们安装了 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 模块在standalone-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$1.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$2.run(MscManagedProcessEngineController.java:131)
    at org.camunda.bpm.container.impl.jboss.service.MscManagedProcessEngineController$2.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$1.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 委托?

4

1 回答 1

0

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

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

于 2015-04-19T22:23:36.887 回答