org.apache.camel.test.spring
Class CamelSpringDelegatingTestContextLoader

java.lang.Object
  extended by org.springframework.test.context.support.AbstractDelegatingSmartContextLoader
      extended by org.springframework.test.context.support.DelegatingSmartContextLoader
          extended by org.apache.camel.test.spring.CamelSpringDelegatingTestContextLoader
All Implemented Interfaces:
org.springframework.test.context.ContextLoader, org.springframework.test.context.SmartContextLoader

public class CamelSpringDelegatingTestContextLoader
extends org.springframework.test.context.support.DelegatingSmartContextLoader

CamelSpringDelegatingTestContextLoader which fixes issues in Camel's JavaConfigContextLoader. (adds support for Camel's test annotations)
This loader can handle either classes or locations for configuring the context.
NOTE: This TestContextLoader doesn't support the annotation of ExcludeRoutes now.


Field Summary
protected  org.slf4j.Logger logger
           
 
Constructor Summary
CamelSpringDelegatingTestContextLoader()
           
 
Method Summary
protected  void cleanup(Class<?> testClass)
          Cleanup/restore global state to defaults / pre-test values after the test setup is complete.
protected  Class<?> getTestClass()
          Returns the class under test in order to enable inspection of annotations while the Spring context is being created.
protected  void handleCamelContextStartup(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Handles starting of Camel contexts based on UseAdviceWith and other state in the JVM.
protected  void handleDisableJmx(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Handles disabling of JMX on Camel contexts based on DisableJmx.
protected  void handleMockEndpoints(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Handles auto-intercepting of endpoints with mocks based on MockEndpoints.
protected  void handleMockEndpointsAndSkip(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Handles auto-intercepting of endpoints with mocks based on MockEndpointsAndSkip and skipping the original endpoint.
protected  void handleProvidesBreakpoint(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Handles the processing of the ProvidesBreakpoint annotation on a test class.
protected  void handleShutdownTimeout(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Handles updating shutdown timeouts on Camel contexts based on ShutdownTimeout.
 org.springframework.context.ApplicationContext loadContext(org.springframework.context.ConfigurableApplicationContext context, Class<?> testClass)
          Performs the bulk of the Spring application context loading/customization.
 org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration mergedConfig)
           
 
Methods inherited from class org.springframework.test.context.support.DelegatingSmartContextLoader
getAnnotationConfigLoader, getXmlLoader
 
Methods inherited from class org.springframework.test.context.support.AbstractDelegatingSmartContextLoader
loadContext, processContextConfiguration, processLocations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.slf4j.Logger logger
Constructor Detail

CamelSpringDelegatingTestContextLoader

public CamelSpringDelegatingTestContextLoader()
Method Detail

loadContext

public org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration mergedConfig)
                                                           throws Exception
Specified by:
loadContext in interface org.springframework.test.context.SmartContextLoader
Overrides:
loadContext in class org.springframework.test.context.support.AbstractDelegatingSmartContextLoader
Throws:
Exception

loadContext

public org.springframework.context.ApplicationContext loadContext(org.springframework.context.ConfigurableApplicationContext context,
                                                                  Class<?> testClass)
                                                           throws Exception
Performs the bulk of the Spring application context loading/customization.

Parameters:
context - the partially configured context. The context should have the bean definitions loaded, but nothing else.
testClass - the test class being executed
Returns:
the initialized (refreshed) Spring application context
Throws:
Exception - if there is an error during initialization/customization

cleanup

protected void cleanup(Class<?> testClass)
Cleanup/restore global state to defaults / pre-test values after the test setup is complete.

Parameters:
testClass - the test class being executed

handleDisableJmx

protected void handleDisableJmx(org.springframework.context.ConfigurableApplicationContext context,
                                Class<?> testClass)
Handles disabling of JMX on Camel contexts based on DisableJmx.

Parameters:
context - the initialized Spring context
testClass - the test class being executed

handleProvidesBreakpoint

protected void handleProvidesBreakpoint(org.springframework.context.ConfigurableApplicationContext context,
                                        Class<?> testClass)
                                 throws Exception
Handles the processing of the ProvidesBreakpoint annotation on a test class. Exists here as it is needed in

Parameters:
context - the initialized Spring context containing the Camel context(s) to insert breakpoints into
testClass - the test class being processed
Throws:
Exception - if there is an error processing the class

handleShutdownTimeout

protected void handleShutdownTimeout(org.springframework.context.ConfigurableApplicationContext context,
                                     Class<?> testClass)
                              throws Exception
Handles updating shutdown timeouts on Camel contexts based on ShutdownTimeout.

Parameters:
context - the initialized Spring context
testClass - the test class being executed
Throws:
Exception

handleMockEndpoints

protected void handleMockEndpoints(org.springframework.context.ConfigurableApplicationContext context,
                                   Class<?> testClass)
                            throws Exception
Handles auto-intercepting of endpoints with mocks based on MockEndpoints.

Parameters:
context - the initialized Spring context
testClass - the test class being executed
Throws:
Exception

handleMockEndpointsAndSkip

protected void handleMockEndpointsAndSkip(org.springframework.context.ConfigurableApplicationContext context,
                                          Class<?> testClass)
                                   throws Exception
Handles auto-intercepting of endpoints with mocks based on MockEndpointsAndSkip and skipping the original endpoint.

Parameters:
context - the initialized Spring context
testClass - the test class being executed
Throws:
Exception

handleCamelContextStartup

protected void handleCamelContextStartup(org.springframework.context.ConfigurableApplicationContext context,
                                         Class<?> testClass)
                                  throws Exception
Handles starting of Camel contexts based on UseAdviceWith and other state in the JVM.

Parameters:
context - the initialized Spring context
testClass - the test class being executed
Throws:
Exception

getTestClass

protected Class<?> getTestClass()
Returns the class under test in order to enable inspection of annotations while the Spring context is being created.

Returns:
the test class that is being executed
See Also:
CamelSpringTestHelper


Apache Camel