Class AbstractQuarkusExtensionTest<S extends AbstractQuarkusExtensionTest<S>>
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.BeforeAllCallback,org.junit.jupiter.api.extension.BeforeEachCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.InvocationInterceptor,org.junit.jupiter.api.extension.ParameterResolver,org.junit.jupiter.api.extension.TestInstantiationAwareExtension
- Direct Known Subclasses:
QuarkusExtensionTest,QuarkusUnitTest
This abstract class will be dropped as soon as we get rid of the deprecated QuarkusUnitTest,
and its content incorporated into QuarkusExtensionTest.
Do NOT use or extend this class.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T>Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
org.junit.jupiter.api.extension.TestInstantiationAwareExtension.ExtensionContextScope -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractQuarkusExtensionTest(boolean useSecureConnection) -
Method Summary
Modifier and TypeMethodDescriptionaddAdditionalDependency(org.jboss.shrinkwrap.api.spec.JavaArchive archive) Add the java archive as an additional dependency.addBootstrapCustomizer(Consumer<io.quarkus.bootstrap.app.QuarkusBootstrap.Builder> consumer) An advanced option that allows tests to customize theQuarkusBootstrap.Builderthat will be used to create theCuratedApplicationaddBuildChainCustomizer(Consumer<io.quarkus.builder.BuildChainBuilder> customizer) addClassLoaderEventListener(io.quarkus.bootstrap.classloading.ClassLoaderEventListener listener) voidafterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) assertException(Consumer<Throwable> assertException) assertLogRecords(Consumer<List<LogRecord>> assertLogRecords) voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) debugBytecode(boolean debugBytecode) Controls bytecode-related debug dumping.Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> String[]voidinterceptAfterAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptBeforeAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) <T> TinterceptTestFactoryMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidinterceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) overrideConfigKey(String propertyKey, String propertyValue) Overriden configuration properties take precedence over anapplication.propertiesasset added in the testJavaArchive.overrideRuntimeConfigKey(String propertyKey, String propertyValue) resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) We don't actually have to resolve the parameter (thus the default values in the implementation) since the class instance that is passed to JUnit isn't really used.setAfterAllCustomizer(Runnable afterAllCustomizer) setAfterUndeployListener(Runnable afterUndeployListener) setAllowTestClassOutsideDeployment(boolean allowTestClassOutsideDeployment) Normally access to any test classes that are not packaged in the deployment will result in a ClassNotFoundException.setArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer) setBeforeAllCustomizer(Runnable beforeAllCustomizer) setCommandLineParameters(String... commandLineParameters) setExcludedDependencies(Set<io.quarkus.maven.dependency.ArtifactKey> excludedDependencies) Provides a convenient way to exclude dependencies from the application.setExpectedException(Class<? extends Throwable> expectedException) setExpectedException(Class<? extends Throwable> expectedException, boolean logMessage) setFlatClassPath(boolean flatClassPath) If this test should use a single ClassLoader to load all the classes.setForcedDependencies(List<io.quarkus.maven.dependency.Dependency> forcedDependencies) Provides a convenient way to either add additional dependencies to the application (if it doesn't already contain a dependency), or override a version (if the dependency already exists)setLogFileName(String logFileName) Deprecated, for removal: This API element is subject to removal in a future version.setLogRecordPredicate(Predicate<LogRecord> predicate) booleansupportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) traceCategories(String... categories) Enables trace logs for the given categories, during both build and runtime.withAdditionalDependency(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> dependencyConsumer) Add the java archive as an additional dependency.withApplicationRoot(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> applicationRootConsumer) Customize the application root.withConfiguration(String configBlock) Adds build-time configuration properties using a text block.withConfigurationResource(String resourceName) Add anapplication.propertiesasset loaded from the specified resource file in the testJavaArchive.Use an empty application for the testwithRuntimeConfiguration(String configBlock) Adds runtime configuration properties using a text block.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
interceptDynamicTest, interceptTestClassConstructorMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScope
-
Field Details
-
THE_BUILD_WAS_EXPECTED_TO_FAIL
- See Also:
-
started
boolean started
-
-
Constructor Details
-
AbstractQuarkusExtensionTest
public AbstractQuarkusExtensionTest() -
AbstractQuarkusExtensionTest
protected AbstractQuarkusExtensionTest(boolean useSecureConnection)
-
-
Method Details
-
setExpectedException
-
setExpectedException
-
assertException
-
getArchiveProducer
-
setArchiveProducer
- Parameters:
archiveProducer-- Returns:
- self
- See Also:
-
withApplicationRoot
public S withApplicationRoot(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> applicationRootConsumer) Customize the application root.- Parameters:
applicationRootConsumer-- Returns:
- self
-
withEmptyApplication
Use an empty application for the test- Returns:
- self
-
addAdditionalDependency
Add the java archive as an additional dependency. This dependency is always considered an application archive, even if it would not otherwise be one.- Parameters:
archive-- Returns:
- self
-
withAdditionalDependency
public S withAdditionalDependency(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> dependencyConsumer) Add the java archive as an additional dependency. This dependency is always considered an application archive, even if it would not otherwise be one.- Parameters:
dependencyConsumer-- Returns:
- self
-
addBuildChainCustomizer
-
addClassLoaderEventListener
public S addClassLoaderEventListener(io.quarkus.bootstrap.classloading.ClassLoaderEventListener listener) -
setLogFileName
Deprecated, for removal: This API element is subject to removal in a future version. -
setLogRecordPredicate
-
setFlatClassPath
If this test should use a single ClassLoader to load all the classes. This is sometimes necessary when testing Quarkus itself, and we want the test classes and Quarkus classes to be in the same CL. -
assertLogRecords
-
setBeforeAllCustomizer
-
setAfterAllCustomizer
-
setForcedDependencies
Provides a convenient way to either add additional dependencies to the application (if it doesn't already contain a dependency), or override a version (if the dependency already exists) -
setExcludedDependencies
Provides a convenient way to exclude dependencies from the application. Dependencies listed here will be removed from the test classpath. -
getCommandLineParameters
-
setCommandLineParameters
-
setAllowTestClassOutsideDeployment
Normally access to any test classes that are not packaged in the deployment will result in a ClassNotFoundException. If this is true then access is allowed, which can be useful when testing shutdown behaviour. -
addBootstrapCustomizer
public S addBootstrapCustomizer(Consumer<io.quarkus.bootstrap.app.QuarkusBootstrap.Builder> consumer) An advanced option that allows tests to customize theQuarkusBootstrap.Builderthat will be used to create theCuratedApplication -
interceptBeforeAllMethod
public void interceptBeforeAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptBeforeAllMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptBeforeEachMethod
public void interceptBeforeEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptBeforeEachMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptTestFactoryMethod
public <T> T interceptTestFactoryMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestFactoryMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptAfterEachMethod
public void interceptAfterEachMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptAfterEachMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptAfterAllMethod
public void interceptAfterAllMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptAfterAllMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptTestMethod
public void interceptTestMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
interceptTestTemplateMethod
public void interceptTestTemplateMethod(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<Void> invocation, org.junit.jupiter.api.extension.ReflectiveInvocationContext<Method> invocationContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Throwable - Specified by:
interceptTestTemplateMethodin interfaceorg.junit.jupiter.api.extension.InvocationInterceptor- Throws:
Throwable
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception - Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception - Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
afterEach
- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
beforeEach
- Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
getAfterUndeployListener
-
setAfterUndeployListener
-
withConfigurationResource
Add anapplication.propertiesasset loaded from the specified resource file in the testJavaArchive.If an
application.propertiesasset was already added explicitly to the archive (for instance throughResourceContainer.addAsResource(String)), this formet asset is removed and completely replaced by the one given here.Configuration properties added with
overrideConfigKey(String, String)take precedence over the properties from the specified resource file.- Parameters:
resourceName-- Returns:
- the test configuration
-
withConfiguration
Adds build-time configuration properties using a text block.- Parameters:
configBlock- text block containingkey=valueconfiguration entries
-
withRuntimeConfiguration
Adds runtime configuration properties using a text block.- Parameters:
configBlock- text block containingkey=valueconfiguration entries
-
overrideConfigKey
Overriden configuration properties take precedence over anapplication.propertiesasset added in the testJavaArchive.- Parameters:
propertyKey-propertyValue-- Returns:
- the test configuration
-
overrideRuntimeConfigKey
-
debugBytecode
Controls bytecode-related debug dumping.When enabled, each Quarkus startup will have configuration properties such as
quarkus.debug.generated-classes-dirset so that generated code gets dumped intarget/debug, within a unique subdirectory for each test execution.Look at the logs of a particular test to identify the corresponding dump directory.
- Parameters:
debugBytecode-trueif debug should be enabled- Returns:
this, for method chaining.
-
traceCategories
Enables trace logs for the given categories, during both build and runtime.- Parameters:
categories- The categories for which to enable trace logging.- Returns:
this, for method chaining.
-
supportsParameter
public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException - Specified by:
supportsParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-
resolveParameter
public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.ParameterResolutionException We don't actually have to resolve the parameter (thus the default values in the implementation) since the class instance that is passed to JUnit isn't really used. The actual test instance that is used is the one that is pulled from Arc, which of course will already have its constructor parameters properly resolved- Specified by:
resolveParameterin interfaceorg.junit.jupiter.api.extension.ParameterResolver- Throws:
org.junit.jupiter.api.extension.ParameterResolutionException
-