|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.test.context.support.AbstractContextLoader
org.apache.camel.test.spring.CamelSpringTestContextLoader
public class CamelSpringTestContextLoader
Replacement for the default GenericXmlContextLoader
that provides hooks for
processing some class level Camel related test annotations.
Constructor Summary | |
---|---|
CamelSpringTestContextLoader()
|
Method Summary | |
---|---|
protected void |
cleanup(Class<?> testClass)
Cleanup/restore global state to defaults / pre-test values after the test setup is complete. |
protected org.springframework.context.support.GenericApplicationContext |
createContext(Class<?> testClass)
Creates and starts the Spring context while optionally starting any loaded Camel contexts. |
String |
getResourceSuffix()
Returns " -context.xml ". |
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.support.GenericApplicationContext context,
Class<?> testClass)
Handles starting of Camel contexts based on UseAdviceWith and other state in the JVM. |
protected void |
handleDisableJmx(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
Handles disabling of JMX on Camel contexts based on DisableJmx . |
protected void |
handleLazyLoadTypeConverters(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
|
protected void |
handleMockEndpoints(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
Handles auto-intercepting of endpoints with mocks based on MockEndpoints . |
protected void |
handleMockEndpointsAndSkip(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
Handles auto-intercepting of endpoints with mocks based on MockEndpointsAndSkip and skipping the
original endpoint. |
protected void |
handleProvidesBreakpoint(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
Handles the processing of the ProvidesBreakpoint annotation on a test class. |
protected void |
handleShutdownTimeout(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
Handles updating shutdown timeouts on Camel contexts based on ShutdownTimeout . |
protected void |
loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext context,
org.springframework.test.context.MergedContextConfiguration mergedConfig)
|
protected void |
loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext context,
String... locations)
|
protected org.springframework.context.ApplicationContext |
loadContext(org.springframework.context.support.GenericApplicationContext context,
Class<?> testClass)
Performs the bulk of the Spring application context loading/customization. |
org.springframework.context.ApplicationContext |
loadContext(org.springframework.test.context.MergedContextConfiguration mergedConfig)
Modeled after the Spring implementation in AbstractGenericContextLoader ,
this method creates and refreshes the application context while providing for
processing of additional Camel specific post-refresh actions. |
org.springframework.context.ApplicationContext |
loadContext(String... locations)
Modeled after the Spring implementation in AbstractGenericContextLoader ,
this method creates and refreshes the application context while providing for
processing of additional Camel specific post-refresh actions. |
Methods inherited from class org.springframework.test.context.support.AbstractContextLoader |
---|
generateDefaultLocations, isGenerateDefaultLocations, modifyLocations, processContextConfiguration, processLocations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CamelSpringTestContextLoader()
Method Detail |
---|
public org.springframework.context.ApplicationContext loadContext(org.springframework.test.context.MergedContextConfiguration mergedConfig) throws Exception
AbstractGenericContextLoader
,
this method creates and refreshes the application context while providing for
processing of additional Camel specific post-refresh actions. We do not provide the
pre-post hooks for customization seen in AbstractGenericContextLoader
because
they probably are unnecessary for 90+% of users.
For some functionality, we cannot use TestExecutionListener
because we need
to both produce the desired outcome during application context loading, and also cleanup
after ourselves even if the test class never executes. Thus the listeners, which
only run if the application context is successfully initialized are insufficient to
provide the behavior described above.
Exception
public org.springframework.context.ApplicationContext loadContext(String... locations) throws Exception
AbstractGenericContextLoader
,
this method creates and refreshes the application context while providing for
processing of additional Camel specific post-refresh actions. We do not provide the
pre-post hooks for customization seen in AbstractGenericContextLoader
because
they probably are unnecessary for 90+% of users.
For some functionality, we cannot use TestExecutionListener
because we need
to both produce the desired outcome during application context loading, and also cleanup
after ourselves even if the test class never executes. Thus the listeners, which
only run if the application context is successfully initialized are insufficient to
provide the behavior described above.
Exception
public String getResourceSuffix()
-context.xml
".
getResourceSuffix
in class org.springframework.test.context.support.AbstractContextLoader
protected org.springframework.context.ApplicationContext loadContext(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
context
- the partially configured context. The context should have the bean definitions loaded, but nothing else.testClass
- the test class being executed
Exception
- if there is an error during initialization/customizationprotected void cleanup(Class<?> testClass)
testClass
- the test class being executedprotected void loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext context, org.springframework.test.context.MergedContextConfiguration mergedConfig)
protected void loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext context, String... locations)
protected org.springframework.context.support.GenericApplicationContext createContext(Class<?> testClass)
testClass
- the test class that is being executed
protected void handleDisableJmx(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass)
DisableJmx
.
context
- the initialized Spring contexttestClass
- the test class being executedprotected void handleProvidesBreakpoint(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
ProvidesBreakpoint
annotation on a test class. Exists here
as it is needed in
context
- the initialized Spring context containing the Camel context(s) to insert breakpoints intotestClass
- the test class being processed
Exception
- if there is an error processing the classprotected void handleShutdownTimeout(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
ShutdownTimeout
.
context
- the initialized Spring contexttestClass
- the test class being executed
Exception
protected void handleMockEndpoints(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
MockEndpoints
.
context
- the initialized Spring contexttestClass
- the test class being executed
Exception
protected void handleMockEndpointsAndSkip(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
MockEndpointsAndSkip
and skipping the
original endpoint.
context
- the initialized Spring contexttestClass
- the test class being executed
Exception
protected void handleLazyLoadTypeConverters(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
Exception
protected void handleCamelContextStartup(org.springframework.context.support.GenericApplicationContext context, Class<?> testClass) throws Exception
UseAdviceWith
and other state in the JVM.
context
- the initialized Spring contexttestClass
- the test class being executed
Exception
protected Class<?> getTestClass()
CamelSpringTestHelper
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |