如何在Mule FunctionalTestCase中指定特定的VM连接器

Gar*_*rpe 3 mule

我正在尝试使用下面的FunctionalTestCase向VM端点发送消息:

@Test
public void CreateAddToCalendarOptionsApiTest() throws Exception{

    MuleClient client = new MuleClient(muleContext);
    String payload = "foo";
    Map<String, Object> properties = null;
    MuleMessage result = client.send("vm://processActivity",  payload, properties);
    assertEquals("foo Received", result.getPayloadAsString());

}
Run Code Online (Sandbox Code Playgroud)

但是,在要测试的流程中,定义了多个VM连接器,因此我收到一个TransportFactoryException:

org.mule.transport.service.TransportFactoryException: There are at least 
2 connectors matching protocol "vm", so the connector to use must be 
specified on the endpoint using the 'connector' property/attribute. 
Connectors in your configuration that support "vm" are: inMemoryVMQueue, 
recordDeletedActivityDLQStore, recordPublishedActivityDLQStore, 
recordUpdatedActivityDLQStore, deleteQueuedActivityDLQStore,  
(java.lang.IllegalStateException)
Run Code Online (Sandbox Code Playgroud)

如何指定client.send("vm:// processActivity",payload,properties)使用特定的VMConnector?

Dav*_*sot 7

使用查询参数:

client.send("vm://processActivity?connector=inMemoryVMQueue",  payload, properties);
Run Code Online (Sandbox Code Playgroud)

...替换inMemoryVMQueue您想要使用的任何连接器.

它在功能上等同于端点属性.