View Javadoc

1   /*
2    * $Id: HttpPollingWithTransformersFunctionalTestCase.java 19817 2010-10-04 18:10:39Z dzapata $
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.transport.http.functional;
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.functional.FunctionalTestNotificationListener;
18  import org.mule.util.concurrent.Latch;
19  
20  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
21  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
22  
23  public class HttpPollingWithTransformersFunctionalTestCase extends DynamicPortTestCase
24  {
25      protected String getConfigResources()
26      {
27          return "mule-http-polling-with-transformers-config.xml";
28      }
29  
30      public void testPollingHttpConnector() throws Exception
31      {
32          final Latch latch = new Latch();
33          final AtomicBoolean transformPropagated = new AtomicBoolean(false);
34          muleContext.registerListener(new FunctionalTestNotificationListener()
35          {
36              public void onNotification(ServerNotification notification)
37              {
38                  latch.countDown();
39                  if(notification.getSource().toString().endsWith("toClient-only"))
40                  {
41                      transformPropagated.set(true);
42                  }
43              }
44          }, "polledUMO");
45  
46          MuleClient client = new MuleClient(muleContext);
47          MuleMessage result = client.request("vm://toclient", 50000);
48          assertNotNull(result.getPayload());
49          assertTrue("Callback called", latch.await(1000, TimeUnit.MILLISECONDS));
50          assertEquals("/foo toClient-only", result.getPayloadAsString());
51          //The transform should not have been propagated to the outbound endpoint
52          assertFalse(transformPropagated.get());
53      }
54  
55      @Override
56      protected int getNumPortsToFind()
57      {
58          return 1;
59      }
60  
61  }