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