Package io.quarkus.test
Class QuarkusDevModeTest
java.lang.Object
io.quarkus.test.QuarkusDevModeTest
- 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.TestInstanceFactory,org.junit.jupiter.api.extension.TestInstantiationAwareExtension
public class QuarkusDevModeTest
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.AfterEachCallback, org.junit.jupiter.api.extension.TestInstanceFactory
A test extension for black-box testing of Quarkus development mode in extensions.
Intended for use by extension developers testing their extension functionality in dev mode.
Note that unlike QuarkusUnitTest:
- Tests run in black-box mode: the classloader of test methods does not give access to the running Quarkus application, so things like CDI will not work. You should define REST endpoints that perform the actions you want to simulate in your tests, and call those REST endpoints in your tests using e.g. RestAssured.
- Each test method will run in a clean deployment. This is necessary to prevent undefined behaviour by making sure the deployment starts in a clean state for each test.
- Tests do not run with
LaunchMode.TESTbut rather withLaunchMode.DEVELOPMENT. This is necessary to ensure dev mode is tested correctly. A side effect of this is that the tests will run on port 8080 by default instead of port 8081.
-
Nested Class Summary
Nested ClassesNested 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 TypeMethodDescriptionvoidaddResourceFile(String path, byte[] data) Adds or overwrites a resource file with the given data.voidaddResourceFile(String path, String data) Adds or overwrites a resource file with the given data encoded into UTF-8.voidaddSourceFile(Class<?> sourceFile) Adds the source file that corresponds to the given class to the deploymentvoidafterAll(org.junit.jupiter.api.extension.ExtensionContext context) voidafterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidbeforeAll(org.junit.jupiter.api.extension.ExtensionContext context) voidbeforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) voidcreateTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext factoryContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) voiddeleteResourceFile(String path) Deletes a resource file.Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> String[]booleanvoidmodifyFile(String file, Function<String, String> mutator) Modifies a file(package private) voidvoidmodifyResourceFile(String path, Function<String, String> mutator) Adds or overwrites a resource file with the given data.voidmodifySourceFile(Class<?> sourceFile, Function<String, String> mutator) Modifies a source file.voidmodifySourceFile(String sourceFile, Function<String, String> mutator) Modifies a source file.voidmodifyTestResourceFile(String path, Function<String, String> mutator) Adds or overwrites a resource file with the given data.voidmodifyTestSourceFile(Class<?> sourceFile, Function<String, String> mutator) Modifies a source file.setAllowFailedStart(boolean allowFailedStart) setArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer) setBuildSystemProperty(String name, String value) setCodeGenSources(String... codeGenSources) setCommandLineArgs(String[] commandLineArgs) setLogFileName(String logFileName) Deprecated, for removal: This API element is subject to removal in a future version.setLogRecordPredicate(Predicate<LogRecord> predicate) setTestArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> testArchiveProducer) withApplicationRoot(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> applicationRootConsumer) Customize the application root.Use an empty application for the testwithTestArchive(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> testArchiveConsumer) Customize the application root.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.TestInstantiationAwareExtension
getTestInstantiationExtensionContextScope
-
Field Details
-
OPEN_OPTIONS
-
-
Constructor Details
-
QuarkusDevModeTest
public QuarkusDevModeTest()
-
-
Method Details
-
getArchiveProducer
-
setArchiveProducer
public QuarkusDevModeTest setArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer) -
withApplicationRoot
public QuarkusDevModeTest 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
-
setTestArchiveProducer
public QuarkusDevModeTest setTestArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> testArchiveProducer) -
withTestArchive
public QuarkusDevModeTest withTestArchive(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> testArchiveConsumer) Customize the application root.- Parameters:
testArchiveConsumer-- Returns:
- self
-
setCodeGenSources
-
setLogFileName
Deprecated, for removal: This API element is subject to removal in a future version. -
setLogRecordPredicate
-
getLogRecords
-
clearLogRecords
public void clearLogRecords() -
setBuildSystemProperty
-
createTestInstance
public Object createTestInstance(org.junit.jupiter.api.extension.TestInstanceFactoryContext factoryContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws org.junit.jupiter.api.extension.TestInstantiationException - Specified by:
createTestInstancein interfaceorg.junit.jupiter.api.extension.TestInstanceFactory- Throws:
org.junit.jupiter.api.extension.TestInstantiationException
-
beforeAll
public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback
-
beforeEach
public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception - Specified by:
beforeEachin interfaceorg.junit.jupiter.api.extension.BeforeEachCallback- Throws:
Exception
-
afterAll
public void afterAll(org.junit.jupiter.api.extension.ExtensionContext context) - Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext extensionContext) throws Exception - Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-
modifySourceFile
Modifies a source file.- Parameters:
sourceFile- The unqualified name of the source file to modifymutator- A function that will modify the source code
-
modifyFile
Modifies a file- Parameters:
file- file path relative to the project's sources parent dir (`src/main` for Maven)mutator- A function that will modify the file
-
modifySourceFile
Modifies a source file.- Parameters:
sourceFile- The Class corresponding to the source file to modifymutator- A function that will modify the source code
-
modifyTestSourceFile
Modifies a source file.- Parameters:
sourceFile- The Class corresponding to the source file to modifymutator- A function that will modify the source code
-
addSourceFile
Adds the source file that corresponds to the given class to the deployment- Parameters:
sourceFile-
-
getCommandLineArgs
-
setCommandLineArgs
-
modifyFile
-
modifyResourceFile
Adds or overwrites a resource file with the given data. The path is an absolute path into to the deployment resources directory -
modifyTestResourceFile
Adds or overwrites a resource file with the given data. The path is an absolute path into to the deployment resources directory -
addResourceFile
Adds or overwrites a resource file with the given data. The path is an absolute path into to the deployment resources directory -
deleteResourceFile
Deletes a resource file. The path is an absolute path into to the deployment resources directory -
addResourceFile
Adds or overwrites a resource file with the given data encoded into UTF-8. The path is an absolute path into to the deployment resources directory -
isAllowFailedStart
public boolean isAllowFailedStart() -
setAllowFailedStart
-