1   /*
2    * $Id: AutoConfigurationBuilderTestCase.java 10590 2008-01-29 01:39:47Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.lifecycle.InitialisationException;
18  import org.mule.config.builders.AutoConfigurationBuilder;
19  import org.mule.config.builders.SimpleConfigurationBuilder;
20  import org.mule.context.DefaultMuleContextFactory;
21  import org.mule.tck.AbstractMuleTestCase;
22  import org.mule.tck.testmodels.mule.TestConnector;
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          TestConnector c = (TestConnector) muleContext.getRegistry().lookupConnector("dummyConnector");
42          assertNotNull(c);
43          assertNotNull(c.getExceptionListener());
44          assertTrue(c.getExceptionListener() instanceof TestExceptionStrategy);
45      }
46  
47      // public void testConfigureGroovy()
48      // {
49      // // TODO
50      // }
51      //
52      // public void testConfigureGalaxySpring()
53      // {
54      // // TODO
55      // }
56      //
57      // public void testConfigureUnkownExtension() throws ConfigurationException
58      // {
59      // ConfigurationBuilder configurationBuilder = new AutoConfigurationBuilder("my.dtd");
60      //
61      // try
62      // {
63      // configurationBuilder.configure(muleContext);
64      // }
65      // catch (ConfigurationException ce)
66      // {
67      // assertEquals(
68      // "No suitable configuration builder for resource \"my.dtd\" found. Check you have configuration module
69      // ion your classpath and are using correct file extension.",
70      // ce.getCause().getMessage());
71      // }
72      // catch (Exception e)
73      // {
74      //            fail("Exception unexpected:" + e);
75      //        }
76      //    }
77  }