View Javadoc

1   /*
2    * $Id: IBeansHolderConfigBuilderTestCase.java 19800 2010-09-30 21:31:55Z rossmason $
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  package org.mule.module.ibeans.annotations;
11  
12  import org.mule.module.ibeans.config.IBeanHolder;
13  import org.mule.module.ibeans.config.IBeansLoader;
14  
15  import java.util.Collection;
16  import java.util.Iterator;
17  import java.util.Set;
18  import java.util.TreeSet;
19  
20  import org.junit.Test;
21  
22  public class IBeansHolderConfigBuilderTestCase extends AbstractIBeansTestCase
23  {
24      @Override
25      protected void doTearDown() throws Exception
26      {
27          System.getProperties().remove(IBeansLoader.SCAN_PACKAGES_PROPERTY);
28      }
29  
30      @Test
31      public void testConfigBuilder() throws Exception
32      {
33          Collection<IBeanHolder> col = muleContext.getRegistry().lookupObjects(IBeanHolder.class);
34          //Ensure IBeanHolder is comparable
35          Set<IBeanHolder> beans = new TreeSet<IBeanHolder>(col);
36  
37          int exprectedSize = 11;
38          assertEquals(exprectedSize, beans.size());
39          String[] ids = new String[exprectedSize];
40          int i = 0;
41          for (Iterator<IBeanHolder> iterator = beans.iterator(); iterator.hasNext(); i++)
42          {
43              IBeanHolder iBeanHolder = iterator.next();
44              ids[i] = iBeanHolder.getId();
45          }
46  
47          assertEquals("errorfilter", ids[0]);
48          //these are loaded from  a jar on the classpath, part test for MULE-5108
49          assertEquals("flickr", ids[1]);
50          assertEquals("flickrauthentication", ids[2]);
51          assertEquals("flickrsearch", ids[3]);
52          assertEquals("flickrupload", ids[4]);
53          assertEquals("hostip", ids[5]);
54          assertEquals("search", ids[6]);
55          assertEquals("testexception", ids[7]);
56          assertEquals("testimplicitpropertiesinfactory", ids[8]);
57          assertEquals("testparamsfactory", ids[9]);
58          assertEquals("testuri", ids[10]);
59      }
60  }