我希望<test:component />
等同于
<component>
<spring-object bean="FTC" />
<component>
FTC bean使用FunctionalTestComponent
类。也就是说,我希望下面的两个配置通过下面进一步显示的功能测试。
配置<test:component />
<mule ...>
<vm:endpoint name="EntryPoint.Name" path="EntryPoint.Path" />
<simple-service name="service" endpoint-ref="EntryPoint.Name" >
<test:component />
</simple-service>
</mule>
使用FunctionalTestComponent配置Spring bean
<mule ...>
<vm:endpoint name="EntryPoint.Name" path="EntryPoint.Path" />
<spring:bean id="FTC" class="org.mule.tck.functional.FunctionalTestComponent" />
<simple-service name="service" endpoint-ref="EntryPoint.Name" >
<component>
<spring-object bean="FTC" />
</component>
</simple-service>
</mule>
测试
@Test
public void aTest() throws Exception {
final MuleClient client = muleContext.getClient();
client.send("vm://EntryPoint.Path", "1", null);
assertEquals("1", getFunctionalTestComponent("service").getLastReceivedMessage());
}
<test:component />
的配置通过了测试。但是,使用FTC bean的那个没有。实际上,使用FTC bean的运行在日志中显示异常:
********************************************************************************
Message : Component that caused exception is: DefaultJavaComponent{service.commponent}. Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.tck.functional.FunctionalTestComponent:215 (null)
2. Component that caused exception is: DefaultJavaComponent{service.commponent}. Message payload is of type: String (org.mule.component.ComponentException)
org.mule.component.DefaultComponentLifecycleAdapter:359 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/ComponentException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.tck.functional.FunctionalTestComponent.process(FunctionalTestComponent.java:215)
at org.mule.tck.functional.FunctionalTestComponent.onCall(FunctionalTestComponent.java:108)
at org.mule.model.resolvers.CallableEntryPointResolver.invoke(CallableEntryPointResolver.java:50)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
知道我可能做错了吗?我正在使用Mule 3.2.1
由于
答案 0 :(得分:0)
我想我明白了。 bean的定义缺少一个属性init-method=
"initialise"
。 documentation似乎缺少这个细节。因此,bean的定义应该是:
<spring:bean id="FTC"
class="org.mule.tck.functional.FunctionalTestComponent" init-method="initialise" />