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.transformers;
8   
9   import org.mule.tck.junit4.FunctionalTestCase;
10  import org.mule.tck.testmodels.fruit.FruitBasket;
11  import org.mule.tck.testmodels.fruit.FruitBowl;
12  import org.mule.tck.testmodels.fruit.Apple;
13  import org.mule.tck.testmodels.fruit.Banana;
14  import org.mule.module.client. MuleClient;
15  import org.mule.util.concurrent.Latch;
16  
17  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
18  import org.junit.Test;
19  
20  import static org.junit.Assert.assertTrue;
21  
22  public class AutoTransformerTestCase extends FunctionalTestCase
23  {
24  
25      private static Latch latch;
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "org/mule/test/integration/transformer/auto-transformer-test.xml";
31      }
32  
33      @Test
34      public void testInboundAutoTransform() throws Exception
35      {
36          latch = new Latch();
37          MuleClient client = new MuleClient(muleContext);
38          client.dispatch("vm://in", new FruitBowl(new Apple(), new Banana()), null);
39  
40          assertTrue(latch.await(3000, TimeUnit.MILLISECONDS));
41      }
42  
43      public static class FruitBasketComponent
44      {
45          public void process(FruitBasket fb)
46          {
47              assertTrue(fb.hasApple());
48              assertTrue(fb.hasBanana());
49              latch.countDown();
50          }
51      }
52  }