View Javadoc

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