Package org.citrusframework.mail.server
Class MailServer
java.lang.Object
org.citrusframework.endpoint.AbstractEndpoint
org.citrusframework.server.AbstractServer
org.citrusframework.mail.server.MailServer
- All Implemented Interfaces:
Runnable,InitializingPhase,Named,ShutdownPhase,Endpoint,Server,ReferenceResolverAware
Mail server implementation starts new SMTP server instance and listens for incoming mail messages. Incoming mail messages
are converted to XML representation and forwarded to some message endpoint adapter (e.g. forwarding mail content to
a message channel).
By default, incoming messages are accepted automatically. When auto accept is disabled the endpoint adapter is invoked with accept request and test case has to decide accept outcome in response.
In case of incoming multipart mail messages the server is able to split the body parts into separate XML messages handled by the endpoint adapter.
- Since:
- 1.4
- Author:
- Christoph Deppisch
-
Field Summary
Fields inherited from class org.citrusframework.server.AbstractServer
DEFAULT_CHANNEL_ID_SUFFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidaddKnownUser(String email, String login, String password) Adds a new user known to this mail server.voiddeliver(jakarta.mail.internet.MimeMessage mimeMessage) Gets the Java mail properties.Gets the known users.Gets the mail message marshaller.Gets the message converter.intgetPort()Gets the server port.jakarta.mail.SessionReturn a new mail session if not already created before.com.icegreen.greenmail.util.GreenMailGets the smtp server instance.protected MessageInvokes the endpoint adapter with constructed mail message and headers.booleanUsers must authenticate properly with the server.booleanIs auto accept enabled.booleanGets the split multipart message.voidsetAuthRequired(boolean authRequired) Enable/disable the user authentication on this server.voidsetAutoAccept(boolean autoAccept) Enable/disable auto accept feature.voidsetJavaMailProperties(Properties javaMailProperties) Sets the Java mail properties.voidsetKnownUsers(List<String> knownUsers) Sets the known users.voidsetMarshaller(MailMarshaller marshaller) Sets the mail message marshaller.voidsetMessageConverter(MailMessageConverter messageConverter) Sets the message converter.voidsetPort(int port) Sets the server port.voidsetSmtpServer(com.icegreen.greenmail.util.GreenMail smtpServer) Sets the smtp server instance.voidsetSplitMultipart(boolean splitMultipart) Sets the split multipart message.protected voidshutdown()protected voidstartup()Methods inherited from class org.citrusframework.server.AbstractServer
createConsumer, createProducer, destroy, getDefaultTimeout, getEndpointAdapter, getInterceptors, getReferenceResolver, initialize, isAutoStart, isDebugLogging, isRunning, join, run, setAutoStart, setDebugLogging, setDefaultTimeout, setEndpointAdapter, setInterceptors, setReferenceResolver, setRunning, start, stopMethods inherited from class org.citrusframework.endpoint.AbstractEndpoint
getActor, getConsumerName, getName, getProducerName, setActor, setName
-
Constructor Details
-
MailServer
public MailServer()
-
-
Method Details
-
startup
protected void startup()- Specified by:
startupin classAbstractServer
-
shutdown
protected void shutdown()- Specified by:
shutdownin classAbstractServer
-
accept
-
deliver
public void deliver(jakarta.mail.internet.MimeMessage mimeMessage) -
invokeEndpointAdapter
Invokes the endpoint adapter with constructed mail message and headers. -
getEndpointConfiguration
- Specified by:
getEndpointConfigurationin interfaceEndpoint- Overrides:
getEndpointConfigurationin classAbstractServer
-
getSession
public jakarta.mail.Session getSession()Return a new mail session if not already created before. -
isAuthRequired
public boolean isAuthRequired()Users must authenticate properly with the server.- Returns:
-
setAuthRequired
public void setAuthRequired(boolean authRequired) Enable/disable the user authentication on this server.- Parameters:
authRequired-
-
isAutoAccept
public boolean isAutoAccept()Is auto accept enabled. -
setAutoAccept
public void setAutoAccept(boolean autoAccept) Enable/disable auto accept feature. -
getMarshaller
Gets the mail message marshaller. -
setMarshaller
Sets the mail message marshaller. -
getJavaMailProperties
Gets the Java mail properties. -
setJavaMailProperties
Sets the Java mail properties. -
getPort
public int getPort()Gets the server port. -
setPort
public void setPort(int port) Sets the server port. -
getSmtpServer
public com.icegreen.greenmail.util.GreenMail getSmtpServer()Gets the smtp server instance. -
setSmtpServer
public void setSmtpServer(com.icegreen.greenmail.util.GreenMail smtpServer) Sets the smtp server instance. -
isSplitMultipart
public boolean isSplitMultipart()Gets the split multipart message. -
setSplitMultipart
public void setSplitMultipart(boolean splitMultipart) Sets the split multipart message. -
getMessageConverter
Gets the message converter. -
setMessageConverter
Sets the message converter. -
getKnownUsers
Gets the known users.- Returns:
-
setKnownUsers
Sets the known users.- Parameters:
knownUsers-
-
addKnownUser
Adds a new user known to this mail server.- Parameters:
email-login-password-
-