Package io.github.achirdlabs.rift.spring
Class RiftTestExecutionListener
java.lang.Object
org.springframework.test.context.support.AbstractTestExecutionListener
io.github.achirdlabs.rift.spring.RiftTestExecutionListener
- All Implemented Interfaces:
org.springframework.core.Ordered,org.springframework.test.context.TestExecutionListener
public final class RiftTestExecutionListener
extends org.springframework.test.context.support.AbstractTestExecutionListener
Injects
InjectRift/InjectImposter fields and drives Reset between test
methods/classes, using the RiftTestContext bean RiftContextCustomizer registers.
Contexts without @EnableRift have no such bean and are left untouched.-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeTestClass(org.springframework.test.context.TestContext testContext) Reads@EnableRift.reset()straight off the test class, rather than through theRiftTestContextbean, so a class not configured forReset.PER_CLASSnever forces the application context to load this early — beforeRiftSpringTestBase-style static initializers (e.g. publishing an admin URI system property) have had a chance to run.voidbeforeTestMethod(org.springframework.test.context.TestContext testContext) intgetOrder()voidprepareTestInstance(org.springframework.test.context.TestContext testContext) Methods inherited from class org.springframework.test.context.support.AbstractTestExecutionListener
afterTestClass, afterTestExecution, afterTestMethod, beforeTestExecution
-
Constructor Details
-
RiftTestExecutionListener
public RiftTestExecutionListener()
-
-
Method Details
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Overrides:
getOrderin classorg.springframework.test.context.support.AbstractTestExecutionListener
-
prepareTestInstance
public void prepareTestInstance(org.springframework.test.context.TestContext testContext) - Specified by:
prepareTestInstancein interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
prepareTestInstancein classorg.springframework.test.context.support.AbstractTestExecutionListener
-
beforeTestMethod
public void beforeTestMethod(org.springframework.test.context.TestContext testContext) - Specified by:
beforeTestMethodin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
beforeTestMethodin classorg.springframework.test.context.support.AbstractTestExecutionListener
-
beforeTestClass
public void beforeTestClass(org.springframework.test.context.TestContext testContext) Reads@EnableRift.reset()straight off the test class, rather than through theRiftTestContextbean, so a class not configured forReset.PER_CLASSnever forces the application context to load this early — beforeRiftSpringTestBase-style static initializers (e.g. publishing an admin URI system property) have had a chance to run. When the class genuinely isReset.PER_CLASS, the context load this triggers is still best-effort: a failure here is swallowed so it doesn't fail the class before a single test runs.- Specified by:
beforeTestClassin interfaceorg.springframework.test.context.TestExecutionListener- Overrides:
beforeTestClassin classorg.springframework.test.context.support.AbstractTestExecutionListener
-