View Javadoc

1   /*
2    * $Id: JettyTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
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.module.cxf.jaxws;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  import org.apache.cxf.BusFactory;
21  import org.apache.hello_world_soap_http.GreeterImpl;
22  
23  public class JettyTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected void suitePreSetUp() throws Exception
28      {
29          BusFactory.setDefaultBus(null);
30          super.suitePreSetUp();
31      }
32  
33      private GreeterImpl getGreeter() throws Exception
34      {
35          Object instance = getComponent("greeterService");
36          
37          return (GreeterImpl) instance;
38      }
39  
40      public void testClientWithMuleClient() throws Exception
41      {
42          MuleClient client = new MuleClient(muleContext);
43          Map<String, Object> props = new HashMap<String, Object>();
44          props.put("operation", "greetMe");
45          MuleMessage result = client.send("clientEndpoint", "Dan", props);
46          assertEquals("Hello Dan", result.getPayload());
47          
48          GreeterImpl impl = getGreeter();
49          
50          Thread.sleep(3000);
51          
52          assertEquals(1, impl.getInvocationCount());
53      }
54      
55      protected String getConfigResources()
56      {
57          return "jetty-conf.xml";
58      }
59  
60  }