Class AbstractTestSupport
- All Implemented Interfaces:
CommonTestSupport,ConfigurableContext,ConfigurableTest
- Direct Known Subclasses:
CamelTestSupport
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CamelContextConfigurationprotected org.apache.camel.ConsumerTemplateprotected org.apache.camel.model.ModelCamelContextprotected org.apache.camel.FluentProducerTemplateprotected org.apache.camel.ProducerTemplateprotected final TestExecutionConfiguration -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractTestSupport(TestExecutionConfiguration testConfigurationBuilder, CamelContextConfiguration camelContextConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionGets theCamelContextConfigurationfor the testorg.apache.camel.ServiceDeprecated.protected voidStrategy to cleanup resources, afterCamelContextis stoppedorg.apache.camel.ConsumerTemplateconsumer()org.apache.camel.CamelContextcontext()Gets a reference to the CamelContext.protected voidDeprecated.protected voidDeprecated.Use the methodstestConfiguration()to enable, disable or check JMX state.org.apache.camel.FluentProducerTemplateorg.apache.camel.ServiceDeprecated.Deprecated.Use the accessors fromtestConfiguration()methodDeprecated.Deprecated.protected BooleanDeprecated.Use the accessors fromcamelContextConfiguration()methodDeprecated.Use the accessors fromcamelContextConfiguration()methodprotected final booleanDeprecated.Use the accessors fromtestConfiguration()methodbooleanDeprecated.Use the accessors fromtestConfiguration()methodDeprecated.Use the accessors fromcamelContextConfiguration()methodDeprecated.Use the accessors fromcamelContextConfiguration()methodprotected booleanDeprecated.Use the methodstestConfiguration()to enable or disable the route converage dumperDeprecated.Use the accessors fromcamelContextConfiguration()methodbooleanDeprecated.Use the accessors fromtestConfiguration()methodbooleanDeprecated.Use the accessors fromtestConfiguration()methodbooleanDeprecated.Use the accessors fromtestConfiguration()methodvoidreplaceRouteFromWith(String routeId, String fromEndpoint) Deprecated.Use the accessors fromcamelContextConfiguration()methodvoidsetCamelContextService(org.apache.camel.Service service) Allows a service to be registered a separate lifecycle service to start and stop the context; such as for Spring when the ApplicationContext is started and stopped, rather than directly stopping the CamelContextvoidsetContext(org.apache.camel.model.ModelCamelContext context) Deprecated.protected voidStrategy to set up resources, beforeCamelContextis created.voidsetUseRouteBuilder(boolean useRouteBuilder) Deprecated.org.apache.camel.ProducerTemplatetemplate()Gets theTestExecutionConfigurationtest execution configuration instance for the testprotected booleanuseJmx()Deprecated.Use the methodstestConfiguration()to enable, disable or check JMX state.protected PropertiesDeprecated.Use the accessors fromcamelContextConfiguration()methodMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.test.junit5.ConfigurableContext
configureContextMethods inherited from interface org.apache.camel.test.junit5.ConfigurableTest
configureTest
-
Field Details
-
testConfigurationBuilder
-
camelContextConfiguration
-
context
protected volatile org.apache.camel.model.ModelCamelContext context -
template
protected volatile org.apache.camel.ProducerTemplate template -
fluentTemplate
protected volatile org.apache.camel.FluentProducerTemplate fluentTemplate -
consumer
protected volatile org.apache.camel.ConsumerTemplate consumer
-
-
Constructor Details
-
AbstractTestSupport
protected AbstractTestSupport() -
AbstractTestSupport
protected AbstractTestSupport(TestExecutionConfiguration testConfigurationBuilder, CamelContextConfiguration camelContextConfiguration)
-
-
Method Details
-
setupResources
Strategy to set up resources, beforeCamelContextis created. This is meant to be used by resources that must be available before the context is created. Do not use this as a replacement for tasks that can be handled using JUnit's annotations.- Throws:
Exception
-
cleanupResources
Strategy to cleanup resources, afterCamelContextis stopped- Throws:
Exception
-
isUseRouteBuilder
Deprecated.Use the accessors fromtestConfiguration()methodUse the RouteBuilder or not- Returns:
- true then
CamelContextwill be auto started, false thenCamelContextwill not be auto started (you will have to start it manually)
-
setUseRouteBuilder
Deprecated. -
isDumpRouteCoverage
Deprecated.Use the accessors fromtestConfiguration()methodWhether to dump route coverage stats at the end of the test. This allows tooling or manual inspection of the stats, so you can generate a route trace diagram of which EIPs have been in use and which have not. Similar concepts as a code coverage report. You can also turn on route coverage globally via setting JVM system property CamelTestRouteCoverage=true.- Returns:
- true to write route coverage status in an xml file in the target/camel-route-coverage directory after the test has finished.
-
getDumpRoute
Deprecated.Use the accessors fromtestConfiguration()methodWhether to dump route as XML or YAML This allows tooling or manual inspection of the tested routes. You can also turn on route dump globally via setting JVM system property CamelTestRouteDump=xml.- Returns:
- xml or yaml to write route dump to the log
-
isUseAdviceWith
Deprecated.Use the accessors fromtestConfiguration()methodOverride when using advice with and return true. This helps to know advice with is to be used, andCamelContextwill not be started before the advice with takes place. This helps by ensuring the advice with has been property setup before theCamelContextis started Important: It's important to startCamelContextmanually from the unit test after you are done doing all the advice with.- Returns:
- true if you use advice with in your unit tests.
-
isCreateCamelContextPerClass
Deprecated.Use the accessors fromtestConfiguration()methodTells whetherCamelContextshould be setup per test or per class. DO NOT USE. By default it will be setup/teardown per test method. This method returnstruewhen the camel test class is annotated with @TestInstance(TestInstance.Lifecycle.PER_CLASS). Important: Use this with care as theCamelContextwill carry over state from previous tests, such as endpoints, components etc. So you cannot use this in all your tests.- Returns:
- true per class, false per test.
-
isMockEndpoints
Deprecated.Use the accessors fromcamelContextConfiguration()methodOverride to enable auto mocking endpoints based on the pattern. Return * to mock all endpoints.- See Also:
-
isMockEndpointsAndSkip
Deprecated.Use the accessors fromcamelContextConfiguration()methodOverride to enable auto mocking endpoints based on the pattern, and skip sending to original endpoint. Return * to mock all endpoints.- See Also:
-
isStubEndpoints
Deprecated.Use the accessors fromcamelContextConfiguration()methodOverride to enable auto stub endpoints based on the pattern. Return * to mock all endpoints.- See Also:
-
isAutoStartupExcludePatterns
Deprecated.Use the accessors fromcamelContextConfiguration()methodOverride to exclusive filtering of routes to not automatically start with Camel starts. The pattern support matching by route id or endpoint urls. Multiple patterns can be specified separated by comma, as example, to exclude all the routes starting from kafka or jms use: kafka,jms.- See Also:
-
replaceRouteFromWith
Deprecated.Use the accessors fromcamelContextConfiguration()methodTo replace from routes- Parameters:
routeId-fromEndpoint-
-
getRouteFilterIncludePattern
Deprecated.Used for filtering routes matching the given pattern, which follows the following rules:- Match by route id - Match by route input endpoint uri
The matching is using exact match, by wildcard and regular expression.
For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from JMS endpoints, use: exclude=jms:*
Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar*
Exclude takes precedence over include.
-
getRouteFilterExcludePattern
Deprecated.Used for filtering routes matching the given pattern, which follows the following rules:- Match by route id - Match by route input endpoint uri
The matching is using exact match, by wildcard and regular expression.
For example to only include routes which starts with foo in their route id's, use: include=foo* And to exclude routes which starts from JMS endpoints, use: exclude=jms:*
Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar*
Exclude takes precedence over include.
-
isUseDebugger
Deprecated.Use the accessors fromtestConfiguration()methodOverride to enable debugger Is default false -
getCamelContextService
Deprecated. -
camelContextService
Deprecated. -
context
public org.apache.camel.CamelContext context()Gets a reference to the CamelContext. Must not be used during test setup.- Returns:
- A reference to the CamelContext
-
setContext
Deprecated.Sets the CamelContext. Used by the manager to override tests that try to access the context during setup. DO NOT USE.- Parameters:
context-
-
template
public org.apache.camel.ProducerTemplate template() -
fluentTemplate
public org.apache.camel.FluentProducerTemplate fluentTemplate() -
consumer
public org.apache.camel.ConsumerTemplate consumer() -
setCamelContextService
public void setCamelContextService(org.apache.camel.Service service) Allows a service to be registered a separate lifecycle service to start and stop the context; such as for Spring when the ApplicationContext is started and stopped, rather than directly stopping the CamelContext -
useJmx
Deprecated.Use the methodstestConfiguration()to enable, disable or check JMX state.Whether JMX should be used during testing.- Returns:
- false by default.
-
useOverridePropertiesWithPropertiesComponent
Deprecated.Use the accessors fromcamelContextConfiguration()methodOverride this method to include and override properties with the CamelPropertiesComponent.- Returns:
- additional properties to add/override.
-
ignoreMissingLocationWithPropertiesComponent
Deprecated.Use the accessors fromcamelContextConfiguration()methodWhether to ignore missing locations with thePropertiesComponent. For example when unit testing you may want to ignore locations that are not available in the environment used for testing.- Returns:
- true to ignore, false to not ignore, and null to leave as configured on
the
PropertiesComponent
-
camelContextConfiguration
Gets theCamelContextConfigurationfor the test- Specified by:
camelContextConfigurationin interfaceConfigurableContext- Returns:
- the camel context configuration
-
testConfiguration
Gets theTestExecutionConfigurationtest execution configuration instance for the test- Specified by:
testConfigurationin interfaceConfigurableTest- Returns:
- the configuration instance for the test
-
disableJMX
Deprecated.Use the methodstestConfiguration()to enable, disable or check JMX state.Disables the JMX agent. Must be called before the setup method. -
enableJMX
Deprecated.Use the methodstestConfiguration()to enable, disable or check JMX state.Enables the JMX agent. Must be called before the setup method. -
isRouteCoverageEnabled
Deprecated.Use the methodstestConfiguration()to enable or disable the route converage dumperWhether route coverage is enabled- Returns:
- true if enabled or false otherwise
-
testConfiguration()to enable, disable or check JMX state.