View Javadoc

1   /*
2    * $Id: BridgeTestCase.java 20320 2010-11-24 15:03:31Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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  }