View Javadoc

1   /*
2    * $Id: AbstractEmailNamespaceHandlerTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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  package org.mule.transport.email.config;
11  
12  import org.mule.api.MuleException;
13  import org.mule.api.endpoint.ImmutableEndpoint;
14  import org.mule.tck.FunctionalTestCase;
15  
16  public abstract class AbstractEmailNamespaceHandlerTestCase extends FunctionalTestCase
17  {
18      protected void testInboundEndpoint(String name, String protocolName) throws MuleException
19      {
20          ImmutableEndpoint endpoint =
21              muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(name);
22          testEndpoint(endpoint, protocolName);
23      }
24  
25      protected void testOutboundEndpoint(String name, String protocolName) throws MuleException
26      {
27          ImmutableEndpoint endpoint =
28              muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(name);
29          testEndpoint(endpoint, protocolName);
30      }
31  
32      private void testEndpoint(ImmutableEndpoint endpoint, String protocolName)
33      {
34          assertNotNull(endpoint);
35          String address = endpoint.getEndpointURI().getAddress();
36          assertNotNull(address);
37          assertEquals("bob@localhost:123", address);
38          String password = endpoint.getEndpointURI().getPassword();
39          assertNotNull(password);
40          assertEquals("secret", password);
41          String protocol = endpoint.getProtocol();
42          assertNotNull(protocol);
43          assertEquals(protocolName, protocol);
44      }
45  }