0

我希望 a<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)
********************************************************************************

知道我做错了什么吗?我正在使用骡子 3.2.1

谢谢

4

1 回答 1

0

我想我想通了。bean 的定义缺少一个属性init-method= "initialise"文档中似乎缺少此细节。因此,bean的定义应该是:

<spring:bean id="FTC"
    class="org.mule.tck.functional.FunctionalTestComponent" init-method="initialise" />
于 2012-04-19T12:55:21.210 回答