View Javadoc

1   /*
2    * $Id: AutoConfigurationBuilderTestCase.java 22387 2011-07-12 03:53:36Z 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.impl.config.builders;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.config.ConfigurationBuilder;
15  import org.mule.api.config.ConfigurationException;
16  import org.mule.api.context.MuleContextFactory;
17  import org.mule.api.exception.MessagingExceptionHandler;
18  import org.mule.api.lifecycle.InitialisationException;
19  import org.mule.config.builders.AutoConfigurationBuilder;
20  import org.mule.config.builders.SimpleConfigurationBuilder;
21  import org.mule.context.DefaultMuleContextFactory;
22  import org.mule.tck.junit4.AbstractMuleContextTestCase;
23  import org.mule.tck.testmodels.mule.TestExceptionStrategy;
24  
25  import org.junit.Test;
26  
27  import static org.junit.Assert.assertNotNull;
28  import static org.junit.Assert.assertTrue;
29  
30  public class AutoConfigurationBuilderTestCase extends AbstractMuleContextTestCase
31  {
32  
33      protected MuleContext createMuleContext() throws Exception
34      {
35          MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
36          return muleContextFactory.createMuleContext(new SimpleConfigurationBuilder(null));
37      }
38  
39      @Test
40      public void testConfigureSpring() throws ConfigurationException, InitialisationException
41      {
42          ConfigurationBuilder configurationBuilder = new AutoConfigurationBuilder(
43              "org/mule/test/spring/config1/test-xml-mule2-config.xml");
44          configurationBuilder.configure(muleContext);
45  
46          // Just a few of the asserts from AbstractConfigBuilderTestCase
47          MessagingExceptionHandler es = muleContext.getRegistry().lookupModel("main").getExceptionListener();
48          assertNotNull(es);
49          assertTrue(es instanceof TestExceptionStrategy);
50      }
51  
52      // @Test
53      //public void testConfigureGroovy()
54      // {
55      // // TODO
56      // }
57      //
58      // @Test
59      //public void testConfigureGalaxySpring()
60      // {
61      // // TODO
62      // }
63      //
64      // @Test
65      //public void testConfigureUnkownExtension() throws ConfigurationException
66      // {
67      // ConfigurationBuilder configurationBuilder = new AutoConfigurationBuilder("my.dtd");
68      //
69      // try
70      // {
71      // configurationBuilder.configure(muleContext);
72      // }
73      // catch (ConfigurationException ce)
74      // {
75      // assertEquals(
76      // "No suitable configuration builder for resource \"my.dtd\" found. Check you have configuration module
77      // ion your classpath and are using correct file extension.",
78      // ce.getCause().getMessage());
79      // }
80      // catch (Exception e)
81      // {
82      //            fail("Exception unexpected:" + e);
83      //        }
84      //    }
85  }