View Javadoc

1   /*
2    * $Id: CustomTransactionTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.FunctionalTestCase;
16  import org.mule.tck.testmodels.mule.TestTransactionFactory;
17  
18  public class CustomTransactionTestCase extends FunctionalTestCase
19  {
20      protected String getConfigResources()
21      {
22          return "org/mule/test/config/custom-transaction-config.xml";
23      }
24  
25      public void testConfig1() throws Exception
26      {
27          EndpointBuilder epb = muleContext.getRegistry().lookupEndpointBuilder("testEndpoint1");
28          assertNotNull(epb);
29          InboundEndpoint iep = epb.buildInboundEndpoint();
30  
31          assertNotNull(iep.getTransactionConfig());
32          assertTrue(iep.getTransactionConfig().getFactory() instanceof TestTransactionFactory);
33          assertEquals(TransactionConfig.ACTION_ALWAYS_BEGIN, iep.getTransactionConfig().getAction());
34          assertEquals(4004, iep.getTransactionConfig().getTimeout());
35      }
36  
37      public void testConfig2() throws Exception
38      {
39          EndpointBuilder epb = muleContext.getRegistry().lookupEndpointBuilder("testEndpoint2");
40          assertNotNull(epb);
41          InboundEndpoint iep = epb.buildInboundEndpoint();
42  
43          assertNotNull(iep.getTransactionConfig());
44          assertTrue(iep.getTransactionConfig().getFactory() instanceof TestTransactionFactory);
45          assertEquals(TransactionConfig.ACTION_ALWAYS_BEGIN, iep.getTransactionConfig().getAction());
46          assertEquals(muleContext.getConfiguration().getDefaultTransactionTimeout(), iep.getTransactionConfig().getTimeout());
47      }
48  }