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.transport.soap.axis;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.module.client.MuleClient;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import java.util.HashMap;
15  import java.util.List;
16  import java.util.Map;
17  
18  import org.dom4j.Document;
19  import org.dom4j.DocumentHelper;
20  import org.dom4j.Element;
21  import org.junit.Test;
22  
23  import static org.junit.Assert.assertEquals;
24  import static org.junit.Assert.assertNotNull;
25  
26  public class AxisServiceUsingCxfEndpointTestCase extends FunctionalTestCase
27  {
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "axis-using-cxf-config.xml";
33      }
34  
35      @Test
36      public void testAxis() throws Exception
37      {
38          MuleClient client = new MuleClient(muleContext);
39          MuleMessage reply = client.send("vm://axis.in", new DefaultMuleMessage("Test String", muleContext));
40  
41          assertNotNull(reply);
42          assertNotNull(reply.getPayload());
43          assertEquals(reply.getPayloadAsString(), "Received: Test String");
44          logger.info(reply.getPayloadAsString());
45      }
46  
47      @Test
48      public void testRequestWsdl() throws Exception
49      {
50          MuleClient client = new MuleClient(muleContext);
51          Map props = new HashMap();
52          props.put("http.method", "GET");
53          MuleMessage reply = client.send("http://localhost:63381/services/AxisService?WSDL", "", props);
54  
55          assertNotNull(reply);
56          assertNotNull(reply.getPayload());
57  
58          Document document = DocumentHelper.parseText(reply.getPayloadAsString());
59          List nodes;
60  
61          nodes = document.selectNodes("//wsdl:definitions/wsdl:service");
62          assertEquals(((Element)nodes.get(0)).attribute("name").getStringValue(), "AxisService");
63      }
64  
65  }