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.module.cxf;
8   
9   import org.mule.api.config.MuleProperties;
10  import org.mule.api.endpoint.EndpointURI;
11  import org.mule.endpoint.MuleEndpointURI;
12  import org.mule.tck.junit4.AbstractMuleContextTestCase;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  
18  public class CxfSoapEndpointTestCase extends AbstractMuleContextTestCase
19  {
20  
21      @Test
22      public void testEndpoint() throws Exception
23      {
24          String url = "cxf:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
25          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
26          endpointUri.initialise();
27  
28          assertEquals("cxf", endpointUri.getSchemeMetaInfo());
29          // it's up to the client to actually strip off the method name if necessary
30          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
31              endpointUri.getAddress());
32          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
33          assertEquals(3, endpointUri.getParams().size());
34  
35          url = "cxf:http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
36          endpointUri = new MuleEndpointURI(url, muleContext);
37          endpointUri.initialise();
38  
39          assertEquals("cxf", endpointUri.getSchemeMetaInfo());
40          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
41              endpointUri.getAddress());
42          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
43          assertEquals(3, endpointUri.getParams().size());
44      }
45  
46      @Test
47      public void testEndpointWithUserInfo() throws Exception
48      {
49          String url = "cxf:http://admin:pwd@www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2";
50          EndpointURI endpointUri = new MuleEndpointURI(url, muleContext);
51          endpointUri.initialise();
52  
53          assertEquals("cxf", endpointUri.getSchemeMetaInfo());
54          // it's up to the client to actually strip off the method name if necessary
55          assertEquals("http://www.xmethods.net/wsdl/query.wsdl?method=getSomething&param1=1&param2=2",
56              endpointUri.getAddress());
57          assertEquals("getSomething", endpointUri.getParams().getProperty(MuleProperties.MULE_METHOD_PROPERTY));
58          assertEquals(3, endpointUri.getParams().size());
59          assertEquals("admin:pwd", endpointUri.getUserInfo());
60          assertEquals("admin", endpointUri.getUser());
61          assertEquals("pwd", endpointUri.getPassword());
62      }
63  
64  }