public class GreenMailExtension extends GreenMailProxy implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback
@RegisterExtension Junit5 mechanism and made variable static.static keyword annotate test class with @TestInstance(TestInstance.Lifecycle.PER_CLASS).
By default you get a new GreenMail instance per method which works with BeforeEach.
You can use withPerMethodLifecycle(boolean) to control this behavior - eg to speed
up at the cost of isolation using only BeforeAll
@RegisterExtension
GreenMailExtension greenMail = new GreenMailExtension(ServerSetupTest.SMTP_IMAP)
.withPerMethodLifecycle(false);
@BeforeAll
public void setup() { ... }
RegisterExtension,
TestInstance| Constructor and Description |
|---|
GreenMailExtension()
Initialize with all server setups.
|
GreenMailExtension(ServerSetup serverSetup)
Initialize with single server setups.
|
GreenMailExtension(ServerSetup[] serverSetups)
Initialize with multiple server setups.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterAll(ExtensionContext context) |
void |
afterEach(ExtensionContext context) |
void |
beforeAll(ExtensionContext context) |
void |
beforeEach(ExtensionContext context) |
protected GreenMail |
getGreenMail() |
boolean |
isRunning() |
GreenMailExtension |
withConfiguration(GreenMailConfiguration config) |
GreenMailExtension |
withPerMethodLifecycle(boolean perMethod)
Specify whether GreenMail should be set up and torn down before and after
each method or before and after all methods.
|
getImap, getImaps, getManagers, getPop3, getPop3s, getReceivedMessages, getReceivedMessagesForDomain, getSmtp, getSmtps, getUserManager, loadEmails, purgeEmailFromAllMailboxes, reset, setQuotaSupported, setUser, setUser, setUsers, start, stop, waitForIncomingEmail, waitForIncomingEmaildoConfigurepublic GreenMailExtension(ServerSetup serverSetup)
serverSetup - Setup to usepublic GreenMailExtension()
public GreenMailExtension(ServerSetup[] serverSetups)
serverSetups - All setups to usepublic void beforeEach(ExtensionContext context)
beforeEach in interface BeforeEachCallbackpublic void afterEach(ExtensionContext context)
afterEach in interface AfterEachCallbackpublic void beforeAll(ExtensionContext context)
beforeAll in interface BeforeAllCallbackpublic void afterAll(ExtensionContext context)
afterAll in interface AfterAllCallbackpublic GreenMailExtension withPerMethodLifecycle(boolean perMethod)
perMethod - If true, per-method lifecycle is used, per-class
otherwise.protected GreenMail getGreenMail()
getGreenMail in class GreenMailProxypublic GreenMailExtension withConfiguration(GreenMailConfiguration config)
withConfiguration in interface GreenMailOperationswithConfiguration in class ConfiguredGreenMailpublic boolean isRunning()
isRunning in interface GreenMailOperationsCopyright © 2006–2023 Icegreen Technologies. All rights reserved.