View Javadoc

1   /*
2    * $Id: InOnlyTestCase.java 22422 2011-07-15 08:22:16Z dirk.olmes $
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.messaging.meps;
12  
13  import org.mule.api.client.MuleClient;
14  import org.mule.api.context.notification.ServerNotification;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  import org.mule.tck.functional.FunctionalTestNotificationListener;
17  import org.mule.util.concurrent.Latch;
18  
19  import java.util.Arrays;
20  import java.util.Collection;
21  import java.util.concurrent.TimeUnit;
22  
23  import org.junit.Test;
24  import org.junit.runners.Parameterized.Parameters;
25  
26  import static org.junit.Assert.assertTrue;
27  
28  // START SNIPPET: full-class
29  public class InOnlyTestCase extends AbstractServiceAndFlowTestCase
30  {
31      public static final long TIMEOUT = 3000;
32  
33      @Parameters
34      public static Collection<Object[]> parameters()
35      {
36          return Arrays.asList(new Object[][]{
37              {ConfigVariant.SERVICE, "org/mule/test/integration/messaging/meps/pattern_In-Only-service.xml"},
38              {ConfigVariant.FLOW, "org/mule/test/integration/messaging/meps/pattern_In-Only-flow.xml"}});
39      }
40  
41      public InOnlyTestCase(ConfigVariant variant, String configResources)
42      {
43          super(variant, configResources);
44      }
45  
46      @Test
47      public void testExchange() throws Exception
48      {
49          MuleClient client = muleContext.getClient();
50  
51          final Latch latch = new Latch();
52          muleContext.registerListener(new FunctionalTestNotificationListener()
53          {
54              @Override
55              public void onNotification(ServerNotification notification)
56              {
57                  latch.countDown();
58              }
59          });
60  
61          client.dispatch("inboundEndpoint", "some data", null);
62          assertTrue(latch.await(TIMEOUT, TimeUnit.MILLISECONDS));
63      }
64  }