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.module.cxf.jaxws;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  import org.mule.tck.junit4.rule.DynamicPort;
13  
14  import java.util.HashMap;
15  import java.util.Map;
16  
17  import org.apache.hello_world_soap_http.GreeterImpl;
18  import org.junit.Rule;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.assertEquals;
22  
23  public class ClientTestCase extends FunctionalTestCase
24  {
25  
26      @Rule
27      public DynamicPort dynamicPort = new DynamicPort("port1");
28  
29      @Override
30      protected String getConfigResources()
31      {
32          return "jaxws-client-conf.xml";
33      }
34  
35      @Test
36      public void testGeneratedClientWithQuartz() throws Exception
37      {
38          GreeterImpl impl = getGreeter();
39  
40          Thread.sleep(5000);
41  
42          assertEquals(1, impl.getInvocationCount());
43      }
44  
45      @Test
46      public void testClientWithMuleClient() throws Exception
47      {
48          MuleClient client = new MuleClient(muleContext);
49          Map<String, Object> props = new HashMap<String, Object>();
50          props.put("operation", "greetMe");
51          MuleMessage result = client.send("clientEndpoint", "Dan", props);
52          assertEquals("Hello Dan", result.getPayload());
53  
54          GreeterImpl impl = getGreeter();
55  
56          Thread.sleep(5000);
57  
58          assertEquals(2, impl.getInvocationCount());
59      }
60  
61      private GreeterImpl getGreeter() throws Exception
62      {
63          Object instance = getComponent("greeterService");
64  
65          return (GreeterImpl) instance;
66      }
67  
68  }