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