1   /*
2    * $Id: EndpointRetrievalMule2021TestCase.java 11035 2008-02-26 17:06:34Z 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.soap.axis.issues;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.endpoint.EndpointBuilder;
15  import org.mule.api.endpoint.ImmutableEndpoint;
16  import org.mule.api.transport.Connector;
17  import org.mule.tck.FunctionalTestCase;
18  import org.mule.transport.soap.axis.AxisConnector;
19  
20  public class EndpointRetrievalMule2021TestCase extends FunctionalTestCase
21  {
22  
23      protected String getConfigResources()
24      {
25          return "endpoint-retrieval-mule-2021-test.xml";
26      }
27  
28      public void testLookupEndpoint() throws MuleException
29      {
30          Object endpoint1 = muleContext.getRegistry().lookupObject("Endpoint");
31          // This returns the builder rather than the endpoint
32          assertTrue(endpoint1 instanceof EndpointBuilder);
33          assertFalse(endpoint1 instanceof ImmutableEndpoint);
34  
35          EndpointBuilder endpointBuiler = muleContext.getRegistry().lookupEndpointBuilder("Endpoint");
36          // There should however be an endpoint builder with this id/name
37          assertNotNull(endpointBuiler);
38  
39          ImmutableEndpoint endpoint2 = (ImmutableEndpoint) muleContext.getRegistry().lookupObject(
40              "axis:http://localhost:18081/mule/Service?method=toString");
41          // Null expected because lookupEndpoint does not create endpoints from uri's.
42          assertNull(endpoint2);
43      }
44  
45      public void testGetOutboundEndpoint() throws MuleException
46      {
47          ImmutableEndpoint endpoint1 = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
48              "Endpoint");
49          assertEndpointOk(endpoint1);
50          ImmutableEndpoint endpoint2 = muleContext.getRegistry().lookupEndpointFactory().getOutboundEndpoint(
51              "axis:http://localhost:18081/mule/Service?method=toString");
52          assertEndpointOk(endpoint2);
53      }
54  
55      public void testGetInboundEndpoint() throws MuleException
56      {
57          ImmutableEndpoint endpoint1 = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(
58              "Endpoint");
59          assertEndpointOk(endpoint1);
60          ImmutableEndpoint endpoint2 = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(
61              "axis:http://localhost:18081/mule/Service?method=toString");
62          assertEndpointOk(endpoint2);
63      }
64  
65      public void testGetResponseEndpoint() throws MuleException
66      {
67          ImmutableEndpoint endpoint1 = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(
68              "Endpoint");
69          assertEndpointOk(endpoint1);
70          ImmutableEndpoint endpoint2 = muleContext.getRegistry().lookupEndpointFactory().getInboundEndpoint(
71              "axis:http://localhost:18081/mule/Service?method=toString");
72          assertEndpointOk(endpoint2);
73      }
74  
75      private void assertEndpointOk(ImmutableEndpoint endpoint)
76      {
77          assertNotNull("Endpoint is null", endpoint);
78          Connector connector = endpoint.getConnector();
79          assertTrue("Connector not AXIS", connector instanceof AxisConnector);
80      }
81  
82  }