View Javadoc

1   /*
2    * $Id: WireTapCxfTestCase.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.test.integration.routing;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.api.context.notification.ServerNotification;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.tck.functional.FunctionalTestNotificationListener;
18  import org.mule.util.concurrent.Latch;
19  
20  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
21  
22  public class WireTapCxfTestCase extends FunctionalTestCase
23  {
24      static final Latch tapLatch = new Latch();
25      
26      @Override
27      protected void doSetUp() throws Exception
28      {
29          super.doSetUp();
30  
31          muleContext.registerListener(new FunctionalTestNotificationListener()
32          {
33              public void onNotification(ServerNotification notification)
34              {
35                  tapLatch.release();
36              }
37          });
38      }
39  
40      @Override
41      protected String getConfigResources()
42      {
43          return "org/mule/test/integration/routing/wire-tap-cxf.xml";
44      }
45  
46      public void testWireTap() throws Exception
47      {
48          String url = "http://localhost:65082/services/EchoUMO";
49          String msg = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
50              + "<soap:Body><echo><text>foo</text></echo></soap:Body></soap:Envelope>";
51  
52          MuleClient client = new MuleClient(muleContext);
53          MuleMessage response = client.send(url, msg, null);
54          assertNotNull(response);
55          
56          String responseString = response.getPayloadAsString();
57          assertTrue(responseString.contains("echoResponse"));
58          assertFalse(responseString.contains("soap:Fault"));
59                  
60          assertTrue(tapLatch.await(RECEIVE_TIMEOUT, TimeUnit.MILLISECONDS));
61      }
62  }