我必须在MUnit测试用例中使用Mule请求程序来读取src/test/resources下的文件,以便能够断言有效负载。在当前的实现中,我在MUnits xml中有Ftp连接器,我指的是mule请求者。我清楚地看到,mule请求者甚至在连接器初始化之前就试图访问它。有什么方法可以让mule提前初始化ftp连接器吗?
例外情况:
********************************************************************************
Message : Cannot perform an action on a connector when it is not started. Connector "no-delete-file-connector-test" is currently in lifecycle phase "initialise"
Element : /no-delete-file-connector-test @ app:haz001-test-suite.xml:33 (File)
--------------------------------------------------------------------------------
Exception stack is:
Cannot perform an action on a connector when it is not started. Connector "no-delete-file-connector-test" is currently in lifecycle phase "initialise" (org.mule.api.lifecycle.LifecycleException)
org.mule.transport.AbstractConnector.getRequester(AbstractConnector.java:1178)
org.mule.transport.AbstractConnector.request(AbstractConnector.java:2269)
org.mule.transport.file.FileConnector$$EnhancerByCGLIB$$d6c65eff.CGLIB$request$75(<generated>:-1)
(97 more...)
(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
以下是我的配置:
<flow-ref name="processMainFlow" doc:name="processMainFlow" />
<mulerequester:request resource="file://src/test/resources/expected-discrete.csv?connector=no-delete-file-connector-test" doc:name="Mule Requester" returnClass="java.lang.String"/>
<munit:assert-payload-equals expectedValue="#[flowVars.outputCSV]" doc:name="Assert Payload"/>
<logger message="response for test #[payload] actual data : #[flowVars.outputCSV]" level="INFO"
doc:name="Logger" />