View Javadoc

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