1   /*
2    * $Id: JmsConnectionFactoryTestCase.java 10489 2008-01-23 17:53:38Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.FunctionalTestCase;
14  import org.mule.transport.jms.test.TestConnectionFactory;
15  
16  import javax.jms.ConnectionFactory;
17  
18  public class JmsConnectionFactoryTestCase extends FunctionalTestCase
19  {
20      protected String getConfigResources()
21      {
22          return "jms-connection-factory.xml";
23      }
24  
25      /**
26       * Test providerProperties set on JmsConnector are not passed to the underlying
27       * ConnectionFactory.
28       */
29      public void testProviderPropertiesNotPassed() throws Exception
30      {
31          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("jmsConnector1");
32          assertNotNull(c);
33  
34          ConnectionFactory cf = c.getConnectionFactory();
35          assertTrue(cf instanceof TestConnectionFactory);
36          assertEquals("Provider properties should not be passed to the ConnectionFactory.", "NOT_SET",
37              ((TestConnectionFactory)cf).getProviderProperty());
38      }
39  
40      /**
41       * Test connectionFactoryProperties set on JmsConnector are actually passed to
42       * the underlying ConnectionFactory.
43       */
44      public void testConnectionFactoryPropertiesPassed() throws Exception
45      {
46          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("jmsConnector2");
47          assertNotNull(c);
48  
49          ConnectionFactory cf = c.getConnectionFactory();
50          assertTrue(cf instanceof TestConnectionFactory);
51          assertEquals("ConnectionFactory properties should be passed to the ConnectionFactory.", "TEST_VALUE",
52              ((TestConnectionFactory)cf).getConnectionFactoryProperty());
53      }
54  }