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.test.integration.transport.cxf;
8   
9   import org.mule.DefaultMuleMessage;
10  import org.mule.api.MuleMessage;
11  import org.mule.api.transport.PropertyScope;
12  import org.mule.module.client.MuleClient;
13  import org.mule.tck.junit4.FunctionalTestCase;
14  
15  import org.junit.Test;
16  
17  import static org.junit.Assert.assertNotNull;
18  import static org.junit.Assert.assertTrue;
19  
20  public class CxfOverJMSTestCase extends FunctionalTestCase
21  {
22      
23      private static final String req = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
24                                        + "<soap:Body>"
25                                        + "<ns2:echo xmlns:ns2=\"http://simple.component.mule.org/\">"
26                                        + "<ns2:echo>hello</ns2:echo>"
27                                        + "</ns2:echo>"
28                                        + "</soap:Body>"
29                                        + "</soap:Envelope>";
30  
31      @Override
32      protected String getConfigResources()
33      {
34          return "org/mule/test/integration/transport/cxf/cxf-over-jms-config.xml";
35      }
36  
37      @Test
38      public void testCxf() throws Exception
39      {
40          MuleClient client = new MuleClient(muleContext);
41          client.dispatch("jms://TestComponent", new DefaultMuleMessage(req, muleContext));
42          MuleMessage message = client.request("jms://testout", 10000);
43          assertNotNull(message.getPayload());
44          assertTrue(message.getPayloadAsString().indexOf("return>hello") != -1);
45      }
46  
47      @Test
48      public void testCxfClientOverJMS() throws Exception
49      {
50          MuleClient client = new MuleClient(muleContext);
51          DefaultMuleMessage msg = new DefaultMuleMessage("hello", muleContext);
52          msg.setProperty("method", "echo", PropertyScope.INVOCATION);
53          client.dispatch("cxf:jms://TestComponent2", msg);
54          MuleMessage message = client.request("jms://testout", 10000);
55          assertNotNull("message reply is null", message);
56          assertNotNull("message payload is null", message.getPayload());
57          assertTrue(message.getPayloadAsString().equals("hello"));
58      }
59  
60      // MULE-4677
61      public void XXtestCxfOverJMSSyncProxy() throws Exception
62      {
63          MuleClient client = new MuleClient(muleContext);
64          MuleMessage result = client.send("http://localhost:63081/services/testBridge",
65              new DefaultMuleMessage(req, muleContext));
66          assertNotNull(result.getPayload());
67          assertTrue(result.getPayloadAsString().contains("<ns2:echo>hello</ns2:echo>"));
68      }
69  }