View Javadoc

1   /*
2    * $Id: AxisEndpointTestCase.java 22387 2011-07-12 03:53:36Z 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  
11  package org.mule.transport.soap.axis;
12  
13  import org.mule.api.config.MuleProperties;
14  import org.mule.api.endpoint.EndpointURI;
15  import org.mule.api.registry.ServiceType;
16  import org.mule.endpoint.MuleEndpointURI;
17  import org.mule.tck.junit4.AbstractMuleContextTestCase;
18  import org.mule.transport.service.TransportServiceDescriptor;
19  
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertEquals;
23  
24  public class AxisEndpointTestCase extends AbstractMuleContextTestCase
25  {
26  
27      @Test
28      public void testEndpoint() throws Exception
29      {
30          String url = "axis:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
31          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
32          endpointUri.initialise();
33  
34          assertEquals("axis", endpointUri.getSchemeMetaInfo());
35          // it's up to the client to actually strip off the method name if
36          // necessary
37          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
38                  endpointUri.getAddress());
39          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
40          assertEquals(3, endpointUri.getParams().size());
41  
42          url = "axis:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
43          endpointUri = new MuleEndpointURI(url, muleContext);
44          endpointUri.initialise();
45  
46          assertEquals("axis", endpointUri.getSchemeMetaInfo());
47          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
48                  endpointUri.getAddress());
49          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
50          assertEquals(3, endpointUri.getParams().size());
51      }
52  
53      @Test
54      public void testEndpointWithUserInfo() throws Exception
55      {
56          String url = "axis:http://admin:pwd@www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
57          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
58          endpointUri.initialise();
59  
60          assertEquals("axis", endpointUri.getSchemeMetaInfo());
61          // it's up to the client to actually strip off the method name if
62          // necessary
63          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
64                  endpointUri.getAddress());
65          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
66          assertEquals(3, endpointUri.getParams().size());
67          assertEquals("admin:pwd", endpointUri.getUserInfo());
68          assertEquals("admin", endpointUri.getUser());
69          assertEquals("pwd", endpointUri.getPassword());
70          assertEquals("http://admin:****@www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
71                  endpointUri.toString());
72      }
73  
74      @Test
75      public void testEndpointFinder() throws Exception
76      {
77          String url = "soap:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
78          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
79          endpointUri.initialise();
80  
81          assertEquals("soap", endpointUri.getSchemeMetaInfo());
82          // it's up to the client to actually strip off the method name if
83          // necessary
84          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
85                  endpointUri.getAddress());
86          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
87          assertEquals(3, endpointUri.getParams().size());
88  
89          TransportServiceDescriptor sd = (TransportServiceDescriptor)
90                  muleContext.getRegistry().lookupServiceDescriptor(ServiceType.TRANSPORT, "soap", null);
91          if (sd != null)
92          {
93              //TODO TC: How do we assert this state in the new model?
94              //assertEquals("axis", sd.getProtocol());
95              //assertEquals("org.mule.transport.soap.axis.AxisConnector", sd.getConnector());
96          }
97      }
98  }