View Javadoc

1   /*
2    * $Id: AxisEndpointTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.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, muleContext);
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, muleContext);
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, muleContext);
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          assertEquals("http://admin:****@www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
65                  endpointUri.toString());
66      }
67  
68      public void testEndpointFinder() throws Exception
69      {
70          String url = "soap:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
71          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
72          endpointUri.initialise();
73  
74          assertEquals("soap", endpointUri.getSchemeMetaInfo());
75          // it's up to the client to actually strip off the method name if
76          // necessary
77          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
78                  endpointUri.getAddress());
79          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
80          assertEquals(3, endpointUri.getParams().size());
81  
82          TransportServiceDescriptor sd = (TransportServiceDescriptor)
83                  muleContext.getRegistry().lookupServiceDescriptor(ServiceType.TRANSPORT, "soap", null);
84          if (sd != null)
85          {
86              //TODO TC: How do we assert this state in the new model?
87              //assertEquals("axis", sd.getProtocol());
88              //assertEquals("org.mule.transport.soap.axis.AxisConnector", sd.getConnector());
89          }
90      }
91  }