View Javadoc

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