View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.integration.messaging.meps;
8   
9   import org.mule.api.context.notification.ServerNotification;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.functional.FunctionalTestNotificationListener;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  import org.mule.util.concurrent.Latch;
14  
15  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
16  import org.junit.Test;
17  
18  import static org.junit.Assert.assertTrue;
19  
20  // START SNIPPET: full-class
21  public class InOnlyTestCase extends FunctionalTestCase
22  {
23  
24      public static final long TIMEOUT = 3000;
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/test/integration/messaging/meps/pattern_In-Only.xml";
30      }
31  
32      @Test
33      public void testExchange() throws Exception
34      {
35          MuleClient client = new MuleClient(muleContext);
36  
37          final Latch latch = new Latch();
38          client.getMuleContext().registerListener(new FunctionalTestNotificationListener()
39          {
40              public void onNotification(ServerNotification notification)
41              {
42                  latch.countDown();
43              }
44          });
45  
46          client.dispatch("inboundEndpoint", "some data", null);
47          assertTrue(latch.await(TIMEOUT, TimeUnit.MILLISECONDS));
48      }
49  }