View Javadoc

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