View Javadoc

1   /*
2    * $Id: AutoTransformerTestCase.java 22431 2011-07-18 07:40:35Z 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.transformers;
12  
13  import org.mule.module.client.MuleClient;
14  import org.mule.tck.AbstractServiceAndFlowTestCase;
15  import org.mule.tck.testmodels.fruit.Apple;
16  import org.mule.tck.testmodels.fruit.Banana;
17  import org.mule.tck.testmodels.fruit.FruitBasket;
18  import org.mule.tck.testmodels.fruit.FruitBowl;
19  import org.mule.util.concurrent.Latch;
20  
21  import java.util.Arrays;
22  import java.util.Collection;
23  import java.util.concurrent.TimeUnit;
24  
25  import org.junit.Test;
26  import org.junit.runners.Parameterized.Parameters;
27  
28  import static org.junit.Assert.assertTrue;
29  
30  public class AutoTransformerTestCase extends AbstractServiceAndFlowTestCase
31  {
32      private static Latch latch;
33  
34      @Parameters
35      public static Collection<Object[]> parameters()
36      {
37          return Arrays.asList(new Object[][]{
38              {ConfigVariant.SERVICE, "org/mule/test/integration/transformer/auto-transformer-test-service.xml"},
39              {ConfigVariant.FLOW, "org/mule/test/integration/transformer/auto-transformer-test-flow.xml"}
40          });
41      }
42  
43      public AutoTransformerTestCase(ConfigVariant variant, String configResources)
44      {
45          super(variant, configResources);
46      }
47  
48      @Test
49      public void testInboundAutoTransform() throws Exception
50      {
51          latch = new Latch();
52          MuleClient client = new MuleClient(muleContext);
53          client.dispatch("vm://in", new FruitBowl(new Apple(), new Banana()), null);
54  
55          assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
56      }
57  
58      public static class FruitBasketComponent
59      {
60          public void process(FruitBasket fb)
61          {
62              assertTrue(fb.hasApple());
63              assertTrue(fb.hasBanana());
64              latch.countDown();
65          }
66      }
67  }