1
2
3
4
5
6
7 package org.mule.transport.soap.axis.issues;
8
9 import org.mule.api.MuleException;
10 import org.mule.api.endpoint.EndpointBuilder;
11 import org.mule.api.endpoint.ImmutableEndpoint;
12 import org.mule.api.transport.Connector;
13 import org.mule.tck.junit4.FunctionalTestCase;
14 import org.mule.tck.junit4.rule.DynamicPort;
15 import org.mule.transport.soap.axis.AxisConnector;
16
17 import org.junit.Rule;
18 import org.junit.Test;
19
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertNotNull;
22 import static org.junit.Assert.assertNull;
23 import static org.junit.Assert.assertTrue;
24
25 public class EndpointRetrievalMule2021TestCase extends FunctionalTestCase
26 {
27
28 @Rule
29 public DynamicPort dynamicPort = new DynamicPort("port1");
30
31 @Override
32 protected String getConfigResources()
33 {
34 return "endpoint-retrieval-mule-2021-test.xml";
35 }
36
37 @Test
38 public void testLookupEndpoint() throws MuleException
39 {
40 Object endpoint1 = muleContext.getRegistry().lookupObject("Endpoint");
41
42 assertTrue(endpoint1 instanceof EndpointBuilder);
43 assertFalse(endpoint1 instanceof ImmutableEndpoint);
44
45 EndpointBuilder endpointBuiler = muleContext.getRegistry().lookupEndpointBuilder("Endpoint");
46
47 assertNotNull(endpointBuiler);
48
49 ImmutableEndpoint endpoint2 = (ImmutableEndpoint) muleContext.getRegistry().lookupObject(
50 "axis:http://localhost:" + dynamicPort.getNumber() + "/mule/Service?method=toString");
51
52 assertNull(endpoint2);
53 }
54
55 @Test
56 public void testGetOutboundEndpoint() throws MuleException
57 {
58 ImmutableEndpoint endpoint1 = muleContext.getEndpointFactory().getOutboundEndpoint(
59 "Endpoint");
60 assertEndpointOk(endpoint1);
61 ImmutableEndpoint endpoint2 = muleContext.getEndpointFactory().getOutboundEndpoint(
62 "axis:http://localhost:" + dynamicPort.getNumber() + "/mule/Service?method=toString");
63 assertEndpointOk(endpoint2);
64 }
65
66 @Test
67 public void testGetInboundEndpoint() throws MuleException
68 {
69 ImmutableEndpoint endpoint1 = muleContext.getEndpointFactory().getInboundEndpoint(
70 "Endpoint");
71 assertEndpointOk(endpoint1);
72 ImmutableEndpoint endpoint2 = muleContext.getEndpointFactory().getInboundEndpoint(
73 "axis:http://localhost:" + dynamicPort.getNumber() + "/mule/Service?method=toString");
74 assertEndpointOk(endpoint2);
75 }
76
77 @Test
78 public void testGetResponseEndpoint() throws MuleException
79 {
80 ImmutableEndpoint endpoint1 = muleContext.getEndpointFactory().getInboundEndpoint(
81 "Endpoint");
82 assertEndpointOk(endpoint1);
83 ImmutableEndpoint endpoint2 = muleContext.getEndpointFactory().getInboundEndpoint(
84 "axis:http://localhost:" + dynamicPort.getNumber() + "/mule/Service?method=toString");
85 assertEndpointOk(endpoint2);
86 }
87
88 private void assertEndpointOk(ImmutableEndpoint endpoint)
89 {
90 assertNotNull("Endpoint is null", endpoint);
91 Connector connector = endpoint.getConnector();
92 assertTrue("Connector not AXIS", connector instanceof AxisConnector);
93 }
94
95 }