View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.construct;
8   
9   import org.mule.MessageExchangePattern;
10  import org.mule.api.MuleEvent;
11  import org.mule.api.endpoint.OutboundEndpoint;
12  import org.mule.api.transport.Connector;
13  import org.mule.tck.MuleTestUtils;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertEquals;
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      @Test
46      public void testProcess() throws Exception
47      {
48          bridge.initialise();
49          bridge.start();
50          MuleEvent response = directInboundMessageSource.process(MuleTestUtils.getTestInboundEvent("hello",
51              muleContext));
52  
53          assertEquals("hello", response.getMessageAsString());
54      }
55  }