View Javadoc

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