Package org.apache.camel.test.junit5
Class CamelTestSupport
java.lang.Object
org.apache.camel.test.junit5.AbstractTestSupport
org.apache.camel.test.junit5.CamelTestSupport
- All Implemented Interfaces:
CommonTestSupport,org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.AfterTestExecutionCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.BeforeTestExecutionCallback,org.junit.jupiter.api.extension.Extension
- Direct Known Subclasses:
EndpointUriFactoryTestSupport,ExchangeTestSupport
public abstract class CamelTestSupport
extends AbstractTestSupport
implements org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeTestExecutionCallback, org.junit.jupiter.api.extension.AfterTestExecutionCallback
A useful base class which creates a
CamelContext with some routes along with a
ProducerTemplate for use in the test case Do not use this class for Spring Boot
testing.-
Field Summary
FieldsFields inherited from class org.apache.camel.test.junit5.AbstractTestSupport
camelContextConfiguration, consumer, context, fluentTemplate, template, testConfigurationBuilder -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedCamelTestSupport(ContextManagerFactory contextManagerFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidafterAll(org.junit.jupiter.api.extension.ExtensionContext context) voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) voidafterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) protected voidDeprecated.protected final voidassertExpression(org.apache.camel.Exchange exchange, String languageName, String expressionText, Object expectedValue) Deprecated.protected final voidassertPredicate(String languageName, String expressionText, org.apache.camel.Exchange exchange, boolean expected) Deprecated.protected final org.apache.camel.spi.LanguageassertResolveLanguage(String languageName) Deprecated.protected final voidassertValidContext(org.apache.camel.CamelContext context) Deprecated.Use JUnit's assertions if neededvoidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) protected voidbindToRegistry(org.apache.camel.spi.Registry registry) Allows binding custom beans to the CamelRegistry.protected org.apache.camel.CamelContextprotected org.apache.camel.spi.RegistryDeprecated.protected final org.apache.camel.ExchangecreateExchangeWithBody(Object body) Deprecated.protected org.apache.camel.RoutesBuilderFactory method which derived classes can use to create aRouteBuilderto define the routes for testingprotected org.apache.camel.RoutesBuilder[]Deprecated.This method will be made private.protected voiddebugAfter(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> definition, String id, String label, long timeTaken) Deprecated.UseAbstractTestSupport.camelContextConfiguration()to set an instance ofDebugBreakpointprotected voiddebugBefore(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> definition, String id, String label) Deprecated.UseAbstractTestSupport.camelContextConfiguration()to set an instance ofDebugBreakpointprotected voidDeprecated.UseAbstractTestSupport.setupResources()insteadprotected voidDeprecated.useAbstractTestSupport.cleanupResources()instead.protected voidDeprecated.UseAbstractTestSupport.setupResources()insteadprotected voidDeprecated.protected final voiddoSetUp()Deprecated.protected voidDeprecated.final StringDeprecated.Use JUnit's TestInfo class or theTestNameExtensionprotected final org.apache.camel.Endpointprotected final <T extends org.apache.camel.Endpoint>
TgetMandatoryEndpoint(String uri, Class<T> type) protected final org.apache.camel.component.mock.MockEndpointgetMockEndpoint(String uri) Resolves the mandatory Mock endpoint using a URI of the formmock:someNameprotected final org.apache.camel.component.mock.MockEndpointgetMockEndpoint(String uri, boolean create) Deprecated.protected intDeprecated.use the accessors fromAbstractTestSupport.camelContextConfiguration()protected booleanhasClassAnnotation(String... names) Deprecated.protected voidDeprecated.useAbstractTestSupport.setupResources()or the JUnit's annotation instead of this methodprotected final org.apache.camel.EndpointDeprecated.Use the methods fromTestSupportprotected final <T extends org.apache.camel.Endpoint>
TresolveMandatoryEndpoint(String uri, Class<T> endpointType) Deprecated.Use the methods fromTestSupportprotected final voidsendBodies(String endpointUri, Object... bodies) Deprecated.protected final voidDeprecated.protected final voidDeprecated.final voidsetUp()Deprecated.UseAbstractTestSupport.setupResources()insteadprotected voidDeprecated.protected voidDeprecated.final voidtearDown()Deprecated.UseAbstractTestSupport.cleanupResources()insteadlongDeprecated.protected voidDeprecated.Methods inherited from class org.apache.camel.test.junit5.AbstractTestSupport
camelContextConfiguration, camelContextService, cleanupResources, consumer, context, disableJMX, enableJMX, fluentTemplate, getCamelContextService, getRouteFilterExcludePattern, getRouteFilterIncludePattern, ignoreMissingLocationWithPropertiesComponent, isCreateCamelContextPerClass, isDumpRouteCoverage, isMockEndpoints, isMockEndpointsAndSkip, isRouteCoverageEnabled, isUseAdviceWith, isUseDebugger, isUseRouteBuilder, replaceRouteFromWith, setCamelContextService, setContext, setupResources, setUseRouteBuilder, template, testConfiguration, useJmx, useOverridePropertiesWithPropertiesComponent
-
Field Details
-
testLoggerExtension
-
camelTestSupportExtension
-
-
Constructor Details
-
CamelTestSupport
-
CamelTestSupport
protected CamelTestSupport()
-
-
Method Details
-
afterTestExecution
public void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
afterTestExecutionin interfaceorg.junit.jupiter.api.extension.AfterTestExecutionCallback- Throws:
Exception
-
beforeTestExecution
public void beforeTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception - Specified by:
beforeTestExecutionin interfaceorg.junit.jupiter.api.extension.BeforeTestExecutionCallback- Throws:
Exception
-
timeTaken
Deprecated. -
beforeEach
- Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
afterEach
- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback
-
getCurrentTestName
Deprecated.Use JUnit's TestInfo class or theTestNameExtensionGets the name of the current test being executed. -
setUp
Deprecated.UseAbstractTestSupport.setupResources()insteadCommon test setup. For internal use.- Throws:
Exception- if unable to setup the test
-
doPreSetup
Deprecated.UseAbstractTestSupport.setupResources()insteadStrategy to perform any pre-setup, before theCamelContextis created. This is for internal Camel usage.- Throws:
Exception
-
doPostSetup
Deprecated.UseAbstractTestSupport.setupResources()insteadStrategy to perform any post-setup afterCamelContextis created. This is for internal Camel usage.- Throws:
Exception
-
doSpringBootCheck
Deprecated.Detects if this is a Spring-Boot test and throws an exception, as these base classes is not intended for testing Camel on Spring Boot. Use ExtensionHelper.hasClassAnnotation instead -
doQuarkusCheck
Deprecated.Detects if this is a Camel-quarkus test and throw an exception, as these base classes is not intended for testing Camel onQuarkus. Use ExtensionHelper.hasClassAnnotation instead. -
unsupportedCheck
Deprecated.Temporary method for the child classes to modify the unsupported check. -
doSetUp
Deprecated.- Throws:
Exception
-
tearDown
Deprecated.UseAbstractTestSupport.cleanupResources()insteadCommon test tear down. For internal use.- Throws:
Exception- if unable to setup the test
-
doPostTearDown
Deprecated.useAbstractTestSupport.cleanupResources()instead.Strategy to perform any post-action, afterCamelContextis stopped. This is meant for internal Camel usage and should not be used by user classes.- Throws:
Exception
-
getShutdownTimeout
Deprecated.use the accessors fromAbstractTestSupport.camelContextConfiguration()Returns the timeout to use when shutting down (unit in seconds). Will default use 10 seconds.- Returns:
- the timeout to use
-
postProcessTest
Deprecated.useAbstractTestSupport.setupResources()or the JUnit's annotation instead of this methodInternal method. Do not use.- Throws:
Exception
-
applyCamelPostProcessor
Deprecated.Applies theCamelBeanPostProcessorto this instance.Derived classes using IoC / DI frameworks may wish to turn this into a NoOp such as for CDI we would just use CDI to inject this
- Throws:
Exception
-
hasClassAnnotation
Deprecated.Does this test class have any of the following annotations on the class-level. -
stopCamelContext
Deprecated.- Throws:
Exception
-
startCamelContext
Deprecated.- Throws:
Exception
-
createCamelContext
- Throws:
Exception
-
bindToRegistry
Allows binding custom beans to the CamelRegistry.- Throws:
Exception
-
createCamelRegistry
@Deprecated(since="4.7.0") protected org.apache.camel.spi.Registry createCamelRegistry() throws ExceptionDeprecated.Override to use a customRegistry.However if you need to bind beans to the registry then this is possible already with the bind method on registry, and there is no need to override this method.
- Throws:
Exception
-
createRouteBuilder
Factory method which derived classes can use to create aRouteBuilderto define the routes for testing- Throws:
Exception
-
createRouteBuilders
@Deprecated(since="4.7.0") protected org.apache.camel.RoutesBuilder[] createRouteBuilders() throws ExceptionDeprecated.This method will be made private. Do not useFactory method which derived classes can use to create an array ofRouteBuilders to define the routes for testing- Throws:
Exception- See Also:
-
resolveMandatoryEndpoint
@Deprecated(since="4.7.0") protected final org.apache.camel.Endpoint resolveMandatoryEndpoint(String uri) Deprecated.Use the methods fromTestSupportResolves a mandatory endpoint for the given URI or an exception is thrown- Parameters:
uri- the Camel URI to use to create or resolve an endpoint- Returns:
- the endpoint
-
resolveMandatoryEndpoint
@Deprecated(since="4.7.0") protected final <T extends org.apache.camel.Endpoint> T resolveMandatoryEndpoint(String uri, Class<T> endpointType) Deprecated.Use the methods fromTestSupportResolves a mandatory endpoint for the given URI and expected type or an exception is thrown- Parameters:
uri- the Camel URI to use to create or resolve an endpoint- Returns:
- the endpoint
-
getMockEndpoint
Resolves the mandatory Mock endpoint using a URI of the formmock:someName- Parameters:
uri- the URI which typically starts with "mock:" and has some name- Returns:
- the mandatory mock endpoint or an exception is thrown if it could not be resolved
-
getMockEndpoint
@Deprecated(since="4.7.0") protected final org.apache.camel.component.mock.MockEndpoint getMockEndpoint(String uri, boolean create) throws org.apache.camel.NoSuchEndpointException Deprecated.Resolves theMockEndpointusing a URI of the formmock:someName, optionally creating it if it does not exist. This implementation will lookup existing mock endpoints and match on the mock queue name, eg mock:foo and mock:foo?retainFirst=5 would match as the queue name is foo.- Parameters:
uri- the URI which typically starts with "mock:" and has some namecreate- whether to allow the endpoint to be created if it doesn't exist- Returns:
- the mock endpoint or an
NoSuchEndpointExceptionis thrown if it could not be resolved - Throws:
org.apache.camel.NoSuchEndpointException- is the mock endpoint does not exist
-
sendBody
Deprecated.Sends a message to the given endpoint URI with the body value- Parameters:
endpointUri- the URI of the endpoint to send tobody- the body for the message
-
sendBody
@Deprecated(since="4.7.0") protected final void sendBody(String endpointUri, Object body, Map<String, Object> headers) Deprecated.Sends a message to the given endpoint URI with the body value and specified headers- Parameters:
endpointUri- the URI of the endpoint to send tobody- the body for the messageheaders- any headers to set on the message
-
sendBodies
Deprecated.Sends messages to the given endpoint for each of the specified bodies- Parameters:
endpointUri- the endpoint URI to send tobodies- the bodies to send, one per message
-
createExchangeWithBody
@Deprecated(since="4.7.0") protected final org.apache.camel.Exchange createExchangeWithBody(Object body) Deprecated.Creates an exchange with the given body -
assertExpression
@Deprecated(since="4.7.0") protected final void assertExpression(org.apache.camel.Exchange exchange, String languageName, String expressionText, Object expectedValue) Deprecated.Asserts that the given language name and expression evaluates to the given value on a specific exchange -
assertPredicate
@Deprecated(since="4.7.0") protected final void assertPredicate(String languageName, String expressionText, org.apache.camel.Exchange exchange, boolean expected) Deprecated.Asserts that the given language name and predicate expression evaluates to the expected value on the message exchange -
assertResolveLanguage
@Deprecated(since="4.7.0") protected final org.apache.camel.spi.Language assertResolveLanguage(String languageName) Deprecated.Asserts that the language name can be resolved -
assertValidContext
@Deprecated(since="4.7.0") protected final void assertValidContext(org.apache.camel.CamelContext context) Deprecated.Use JUnit's assertions if neededAsserts the validity of the context- Parameters:
context-
-
getMandatoryEndpoint
-
getMandatoryEndpoint
-
debugBefore
@Deprecated(since="4.7.0") protected void debugBefore(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> definition, String id, String label) Deprecated.UseAbstractTestSupport.camelContextConfiguration()to set an instance ofDebugBreakpointSingle step debugs and Camel invokes this method before entering the given processor. This method is NOOP. -
debugAfter
@Deprecated(since="4.7.0") protected void debugAfter(org.apache.camel.Exchange exchange, org.apache.camel.Processor processor, org.apache.camel.model.ProcessorDefinition<?> definition, String id, String label, long timeTaken) Deprecated.UseAbstractTestSupport.camelContextConfiguration()to set an instance ofDebugBreakpointSingle step debugs and Camel invokes this method after processing the given processor. This method is NOOP.
-