View Javadoc

1   /*
2    * $Id: ServiceUsingAxisEndpointTestCase.java 22450 2011-07-19 08:20:41Z 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.cxf;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.junit4.FunctionalTestCase;
17  import org.mule.tck.junit4.rule.DynamicPort;
18  
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.dom4j.Document;
24  import org.dom4j.DocumentHelper;
25  import org.dom4j.Element;
26  import org.junit.Rule;
27  import org.junit.Test;
28  
29  import static org.junit.Assert.assertEquals;
30  import static org.junit.Assert.assertNotNull;
31  
32  public class ServiceUsingAxisEndpointTestCase extends FunctionalTestCase
33  {
34  
35      @Rule
36      public DynamicPort dynamicPort = new DynamicPort("port1");
37      
38      @Test
39      public void testCXF() throws Exception
40      {
41          MuleClient client = new MuleClient(muleContext);
42          MuleMessage reply = client.send("vm://cxf.in", new DefaultMuleMessage("Testing String", muleContext));
43  
44          assertNotNull(reply);
45          assertNotNull(reply.getPayload());
46          assertEquals("Received: Testing String", reply.getPayloadAsString());
47      }
48  
49      @Test
50      public void testRequestWsdl() throws Exception
51      {
52          MuleClient client = new MuleClient(muleContext);
53          Map<String, String> props = new HashMap<String, String>();
54          props.put("http.method", "GET");
55          MuleMessage reply = client.send("http://localhost:" + dynamicPort.getNumber() + "/services/CxfService?wsdl",
56              "/services/CxfService?wsdl", props);
57  
58          assertNotNull(reply);
59          assertNotNull(reply.getPayload());
60  
61          Document document = DocumentHelper.parseText(reply.getPayloadAsString());
62          
63          List<?> nodes = document.selectNodes("//wsdl:definitions/wsdl:service");
64          assertEquals("CxfService", ((Element) nodes.get(0)).attribute("name").getStringValue());
65      }
66  
67      @Override
68      protected String getConfigResources()
69      {
70          return "using-axis-conf.xml";
71      }
72  
73  }