1   /*
2    * $Id: JmsVendorNamespaceHandlerTestCase.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  package org.mule.transport.jms.config;
11  
12  import org.mule.tck.FunctionalTestCase;
13  import org.mule.transport.jms.JmsConnector;
14  import org.mule.transport.jms.activemq.ActiveMQJmsConnector;
15  import org.mule.transport.jms.weblogic.WeblogicJmsConnector;
16  import org.mule.transport.jms.websphere.WebsphereJmsConnector;
17  
18  import javax.jms.ConnectionFactory;
19  
20  import org.apache.activemq.ActiveMQConnectionFactory;
21  
22  
23  /**
24   * Tests the "jms" namespace for vendor-specific configs.
25   */
26  public class JmsVendorNamespaceHandlerTestCase extends FunctionalTestCase
27  {
28      public JmsVendorNamespaceHandlerTestCase()
29      {
30          setStartContext(false);
31      }
32      
33      protected String getConfigResources()
34      {
35          return "jms-vendor-namespace-config.xml";
36      }
37  
38      public void testActiveMqDefault() throws Exception
39      {
40          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("activeMqConnectorDefaults");
41          assertNotNull(c);
42          assertTrue(c instanceof ActiveMQJmsConnector);
43  
44          assertNotNull(c.getConnectionFactory());
45          ConnectionFactory cf = c.getConnectionFactory();
46          assertTrue(cf instanceof ActiveMQConnectionFactory);
47          assertEquals(ActiveMQJmsConnector.DEFAULT_BROKER_URL, ((ActiveMQConnectionFactory) cf).getBrokerURL());
48      }
49      
50      public void testActiveMqBrokerURL() throws Exception
51      {
52          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("activeMqConnectorBroker");
53          assertNotNull(c);
54          assertTrue(c instanceof ActiveMQJmsConnector);
55  
56          assertNotNull(c.getConnectionFactory());
57          ConnectionFactory cf = c.getConnectionFactory();
58          assertTrue(cf instanceof ActiveMQConnectionFactory);
59          assertEquals("tcp://localhost:1234", ((ActiveMQConnectionFactory) cf).getBrokerURL());
60      }
61      
62      public void testWeblogicDefaultConfig() throws Exception
63      {
64          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("weblogicConnector");
65          assertNotNull(c);
66          assertTrue(c instanceof WeblogicJmsConnector);
67      }
68  
69      public void testWebsphereDefaultConfig() throws Exception
70      {
71          JmsConnector c = (JmsConnector)muleContext.getRegistry().lookupConnector("websphereConnector");
72          assertNotNull(c);
73          assertTrue(c instanceof WebsphereJmsConnector);
74      }
75  }