View Javadoc

1   /*
2    * $Id: MapMule2478TestCase.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.ChildBean;
14  import org.mule.config.spring.parsers.beans.OrphanBean;
15  
16  import java.util.List;
17  import java.util.Map;
18  
19  public class MapMule2478TestCase extends AbstractNamespaceTestCase
20  {
21  
22      protected String getConfigResources()
23      {
24          return "org/mule/config/spring/parsers/map-mule-2478-test.xml";
25      }
26  
27      public void testDirectChild()
28      {
29          OrphanBean orphan = (OrphanBean) assertBeanExists("orphan", OrphanBean.class);
30          ChildBean child1 = (ChildBean) assertContentExists(orphan.getChild(), ChildBean.class);
31          assertEquals("string1", child1.getString());
32          assertNotNull(child1.getList());
33          assertEquals("list1", child1.getList().get(0));
34      }
35  
36      public void testMappedChild()
37      {
38          OrphanBean orphan = (OrphanBean) assertBeanExists("orphan", OrphanBean.class);
39          Map map = orphan.getMap();
40          assertNotNull(map);
41          assertTrue(map.containsKey("string"));
42          assertEquals("string2", map.get("string"));
43          assertTrue(map.containsKey("name"));
44          assertEquals("child2", map.get("name"));
45          assertTrue(map.containsKey("list"));
46          assertEquals("list2", ((List) map.get("list")).get(0));
47      }
48  
49  // TODO ComplexComponentDefinitionParser is not longer used, is there any way to rewrite/reuse the "factory" element for testing?
50  //    public void testFactory() throws Exception
51  //    {
52  //        OrphanBean orphan = (OrphanBean) assertBeanExists("orphan", OrphanBean.class);
53  //        ObjectFactory factory = (ObjectFactory) orphan.getObject();
54  //        assertNotNull(factory);
55  //        Object product = factory.getInstance();
56  //        assertNotNull(product);
57  //        assertTrue(product instanceof ChildBean);
58  //        ChildBean child3 = (ChildBean) product;
59  //        assertEquals("string3", child3.getString());
60  //        assertNotNull(child3.getList());
61  //        assertEquals("list3", child3.getList().get(0));
62  //    }
63  
64  }