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.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 Classes Modifier and Type Class Description static classQuarkusProdModeTest.BuildChainCustomizerEntry-
Nested classes/interfaces inherited from interface org.junit.jupiter.api.extension.InvocationInterceptor
org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static StringBUILD_CONTEXT_BUILD_STEP_ENTRIES(package private) static StringBUILD_CONTEXT_BUILD_STEP_ENTRY_CONSUMES(package private) static StringBUILD_CONTEXT_BUILD_STEP_ENTRY_PRODUCESstatic StringBUILD_CONTEXT_CUSTOM_SOURCES_PATH_KEY
-
Constructor Summary
Constructors Constructor Description QuarkusProdModeTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QuarkusProdModeTestaddBuildChainCustomizerEntries(QuarkusProdModeTest.BuildChainCustomizerEntry entry)QuarkusProdModeTestaddCustomResourceEntry(Path outputPath, String classPathLocation)voidafterAll(org.junit.jupiter.api.extension.ExtensionContext extensionContext)QuarkusProdModeTestassertBuildException(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>getArchiveProducer()IntegergetExitCode()Returns the process exit code, this can only be used ifexpectExitis true.StringgetStartupConsoleOutput()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)QuarkusProdModeTestoverrideConfigKey(String propertyKey, String propertyValue)QuarkusProdModeTestsetApplicationName(String applicationName)Effectively sets the quarkus.application.name property.QuarkusProdModeTestsetApplicationVersion(String applicationVersion)Effectively sets the quarkus.application.version property.QuarkusProdModeTestsetArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer)QuarkusProdModeTestsetBuildNative(boolean buildNative)Effectively sets the quarkus.packaging.type property.QuarkusProdModeTestsetCommandLineParameters(String... commandLineParameters)QuarkusProdModeTestsetExpectedException(Class<? extends Throwable> expectedException)QuarkusProdModeTestsetExpectExit(boolean expectExit)If this is true then the Quarkus application is expected to exit immediately (i.e.QuarkusProdModeTestsetForcedDependencies(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)QuarkusProdModeTestsetJVMArgs(List<String> jvmArgs)The complete set of JVM args to be used if the built artifact is configured to be runQuarkusProdModeTestsetLogFileName(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 testQuarkusProdModeTestsetLogRecordPredicate(Predicate<LogRecord> predicate)QuarkusProdModeTestsetRun(boolean run)If set to true, the built artifact will be run before starting the testsQuarkusProdModeTestsetRuntimeProperties(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)QuarkusProdModeTestwithApplicationRoot(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> applicationRootConsumer)Customize the application root.QuarkusProdModeTestwithConfigurationResource(String resourceName)QuarkusProdModeTestwithEmptyApplication()Use an empty application for the test-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
BUILD_CONTEXT_BUILD_STEP_ENTRIES
static final String BUILD_CONTEXT_BUILD_STEP_ENTRIES
- See Also:
- Constant Field Values
-
BUILD_CONTEXT_BUILD_STEP_ENTRY_CONSUMES
static final String BUILD_CONTEXT_BUILD_STEP_ENTRY_CONSUMES
- See Also:
- Constant Field Values
-
BUILD_CONTEXT_BUILD_STEP_ENTRY_PRODUCES
static final String BUILD_CONTEXT_BUILD_STEP_ENTRY_PRODUCES
- See Also:
- Constant Field Values
-
BUILD_CONTEXT_CUSTOM_SOURCES_PATH_KEY
public static String BUILD_CONTEXT_CUSTOM_SOURCES_PATH_KEY
-
-
Method Detail
-
getArchiveProducer
public Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> 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
public QuarkusProdModeTest withEmptyApplication()
Use an empty application for the test- Returns:
- self
-
addBuildChainCustomizerEntries
public QuarkusProdModeTest addBuildChainCustomizerEntries(QuarkusProdModeTest.BuildChainCustomizerEntry entry)
-
addCustomResourceEntry
public QuarkusProdModeTest addCustomResourceEntry(Path outputPath, String classPathLocation)
-
setApplicationName
public QuarkusProdModeTest setApplicationName(String applicationName)
Effectively sets the quarkus.application.name property. This value will override quarkus.application.name if that has been set in the configuration properties
-
setApplicationVersion
public QuarkusProdModeTest setApplicationVersion(String applicationVersion)
Effectively sets the quarkus.application.version property. This value will override quarkus.application.version if that has been set in the configuration properties
-
setBuildNative
public QuarkusProdModeTest setBuildNative(boolean buildNative)
Effectively sets the quarkus.packaging.type property. This value will override quarkus.packaging.type if that has been set in the configuration properties
-
setRun
public QuarkusProdModeTest setRun(boolean run)
If set to true, the built artifact will be run before starting the tests
-
setLogFileName
public QuarkusProdModeTest setLogFileName(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 test
-
setJVMArgs
public QuarkusProdModeTest setJVMArgs(List<String> jvmArgs)
The complete set of JVM args to be used if the built artifact is configured to be run
-
setRuntimeProperties
public QuarkusProdModeTest setRuntimeProperties(Map<String,String> runtimeProperties)
The runtime configuration properties to be used if the built artifact is configured to be run
-
setLogRecordPredicate
public QuarkusProdModeTest setLogRecordPredicate(Predicate<LogRecord> predicate)
-
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
public QuarkusProdModeTest setExpectExit(boolean expectExit)
If this is true then the Quarkus application is expected to exit immediately (i.e. is a command mode app)
-
assertBuildException
public QuarkusProdModeTest assertBuildException(Consumer<Throwable> assertException)
-
setExpectedException
public QuarkusProdModeTest setExpectedException(Class<? extends Throwable> expectedException)
-
getStartupConsoleOutput
public String getStartupConsoleOutput()
Returns the console output from startup. IfexpectExitis true then this will contain all the console output.
-
getExitCode
public Integer 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
public void testFailed(org.junit.jupiter.api.extension.ExtensionContext context, Throwable cause)- 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
public QuarkusProdModeTest withConfigurationResource(String resourceName)
-
overrideConfigKey
public QuarkusProdModeTest overrideConfigKey(String propertyKey, String propertyValue)
-
setCommandLineParameters
public QuarkusProdModeTest setCommandLineParameters(String... commandLineParameters)
-
-