1   /*
2    * $Id: AbstractNamespaceHandlerTestCase.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.xmpp;
12  
13  import org.mule.api.endpoint.EndpointException;
14  import org.mule.api.endpoint.ImmutableEndpoint;
15  import org.mule.api.lifecycle.InitialisationException;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.transport.xmpp.XmppConnector;
18  
19  public abstract class AbstractNamespaceHandlerTestCase extends FunctionalTestCase
20  {
21  
22      private String protocolName;
23  
24      public AbstractNamespaceHandlerTestCase(String protocolName)
25      {
26          this.protocolName = protocolName;
27      }
28  
29      protected String getConfigResources()
30      {
31          return protocolName + "-namespace-config.xml";
32      }
33  
34      public void testConfig() throws Exception
35      {
36          XmppConnector connector = (XmppConnector) muleContext.getRegistry().lookupConnector(protocolName + "Connector");
37          assertNotNull(connector);
38      }
39  
40      public void testEndpoints() throws EndpointException, InitialisationException
41      {
42          ImmutableEndpoint simpleEndpoint = muleContext.getRegistry()
43              .lookupEndpointBuilder("simpleEndpoint")
44              .buildOutboundEndpoint();
45          assertEquals(protocolName + "://mule:secret@localhost:1234/recipient", simpleEndpoint.getEndpointURI()
46              .toString());
47  
48          ImmutableEndpoint groupChatEndpoint = muleContext.getRegistry()
49              .lookupEndpointBuilder("groupChatEndpoint")
50              .buildOutboundEndpoint();
51          assertEquals(protocolName + "://mule:secret@localhost:1234/recipient", groupChatEndpoint.getEndpointURI()
52              .toString());
53          assertNotNull(groupChatEndpoint.getProperty("groupChat"));
54          assertTrue(groupChatEndpoint.getProperty("groupChat") instanceof String);
55          assertEquals("true", groupChatEndpoint.getProperty("groupChat"));
56          assertNotNull(groupChatEndpoint.getProperty("nickname"));
57          assertTrue(groupChatEndpoint.getProperty("nickname") instanceof String);
58          assertEquals("bob", groupChatEndpoint.getProperty("nickname"));
59      }
60  
61  }