View Javadoc

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