View Javadoc

1   /*
2    * $Id: JettySslTestCase.java 23222 2011-10-19 17:35:57Z evangelinamrm $
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.api.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  import org.mule.tck.junit4.rule.DynamicPort;
17  
18  import java.util.Arrays;
19  import java.util.Collection;
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  import org.apache.cxf.Bus;
24  import org.apache.cxf.BusFactory;
25  import org.apache.hello_world_soap_http.GreeterImpl;
26  import org.junit.AfterClass;
27  import org.junit.BeforeClass;
28  import org.junit.Rule;
29  import org.junit.Test;
30  import org.junit.runners.Parameterized;
31  
32  import static org.junit.Assert.assertEquals;
33  
34  public class JettySslTestCase extends AbstractServiceAndFlowTestCase
35  {
36      private static final Bus defaultBus = BusFactory.getDefaultBus();
37  
38      @Rule
39      public DynamicPort dynamicPort = new DynamicPort("port1");
40  
41      public JettySslTestCase(ConfigVariant variant, String configResources)
42      {
43          super(variant, configResources);
44      }
45  
46      @Parameterized.Parameters
47      public static Collection<Object[]> parameters()
48      {
49          return Arrays.asList(new Object[][] {
50                  {ConfigVariant.SERVICE, "jetty-ssl-conf-service.xml"},
51                  {ConfigVariant.FLOW, "jetty-ssl-conf-flow.xml"}
52          });
53      }
54  
55      @BeforeClass
56      public static void setUpDefaultBus()
57      {
58          BusFactory.setDefaultBus(null);
59      }
60  
61      @AfterClass
62      public static void restoreDefaultBus()
63      {
64          BusFactory.setDefaultBus(defaultBus);
65      }
66  
67      @Test
68      public void testClientWithMuleClient() throws Exception
69      {
70          MuleClient client = muleContext.getClient();
71          Map<String, Object> props = new HashMap<String, Object>();
72          props.put("operation", "greetMe");
73          MuleMessage result = client.send("clientEndpoint", "Dan", props);
74          assertEquals("Hello Dan", result.getPayload());
75  
76          GreeterImpl impl = getGreeter();
77          assertEquals(1, impl.getInvocationCount());
78      }
79  
80      private GreeterImpl getGreeter() throws Exception
81      {
82          return (GreeterImpl) getComponent("greeterService");
83      }
84  
85  
86  }