Class CamelSpringTestSupport
java.lang.Object
org.apache.camel.test.junit5.AbstractTestSupport
org.apache.camel.test.junit5.CamelTestSupport
org.apache.camel.test.spring.junit5.CamelSpringTestSupport
- All Implemented Interfaces:
org.apache.camel.test.junit5.CommonTestSupport,org.apache.camel.test.junit5.ConfigurableContext,org.apache.camel.test.junit5.ConfigurableTest,org.junit.jupiter.api.extension.AfterTestExecutionCallback,org.junit.jupiter.api.extension.BeforeTestExecutionCallback,org.junit.jupiter.api.extension.Extension
public abstract class CamelSpringTestSupport
extends org.apache.camel.test.junit5.CamelTestSupport
Base test-class for classic Spring application such as standalone, web applications. Do not use this class
for Spring Boot testing, instead use
@CamelSpringBootTest.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.support.AbstractApplicationContextprotected static final Objectstatic final Stringstatic final Stringstatic final Stringprotected static final ThreadLocal<org.springframework.context.support.AbstractApplicationContext> Fields inherited from class org.apache.camel.test.junit5.CamelTestSupport
camelTestSupportExtension, contextManagerExtension, testLoggerExtensionFields inherited from class org.apache.camel.test.junit5.AbstractTestSupport
camelContextConfiguration, consumer, context, fluentTemplate, template, testConfigurationBuilder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]Which active profiles should be used.protected abstract org.springframework.context.support.AbstractApplicationContextprotected org.apache.camel.CamelContextvoidprotected final voidprotected Class<?> Template method used to exclude aRoutefrom the test camel contextprotected Class<?>[]Template method used to excludeRoutefrom the test time context route scanning<T> TgetMandatoryBean(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 typeprotected org.springframework.context.ApplicationContextCreate a parent context that initializes aPackageScanClassResolverto exclude a set of given classes from being resolved.org.springframework.context.support.AbstractXmlApplicationContextnewAppContext(String configLocation) org.springframework.context.support.AbstractXmlApplicationContextnewAppContext(String... configLocations) static org.springframework.context.support.AbstractXmlApplicationContextnewAppContext(String configLocation, Class<?> clazz) protected final voidMethods inherited from class org.apache.camel.test.junit5.CamelTestSupport
afterTestExecution, applyCamelPostProcessor, assertExpression, assertPredicate, assertResolveLanguage, assertValidContext, beforeTestExecution, bindToRegistry, configureContext, configureTest, createCamelRegistry, createExchangeWithBody, createRouteBuilder, createRouteBuilders, debugAfter, debugBefore, doPostSetup, doQuarkusCheck, doSetUp, doSpringBootCheck, expression, getCurrentTestName, getMandatoryEndpoint, getMandatoryEndpoint, getMockEndpoint, getMockEndpoint, getShutdownTimeout, hasClassAnnotation, resolveMandatoryEndpoint, resolveMandatoryEndpoint, sendBodies, sendBody, sendBody, setUp, startCamelContext, stopCamelContext, tearDown, timeTaken, unsupportedCheckMethods inherited from class org.apache.camel.test.junit5.AbstractTestSupport
camelContextConfiguration, camelContextService, cleanupResources, consumer, context, disableJMX, enableJMX, fluentTemplate, getCamelContextService, getDumpRoute, getRouteFilterExcludePattern, getRouteFilterIncludePattern, ignoreMissingLocationWithPropertiesComponent, isAutoStartupExcludePatterns, isCreateCamelContextPerClass, isDumpRouteCoverage, isMockEndpoints, isMockEndpointsAndSkip, isRouteCoverageEnabled, isStubEndpoints, isUseAdviceWith, isUseDebugger, isUseRouteBuilder, replaceRouteFromWith, setCamelContextService, setContext, setupResources, setUseRouteBuilder, template, testConfiguration, useJmx, useOverridePropertiesWithPropertiesComponent
-
Field Details
-
TEST_CLASS_NAME_PROPERTY
- See Also:
-
TEST_CLASS_SIMPLE_NAME_PROPERTY
- See Also:
-
TEST_DIRECTORY_PROPERTY
- See Also:
-
THREAD_APP_CONTEXT
protected static final ThreadLocal<org.springframework.context.support.AbstractApplicationContext> THREAD_APP_CONTEXT -
LOCK
-
applicationContext
protected org.springframework.context.support.AbstractApplicationContext applicationContext
-
-
Constructor Details
-
CamelSpringTestSupport
public CamelSpringTestSupport()
-
-
Method Details
-
createApplicationContext
protected abstract org.springframework.context.support.AbstractApplicationContext createApplicationContext() -
postProcessTest
- Overrides:
postProcessTestin classorg.apache.camel.test.junit5.CamelTestSupport- Throws:
Exception
-
doPreSetup
- Overrides:
doPreSetupin classorg.apache.camel.test.junit5.CamelTestSupport- Throws:
Exception
-
doPostTearDown
- Overrides:
doPostTearDownin classorg.apache.camel.test.junit5.CamelTestSupport- Throws:
Exception
-
getRouteExcludingApplicationContext
protected org.springframework.context.ApplicationContext getRouteExcludingApplicationContext()Create a parent context that initializes aPackageScanClassResolverto 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 theApplicationContextreturned 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 methodsexcludedRoutesandexcludedRouteto determine the classes to be excluded from scanning.- Returns:
- ApplicationContext a parent
ApplicationContextconfigured to exclude certain classes from package scanning
-
excludeRoutes
Template method used to excludeRoutefrom the test time context route scanning- Returns:
- Class[] the classes to be excluded from test time context route scanning
-
excludeRoute
Template method used to exclude aRoutefrom the test camel context -
getMandatoryBean
Looks up the mandatory spring bean of the given name and type, failing if it is not present or the correct type -
activeProfiles
Which active profiles should be used. Important: When using active profiles, then the code increateApplicationContext()should create the SpringAbstractApplicationContextwithout refreshing. For example creating anClassPathXmlApplicationContextyou would need to pass in false in the refresh parameter, in the constructor. Camel will thrown anIllegalStateExceptionif 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.- Returns:
- an array of active profiles to use, use null to not use any active profiles.
-
createCamelContext
- Overrides:
createCamelContextin classorg.apache.camel.test.junit5.CamelTestSupport- Throws:
Exception
-
newAppContext
public org.springframework.context.support.AbstractXmlApplicationContext newAppContext(String configLocation) throws org.springframework.beans.BeansException - Throws:
org.springframework.beans.BeansException
-
newAppContext
public org.springframework.context.support.AbstractXmlApplicationContext newAppContext(String... configLocations) throws org.springframework.beans.BeansException - Throws:
org.springframework.beans.BeansException
-
getTranslationProperties
-
newAppContext
-
newAppContext
-
newAppContext
-