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