View Javadoc

1   /*
2    * $Id: JmsConnectionFactoryTestCase.java 22431 2011-07-18 07:40:35Z 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  
11  package org.mule.transport.jms;
12  
13  import org.mule.tck.junit4.FunctionalTestCase;
14  import org.mule.transport.jms.test.TestConnectionFactory;
15  
16  import javax.jms.ConnectionFactory;
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 JmsConnectionFactoryTestCase extends FunctionalTestCase
25  {
26      
27      @Override
28      protected String getConfigResources()
29      {
30          return "jms-connection-factory.xml";
31      }
32  
33      /**
34       * Test providerProperties set on JmsConnector are not passed to the underlying
35       * ConnectionFactory.
36       */
37      @Test
38      public void testProviderPropertiesNotPassed() throws Exception
39      {
40          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("jmsConnector1");
41          assertNotNull(c);
42  
43          ConnectionFactory cf = c.getConnectionFactory();
44          assertTrue(cf instanceof TestConnectionFactory);
45          assertEquals("Provider properties should not be passed to the ConnectionFactory.", "NOT_SET",
46              ((TestConnectionFactory)cf).getProviderProperty());
47      }
48  
49      /**
50       * Test connectionFactoryProperties set on JmsConnector are actually passed to
51       * the underlying ConnectionFactory.
52       */
53      @Test
54      public void testConnectionFactoryPropertiesPassed() throws Exception
55      {
56          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("jmsConnector2");
57          assertNotNull(c);
58  
59          ConnectionFactory cf = c.getConnectionFactory();
60          assertTrue(cf instanceof TestConnectionFactory);
61          assertEquals("ConnectionFactory properties should be passed to the ConnectionFactory.", "TEST_VALUE",
62              ((TestConnectionFactory)cf).getConnectionFactoryProperty());
63      }
64  }