View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.soap.axis;
8   
9   import org.mule.api.config.MuleProperties;
10  import org.mule.api.endpoint.EndpointURI;
11  import org.mule.api.registry.ServiceType;
12  import org.mule.endpoint.MuleEndpointURI;
13  import org.mule.tck.junit4.AbstractMuleContextTestCase;
14  import org.mule.transport.service.TransportServiceDescriptor;
15  
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertEquals;
19  
20  public class AxisEndpointTestCase extends AbstractMuleContextTestCase
21  {
22  
23      @Test
24      public void testEndpoint() throws Exception
25      {
26          String url = "axis:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
27          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
28          endpointUri.initialise();
29  
30          assertEquals("axis", endpointUri.getSchemeMetaInfo());
31          // it's up to the client to actually strip off the method name if
32          // necessary
33          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
34                  endpointUri.getAddress());
35          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
36          assertEquals(3, endpointUri.getParams().size());
37  
38          url = "axis:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
39          endpointUri = new MuleEndpointURI(url, muleContext);
40          endpointUri.initialise();
41  
42          assertEquals("axis", endpointUri.getSchemeMetaInfo());
43          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
44                  endpointUri.getAddress());
45          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
46          assertEquals(3, endpointUri.getParams().size());
47      }
48  
49      @Test
50      public void testEndpointWithUserInfo() throws Exception
51      {
52          String url = "axis:http://admin:pwd@www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
53          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
54          endpointUri.initialise();
55  
56          assertEquals("axis", endpointUri.getSchemeMetaInfo());
57          // it's up to the client to actually strip off the method name if
58          // necessary
59          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
60                  endpointUri.getAddress());
61          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
62          assertEquals(3, endpointUri.getParams().size());
63          assertEquals("admin:pwd", endpointUri.getUserInfo());
64          assertEquals("admin", endpointUri.getUser());
65          assertEquals("pwd", endpointUri.getPassword());
66          assertEquals("http://admin:****@www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
67                  endpointUri.toString());
68      }
69  
70      @Test
71      public void testEndpointFinder() throws Exception
72      {
73          String url = "soap:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
74          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
75          endpointUri.initialise();
76  
77          assertEquals("soap", endpointUri.getSchemeMetaInfo());
78          // it's up to the client to actually strip off the method name if
79          // necessary
80          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
81                  endpointUri.getAddress());
82          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
83          assertEquals(3, endpointUri.getParams().size());
84  
85          TransportServiceDescriptor sd = (TransportServiceDescriptor)
86                  muleContext.getRegistry().lookupServiceDescriptor(ServiceType.TRANSPORT, "soap", null);
87          if (sd != null)
88          {
89              //TODO TC: How do we assert this state in the new model?
90              //assertEquals("axis", sd.getProtocol());
91              //assertEquals("org.mule.transport.soap.axis.AxisConnector", sd.getConnector());
92          }
93      }
94  }