View Javadoc

1   /*
2    * $Id: AbstractEmailNamespaceHandlerTestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
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.junit4.FunctionalTestCase;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNotNull;
18  
19  public abstract class AbstractEmailNamespaceHandlerTestCase extends FunctionalTestCase
20  {
21  
22      protected void testInboundEndpoint(String name, String protocolName) throws MuleException
23      {
24          ImmutableEndpoint endpoint =
25              muleContext.getEndpointFactory().getInboundEndpoint(name);
26          testEndpoint(endpoint, protocolName);
27      }
28  
29      protected void testOutboundEndpoint(String name, String protocolName) throws MuleException
30      {
31          ImmutableEndpoint endpoint =
32              muleContext.getEndpointFactory().getOutboundEndpoint(name);
33          testEndpoint(endpoint, protocolName);
34      }
35  
36      private void testEndpoint(ImmutableEndpoint endpoint, String protocolName)
37      {
38          assertNotNull(endpoint);
39          String address = endpoint.getEndpointURI().getAddress();
40          assertNotNull(address);
41          assertEquals("bob@localhost:123", address);
42          String password = endpoint.getEndpointURI().getPassword();
43          assertNotNull(password);
44          assertEquals("secret", password);
45          String protocol = endpoint.getProtocol();
46          assertNotNull(protocol);
47          assertEquals(protocolName, protocol);
48      }
49  }