View Javadoc

1   /*
2    * $Id: ReferenceCollectionTestCase.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 java.util.Collection;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertEquals;
20  
21  /**
22   * References to collections in attributes are currently not handled correctly
23   */
24  public class ReferenceCollectionTestCase extends AbstractNamespaceTestCase
25  {
26  
27      @Override
28      protected String getConfigResources()
29      {
30          return "org/mule/config/spring/parsers/reference-collection-test.xml";
31      }
32  
33      protected void testOffspringRef(int index, int size)
34      {
35          OrphanBean orphan = (OrphanBean) assertBeanExists("orphan" + index, OrphanBean.class);
36          Collection offspring = (Collection) assertContentExists(orphan.getOffspring(), Collection.class);
37          assertEquals(size, offspring.size());
38      }
39  
40      @Test
41      public void testNamed()
42      {
43          testOffspringRef(1, 2);
44      }
45  
46      @Test
47      public void testOrphan()
48      {
49          testOffspringRef(2, 1);
50      }
51  
52      @Test
53      public void testParent()
54      {
55          testOffspringRef(3, 3);
56      }
57  
58  }