public abstract class CamelSpringTestSupport
extends org.apache.camel.test.junit4.CamelTestSupport
@RunWith(CamelSpringBootRunner.class).| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.support.AbstractApplicationContext |
applicationContext |
protected static Object |
lock |
protected static ThreadLocal<org.springframework.context.support.AbstractApplicationContext> |
threadAppContext |
| Constructor and Description |
|---|
CamelSpringTestSupport() |
| Modifier and Type | Method and Description |
|---|---|
protected String[] |
activeProfiles()
Which active profiles should be used.
|
protected abstract org.springframework.context.support.AbstractApplicationContext |
createApplicationContext() |
protected org.apache.camel.CamelContext |
createCamelContext() |
void |
doPostTearDown() |
void |
doPreSetup() |
protected Class<?> |
excludeRoute()
Template method used to exclude a
Route from the test camel context |
protected Class<?>[] |
excludeRoutes()
Template method used to exclude
Route from the test time context
route scanning |
<T> T |
getMandatoryBean(Class<T> type,
String name)
Looks up the mandatory spring bean of the given name and type, failing if
it is not present or the correct type
|
protected org.springframework.context.ApplicationContext |
getRouteExcludingApplicationContext()
Create a parent context that initializes a
PackageScanClassResolver to exclude a set of given classes from
being resolved. |
void |
postProcessTest()
Lets post process this test instance to process any Camel annotations.
|
void |
tearDown() |
applyCamelPostProcessor, assertExpression, assertMockEndpointsSatisfied, assertMockEndpointsSatisfied, assertPredicate, assertResolveLanguage, assertValidContext, bindToRegistry, camelContextService, cleanupResources, consumer, context, createCamelRegistry, createExchangeWithBody, createJndiContext, createRegistry, createRouteBuilder, createRouteBuilders, debugAfter, debugBefore, disableJMX, doPostSetup, doSpringBootCheck, enableJMX, fluentTemplate, getCamelContextService, getCamelTestWatcher, getMandatoryEndpoint, getMandatoryEndpoint, getMockEndpoint, getMockEndpoint, getShutdownTimeout, hasClassAnnotation, ignoreMissingLocationWithPropertiesComponent, isCreateCamelContextPerClass, isDumpRouteCoverage, isLazyLoadingTypeConverter, isMockEndpoints, isMockEndpointsAndSkip, isUseAdviceWith, isUseDebugger, isUseRouteBuilder, replaceRouteFromWith, resetMocks, resolveMandatoryEndpoint, resolveMandatoryEndpoint, sendBodies, sendBody, sendBody, setCamelContextService, setUp, setupResources, setUseRouteBuilder, startCamelContext, stopCamelContext, template, useJmx, useOverridePropertiesWithPropertiesComponentassertCollectionSize, assertCollectionSize, assertDirectoryEquals, assertDirectoryEquals, assertDirectoryExists, assertEndpointUri, assertExpression, assertFileExists, assertFileNotExists, assertInMessageBodyEquals, assertInMessageHeader, assertIsInstanceOf, assertListSize, assertListSize, assertMessageHeader, assertOneElement, assertOutMessageBodyEquals, assertOutMessageHeader, assertPredicate, assertPredicateDoesNotMatch, assertPredicateMatches, assertStringContains, body, bodyAs, createDirectory, createExchangeWithBody, deleteDirectory, deleteDirectory, exchangeProperty, getJavaMajorVersion, getRouteList, getTestMethodName, getTestName, header, isJava15, isJava16, isJava17, isJava18, isJava19, isJavaVendor, isPlatform, property, resolveMandatoryEndpoint, resolveMandatoryEndpoint, systemProperty, systemPropertyassertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertThat, assertThat, assertTrue, assertTrue, fail, failprotected static ThreadLocal<org.springframework.context.support.AbstractApplicationContext> threadAppContext
protected static Object lock
protected org.springframework.context.support.AbstractApplicationContext applicationContext
protected abstract org.springframework.context.support.AbstractApplicationContext createApplicationContext()
public void postProcessTest()
throws Exception
postProcessTest in class org.apache.camel.test.junit4.CamelTestSupportExceptionpublic void doPreSetup()
throws Exception
doPreSetup in class org.apache.camel.test.junit4.CamelTestSupportExceptionpublic void tearDown()
throws Exception
tearDown in class org.apache.camel.test.junit4.CamelTestSupportExceptionpublic void doPostTearDown()
throws Exception
doPostTearDown in class org.apache.camel.test.junit4.CamelTestSupportExceptionprotected org.springframework.context.ApplicationContext getRouteExcludingApplicationContext()
PackageScanClassResolver to exclude a set of given classes from
being resolved. Typically this is used at test time to exclude certain routes,
which might otherwise be just noisy, from being discovered and initialized.
To use this filtering mechanism it is necessary to provide the
ApplicationContext returned from here as the parent context to
your test context e.g.
protected AbstractXmlApplicationContext createApplicationContext() {
return new ClassPathXmlApplicationContext(new String[] {"test-context.xml"}, getRouteExcludingApplicationContext());
}
This will, in turn, call the template methods excludedRoutes
and excludedRoute to determine the classes to be excluded from scanning.ApplicationContext configured
to exclude certain classes from package scanningprotected Class<?>[] excludeRoutes()
Route from the test time context
route scanningprotected Class<?> excludeRoute()
Route from the test camel contextpublic <T> T getMandatoryBean(Class<T> type, String name)
protected String[] activeProfiles()
createApplicationContext() should create
the Spring AbstractApplicationContext without refreshing. For example creating an
ClassPathXmlApplicationContext you would need to pass in
false in the refresh parameter, in the constructor.
Camel will thrown an IllegalStateException if this is not correct stating this problem.
The reason is that we cannot active profiles after a Spring application context has already
been refreshed, and is active.Apache Camel