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.config.spring.parsers;
8   
9   import org.mule.config.spring.parsers.beans.AbstractBean;
10  import org.mule.config.spring.parsers.beans.ChildBean;
11  import org.mule.config.spring.parsers.beans.OrphanBean;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertEquals;
16  import static org.junit.Assert.assertNotNull;
17  
18  public class AliasTestCase extends AbstractNamespaceTestCase
19  {
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "org/mule/config/spring/parsers/alias-test.xml";
25      }
26  
27      protected void assertFooExists(int index)
28      {
29          OrphanBean orphan = (OrphanBean) assertBeanExists("orphan" + index, OrphanBean.class);
30          assertFooExists(orphan, 10 * index + 1);
31          ChildBean child = (ChildBean) assertContentExists(orphan.getChild(), ChildBean.class);
32          assertFooExists(child, 10 * index + 2);
33      }
34  
35      protected void assertFooExists(AbstractBean bean, int value)
36      {
37          assertNotNull(bean);
38          assertEquals(value, bean.getFoo());
39      }
40  
41      @Test
42      public void testNamed()
43      {
44          assertFooExists(1);
45      }
46  
47      @Test
48      public void testOrphan()
49      {
50          assertFooExists(2);
51      }
52  
53      @Test
54      public void testParent()
55      {
56          assertFooExists(3);
57      }
58  
59  }