テスト方法があります:
@Test
public void testHello_with_muleXmlConfig() throws Exception {
MuleClient client = new MuleClient("mule-config-test.xml");
client.getMuleContext().start();
MuleMessage result = client.send("http://127.0.0.1:8080/hello", "some data", null);
assertNotNull(result);
assertNull(result.getExceptionPayload());
assertFalse(result.getPayload() instanceof NullPayload);
assertEquals("hello", result.getPayloadAsString());
}
ここ (client.send("http://127.0.0.1:8080/hello", "some data", null)) では、パラメーター/データ = 'some data' を渡しています。
そして、私はクラスを持っています:
public class HelloWorld {
public String sayHello() {
return "hello";
}
}
これは、mule-config.xml で Spring Bean として公開されます。
<spring:bean id="helloWorld" class="org.mule.application.hello.HelloWorld"/>
<flow name="HelloWorld">
<inbound-endpoint address="http://127.0.0.1:8080/hello"/>
<invoke method="sayHello" object-ref="helloWorld"/>
</flow>
パラメータ「hello」を「sayHello()」メソッドに渡すにはどうすればよいですか。「sayHello(String text)」に変更するだけでは機能しません。