C
- The extension contextpublic abstract class AbstractMicronautExtension<C> extends java.lang.Object implements TestTransactionInterceptor
Modifier and Type | Field and Description |
---|---|
protected io.micronaut.context.ApplicationContext |
applicationContext |
static java.lang.String |
DISABLED_MESSAGE |
protected io.micronaut.runtime.EmbeddedApplication |
embeddedApplication |
static java.lang.String |
MISCONFIGURED_MESSAGE |
protected java.util.Map<java.lang.String,java.lang.Object> |
oldValues |
protected io.micronaut.runtime.context.scope.refresh.RefreshScope |
refreshScope |
protected io.micronaut.inject.BeanDefinition<?> |
specDefinition |
protected java.util.Map<java.lang.String,java.lang.Object> |
testProperties |
Constructor and Description |
---|
AbstractMicronautExtension() |
Modifier and Type | Method and Description |
---|---|
protected void |
afterClass(C context)
Executed after the class is complete.
|
void |
afterEach(C context)
Executed after each test completes.
|
protected abstract void |
alignMocks(C context,
java.lang.Object instance) |
protected void |
beforeClass(C context,
java.lang.Class<?> testClass,
MicronautTest testAnnotation)
Executed before tests within a class are run.
|
protected void |
beforeEach(C context,
java.lang.Object testInstance,
java.lang.reflect.AnnotatedElement method,
java.util.List<io.micronaut.context.annotation.Property> propertyAnnotations)
To be called by the different implementations before each test method.
|
void |
begin()
Begin the transaction.
|
void |
commit()
Commit the transaction.
|
protected boolean |
isTestSuiteBeanPresent(java.lang.Class<?> requiredTestClass) |
protected abstract void |
resolveTestProperties(C context,
MicronautTest testAnnotation,
java.util.Map<java.lang.String,java.lang.Object> testProperties)
Resolves any test properties.
|
void |
rollback()
Rollback the transaction.
|
protected void |
startApplicationContext()
Starts the application context.
|
public static final java.lang.String DISABLED_MESSAGE
public static final java.lang.String MISCONFIGURED_MESSAGE
protected io.micronaut.context.ApplicationContext applicationContext
protected io.micronaut.runtime.EmbeddedApplication embeddedApplication
protected io.micronaut.runtime.context.scope.refresh.RefreshScope refreshScope
protected io.micronaut.inject.BeanDefinition<?> specDefinition
protected java.util.Map<java.lang.String,java.lang.Object> testProperties
protected java.util.Map<java.lang.String,java.lang.Object> oldValues
public void begin()
TestTransactionInterceptor
begin
in interface TestTransactionInterceptor
public void commit()
TestTransactionInterceptor
commit
in interface TestTransactionInterceptor
public void rollback()
TestTransactionInterceptor
rollback
in interface TestTransactionInterceptor
protected void beforeClass(C context, java.lang.Class<?> testClass, @Nullable MicronautTest testAnnotation)
context
- The test contexttestClass
- The test classtestAnnotation
- The test annotationprotected abstract void resolveTestProperties(C context, MicronautTest testAnnotation, java.util.Map<java.lang.String,java.lang.Object> testProperties)
context
- The test contexttestAnnotation
- The test annotationtestProperties
- The test propertiesprotected void beforeEach(C context, @Nullable java.lang.Object testInstance, @Nullable java.lang.reflect.AnnotatedElement method, java.util.List<io.micronaut.context.annotation.Property> propertyAnnotations)
context
- The test contexttestInstance
- The test instancemethod
- The test methodpropertyAnnotations
- The @Property
annotations found in the test method, if anyprotected void afterClass(C context)
context
- the contextpublic void afterEach(C context)
context
- The contextprotected void startApplicationContext()
protected boolean isTestSuiteBeanPresent(java.lang.Class<?> requiredTestClass)
requiredTestClass
- The test classprotected abstract void alignMocks(C context, java.lang.Object instance)
context
- The contextinstance
- The mock instance to inject