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
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 testing Quarkus development mode in extensions. Intended for use by extension developers testing their extension functionality in dev mode. UnlikeQuarkusUnitTestthis will test against a clean deployment for each test method. This is necessary to prevent undefined behaviour by making sure the deployment starts in a clean state for each test.NOTE: These 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 Classes Modifier and Type Class Description (package private) static classQuarkusDevModeTest.ChangeSet
-
Field Summary
Fields Modifier and Type Field Description static OpenOption[]OPEN_OPTIONS
-
Constructor Summary
Constructors Constructor Description QuarkusDevModeTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddResourceFile(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)voidclearLogRecords()ObjectcreateTestInstance(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>getArchiveProducer()String[]getCommandLineArgs()List<LogRecord>getLogRecords()booleanisAllowFailedStart()voidmodifyFile(String file, Function<String,String> mutator)Modifies a file(package private) voidmodifyFile(String name, Function<String,String> mutator, Path path)voidmodifyResourceFile(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.QuarkusDevModeTestsetAllowFailedStart(boolean allowFailedStart)QuarkusDevModeTestsetArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> archiveProducer)QuarkusDevModeTestsetBuildSystemProperty(String name, String value)QuarkusDevModeTestsetCodeGenSources(String... codeGenSources)QuarkusDevModeTestsetCommandLineArgs(String[] commandLineArgs)QuarkusDevModeTestsetLogFileName(String logFileName)QuarkusDevModeTestsetLogRecordPredicate(Predicate<LogRecord> predicate)QuarkusDevModeTestsetTestArchiveProducer(Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> testArchiveProducer)QuarkusDevModeTestwithApplicationRoot(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> applicationRootConsumer)Customize the application root.QuarkusDevModeTestwithEmptyApplication()Use an empty application for the testQuarkusDevModeTestwithTestArchive(Consumer<org.jboss.shrinkwrap.api.spec.JavaArchive> testArchiveConsumer)Customize the application root.
-
-
-
Field Detail
-
OPEN_OPTIONS
public static final OpenOption[] OPEN_OPTIONS
-
-
Method Detail
-
getArchiveProducer
public Supplier<org.jboss.shrinkwrap.api.spec.JavaArchive> 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
public QuarkusDevModeTest 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:
applicationRootConsumer-- Returns:
- self
-
setCodeGenSources
public QuarkusDevModeTest setCodeGenSources(String... codeGenSources)
-
setLogFileName
public QuarkusDevModeTest setLogFileName(String logFileName)
-
setLogRecordPredicate
public QuarkusDevModeTest setLogRecordPredicate(Predicate<LogRecord> predicate)
-
clearLogRecords
public void clearLogRecords()
-
setBuildSystemProperty
public QuarkusDevModeTest setBuildSystemProperty(String name, String value)
-
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) throws Exception- Specified by:
beforeAllin interfaceorg.junit.jupiter.api.extension.BeforeAllCallback- Throws:
Exception
-
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) throws Exception- Specified by:
afterAllin interfaceorg.junit.jupiter.api.extension.AfterAllCallback- Throws:
Exception
-
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
public void modifySourceFile(String sourceFile, Function<String,String> mutator)
Modifies a source file.- Parameters:
sourceFile- The unqualified name of the source file to modifymutator- A function that will modify the source code
-
modifyFile
public void modifyFile(String file, Function<String,String> mutator)
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
public void modifySourceFile(Class<?> sourceFile, Function<String,String> mutator)
Modifies a source file.- Parameters:
sourceFile- The Class corresponding to the source file to modifymutator- A function that will modify the source code
-
modifyTestSourceFile
public void modifyTestSourceFile(Class<?> sourceFile, Function<String,String> mutator)
Modifies a source file.- Parameters:
sourceFile- The Class corresponding to the source file to modifymutator- A function that will modify the source code
-
addSourceFile
public void addSourceFile(Class<?> sourceFile)
Adds the source file that corresponds to the given class to the deployment- Parameters:
sourceFile-
-
getCommandLineArgs
public String[] getCommandLineArgs()
-
setCommandLineArgs
public QuarkusDevModeTest setCommandLineArgs(String[] commandLineArgs)
-
modifyResourceFile
public void modifyResourceFile(String path, Function<String,String> mutator)
Adds or overwrites a resource file with the given data. The path is an absolute path into to the deployment resources directory
-
modifyTestResourceFile
public void modifyTestResourceFile(String path, Function<String,String> mutator)
Adds or overwrites a resource file with the given data. The path is an absolute path into to the deployment resources directory
-
addResourceFile
public void addResourceFile(String path, byte[] data)
Adds or overwrites a resource file with the given data. The path is an absolute path into to the deployment resources directory
-
deleteResourceFile
public void deleteResourceFile(String path)
Deletes a resource file. The path is an absolute path into to the deployment resources directory
-
addResourceFile
public void addResourceFile(String path, String data)
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
public QuarkusDevModeTest setAllowFailedStart(boolean allowFailedStart)
-
-