在尝试模拟sfdc端点时,Munit测试用例失败

时间:2015-05-27 17:28:09

标签: munit

我正在尝试模拟一个sfdc-endpoint。但是在我的实际流程中,这个端点会返回一些值。当我试图通过模拟这个端点返回任何值时,它会抛出异常:

org.mule.api.MessagingException: Execution of the expression "payload.size()" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: String
    at org.mule.el.mvel.MVELExpressionLanguage.evaluateInternal(MVELExpressionLanguage.java:202)
    at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:154)
    at org.mule.el.mvel.MVELExpressionLanguage.evaluate(MVELExpressionLanguage.java:133)
    at org.mule.expression.DefaultExpressionManager.evaluate(DefaultExpressionManager.java:215)
    at org.mule.expression.DefaultExpressionManager$2.match(DefaultExpressionManager.java:476)
    at org.mule.util.TemplateParser.parse(TemplateParser.java:149)
    at org.mule.util.TemplateParser.parse(TemplateParser.java:126)
    at org.mule.expression.DefaultExpressionManager.parse(DefaultExpressionManager.java:472)
    at org.mule.expression.DefaultExpressionManager.parse(DefaultExpressionManager.java:431)
    at org.mule.api.processor.LoggerMessageProcessor.log(LoggerMessageProcessor.java:88)
    at org.mule.api.processor.LoggerMessageProcessor.process(LoggerMessageProcessor.java:67)
    at org.mule.api.processor.LoggerMessageProcessor$$EnhancerByMUNIT$$5003da6e.CGLIB$process$1(<generated>)
    at org.mule.api.processor.LoggerMessageProcessor$$EnhancerByMUNIT$$5003da6e$$FastClassByMUNIT$$60cdcd72.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
    at org.mule.munit.common.mp.MunitMessageProcessorInterceptor.invokeSuper(MunitMessageProcessorInterceptor.java:66)
    at org.mule.munit.common.mp.MunitMessageProcessorInterceptor.process(MunitMessageProcessorInterceptor.java:59)
    at org.mule.modules.interceptor.processors.AbstractMessageProcessorInterceptor.intercept(AbstractMessageProcessorInterceptor.java:44)
    at org.mule.api.processor.LoggerMessageProcessor$$EnhancerByMUNIT$$5003da6e.process(<generated>)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.AsyncInterceptingMessageProcessor.process(AsyncInterceptingMessageProcessor.java:97)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.construct.DynamicPipelineMessageProcessor.process(DynamicPipelineMessageProcessor.java:54)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.interceptor.AbstractEnvelopeInterceptor.process(AbstractEnvelopeInterceptor.java:51)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.processor.AbstractFilteringMessageProcessor.process(AbstractFilteringMessageProcessor.java:40)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.construct.AbstractPipeline$1.process(AbstractPipeline.java:109)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor.execute(ExceptionToMessagingExceptionExecutionInterceptor.java:24)
    at org.mule.execution.MessageProcessorNotificationExecutionInterceptor.execute(MessageProcessorNotificationExecutionInterceptor.java:58)
    at org.mule.execution.MessageProcessorExecutionTemplate.execute(MessageProcessorExecutionTemplate.java:44)
    at org.mule.construct.Flow$1.process(Flow.java:82)
    at org.mule.construct.Flow$1.process(Flow.java:77)
    at org.mule.execution.ExecuteCallbackInterceptor.execute(ExecuteCallbackInterceptor.java:16)
    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:54)
    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:59)
    at org.mule.execution.ErrorHandlingExecutionTemplate.execute(ErrorHandlingExecutionTemplate.java:30)
    at org.mule.construct.Flow.process(Flow.java:76)
    at org.mule.construct.Flow$$EnhancerByMUNIT$$bb7e3368.CGLIB$process$0(<generated>)
    at org.mule.construct.Flow$$EnhancerByMUNIT$$bb7e3368$$FastClassByMUNIT$$45e5ae9e.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
    at org.mule.munit.common.mp.MunitMessageProcessorInterceptor.invokeSuper(MunitMessageProcessorInterceptor.java:66)
    at org.mule.munit.common.mp.MunitMessageProcessorInterceptor.process(MunitMessageProcessorInterceptor.java:59)
    at org.mule.modules.interceptor.processors.AbstractMessageProcessorInterceptor.intercept(AbstractMessageProcessorInterceptor.java:44)
    at org.mule.construct.Flow$$EnhancerByMUNIT$$bb7e3368.process(<generated>)
    at org.mule.munit.runner.functional.FunctionalMunitSuite.runFlow(FunctionalMunitSuite.java:261)
    at mule_work_with_form.TestGetEmployeeFlow.validateEchoFlow(TestGetEmployeeFlow.java:56)
Caused by: org.mule.mvel2.PropertyAccessException: [Error: unable to resolve method: java.lang.String.size() [arglength=0]]
[Near : {... payload.size() ....}]
             ^
[Line: 1, Column: 1]
    at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1084)
    at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:993)
    at org.mule.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:343)

我使用的是Munit-3.5-m2。

1 个答案:

答案 0 :(得分:0)

不确定您是否无法模拟连接器。

您可以看到,异常指向执行MEL表达式时的MEL错误,并且它抱怨无论有效负载在达到该表达式时是什么,它都没有size()方法。

它实际上表示有效负载是一个字符串,并且没有size方法:

引起:org.mule.mvel2.PropertyAccessException:[错误:无法解析方法:java.lang.String.size()[arglength = 0]] [近:{... payload.size()....}]

我认为你期望有效载荷是列表或集合。

我会在那里开始查看错误。

如果您仍然发现问题,请分享失败测试的代码和尝试测试的流程之一。

HTH