I would expect a <test:component /> to be equivalent to
<component>
<spring-object bean="FTC" />
<component>
where the FTC bean uses the FunctionalTestComponent class. That is, I would expect the two configurations below to pass the functional test shown further below.
config with <test:component />
<mule ...>
<vm:endpoint name="EntryPoint.Name" path="EntryPoint.Path" />
<simple-service name="service" endpoint-ref="EntryPoint.Name" >
<test:component />
</simple-service>
</mule>
config with spring bean using FunctionalTestComponent
<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
@Test
public void aTest() throws Exception {
final MuleClient client = muleContext.getClient();
client.send("vm://EntryPoint.Path", "1", null);
assertEquals("1", getFunctionalTestComponent("service").getLastReceivedMessage());
}
The config with <test:component /> passes the test. However, the one with the FTC bean does not. In fact, the run with the FTC bean shows an exception in the logs:
********************************************************************************
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)
********************************************************************************
Any idea what I could be doing wrong? I am using Mule 3.2.1
Thanks
I think I figured it out. The definition of the bean is missing one attribute
init-method=. This detail seems to be missing from the documentation. Hence, the definition of the bean should be:"initialise"