View Javadoc

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