View Javadoc

1   /*
2    * $Id: CustomTransactionTestCase.java 22414 2011-07-14 13:24:46Z dirk.olmes $
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  package org.mule.test.config;
11  
12  import org.mule.api.endpoint.EndpointBuilder;
13  import org.mule.api.endpoint.InboundEndpoint;
14  import org.mule.api.transaction.TransactionConfig;
15  import org.mule.tck.junit4.FunctionalTestCase;
16  import org.mule.tck.testmodels.mule.TestTransactionFactory;
17  
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertEquals;
21  import static org.junit.Assert.assertNotNull;
22  import static org.junit.Assert.assertTrue;
23  
24  public class CustomTransactionTestCase extends FunctionalTestCase
25  {
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "org/mule/test/config/custom-transaction-config.xml";
31      }
32  
33      @Test
34      public void testConfig1() throws Exception
35      {
36          EndpointBuilder epb = muleContext.getRegistry().lookupEndpointBuilder("testEndpoint1");
37          assertNotNull(epb);
38          InboundEndpoint iep = epb.buildInboundEndpoint();
39  
40          assertNotNull(iep.getTransactionConfig());
41          assertTrue(iep.getTransactionConfig().getFactory() instanceof TestTransactionFactory);
42          assertEquals(TransactionConfig.ACTION_ALWAYS_BEGIN, iep.getTransactionConfig().getAction());
43          assertEquals(4004, iep.getTransactionConfig().getTimeout());
44      }
45  
46      @Test
47      public void testConfig2() throws Exception
48      {
49          EndpointBuilder epb = muleContext.getRegistry().lookupEndpointBuilder("testEndpoint2");
50          assertNotNull(epb);
51          InboundEndpoint iep = epb.buildInboundEndpoint();
52  
53          assertNotNull(iep.getTransactionConfig());
54          assertTrue(iep.getTransactionConfig().getFactory() instanceof TestTransactionFactory);
55          assertEquals(TransactionConfig.ACTION_ALWAYS_BEGIN, iep.getTransactionConfig().getAction());
56          assertEquals(muleContext.getConfiguration().getDefaultTransactionTimeout(), iep.getTransactionConfig().getTimeout());
57      }
58  }