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.OrphanBean;
10  
11  import org.junit.Test;
12  
13  /**
14   * This constructs a <em>temporary</em> bean whose contents are injected into a parent map by
15   * {@link org.mule.config.spring.parsers.assembly.DefaultBeanAssembler}.  Since this occurs
16   * <em>before</em> child elements are processed this will <em>cannot</em> handle nested elements.
17   */
18  public class MapEntryCombinerTestCase extends AbstractNamespaceTestCase
19  {
20  
21      @Override
22      protected String getConfigResources()
23      {
24          return "org/mule/config/spring/parsers/map-entry-combiner-test.xml";
25      }
26  
27      @Test
28      public void testProperties()
29      {
30          OrphanBean bean = (OrphanBean) assertBeanExists("checkProps", OrphanBean.class);
31          logger.info("Map size: " + bean.getMap().size());
32          assertMapEntryExists(bean.getMap(), "0", 0);
33      }
34  
35      @Test
36      public void testCombinedMap()
37      {
38          OrphanBean bean = (OrphanBean) assertBeanExists("orphan", OrphanBean.class);
39          logger.info("Map size: " + bean.getMap().size());
40          for (int i = 0; i < 6; ++i)
41          {
42              assertMapEntryExists(bean.getMap(), Integer.toString(i+1), i+1);
43          }
44      }
45  
46      @Test
47      public void testReversedOrder()
48      {
49          OrphanBean bean = (OrphanBean) assertBeanExists("orphan2", OrphanBean.class);
50          logger.info("Map size: " + bean.getMap().size());
51          for (int i = 0; i < 2; ++i)
52          {
53              assertMapEntryExists(bean.getMap(), Integer.toString(i+1), i+1);
54          }
55  
56      }
57  
58  }