View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.impl.config.builders;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.config.ConfigurationBuilder;
11  import org.mule.api.config.ConfigurationException;
12  import org.mule.api.context.MuleContextFactory;
13  import org.mule.api.exception.MessagingExceptionHandler;
14  import org.mule.api.lifecycle.InitialisationException;
15  import org.mule.config.builders.AutoConfigurationBuilder;
16  import org.mule.config.builders.SimpleConfigurationBuilder;
17  import org.mule.context.DefaultMuleContextFactory;
18  import org.mule.tck.junit4.AbstractMuleContextTestCase;
19  import org.mule.tck.testmodels.mule.TestExceptionStrategy;
20  
21  import org.junit.Test;
22  
23  import static org.junit.Assert.assertNotNull;
24  import static org.junit.Assert.assertTrue;
25  
26  public class AutoConfigurationBuilderTestCase extends AbstractMuleContextTestCase
27  {
28  
29      protected MuleContext createMuleContext() throws Exception
30      {
31          MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
32          return muleContextFactory.createMuleContext(new SimpleConfigurationBuilder(null));
33      }
34  
35      @Test
36      public void testConfigureSpring() throws ConfigurationException, InitialisationException
37      {
38          ConfigurationBuilder configurationBuilder = new AutoConfigurationBuilder(
39              "org/mule/test/spring/config1/test-xml-mule2-config.xml");
40          configurationBuilder.configure(muleContext);
41  
42          // Just a few of the asserts from AbstractConfigBuilderTestCase
43          MessagingExceptionHandler es = muleContext.getRegistry().lookupModel("main").getExceptionListener();
44          assertNotNull(es);
45          assertTrue(es instanceof TestExceptionStrategy);
46      }
47  
48      // @Test
49      //public void testConfigureGroovy()
50      // {
51      // // TODO
52      // }
53      //
54      // @Test
55      //public void testConfigureGalaxySpring()
56      // {
57      // // TODO
58      // }
59      //
60      // @Test
61      //public void testConfigureUnkownExtension() throws ConfigurationException
62      // {
63      // ConfigurationBuilder configurationBuilder = new AutoConfigurationBuilder("my.dtd");
64      //
65      // try
66      // {
67      // configurationBuilder.configure(muleContext);
68      // }
69      // catch (ConfigurationException ce)
70      // {
71      // assertEquals(
72      // "No suitable configuration builder for resource \"my.dtd\" found. Check you have configuration module
73      // ion your classpath and are using correct file extension.",
74      // ce.getCause().getMessage());
75      // }
76      // catch (Exception e)
77      // {
78      //            fail("Exception unexpected:" + e);
79      //        }
80      //    }
81  }