Coverage Report - org.mule.tck.FunctionalTestCase
 
Classes in this File Line Coverage Branch Coverage Complexity
FunctionalTestCase
0%
0/22
0%
0/2
1.556
 
 1  
 /*
 2  
  * $Id: FunctionalTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 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.tck;
 12  
 
 13  
 import org.mule.MuleManager;
 14  
 import org.mule.config.ConfigurationBuilder;
 15  
 import org.mule.util.ClassUtils;
 16  
 
 17  
 /**
 18  
  * Is a base tast case for tests that initialise Mule using a configuration file. The
 19  
  * default configuration builder used is the MuleXmlConfigurationBuilder. This you
 20  
  * need to have the mule-modules-builders module/jar on your classpath. If you want
 21  
  * to use a different builder, just overload the <code>getBuilder()</code> method
 22  
  * of this class to return the type of builder you want to use with your test. Note
 23  
  * you can overload the <code>getBuilder()</code> to return an initialised instance
 24  
  * of the QuickConfiguratonBuilder, this allows the developer to programmatically
 25  
  * build a Mule instance and roves the need for additional config files for the test.
 26  
  */
 27  0
 public abstract class FunctionalTestCase extends AbstractMuleTestCase
 28  
 {
 29  
 
 30  
     public static final String DEFAULT_BUILDER_CLASS = "org.mule.config.builders.MuleXmlConfigurationBuilder";
 31  
 
 32  
     protected final void doSetUp() throws Exception
 33  
     {
 34  0
         doPreFunctionalSetUp();
 35  
         // Should we set up te manager for every method?
 36  0
         if (!getTestInfo().isDisposeManagerPerSuite())
 37  
         {
 38  0
             setupManager();
 39  
         }
 40  0
         doPostFunctionalSetUp();
 41  0
     }
 42  
 
 43  
     protected void suitePreSetUp() throws Exception
 44  
     {
 45  0
         if (getTestInfo().isDisposeManagerPerSuite())
 46  
         {
 47  0
             setupManager();
 48  
         }
 49  0
     }
 50  
 
 51  
     protected void setupManager() throws Exception
 52  
     {
 53  0
         MuleManager.getConfiguration().setWorkListener(new TestingWorkListener());
 54  0
         ConfigurationBuilder builder = getBuilder();
 55  0
         builder.configure(getConfigResources(), null);
 56  0
     }
 57  
 
 58  
     protected final void doTearDown() throws Exception
 59  
     {
 60  0
         doFunctionalTearDown();
 61  0
     }
 62  
 
 63  
     protected ConfigurationBuilder getBuilder() throws Exception
 64  
     {
 65  
 
 66  
         try
 67  
         {
 68  0
             Class builderClass = ClassUtils.loadClass(DEFAULT_BUILDER_CLASS, getClass());
 69  0
             return (ConfigurationBuilder)builderClass.newInstance();
 70  
         }
 71  0
         catch (ClassNotFoundException e)
 72  
         {
 73  0
             throw new ClassNotFoundException(
 74  
                 "The builder "
 75  
                                 + DEFAULT_BUILDER_CLASS
 76  
                                 + " is not on your classpath and "
 77  
                                 + "the getBuilder() method of this class has not been overloaded to return a different builder. Please "
 78  
                                 + "check your functional test.", e);
 79  
         }
 80  
 
 81  
     }
 82  
 
 83  
     protected void doPreFunctionalSetUp() throws Exception
 84  
     {
 85  
         // template method
 86  0
     }
 87  
 
 88  
     protected void doPostFunctionalSetUp() throws Exception
 89  
     {
 90  
         // template method
 91  0
     }
 92  
 
 93  
     protected void doFunctionalTearDown() throws Exception
 94  
     {
 95  
         // template method
 96  0
     }
 97  
 
 98  
     protected abstract String getConfigResources();
 99  
 }