类 CamelQuarkusTestSupport
java.lang.Object
org.apache.camel.test.junit5.CamelTestSupport
org.apache.camel.quarkus.test.CamelQuarkusTestSupport
- 所有已实现的接口:
io.quarkus.test.junit.QuarkusTestProfile,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
public class CamelQuarkusTestSupport
extends org.apache.camel.test.junit5.CamelTestSupport
implements io.quarkus.test.junit.QuarkusTestProfile
The
CamelTestSupport class does not work on Quarkus. This class provides a replacement, which can be used in
JVM mode. There are several differences between CamelTestSupport and this class.
- Starting and stopping
CamelContextin Camel Quarkus is generally bound to starting and stopping the application and this holds also when testing. - Starting and stopping the application under test (and thus also
CamelContextis under full control of Quarkus JUnit Extension. It prefers keeping the application up and running unless it is told to do otherwise. - Hence normally the application under test is started only once for all test classes of the given Maven/Gradle module.
- To force Quarkus JUnit Extension to restart the application (and thus also `CamelContext`) for a given test
class, you need to assign a unique
@io.quarkus.test.junit.TestProfileto that class. Check the Quarkus documentation for how you can do that. (Note that QuarkusTestResource has a similar effect.) - Camel Quarkus executes the production of beans during the build phase. Because all the tests are
build together, exclusion behavior is implemented into
CamelQuarkusTestSupport. If a producer of the specific type and name is used in one tests, the instance will be the same for the rest of the tests. - JUnit Jupiter callbacks
BeforeEachCallback,AfterEachCallback,AfterAllCallback,BeforeAllCallback,BeforeTestExecutionCallbackandAfterTestExecutionCallback) might not work correctly. See the documentation. MethodsafterAll,afterEach,afterTestExecution,beforeAllandbeforeEachare not executed anymore. You should usedoAfterAll,doAfterConstruct,doAfterEach,doBeforeEachanddoBeforeAllinstead of them.
-
嵌套类概要
从接口继承的嵌套类/接口 io.quarkus.test.junit.QuarkusTestProfile
io.quarkus.test.junit.QuarkusTestProfile.TestResourceEntry -
字段概要
字段从类继承的字段 org.apache.camel.test.junit5.CamelTestSupport
camelContextService, camelTestSupportExtension, consumer, extra, fluentTemplate, ROUTE_COVERAGE_ENABLED, template -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明final voidafterAll(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing.final voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing.final voidafterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing All necessary tasks are performed inBeforeEachCallback.beforeEach(QuarkusTestMethodContext)UsedoAfterEach(QuarkusTestMethodContext)instead of this method.final voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing.final voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing.protected voidbindToRegistry(org.apache.camel.spi.Registry registry) The same functionality asCamelTestSupport.bindToRegistry(Registry).org.apache.camel.CamelContextcontext()The same functionality asCamelTestSupport.context().protected org.apache.camel.CamelContextFeel free to override this method for the sake of customizing the instance returned by this implementation.protected final org.apache.camel.spi.RegistryThis method is not called on Camel Quarkus because the `CamelRegistry` is created and owned by Quarkus CDI container.protected voiddoAfterAll(io.quarkus.test.junit.callback.QuarkusTestContext context) Replacement ofafterAll(ExtensionContext)called fromAfterAllCallback.afterAll(QuarkusTestContext)protected voidReplacement ofbeforeAll(ExtensionContext)called fromAfterConstructCallback.afterConstruct(Object)Execution differs in case of @TestInstance(TestInstance.Lifecycle.PER_METHOD) in which case callback is called before each test (instead ofbeforeAll(ExtensionContext)).protected voiddoAfterEach(io.quarkus.test.junit.callback.QuarkusTestMethodContext context) Replacement ofafterEach(ExtensionContext)called fromAfterEachCallback.afterEach(QuarkusTestMethodContext)protected voiddoBeforeEach(io.quarkus.test.junit.callback.QuarkusTestMethodContext context) Replacement ofbeforeEach(ExtensionContext)called fromBeforeEachCallback.beforeEach(QuarkusTestMethodContext)protected voidStrategy to perform any post setup afterCamelContextis createdprotected voidStrategy to perform any pre setup, beforeCamelContextis createdprotected final voidAllows running of the CamelTestSupport child in the Quarkus application.protected final voiddoStopCamelContext(org.apache.camel.CamelContext context, org.apache.camel.Service camelContextService) Internal disablement of the context stop functionality.(专用程序包) voidinternalAfterAll(io.quarkus.test.junit.callback.QuarkusTestContext context, org.junit.jupiter.api.extension.ExtensionContext extensionContext) (专用程序包) voidinternalBeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) (专用程序包) voidinternalBeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) booleanOverride when using advice with and return true.protected voidThe same functionality asCamelTestSupport.postProcessTest().voidsetUp()MethodCamelTestSupport.setUp()is triggered via annotationBeforeEach.protected final voidThis method does nothing.protected voidHelper method to start routeDefinitions (to be used with `adviceWith`).protected voidThis method stops the Camel context.voidtearDown()MethodCamelTestSupport.tearDown()is triggered via annotationAfterEach.从类继承的方法 org.apache.camel.test.junit5.CamelTestSupport
applyCamelPostProcessor, assertExpression, assertPredicate, assertResolveLanguage, assertValidContext, beforeTestExecution, camelContextService, cleanupResources, consumer, createExchangeWithBody, createRouteBuilder, createRouteBuilders, debugAfter, debugBefore, disableJMX, doPostTearDown, doSetUp, doSpringBootCheck, enableJMX, fluentTemplate, getCamelContextService, getCurrentTestName, getMandatoryEndpoint, getMandatoryEndpoint, getMockEndpoint, getMockEndpoint, getRouteFilterExcludePattern, getRouteFilterIncludePattern, getShutdownTimeout, hasClassAnnotation, ignoreMissingLocationWithPropertiesComponent, isCreateCamelContextPerClass, isDumpRouteCoverage, isMockEndpoints, isMockEndpointsAndSkip, isUseDebugger, isUseRouteBuilder, replaceRouteFromWith, resolveMandatoryEndpoint, resolveMandatoryEndpoint, sendBodies, sendBody, sendBody, setCamelContextService, setupResources, setUseRouteBuilder, template, timeTaken, useJmx, useOverridePropertiesWithPropertiesComponent从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.quarkus.test.junit.QuarkusTestProfile
commandLineParameters, disableApplicationLifecycleObservers, disableGlobalTestResources, getConfigOverrides, getConfigProfile, getEnabledAlternatives, runMainMethod, tags, testResources
-
字段详细资料
-
context
@Inject protected org.apache.camel.CamelContext context -
createdRoutes
-
-
构造器详细资料
-
CamelQuarkusTestSupport
public CamelQuarkusTestSupport()
-
-
方法详细资料
-
doAfterAll
protected void doAfterAll(io.quarkus.test.junit.callback.QuarkusTestContext context) throws Exception Replacement ofafterAll(ExtensionContext)called fromAfterAllCallback.afterAll(QuarkusTestContext)- 抛出:
Exception
-
doAfterEach
protected void doAfterEach(io.quarkus.test.junit.callback.QuarkusTestMethodContext context) throws Exception Replacement ofafterEach(ExtensionContext)called fromAfterEachCallback.afterEach(QuarkusTestMethodContext)- 抛出:
Exception
-
doAfterConstruct
Replacement ofbeforeAll(ExtensionContext)called fromAfterConstructCallback.afterConstruct(Object)Execution differs in case of @TestInstance(TestInstance.Lifecycle.PER_METHOD) in which case callback is called before each test (instead ofbeforeAll(ExtensionContext)).- 抛出:
Exception
-
doBeforeEach
protected void doBeforeEach(io.quarkus.test.junit.callback.QuarkusTestMethodContext context) throws Exception Replacement ofbeforeEach(ExtensionContext)called fromBeforeEachCallback.beforeEach(QuarkusTestMethodContext)- 抛出:
Exception
-
createCamelContext
Feel free to override this method for the sake of customizing the instance returned by this implementation. Do not create your own CamelContext instance, because there needs to exist just a single instance owned by Quarkus CDI container. There are checks in place that will make your tests fail if you do otherwise.- 覆盖:
createCamelContext在类中org.apache.camel.test.junit5.CamelTestSupport- 返回:
- The context from Quarkus CDI container
- 抛出:
Exception- Overridden method has to throw the same Exception as superclass.
-
bindToRegistry
The same functionality asCamelTestSupport.bindToRegistry(Registry).- 覆盖:
bindToRegistry在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
postProcessTest
The same functionality asCamelTestSupport.postProcessTest().- 覆盖:
postProcessTest在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
context
public org.apache.camel.CamelContext context()The same functionality asCamelTestSupport.context().- 覆盖:
context在类中org.apache.camel.test.junit5.CamelTestSupport
-
createCamelRegistry
protected final org.apache.camel.spi.Registry createCamelRegistry()This method is not called on Camel Quarkus because the `CamelRegistry` is created and owned by Quarkus CDI container. If you need to customize the registry upon creation, you may want to overridecreateCamelContext()in the following way:@Override protected CamelContext createCamelContext() throws Exception { CamelContext ctx = super.createCamelContext(); Registry registry = ctx.getRegistry(); // do something with the registry... return ctx; }- 覆盖:
createCamelRegistry在类中org.apache.camel.test.junit5.CamelTestSupport- 返回:
- Never returns any result. UnsupportedOperationException is thrown instead.
-
beforeAll
public final void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing. All necessary tasks are performed inBeforeEachCallback.beforeEach(QuarkusTestMethodContext)UsedoAfterConstruct()instead of this method.- 指定者:
beforeAll在接口中org.junit.jupiter.api.extension.BeforeAllCallback- 覆盖:
beforeAll在类中org.apache.camel.test.junit5.CamelTestSupport
-
beforeEach
public final void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception This method does nothing. All tasks are performed inBeforeEachCallback.beforeEach(QuarkusTestMethodContext)UsedoBeforeEach(QuarkusTestMethodContext)instead of this method.- 指定者:
beforeEach在接口中org.junit.jupiter.api.extension.BeforeEachCallback- 覆盖:
beforeEach在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
afterAll
public final void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) This method does nothing. All necessary tasks are performed inBeforeEachCallback.beforeEach(QuarkusTestMethodContext)UsedoAfterAll(QuarkusTestContext)instead of this method.- 指定者:
afterAll在接口中org.junit.jupiter.api.extension.AfterAllCallback- 覆盖:
afterAll在类中org.apache.camel.test.junit5.CamelTestSupport
-
afterEach
public final void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception This method does nothing. All necessary tasks are performed inBeforeEachCallback.beforeEach(QuarkusTestMethodContext)UsedoAfterEach(QuarkusTestMethodContext)instead of this method.- 指定者:
afterEach在接口中org.junit.jupiter.api.extension.AfterEachCallback- 覆盖:
afterEach在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
afterTestExecution
public final void afterTestExecution(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception This method does nothing All necessary tasks are performed inBeforeEachCallback.beforeEach(QuarkusTestMethodContext)UsedoAfterEach(QuarkusTestMethodContext)instead of this method.- 指定者:
afterTestExecution在接口中org.junit.jupiter.api.extension.AfterTestExecutionCallback- 覆盖:
afterTestExecution在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
setUp
MethodCamelTestSupport.setUp()is triggered via annotationBeforeEach. Its execution is disabled (by using overriding method without any annotation) and is executed fromBeforeEachCallback- 覆盖:
setUp在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
tearDown
MethodCamelTestSupport.tearDown()is triggered via annotationAfterEach. Its execution is disabled (by using overriding method without any annotation) and is executed fromAfterEachCallback- 覆盖:
tearDown在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
stopCamelContext
This method stops the Camel context. Be aware that on of the limitation that Quarkus brings is that context can not be started (lifecycle f the context is bound to the application) .- 覆盖:
stopCamelContext在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
doQuarkusCheck
protected final void doQuarkusCheck()Allows running of the CamelTestSupport child in the Quarkus application. Method is not intended to be overridden.- 覆盖:
doQuarkusCheck在类中org.apache.camel.test.junit5.CamelTestSupport
-
internalAfterAll
void internalAfterAll(io.quarkus.test.junit.callback.QuarkusTestContext context, org.junit.jupiter.api.extension.ExtensionContext extensionContext) -
internalBeforeAll
void internalBeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) -
internalBeforeEach
- 抛出:
Exception
-
doPreSetup
Strategy to perform any pre setup, beforeCamelContextis createdBe aware that difference in lifecycle with Quarkus may require a special behavior. If this method is overridden, super.doPreSetup() has to be called.
- 覆盖:
doPreSetup在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
doPostSetup
Strategy to perform any post setup afterCamelContextis createdBe aware that difference in lifecycle with Quarkus may require a special behavior. If this method is overridden, super.doPostSetup() has to be called.
- 覆盖:
doPostSetup在类中org.apache.camel.test.junit5.CamelTestSupport- 抛出:
Exception
-
doStopCamelContext
protected final void doStopCamelContext(org.apache.camel.CamelContext context, org.apache.camel.Service camelContextService) Internal disablement of the context stop functionality.- 覆盖:
doStopCamelContext在类中org.apache.camel.test.junit5.CamelTestSupport
-
startCamelContext
protected final void startCamelContext()This method does nothing. The context starts together with Quarkus engine.- 覆盖:
startCamelContext在类中org.apache.camel.test.junit5.CamelTestSupport
-
isUseAdviceWith
public boolean isUseAdviceWith()Override when using advice with and return true. This helps knowing advice with is to be used. Important: Its important to execute methodstartRouteDefinitions()} manually from the unit test after you are done doing all the advice with.- 覆盖:
isUseAdviceWith在类中org.apache.camel.test.junit5.CamelTestSupport- 返回:
- true if you use advice with in your unit tests.
-
startRouteDefinitions
Helper method to start routeDefinitions (to be used with `adviceWith`).- 抛出:
Exception
-