View Javadoc

1   /*
2    * $Id: ArrayEntryPointResolverTestCase.java 22377 2011-07-11 12:41:42Z 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.mule.model;
12  
13  import org.mule.api.model.InvocationResult;
14  import org.mule.model.resolvers.AbstractArgumentEntryPointResolver;
15  import org.mule.model.resolvers.ArrayEntryPointResolver;
16  import org.mule.tck.junit4.AbstractMuleContextTestCase;
17  import org.mule.tck.testmodels.fruit.Apple;
18  import org.mule.tck.testmodels.fruit.Fruit;
19  import org.mule.tck.testmodels.fruit.FruitBowl;
20  import org.mule.tck.testmodels.fruit.Orange;
21  
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertEquals;
25  
26  public class ArrayEntryPointResolverTestCase extends AbstractMuleContextTestCase
27  {
28  
29      @Test
30      public void testArrayMatch() throws Exception
31      {
32          AbstractArgumentEntryPointResolver resolver = new ArrayEntryPointResolver();
33          InvocationResult ctx = resolver.invoke(new FruitBowl(), getTestEventContext(new Fruit[]{new Apple(), new Orange()}));
34          assertEquals(ctx.getState(), InvocationResult.State.SUCCESSFUL);
35  
36      }
37  
38      @Test
39      public void testArrayMatchGenericFail() throws Exception
40      {
41          AbstractArgumentEntryPointResolver resolver = new ArrayEntryPointResolver();
42          InvocationResult ctx = resolver.invoke(new FruitBowl(), getTestEventContext(new Object[]{new Apple(), new Orange()}));
43          assertEquals(ctx.getState(), InvocationResult.State.FAILED);
44      }
45  
46  
47      @Test
48      public void testArrayMatchFail() throws Exception
49      {
50          AbstractArgumentEntryPointResolver resolver = new ArrayEntryPointResolver();
51          InvocationResult ctx = resolver.invoke(new Apple(), getTestEventContext(new Object[]{"blah"}));
52          assertEquals(ctx.getState(), InvocationResult.State.FAILED);
53      }
54  }