View Javadoc

1   /*
2    * $Id: BeanCreationExceptionPropagationTestCase.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;
12  
13  import org.mule.api.MuleRuntimeException;
14  import org.mule.tck.junit4.FunctionalTestCase;
15  
16  import org.junit.Test;
17  import org.springframework.beans.FatalBeanException;
18  
19  import static org.junit.Assert.assertNotNull;
20  import static org.junit.Assert.assertTrue;
21  import static org.junit.Assert.fail;
22  
23  public class BeanCreationExceptionPropagationTestCase extends FunctionalTestCase
24  {
25  
26      @Override
27      protected String getConfigResources()
28      {
29          return "org/mule/config/spring/bean-creation-exception-propagation-config.xml";
30      }
31  
32      @Override
33      protected boolean isStartContext()
34      {
35          // need to start it ourselves and catch the exception
36          return false;
37      }
38  
39      @Test
40      public void testBeanCreationExceptionPropagation()
41      {
42          // lookup all objects
43          try
44          {
45              muleContext.getRegistry().lookupObjects(Object.class);
46              fail("Should've failed with an exception");
47          }
48          catch (MuleRuntimeException e)
49          {
50              Throwable t = e.getCause();
51              assertNotNull(t);
52              assertTrue(t instanceof FatalBeanException);
53          }
54      }
55  }