public class GreenMailExtension extends GreenMailProxy 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
@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(org.junit.jupiter.api.extension.ExtensionContext context) |
void |
afterEach(org.junit.jupiter.api.extension.ExtensionContext context) |
void |
beforeAll(org.junit.jupiter.api.extension.ExtensionContext context) |
void |
beforeEach(org.junit.jupiter.api.extension.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, 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(org.junit.jupiter.api.extension.ExtensionContext context)
beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallbackpublic void afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
afterEach in interface org.junit.jupiter.api.extension.AfterEachCallbackpublic void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallbackpublic void afterAll(org.junit.jupiter.api.extension.ExtensionContext context)
afterAll in interface org.junit.jupiter.api.extension.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–2021 Icegreen Technologies. All rights reserved.