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.builder;
8   
9   import org.mule.MessageExchangePattern;
10  import org.mule.construct.Bridge;
11  import org.mule.exception.DefaultServiceExceptionStrategy;
12  import org.mule.tck.junit4.AbstractMuleContextTestCase;
13  import org.mule.transformer.compression.GZipCompressTransformer;
14  import org.mule.transformer.simple.ObjectToByteArray;
15  import org.mule.transformer.simple.StringAppendTransformer;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  
21  public class BridgeBuilderTestCase extends AbstractMuleContextTestCase
22  {
23      @Test
24      public void testFullConfiguration() throws Exception
25      {
26          Bridge bridge = new BridgeBuilder().name("test-bridge-full")
27              .inboundAddress("test://foo.in")
28              .inboundTransformers(new StringAppendTransformer("bar"))
29              .inboundResponseTransformers(new ObjectToByteArray(), new GZipCompressTransformer())
30              .outboundAddress("test://foo.out")
31              .exchangePattern(MessageExchangePattern.REQUEST_RESPONSE)
32              .transacted(false)
33              .exceptionStrategy(new DefaultServiceExceptionStrategy(muleContext))
34              .build(muleContext);
35  
36          assertEquals("test-bridge-full", bridge.getName());
37      }
38  
39      @Test
40      public void testTransacted() throws Exception
41      {
42          Bridge bridge = new BridgeBuilder().name("test-bridge-transacted")
43              .inboundAddress("test://foo.in")
44              .outboundAddress("test2://foo.out")
45              .transacted(true)
46              .build(muleContext);
47  
48          assertEquals("test-bridge-transacted", bridge.getName());
49      }
50  }