View Javadoc

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