1
2
3
4
5
6
7
8
9
10
11 package org.mule.construct;
12
13 import org.mule.MessageExchangePattern;
14 import org.mule.api.MuleEvent;
15 import org.mule.api.endpoint.OutboundEndpoint;
16 import org.mule.api.transport.Connector;
17 import org.mule.tck.MuleTestUtils;
18
19 public class BridgeTestCase extends AbstractFlowConstuctTestCase
20 {
21 private Bridge bridge;
22 protected Connector testConnector;
23
24 @Override
25 protected void doSetUp() throws Exception
26 {
27 super.doSetUp();
28
29 final OutboundEndpoint testOutboundEndpoint = MuleTestUtils.getTestOutboundEndpoint(
30 MessageExchangePattern.REQUEST_RESPONSE, muleContext);
31 testConnector = testOutboundEndpoint.getConnector();
32 muleContext.getRegistry().registerConnector(testConnector);
33 testConnector.start();
34
35 bridge = new Bridge("test-bridge", muleContext, directInboundMessageSource, testOutboundEndpoint,
36 MessageExchangePattern.REQUEST_RESPONSE, false);
37 }
38
39 @Override
40 protected AbstractFlowConstruct getFlowConstruct() throws Exception
41 {
42 return bridge;
43 }
44
45 public void testProcess() throws Exception
46 {
47 bridge.initialise();
48 bridge.start();
49 MuleEvent response = directInboundMessageSource.process(MuleTestUtils.getTestInboundEvent("hello",
50 muleContext));
51
52 assertEquals("hello", response.getMessageAsString());
53 }
54 }