View Javadoc

1   /*
2    * $Id: CxfOverJMSTestCase.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.test.integration.transport.cxf;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.transport.PropertyScope;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.AbstractServiceAndFlowTestCase;
18  
19  import java.util.Arrays;
20  import java.util.Collection;
21  
22  import org.junit.Ignore;
23  import org.junit.Test;
24  import org.junit.runners.Parameterized.Parameters;
25  
26  import static org.junit.Assert.assertNotNull;
27  import static org.junit.Assert.assertTrue;
28  
29  public class CxfOverJMSTestCase extends AbstractServiceAndFlowTestCase
30  {
31      private static final String req = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
32                                        + "<soap:Body>"
33                                        + "<ns2:echo xmlns:ns2=\"http://simple.component.mule.org/\">"
34                                        + "<ns2:echo>hello</ns2:echo>"
35                                        + "</ns2:echo>"
36                                        + "</soap:Body>"
37                                        + "</soap:Envelope>";
38  
39      @Parameters
40      public static Collection<Object[]> parameters()
41      {
42          return Arrays.asList(new Object[][]{
43              {ConfigVariant.SERVICE, "org/mule/test/integration/transport/cxf/cxf-over-jms-config-service.xml"},
44              {ConfigVariant.FLOW, "org/mule/test/integration/transport/cxf/cxf-over-jms-config-flow.xml"}
45          });
46      }
47  
48      public CxfOverJMSTestCase(ConfigVariant variant, String configResources)
49      {
50          super(variant, configResources);
51      }
52  
53      @Test
54      public void testCxf() throws Exception
55      {
56          MuleClient client = new MuleClient(muleContext);
57          client.dispatch("jms://TestComponent", new DefaultMuleMessage(req, muleContext));
58          MuleMessage message = client.request("jms://testout", 10000);
59          assertNotNull(message.getPayload());
60          assertTrue(message.getPayloadAsString().indexOf("return>hello") != -1);
61      }
62  
63      @Test
64      public void testCxfClientOverJMS() throws Exception
65      {
66          MuleClient client = new MuleClient(muleContext);
67          DefaultMuleMessage msg = new DefaultMuleMessage("hello", muleContext);
68          msg.setProperty("method", "echo", PropertyScope.INVOCATION);
69          client.dispatch("cxf:jms://TestComponent2", msg);
70          MuleMessage message = client.request("jms://testout", 10000);
71          assertNotNull("message reply is null", message);
72          assertNotNull("message payload is null", message.getPayload());
73          assertTrue(message.getPayloadAsString().equals("hello"));
74      }
75  
76      // MULE-4677
77      @Ignore
78      @Test
79      public void testCxfOverJMSSyncProxy() throws Exception
80      {
81          MuleClient client = new MuleClient(muleContext);
82          MuleMessage result = client.send("http://localhost:63081/services/testBridge",
83              new DefaultMuleMessage(req, muleContext));
84          assertNotNull(result.getPayload());
85          assertTrue(result.getPayloadAsString().contains("<ns2:echo>hello</ns2:echo>"));
86      }
87  }