View Javadoc

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