为我的基于maven的mule项目进行munit(xml)测试。
以下是仅使用记录器的样本批次
<batch:job name="sample-mavenBatch">
<batch:input>
<logger message="I am in input phase" level="INFO" doc:name="Logger"/>
</batch:input>
<batch:process-records>
<batch:step name="Batch_Step">
<logger message="I am in processing phase" level="INFO" doc:name="Logger"/>
</batch:step>
</batch:process-records>
<batch:on-complete>
<logger message="I am in complete phase" level="INFO" doc:name="Logger"/>
</batch:on-complete>
</batch:job>
The corresponding test for the flow
<munit:test name="new-test-suite-sample-mavenBatchTest" description="Test">
<munit:set payload="#['rasmita']" doc:name="Set Message"/>
<synchronize:run-and-wait doc:name="Synchronize">
<batch:execute name="sample-mavenBatch" doc:name="Run Batch sample-mavenBatch"/>
</synchronize:run-and-wait>
</munit:test>
这会让我遇到以下异常
消息
: Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)
Element : /new-test-suite-sample-mavenBatchTest/processors/1 @ b185c7c0-9c20-11e6-9bef-c03fd56639e7
--------------------------------------------------------------------------------
Exception stack is:
Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) (com.mulesoft.module.batch.exception.BatchException)
org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:65)
org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:26)
com.mulesoft.module.batch.engine.queue.BatchQueueLoader.splitAndLoad(BatchQueueLoader.java:63)
(98 more...)
(set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR - The test new-test-suite-sample-mavenBatchTest finished with an Error.
Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) (com.mulesoft.module.batch.exception.BatchException) (org.mule.api.DefaultMuleException).
org.mule.api.MessagingException: Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) (com.mulesoft.module.batch.exception.BatchException) (org.mule.api.DefaultMuleException).
at sample-mavenBatch.mule:logger{doc:name=Logger, level=INFO, message=I am in input phase}(sample-maven.xml:18)
at sample-mavenBatch.batch:input{}(sample-maven.xml:17)
at new-test-suite-sample-mavenBatchTest.batch:execute{doc:name=Run Batch sample-mavenBatch}(new-test-suite.xml:18)
at new-test-suite-sample-mavenBatchTest.synchronize:run-and-wait{doc:name=Synchronize, timeout=2000, runAsync=false}(new-test-suite.xml:17)
at new-test-suite-sample-mavenBatchTest.munit:set{doc:name=Set Message, payload=rasmita}(new-test-suite.xml:16)
at appleFlow.munit:test{initialState=started, description=Test, ignore=false, abstract=false, id=MunitTestFlow$$EnhancerByMUNIT$$904837f0{new-test-suite-sample-mavenBatchTest}}(new-test-suite.xml:15)
Caused by: org.mule.api.DefaultMuleException: Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) (com.mulesoft.module.batch.exception.BatchException)
at org.mule.config.RunAndWait.process(RunAndWait.java:52)
at org.mule.config.RunAndWait$$EnhancerByMUNIT$$b91d97ea.CGLIB$process$0(<generated>)
at org.mule.config.RunAndWait$$EnhancerByMUNIT$$b91d97ea$$FastClassByMUNIT$$2ac5af50.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at org.mule.munit.common.processor.interceptor.MunitMessageProcessorInterceptor.invokeSuper(MunitMessageProcessorInterceptor.java:95)
at org.mule.munit.common.processor.interceptor.MunitMessageProcessorInterceptor.process(MunitMessageProcessorInterceptor.java:82)
at org.mule.modules.interceptor.processors.AbstractMessageProcessorInterceptor.intercept(AbstractMessageProcessorInterceptor.java:46)
at org.mule.config.RunAndWait$$EnhancerByMUNIT$$b91d97ea.process(<generated>)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:102)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:55)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.interceptor.AbstractEnvelopeInterceptor.processBlocking(AbstractEnvelopeInterceptor.java:58)
at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:52)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:98)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.processor.AbstractRequestResponseMessageProcessor.processBlocking(AbstractRequestResponseMessageProcessor.java:56)
at org.mule.processor.AbstractRequestResponseMessageProcessor.process(AbstractRequestResponseMessageProcessor.java:47)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.processor.BlockingProcessorExecutor.executeNext(BlockingProcessorExecutor.java:88)
at org.mule.processor.BlockingProcessorExecutor.execute(BlockingProcessorExecutor.java:59)
at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:27)
at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:108)
at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
at org.mule.construct.Flow$2.process(Flow.java:138)
at org.mule.construct.Flow$2.process(Flow.java:133)
at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:35)
at org.mule.execution.CommitTransactionInterceptor.execute(CommitTransactionInterceptor.java:22)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:30)
at org.mule.execution.HandleExceptionInterceptor.execute(HandleExceptionInterceptor.java:14)
at org.mule.execution.BeginAndResolveTransactionInterceptor.execute(BeginAndResolveTransactionInterceptor.java:67)
at org.mule.execution.SuspendXaTransactionInterceptor.execute(SuspendXaTransactionInterceptor.java:50)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:28)
at org.mule.execution.RethrowExceptionInterceptor.execute(RethrowExceptionInterceptor.java:13)
at org.mule.execution.ErrorHandlingExecutionTemplate.execute(ErrorHandlingExecutionTemplate.java:60)
at org.mule.execution.ErrorHandlingExecutionTemplate.execute(ErrorHandlingExecutionTemplate.java:30)
at org.mule.construct.Flow.process(Flow.java:132)
at org.mule.munit.assertion.processors.MunitTestFlow.process(MunitTestFlow.java:121)
at org.mule.munit.assertion.processors.MunitTestFlow$$EnhancerByMUNIT$$904837f0.CGLIB$process$0(<generated>)
at org.mule.munit.assertion.processors.MunitTestFlow$$EnhancerByMUNIT$$904837f0$$FastClassByMUNIT$$f664bbef.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
at org.mule.munit.common.processor.interceptor.MunitMessageProcessorInterceptor.invokeSuper(MunitMessageProcessorInterceptor.java:95)
at org.mule.munit.common.processor.interceptor.MunitMessageProcessorInterceptor.process(MunitMessageProcessorInterceptor.java:82)
at org.mule.modules.interceptor.processors.AbstractMessageProcessorInterceptor.intercept(AbstractMessageProcessorInterceptor.java:46)
at org.mule.munit.assertion.processors.MunitTestFlow$$EnhancerByMUNIT$$904837f0.process(<generated>)
at org.mule.munit.runner.mule.MunitTest.run(MunitTest.java:108)
at org.mule.munit.runner.mule.MunitSuite.run(MunitSuite.java:49)
at org.mule.munit.runner.mule.MunitSuiteRunner$1.runSuite(MunitSuiteRunner.java:53)
at org.mule.munit.runner.mule.MunitSuiteRunner$1.runSuite(MunitSuiteRunner.java:49)
at org.mule.munit.runner.MunitRunner.run(MunitRunner.java:75)
at org.mule.munit.runner.mule.MunitSuiteRunner.run(MunitSuiteRunner.java:49)
at org.mule.munit.remote.MunitRemoteRunner.runTestSuite(MunitRemoteRunner.java:193)
at org.mule.munit.remote.MunitRemoteRunner.run(MunitRemoteRunner.java:102)
at org.mule.munit.remote.MunitRemoteRunner.main(MunitRemoteRunner.java:76)
Caused by: com.mulesoft.module.batch.exception.BatchException: Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException)
at com.mulesoft.module.batch.engine.DefaultBatchEngine.load(DefaultBatchEngine.java:419)
at com.mulesoft.module.batch.DefaultBatchJob.execute(DefaultBatchJob.java:357)
at com.mulesoft.module.batch.processor.BatchExecuteMessageProcessor.process(BatchExecuteMessageProcessor.java:49)
at com.mulesoft.module.batch.processor.BatchExecuteMessageProcessor$$FastClassByCGLIB$$c5698262.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.mule.munit.common.processor.interceptor.WrapperMunitMessageProcessorInterceptor.invokeSuper(WrapperMunitMessageProcessorInterceptor.java:62)
at org.mule.munit.common.processor.interceptor.MunitMessageProcessorInterceptor.process(MunitMessageProcessorInterceptor.java:82)
at org.mule.munit.common.processor.interceptor.WrapperMunitMessageProcessorInterceptor.intercept(WrapperMunitMessageProcessorInterceptor.java:42)
at com.mulesoft.module.batch.processor.BatchExecuteMessageProcessor$$EnhancerByMUNIT$$c5698262.process(<generated>)
at org.mule.config.RunAndWait$1.process(RunAndWait.java:42)
at org.mule.Synchronizer.runAndWait(Synchronizer.java:39)
at org.mule.config.RunAndWait.process(RunAndWait.java:48)
... 86 more
Caused by: java.lang.IllegalArgumentException: Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}"
at org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:65)
at org.mule.util.collection.EventToMessageSequenceSplittingStrategy.split(EventToMessageSequenceSplittingStrategy.java:26)
at com.mulesoft.module.batch.engine.queue.BatchQueueLoader.splitAndLoad(BatchQueueLoader.java:63)
at com.mulesoft.module.batch.engine.DefaultBatchEngine.load(DefaultBatchEngine.java:402)
... 97 more
其中相同的测试用例适用于非maven mule项目。
请帮帮我。提前谢谢。
答案 0 :(得分:0)
这是Munit输入集的问题。正如错误信息明确指出
Object "java.lang.String" not of correct type. It must be of type "{interface java.lang.Iterable,interface java.util.Iterator,interface org.mule.routing.MessageSequence,interface java.util.Collection}" (java.lang.IllegalArgumentException) (com.mulesoft.module.batch.exception.BatchException) (org.mule.api.DefaultMuleException).
批量输入应该是Iterable,但是您提供了字符串#['rasmita']
。而不是尝试传递数组列表。您可以使用MEL或dataweave。
希望这有帮助。
答案 1 :(得分:0)
我以两种方式解决了我的问题
1) in Set payload as @anupambhusari said use arraylist, so using MEL #[{'rasmita','ananda'}]
2)With transform message which was throwing the below exception org.threeten.bp.zone.ZoneRulesProvider: Provider org.threeten.bp.zone.TzdbZoneRulesProvider
Added the below dependency.
Test <dependency>
<groupId>com.mulesoft.weave</groupId>
<artifactId>mule-plugin-weave_2.11</artifactId>
<version>${mule.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
</exclusion>
</exclusions>
</dependency>