Class AbstractTestSupport
- All Implemented Interfaces:
CommonTestSupport
- Direct Known Subclasses:
CamelTestSupport
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CamelContextConfiguration
protected org.apache.camel.ConsumerTemplate
protected org.apache.camel.model.ModelCamelContext
protected org.apache.camel.FluentProducerTemplate
protected org.apache.camel.ProducerTemplate
protected final TestExecutionConfiguration
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractTestSupport
(TestExecutionConfiguration testConfigurationBuilder, CamelContextConfiguration camelContextConfiguration) -
Method Summary
Modifier and TypeMethodDescriptionGets theCamelContextConfiguration
for the testorg.apache.camel.Service
Deprecated.protected void
Strategy to cleanup resources, afterCamelContext
is stoppedorg.apache.camel.ConsumerTemplate
consumer()
org.apache.camel.CamelContext
context()
Gets a reference to the CamelContext.protected void
Deprecated.protected void
Deprecated.Use the methodstestConfiguration()
to enable, disable or check JMX state.org.apache.camel.FluentProducerTemplate
org.apache.camel.Service
Deprecated.Deprecated.Deprecated.protected Boolean
Deprecated.Use the accessors fromcamelContextConfiguration()
methodprotected final boolean
Deprecated.Use the accessors fromtestConfiguration()
methodboolean
Deprecated.Use the accessors fromtestConfiguration()
methodDeprecated.Use the accessors fromcamelContextConfiguration()
methodDeprecated.Use the accessors fromcamelContextConfiguration()
methodprotected boolean
Deprecated.Use the methodstestConfiguration()
to enable or disable the route converage dumperboolean
Deprecated.Use the accessors fromtestConfiguration()
methodboolean
Deprecated.Use the accessors fromtestConfiguration()
methodboolean
Deprecated.Use the accessors fromtestConfiguration()
methodvoid
replaceRouteFromWith
(String routeId, String fromEndpoint) Deprecated.Use the accessors fromcamelContextConfiguration()
methodvoid
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 CamelContextvoid
setContext
(org.apache.camel.model.ModelCamelContext context) Deprecated.protected void
Strategy to set up resources, beforeCamelContext
is created.void
setUseRouteBuilder
(boolean useRouteBuilder) Deprecated.org.apache.camel.ProducerTemplate
template()
Gets theTestExecutionConfiguration
test execution configuration instance for the testprotected boolean
useJmx()
Deprecated.Use the methodstestConfiguration()
to enable, disable or check JMX state.protected Properties
Deprecated.Use the accessors fromcamelContextConfiguration()
method
-
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, beforeCamelContext
is 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, afterCamelContext
is stopped- Throws:
Exception
-
isUseRouteBuilder
Deprecated.Use the accessors fromtestConfiguration()
methodUse the RouteBuilder or not- Returns:
- true then
CamelContext
will be auto started, false thenCamelContext
will 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.
-
isUseAdviceWith
Deprecated.Use the accessors fromtestConfiguration()
methodOverride when using advice with and return true. This helps to know advice with is to be used, andCamelContext
will not be started before the advice with takes place. This helps by ensuring the advice with has been property setup before theCamelContext
is started Important: It's important to startCamelContext
manually 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 whetherCamelContext
should be setup per test or per class. DO NOT USE. By default it will be setup/teardown per test method. This method returnstrue
when the camel test class is annotated with @TestInstance(TestInstance.Lifecycle.PER_CLASS). Important: Use this with care as theCamelContext
will 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:
-
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 theCamelContextConfiguration
for the test- Specified by:
camelContextConfiguration
in interfaceCommonTestSupport
- Returns:
- the camel context configuration
-
testConfiguration
Gets theTestExecutionConfiguration
test execution configuration instance for the test- Specified by:
testConfiguration
in interfaceCommonTestSupport
- 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.