View Javadoc

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