Package io.quarkus.test
Class QuarkusProdModeTest
java.lang.Object
io.quarkus.test.QuarkusProdModeTest
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterAllCallback,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.TestInstantiationAwareExtension,org.junit.jupiter.api.extension.TestWatcher
public class QuarkusProdModeTest
extends Object
implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.TestWatcher, org.junit.jupiter.api.extension.InvocationInterceptor
A test extension for producing a prod-mode jar. This is meant to be used by extension authors, it's not intended for end user
consumption
-
Nested Class Summary
Nested ClassesNested 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCustomResourceEntry(Path outputPath, String classPathLocation) voidafterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) assertBuildException(Consumer<Throwable> assertException) voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext context) Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> Returns the process exit code, this can only be used ifexpectExitis true.Returns the console output from startup.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) 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) overrideConfigKey(String propertyKey, String propertyValue) Overriden configuration properties take precedence over anapplication.propertiesasset added in the testJavaArchive.setApplicationName(String applicationName) Effectively sets the quarkus.application.name property.setApplicationVersion(String applicationVersion) Effectively sets the quarkus.application.version property.setArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer) setBuildNative(boolean buildNative) Effectively sets the quarkus.packaging.type property.setCommandLineParameters(String... commandLineParameters) setExpectedException(Class<? extends Throwable> expectedException) setExpectExit(boolean expectExit) If this is true then the Quarkus application is expected to exit immediately (i.e. is a command mode app)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)setJVMArgs(List<String> jvmArgs) The complete set of JVM args to be used if the built artifact is configured to be runsetLogFileName(String logFileName) File where the running application logs its output This property effectively sets the quarkus.log.file.path runtime configuration property and will override that value if it has been set in the configuration properties of the testsetLogRecordPredicate(Predicate<LogRecord> predicate) setRun(boolean run) If set to true, the built artifact will be run before starting the testssetRuntimeProperties(Map<String, String> runtimeProperties) The runtime configuration properties to be used if the built artifact is configured to be runvoidstart()Start the Quarkus application.voidstop()Stop the Quarkus application.voidtestFailed(org.junit.jupiter.api.extension.ExtensionContext context, Throwable cause) withApplicationRoot(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> applicationRootConsumer) Customize the application root.withConfigurationResource(String resourceName) Add anapplication.propertiesasset loaded from the specified resource file in the testJavaArchive.Use an empty application for the testMethods 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
interceptAfterAllMethod, interceptAfterEachMethod, interceptDynamicTest, interceptDynamicTest, interceptTestClassConstructor, interceptTestFactoryMethod, interceptTestTemplateMethodMethods inherited from interface org.junit.jupiter.api.extension.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScopeMethods inherited from interface org.junit.jupiter.api.extension.TestWatcher
testAborted, testDisabled, testSuccessful
-
Field Details
-
BUILD_CONTEXT_BUILD_STEP_ENTRIES
- See Also:
-
BUILD_CONTEXT_BUILD_STEP_ENTRY_CONSUMES
- See Also:
-
BUILD_CONTEXT_BUILD_STEP_ENTRY_PRODUCES
- See Also:
-
BUILD_CONTEXT_CUSTOM_SOURCES_PATH_KEY
-
-
Constructor Details
-
QuarkusProdModeTest
public QuarkusProdModeTest()
-
-
Method Details
-
getArchiveProducer
-
setArchiveProducer
public QuarkusProdModeTest setArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer) -
withApplicationRoot
public QuarkusProdModeTest 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
-
addBuildChainCustomizerEntries
public QuarkusProdModeTest addBuildChainCustomizerEntries(QuarkusProdModeTest.BuildChainCustomizerEntry entry) -
addCustomResourceEntry
-
setApplicationName
Effectively sets the quarkus.application.name property. This value will override quarkus.application.name if that has been set in the configuration properties -
setApplicationVersion
Effectively sets the quarkus.application.version property. This value will override quarkus.application.version if that has been set in the configuration properties -
setBuildNative
Effectively sets the quarkus.packaging.type property. This value will override quarkus.packaging.type if that has been set in the configuration properties -
setRun
If set to true, the built artifact will be run before starting the tests -
setLogFileName
File where the running application logs its output This property effectively sets the quarkus.log.file.path runtime configuration property and will override that value if it has been set in the configuration properties of the test -
setJVMArgs
The complete set of JVM args to be used if the built artifact is configured to be run -
setRuntimeProperties
The runtime configuration properties to be used if the built artifact is configured to be run -
setLogRecordPredicate
-
setForcedDependencies
public QuarkusProdModeTest 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) -
setExpectExit
If this is true then the Quarkus application is expected to exit immediately (i.e. is a command mode app) -
assertBuildException
-
setExpectedException
-
getStartupConsoleOutput
Returns the console output from startup. IfexpectExitis true then this will contain all the console output. -
getExitCode
Returns the process exit code, this can only be used ifexpectExitis true. Null if the app is running. -
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception - Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
start
public void start()Start the Quarkus application. If the application is already started, it raises anIllegalStateExceptionexception.- Throws:
RuntimeException- when application errors at startup.IllegalStateException- if the application is already started.
-
stop
public void stop()Stop the Quarkus application. -
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
-
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
-
testFailed
- Specified by:
testFailedin interfaceorg.junit.jupiter.api.extension.TestWatcher
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception - Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback
-
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
-
overrideConfigKey
Overriden configuration properties take precedence over anapplication.propertiesasset added in the testJavaArchive.- Parameters:
propertyKey-propertyValue-- Returns:
- the test configuration
-
setCommandLineParameters
-