1   /*
2    * $Id: HttpsFunctionalTestCase.java 12017 2008-06-12 09:04:04Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.transport.servlet.jetty;
12  
13  import org.mule.api.MuleEventContext;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.functional.EventCallback;
17  import org.mule.tck.functional.FunctionalTestComponent;
18  import org.mule.tck.testmodels.mule.TestSedaService;
19  import org.mule.transport.http.HttpConstants;
20  import org.mule.transport.http.HttpsConnector;
21  import org.mule.transport.http.functional.HttpFunctionalTestCase;
22  
23  import java.util.HashMap;
24  import java.util.Map;
25  
26  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
27  
28  public class JettyHttpsFunctionalTestCase extends HttpFunctionalTestCase
29  {
30      protected String getConfigResources()
31      {
32          return "jetty-https-functional-test.xml";
33      }
34  
35      public void testSend() throws Exception
36      {
37          final TestSedaService testSedaService = (TestSedaService) muleContext.getRegistry().lookupService("testComponent");
38          FunctionalTestComponent testComponent = (FunctionalTestComponent) getComponent(testSedaService);
39          assertNotNull(testComponent);
40  
41          final AtomicBoolean callbackMade = new AtomicBoolean(false);
42          EventCallback callback = new EventCallback()
43          {
44              public void eventReceived(final MuleEventContext context, final Object component) throws Exception
45              {
46                  MuleMessage msg = context.getMessage();
47                  assertTrue(callbackMade.compareAndSet(false, true));
48  //                assertNotNull(msg.getProperty(HttpsConnector.LOCAL_CERTIFICATES));
49              }
50          };
51  
52          testComponent.setEventCallback(callback);
53  
54          MuleClient client = new MuleClient();
55          Map props = new HashMap();
56          props.put(HttpConstants.HEADER_CONTENT_TYPE, "text/plain;charset=UTF-8");
57          MuleMessage result = client.send("clientEndpoint", TEST_MESSAGE, props);
58          assertNotNull(result);
59          assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
60          assertTrue("Callback never fired", callbackMade.get());
61  
62      }
63  
64  }