You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2017/01/11 09:25:53 UTC
[05/50] [abbrv] james-project git commit: MAILET-115 Extract simple
init parameters methods from AbstractRedirect
MAILET-115 Extract simple init parameters methods from AbstractRedirect
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/464f6849
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/464f6849
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/464f6849
Branch: refs/heads/master
Commit: 464f6849a334e858e4d5553d8d0cac8a36c1dd55
Parents: 5e493a1
Author: Antoine Duprat <ad...@linagora.com>
Authored: Tue Sep 13 13:32:15 2016 +0200
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Jan 11 10:03:27 2017 +0700
----------------------------------------------------------------------
.../apache/james/transport/mailets/Bounce.java | 8 +-
.../james/transport/mailets/DSNBounce.java | 23 +-
.../apache/james/transport/mailets/Forward.java | 37 +--
.../transport/mailets/NotifyPostmaster.java | 13 +-
.../james/transport/mailets/NotifySender.java | 13 +-
.../james/transport/mailets/Redirect.java | 13 +-
.../mailets/redirect/AbstractRedirect.java | 331 +++----------------
.../redirect/RedirectMailetInitParameters.java | 10 +-
.../james/transport/mailets/ForwardTest.java | 38 +--
.../transport/mailets/NotifyPostmasterTest.java | 28 +-
.../transport/mailets/NotifySenderTest.java | 30 +-
.../james/transport/mailets/RedirectTest.java | 43 ---
12 files changed, 72 insertions(+), 515 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
index 89a2aa7..77780fe 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Bounce.java
@@ -51,7 +51,7 @@ import com.google.common.collect.ImmutableList;
* A notice text can be specified, and in such case will be inserted into the
* notification inline text.<br>
* If the notified message has an "error message" set, it will be inserted into
- * the notification inline text. If the <code>attachStackTrace</code> init
+ * the notification inline text. If the <code>attachError</code> init
* parameter is set to true, such error message will be attached to the
* notification message.<br>
* <p>
@@ -155,7 +155,7 @@ public class Bounce extends AbstractRedirect {
if (originalMail.getSender() == null) {
passThrough(originalMail);
} else {
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("Processing a bounce request for a message with a reverse path. The bounce will be sent to " + originalMail.getSender().toString());
}
super.service(originalMail);
@@ -163,10 +163,10 @@ public class Bounce extends AbstractRedirect {
}
private void passThrough(Mail originalMail) throws MessagingException {
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("Processing a bounce request for a message with an empty reverse-path. No bounce will be sent.");
}
- if (!getPassThrough(originalMail)) {
+ if (!getInitParameters().getPassThrough()) {
originalMail.setState(Mail.GHOST);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
index 63316a8..01b6cb4 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
@@ -130,11 +130,6 @@ public class DSNBounce extends AbstractRedirect {
}
@Override
- protected TypeCode getAttachmentType() {
- return TypeCode.from(getInitParameter("attachment", "message"));
- }
-
- @Override
protected Collection<MailAddress> getRecipients() {
return RECIPIENT_MAIL_ADDRESSES;
}
@@ -152,10 +147,10 @@ public class DSNBounce extends AbstractRedirect {
@Override
public void service(Mail originalMail) throws MessagingException {
if (originalMail.getSender() == null) {
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("Processing a bounce request for a message with an empty reverse-path. No bounce will be sent.");
}
- if (!getPassThrough(originalMail)) {
+ if (!getInitParameters().getPassThrough()) {
originalMail.setState(Mail.GHOST);
}
return;
@@ -168,7 +163,7 @@ public class DSNBounce extends AbstractRedirect {
newMail.setRemoteAddr(getRemoteAddr());
newMail.setRecipients(getSenderAsList(originalMail));
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("New mail - sender: " + newMail.getSender() + ", recipients: " + arrayToString(newMail.getRecipients().toArray()) + ", name: " + newMail.getName() + ", remoteHost: " + newMail.getRemoteHost() + ", remoteAddr: " + newMail.getRemoteAddr() + ", state: " + newMail.getState()
+ ", lastUpdated: " + newMail.getLastUpdated() + ", errorMessage: " + newMail.getErrorMessage());
}
@@ -178,12 +173,12 @@ public class DSNBounce extends AbstractRedirect {
// Set additional headers
setRecipients(newMail, getRecipients(originalMail), originalMail);
setTo(newMail, getTo(originalMail), originalMail);
- setSubjectPrefix(newMail, getSubjectPrefix(originalMail), originalMail);
+ setSubjectPrefix(newMail, getInitParameters().getSubjectPrefix(), originalMail);
newMail.getMessage().setHeader(RFC2822Headers.DATE, getDateHeader(originalMail));
setReplyTo(newMail, getReplyTo(originalMail), originalMail);
setReversePath(newMail, getReversePath(originalMail), originalMail);
setSender(newMail, getSender(originalMail), originalMail);
- setIsReply(newMail, isReply(originalMail), originalMail);
+ setIsReply(newMail, getInitParameters().isReply(), originalMail);
newMail.getMessage().saveChanges();
getMailetContext().sendMail(newMail);
@@ -191,7 +186,7 @@ public class DSNBounce extends AbstractRedirect {
newMail.dispose();
}
- if (!getPassThrough(originalMail)) {
+ if (!getInitParameters().getPassThrough()) {
originalMail.setState(Mail.GHOST);
}
}
@@ -222,7 +217,7 @@ public class DSNBounce extends AbstractRedirect {
private List<MailAddress> getSenderAsList(Mail originalMail) {
MailAddress reversePath = originalMail.getSender();
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("Processing a bounce request for a message with a reverse path. The bounce will be sent to " + reversePath);
}
@@ -244,8 +239,8 @@ public class DSNBounce extends AbstractRedirect {
multipart.addBodyPart(createTextMsg(originalMail));
multipart.addBodyPart(createDSN(originalMail));
- if (!getAttachmentType().equals(TypeCode.NONE)) {
- multipart.addBodyPart(createAttachedOriginal(originalMail, getAttachmentType()));
+ if (!getInitParameters().getAttachmentType().equals(TypeCode.NONE)) {
+ multipart.addBodyPart(createAttachedOriginal(originalMail, getInitParameters().getAttachmentType()));
}
return multipart;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
index 7dab178..e075204 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Forward.java
@@ -95,7 +95,7 @@ public class Forward extends AbstractRedirect {
@Override
protected InitParameters getInitParameters() {
- return RedirectMailetInitParameters.from(this);
+ return RedirectMailetInitParameters.from(this, Optional.of(TypeCode.NONE), Optional.<TypeCode> absent());
}
@Override
@@ -109,21 +109,6 @@ public class Forward extends AbstractRedirect {
}
@Override
- protected TypeCode getInLineType() {
- return TypeCode.UNALTERED;
- }
-
- @Override
- protected TypeCode getAttachmentType() {
- return TypeCode.NONE;
- }
-
- @Override
- protected String getMessage() {
- return "";
- }
-
- @Override
protected Collection<MailAddress> getRecipients() throws MessagingException {
ImmutableList.Builder<MailAddress> builder = ImmutableList.builder();
for (InternetAddress address : extractAddresses(getForwardTo())) {
@@ -181,24 +166,4 @@ public class Forward extends AbstractRedirect {
protected MailAddress getSender() throws MessagingException {
return null;
}
-
- @Override
- protected String getSubject() {
- return null;
- }
-
- @Override
- protected String getSubjectPrefix() {
- return null;
- }
-
- @Override
- protected boolean attachError() {
- return false;
- }
-
- @Override
- protected boolean isReply() {
- return false;
- }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
index c74b2f8..e9e2daa 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifyPostmaster.java
@@ -48,7 +48,7 @@ import com.google.common.collect.ImmutableSet;
* A notice text can be specified, and in such case will be inserted into the
* notification inline text.<br>
* If the notified message has an "error message" set, it will be inserted into
- * the notification inline text. If the <code>attachStackTrace</code> init
+ * the notification inline text. If the <code>attachError</code> init
* parameter is set to true, such error message will be attached to the
* notification message.<br>
* The notified messages are attached in their entirety (headers and content)
@@ -103,7 +103,7 @@ import com.google.common.collect.ImmutableSet;
* </code>
* </pre>
* <p>
- * <i>notice</i>, <i>sendingAddress</i> and <i>attachStackTrace</i> can be used
+ * <i>notice</i>, <i>sendingAddress</i> and <i>attachError</i> can be used
* instead of <i>message</i>, <i>sender</i> and <i>attachError</i>; such names
* are kept for backward compatibility.
* </p>
@@ -111,16 +111,14 @@ import com.google.common.collect.ImmutableSet;
public class NotifyPostmaster extends AbstractRedirect {
private static final String[] CONFIGURABLE_PARAMETERS = new String[]{
- "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "attachStackTrace", "to" };
+ "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" };
private static final List<String> ALLOWED_SPECIALS = ImmutableList.of("postmaster", "unaltered");
- private boolean attachStackTrace;
private Optional<String> to = Optional.absent();
@Override
public void init(MailetConfig mailetConfig) throws MessagingException {
super.init(mailetConfig);
- attachStackTrace = getInitParameter("attachStackTrace", false);
to = Optional.fromNullable(getInitParameter("to"));
}
@@ -163,9 +161,4 @@ public class NotifyPostmaster extends AbstractRedirect {
return new InternetAddress[] { getMailetContext().getPostmaster().toInternetAddress() };
}
- @Override
- protected boolean attachError() throws MessagingException {
- return attachStackTrace || super.attachError();
- }
-
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
index e1857f9..34fe6f5 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/NotifySender.java
@@ -50,7 +50,7 @@ import com.google.common.collect.ImmutableSet;
* A notice text can be specified, and in such case will be inserted into the
* notification inline text.<br>
* If the notified message has an "error message" set, it will be inserted into
- * the notification inline text. If the <code>attachStackTrace</code> init
+ * the notification inline text. If the <code>attachError</code> init
* parameter is set to true, such error message will be attached to the
* notification message.<br>
* The notified messages are attached in their entirety (headers and content)
@@ -104,7 +104,7 @@ import com.google.common.collect.ImmutableSet;
* </code>
* </pre>
* <p>
- * <i>notice</i>, <i>sendingAddress</i> and <i>attachStackTrace</i> can be used
+ * <i>notice</i>, <i>sendingAddress</i> and <i>attachError</i> can be used
* instead of <i>message</i>, <i>sender</i> and <i>attachError</i>; such names
* are kept for backward compatibility.
* </p>
@@ -112,17 +112,15 @@ import com.google.common.collect.ImmutableSet;
public class NotifySender extends AbstractRedirect {
private static final String[] CONFIGURABLE_PARAMETERS = new String[]{
- "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "attachStackTrace", "to" };
+ "debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to" };
private static final Set<MailAddress> RECIPIENT_MAIL_ADDRESSES = ImmutableSet.of(SpecialAddress.SENDER);
private static final List<String> ALLOWED_SPECIALS = ImmutableList.of("sender", "unaltered", "from");
- private boolean attachStackTrace;
private Optional<String> to = Optional.absent();
@Override
public void init(MailetConfig mailetConfig) throws MessagingException {
super.init(mailetConfig);
- attachStackTrace = getInitParameter("attachStackTrace", false);
to = Optional.fromNullable(getInitParameter("to"));
}
@@ -164,9 +162,4 @@ public class NotifySender extends AbstractRedirect {
}
return new InternetAddress[] { SpecialAddress.SENDER.toInternetAddress() };
}
-
- @Override
- protected boolean attachError() throws MessagingException {
- return attachStackTrace || super.attachError();
- }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
index 964e54f..ae1e8e1 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/Redirect.java
@@ -33,6 +33,7 @@ import org.apache.james.transport.mailets.redirect.TypeCode;
import org.apache.mailet.Mail;
import org.apache.mailet.MailAddress;
+import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
@@ -301,7 +302,7 @@ public class Redirect extends AbstractRedirect {
@Override
protected InitParameters getInitParameters() {
- return RedirectMailetInitParameters.from(this);
+ return RedirectMailetInitParameters.from(this, Optional.<TypeCode> absent(), Optional.of(TypeCode.BODY));
}
@Override
@@ -315,16 +316,6 @@ public class Redirect extends AbstractRedirect {
}
@Override
- protected boolean isStatic() {
- return isStatic;
- }
-
- @Override
- protected TypeCode getInLineType() {
- return TypeCode.from(getInitParameter("inline", "body"));
- }
-
- @Override
protected Collection<MailAddress> getRecipients() throws MessagingException {
String recipientsOrTo = getRecipientsOrTo();
if (recipientsOrTo == null) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java
index 8b740da..b8df05c 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/AbstractRedirect.java
@@ -162,25 +162,6 @@ public abstract class AbstractRedirect extends GenericMailet {
protected abstract String[] getAllowedInitParameters();
- protected boolean isDebug = false;
-
- protected boolean isStatic = false;
-
- private boolean passThrough = false;
- private boolean fakeDomainCheck = true;
- private TypeCode attachmentType = TypeCode.NONE;
- private TypeCode inLineType = TypeCode.BODY;
- private String messageText;
- private Collection<MailAddress> recipients;
- private MailAddress replyTo;
- private MailAddress reversePath;
- private MailAddress sender;
- private String subject;
- private String subjectPrefix;
- private InternetAddress[] apparentlyTo;
- private boolean attachError = false;
- private boolean isReply = false;
-
protected DNSService dns;
@Inject
@@ -189,156 +170,6 @@ public abstract class AbstractRedirect extends GenericMailet {
}
/**
- * <p>
- * Gets the <code>static</code> property.
- * </p>
- * <p>
- * Return true to reduce calls to getTo, getSender, getRecipients,
- * getReplyTo, getReversePath amd getMessage where these values don't change
- * (eg hard coded, or got at startup from the mailet config); return false
- * where any of these methods generate their results dynamically eg in
- * response to the message being processed, or by reference to a repository
- * of users.
- * </p>
- * <p>
- * It is now (from version 2.2) somehow obsolete, as should be always true
- * because the "good practice" is to use "getX()" methods statically, and
- * use instead "getX(Mail)" methods for dynamic situations. A false value is
- * now meaningful only for subclasses of {@link Redirect} older than version
- * 2.2 that were relying on this.
- * </p>
- * <p/>
- * <p>
- * Is a "getX()" method.
- * </p>
- *
- * @return true, as normally "getX()" methods shouls be static
- */
- protected boolean isStatic() {
- return true;
- }
-
- /**
- * Gets the <code>passThrough</code> property. Return true to allow the
- * original message to continue through the processor, false to GHOST it. Is
- * a "getX()" method.
- *
- * @return the <code>passThrough</code> init parameter, or false if missing
- */
- protected boolean getPassThrough() {
- return getInitParameters().getPassThrough();
- }
-
- /**
- * Gets the <code>passThrough</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #getPassThrough()}
- */
- protected boolean getPassThrough(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.passThrough : getPassThrough();
- }
-
- /**
- * Gets the <code>fakeDomainCheck</code> property. Return true to check if
- * the sender domain is valid. Is a "getX()" method.
- *
- * @return the <code>fakeDomainCheck</code> init parameter, or true if
- * missing
- */
- protected boolean getFakeDomainCheck() {
- return getInitParameters().getFakeDomainCheck();
- }
-
- /**
- * Gets the <code>fakeDomainCheck</code> property, built dynamically using
- * the original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #getFakeDomainCheck()}
- */
- protected boolean getFakeDomainCheck(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.fakeDomainCheck : getFakeDomainCheck();
- }
-
- /**
- * Gets the <code>inline</code> property. May return one of the following
- * values to indicate how to append the original message to build the new
- * message:
- * <ul>
- * <li><code>UNALTERED</code> : original message is the new message body</li>
- * <li><code>BODY</code> : original message body is appended to the new
- * message</li>
- * <li><code>HEADS</code> : original message headers are appended to the new
- * message</li>
- * <li><code>ALL</code> : original is appended with all headers</li>
- * <li><code>NONE</code> : original is not appended</li>
- * </ul>
- * Is a "getX()" method.
- *
- * @return the <code>inline</code> init parameter, or <code>UNALTERED</code>
- * if missing
- */
- protected TypeCode getInLineType() {
- return getInitParameters().getInLineType();
- }
-
- /**
- * Gets the <code>inline</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #getInLineType()}
- */
- protected TypeCode getInLineType(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.inLineType : getInLineType();
- }
-
- /**
- * Gets the <code>attachment</code> property. May return one of the
- * following values to indicate how to attach the original message to the
- * new message:
- * <ul>
- * <li><code>BODY</code> : original message body is attached as plain text
- * to the new message</li>
- * <li><code>HEADS</code> : original message headers are attached as plain
- * text to the new message</li>
- * <li><code>ALL</code> : original is attached as plain text with all
- * headers</li>
- * <li><code>MESSAGE</code> : original message is attached as type
- * message/rfc822, a complete mail message.</li>
- * <li><code>NONE</code> : original is not attached</li>
- * </ul>
- * Is a "getX()" method.
- *
- * @return the <code>attachment</code> init parameter, or <code>NONE</code>
- * if missing
- */
- protected TypeCode getAttachmentType() {
- return getInitParameters().getAttachmentType();
- }
-
- /**
- * Gets the <code>attachment</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #getAttachmentType()}
- */
- protected TypeCode getAttachmentType(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.attachmentType : getAttachmentType();
- }
-
- /**
- * Gets the <code>message</code> property. Returns a message to which the
- * original message can be attached/appended to build the new message. Is a
- * "getX()" method.
- *
- * @return the <code>message</code> init parameter or an empty string if
- * missing
- */
- protected String getMessage() {
- return getInitParameters().getMessage();
- }
-
- /**
* Gets the <code>message</code> property, built dynamically using the
* original Mail object. Is a "getX(Mail)" method.
*
@@ -346,9 +177,9 @@ public abstract class AbstractRedirect extends GenericMailet {
*/
protected String getMessage(Mail originalMail) throws MessagingException {
if (isNotifyMailet()) {
- return new NotifyMailetsMessage().generateMessage(getMessage(), originalMail);
+ return new NotifyMailetsMessage().generateMessage(getInitParameters().getMessage(), originalMail);
}
- return (isStatic()) ? this.messageText : getMessage();
+ return getInitParameters().getMessage();
}
/**
@@ -383,7 +214,7 @@ public abstract class AbstractRedirect extends GenericMailet {
* @return {@link #replaceMailAddresses} on {@link #getRecipients()},
*/
protected Collection<MailAddress> getRecipients(Mail originalMail) throws MessagingException {
- Collection<MailAddress> recipients = (isStatic()) ? this.recipients : getRecipients();
+ Collection<MailAddress> recipients = getRecipients();
if (recipients != null) {
if (containsOnlyUnalteredOrRecipients(recipients)) {
return null;
@@ -405,7 +236,7 @@ public abstract class AbstractRedirect extends GenericMailet {
protected void setRecipients(Mail newMail, Collection<MailAddress> recipients, Mail originalMail) {
if (recipients != null) {
newMail.setRecipients(recipients);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("recipients set to: " + arrayToString(recipients.toArray()));
}
}
@@ -447,7 +278,7 @@ public abstract class AbstractRedirect extends GenericMailet {
* @return {@link #replaceInternetAddresses} on {@link #getRecipients()},
*/
protected InternetAddress[] getTo(Mail originalMail) throws MessagingException {
- InternetAddress[] apparentlyTo = (isStatic()) ? this.apparentlyTo : getTo();
+ InternetAddress[] apparentlyTo = getTo();
if (apparentlyTo != null) {
if (containsOnlyUnalteredOrTo(apparentlyTo)) {
return null;
@@ -471,7 +302,7 @@ public abstract class AbstractRedirect extends GenericMailet {
protected void setTo(Mail newMail, InternetAddress[] to, Mail originalMail) throws MessagingException {
if (to != null) {
newMail.getMessage().setRecipients(Message.RecipientType.TO, to);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("apparentlyTo set to: " + arrayToString(to));
}
}
@@ -514,7 +345,7 @@ public abstract class AbstractRedirect extends GenericMailet {
* <code>SpecialAddress.SENDER</code> with the original mail sender
*/
protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
- MailAddress replyTo = (isStatic()) ? this.replyTo : getReplyTo();
+ MailAddress replyTo = getReplyTo();
if (replyTo != null) {
if (replyTo.equals(SpecialAddress.UNALTERED)) {
return null;
@@ -536,12 +367,12 @@ public abstract class AbstractRedirect extends GenericMailet {
if (replyTo != null) {
if (replyTo.equals(SpecialAddress.NULL)) {
newMail.getMessage().setReplyTo(null);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("replyTo set to: null");
}
} else {
newMail.getMessage().setReplyTo(new InternetAddress[] { replyTo.toInternetAddress() });
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("replyTo set to: " + replyTo);
}
}
@@ -589,7 +420,7 @@ public abstract class AbstractRedirect extends GenericMailet {
return getSender(originalMail);
}
- MailAddress reversePath = (isStatic()) ? this.reversePath : getReversePath();
+ MailAddress reversePath = getReversePath();
if (reversePath != null) {
if (isUnalteredOrReversePathOrSender(reversePath)) {
return null;
@@ -614,12 +445,12 @@ public abstract class AbstractRedirect extends GenericMailet {
if (reversePath != null) {
if (reversePath.equals(SpecialAddress.NULL)) {
newMail.setSender(null);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("reversePath set to: null");
}
} else {
newMail.setSender(reversePath);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("reversePath set to: " + reversePath);
}
}
@@ -659,7 +490,7 @@ public abstract class AbstractRedirect extends GenericMailet {
* <code>SpecialAddress.SENDER</code> if applicable with null
*/
protected MailAddress getSender(Mail originalMail) throws MessagingException {
- MailAddress sender = (isStatic()) ? this.sender : getSender();
+ MailAddress sender = getSender();
if (sender != null) {
if (isUnalteredOrSender(sender)) {
return null;
@@ -680,54 +511,13 @@ public abstract class AbstractRedirect extends GenericMailet {
if (sender != null) {
newMail.getMessage().setFrom(sender.toInternetAddress());
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("sender set to: " + sender);
}
}
}
/**
- * Gets the <code>subject</code> property. Returns a string for the new
- * message subject. Is a "getX()" method.
- *
- * @return the <code>subject</code> init parameter or null if missing
- */
- protected String getSubject() {
- return getInitParameters().getSubject();
- }
-
- /**
- * Gets the <code>subject</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #getSubject()}
- */
- protected String getSubject(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.subject : getSubject();
- }
-
- /**
- * Gets the <code>prefix</code> property. Returns a prefix for the new
- * message subject. Is a "getX()" method.
- *
- * @return the <code>prefix</code> init parameter or an empty string if
- * missing
- */
- protected String getSubjectPrefix() {
- return getInitParameters().getSubjectPrefix();
- }
-
- /**
- * Gets the <code>subjectPrefix</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #getSubjectPrefix()}
- */
- protected String getSubjectPrefix(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.subjectPrefix : getSubjectPrefix();
- }
-
- /**
* Builds the subject of <i>newMail</i> appending the subject of
* <i>originalMail</i> to <i>subjectPrefix</i>. Is a "setX(Mail, Tx, Mail)"
* method.
@@ -737,20 +527,20 @@ public abstract class AbstractRedirect extends GenericMailet {
new MimeMessageModifier(originalMail.getMessage()).addSubjectPrefix(subjectPrefix);
}
- String subject = getSubject(originalMail);
+ String subject = getInitParameters().getSubject();
if (!Strings.isNullOrEmpty(subjectPrefix) || subject != null) {
String newSubject = Strings.nullToEmpty(subject);
if (subject == null) {
newSubject = Strings.nullToEmpty(originalMail.getMessage().getSubject());
} else {
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("subject set to: " + subject);
}
}
if (subjectPrefix != null) {
newSubject = subjectPrefix + newSubject;
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("subjectPrefix set to: " + subjectPrefix);
}
}
@@ -759,50 +549,6 @@ public abstract class AbstractRedirect extends GenericMailet {
}
/**
- * Gets the <code>attachError</code> property. Returns a boolean indicating
- * whether to append a description of any error to the main body part of the
- * new message, if getInlineType does not return "UNALTERED". Is a "getX()"
- * method.
- *
- * @return the <code>attachError</code> init parameter; false if missing
- */
- protected boolean attachError() throws MessagingException {
- return getInitParameters().isAttachError();
- }
-
- /**
- * Gets the <code>attachError</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #attachError()}
- */
- protected boolean attachError(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.attachError : attachError();
- }
-
- /**
- * Gets the <code>isReply</code> property. Returns a boolean indicating
- * whether the new message must be considered a reply to the original
- * message, setting the IN_REPLY_TO header of the new message to the id of
- * the original message. Is a "getX()" method.
- *
- * @return the <code>isReply</code> init parameter; false if missing
- */
- protected boolean isReply() {
- return getInitParameters().isReply();
- }
-
- /**
- * Gets the <code>isReply</code> property, built dynamically using the
- * original Mail object. Is a "getX(Mail)" method.
- *
- * @return {@link #isReply()}
- */
- protected boolean isReply(Mail originalMail) throws MessagingException {
- return (isStatic()) ? this.isReply : isReply();
- }
-
- /**
* Sets the "In-Reply-To:" header of <i>newMail</i> to the "Message-Id:" of
* <i>originalMail</i>, if <i>isReply</i> is true.
*/
@@ -811,7 +557,7 @@ public abstract class AbstractRedirect extends GenericMailet {
String messageId = originalMail.getMessage().getMessageID();
if (messageId != null) {
newMail.getMessage().setHeader(RFC2822Headers.IN_REPLY_TO, messageId);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("IN_REPLY_TO set to: " + messageId);
}
}
@@ -825,10 +571,7 @@ public abstract class AbstractRedirect extends GenericMailet {
*/
@Override
public void init() throws MessagingException {
- isDebug = getInitParameters().isDebug();
- isStatic = getInitParameters().isStatic();
-
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("Initializing");
}
@@ -862,14 +605,14 @@ public abstract class AbstractRedirect extends GenericMailet {
setRemoteAddr(newMail);
setRemoteHost(newMail);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("New mail - sender: " + newMail.getSender() + ", recipients: " + arrayToString(newMail.getRecipients().toArray()) + ", name: " + newMail.getName() + ", remoteHost: " + newMail.getRemoteHost() + ", remoteAddr: " + newMail.getRemoteAddr() + ", state: " + newMail.getState()
+ ", lastUpdated: " + newMail.getLastUpdated() + ", errorMessage: " + newMail.getErrorMessage());
}
// Create the message
- if (!getInLineType(originalMail).equals(TypeCode.UNALTERED)) {
- if (isDebug) {
+ if (!getInitParameters().getInLineType().equals(TypeCode.UNALTERED)) {
+ if (getInitParameters().isDebug()) {
log("Alter message");
}
newMail.setMessage(new MimeMessage(Session.getDefaultInstance(System.getProperties(), null)));
@@ -880,7 +623,7 @@ public abstract class AbstractRedirect extends GenericMailet {
} else {
// if we need the original, create a copy of this message to
// redirect
- if (getPassThrough(originalMail)) {
+ if (getInitParameters().getPassThrough()) {
newMail.setMessage(new MimeMessage(originalMail.getMessage()) {
protected void updateHeaders() throws MessagingException {
if (getMessageID() == null)
@@ -891,7 +634,7 @@ public abstract class AbstractRedirect extends GenericMailet {
}
});
}
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("Message resent unaltered.");
}
keepMessageId = true;
@@ -903,7 +646,7 @@ public abstract class AbstractRedirect extends GenericMailet {
setTo(newMail, getTo(originalMail), originalMail);
- setSubjectPrefix(newMail, getSubjectPrefix(originalMail), originalMail);
+ setSubjectPrefix(newMail, getInitParameters().getSubjectPrefix(), originalMail);
if (newMail.getMessage().getHeader(RFC2822Headers.DATE) == null) {
newMail.getMessage().setHeader(RFC2822Headers.DATE, DateFormats.RFC822_DATE_FORMAT.format(new Date()));
@@ -915,7 +658,7 @@ public abstract class AbstractRedirect extends GenericMailet {
setSender(newMail, getSender(originalMail), originalMail);
- setIsReply(newMail, isReply(originalMail), originalMail);
+ setIsReply(newMail, getInitParameters().isReply(), originalMail);
newMail.getMessage().saveChanges();
newMail.removeAllAttributes();
@@ -936,7 +679,7 @@ public abstract class AbstractRedirect extends GenericMailet {
newMail.dispose();
}
- if (!getPassThrough(originalMail)) {
+ if (!getInitParameters().getPassThrough()) {
originalMail.setState(Mail.GHOST);
}
}
@@ -1008,14 +751,14 @@ public abstract class AbstractRedirect extends GenericMailet {
multipart.addBodyPart(contentPartRoot);
- if (isDebug) {
- log("attachmentType:" + getAttachmentType(originalMail));
+ if (getInitParameters().isDebug()) {
+ log("attachmentType:" + getInitParameters().getAttachmentType());
}
- if (!getAttachmentType(originalMail).equals(TypeCode.NONE)) {
+ if (!getInitParameters().getAttachmentType().equals(TypeCode.NONE)) {
multipart.addBodyPart(getAttachmentPart(originalMail, originalMessage, head));
}
- if (attachError(originalMail) && originalMail.getErrorMessage() != null) {
+ if (getInitParameters().isAttachError() && originalMail.getErrorMessage() != null) {
multipart.addBodyPart(getErrorPart(originalMail));
}
newMail.getMessage().setContent(multipart);
@@ -1035,7 +778,7 @@ public abstract class AbstractRedirect extends GenericMailet {
private MimeBodyPart getAttachmentPart(Mail originalMail, MimeMessage originalMessage, String head) throws MessagingException, Exception {
MimeBodyPart attachmentPart = new MimeBodyPart();
- switch (getAttachmentType(originalMail)) {
+ switch (getInitParameters().getAttachmentType()) {
case HEADS:
attachmentPart.setText(head);
break;
@@ -1084,11 +827,11 @@ public abstract class AbstractRedirect extends GenericMailet {
.append(LINE_BREAK);
}
- if (isDebug) {
- log("inline:" + getInLineType(originalMail));
+ if (getInitParameters().isDebug()) {
+ log("inline:" + getInitParameters().getInLineType());
}
boolean all = false;
- switch (getInLineType(originalMail)) {
+ switch (getInitParameters().getInLineType()) {
case ALL:
all = true;
case HEADS:
@@ -1138,7 +881,7 @@ public abstract class AbstractRedirect extends GenericMailet {
String messageId = originalMail.getMessage().getMessageID();
if (messageId != null) {
newMail.getMessage().setHeader(RFC2822Headers.MESSAGE_ID, messageId);
- if (isDebug) {
+ if (getInitParameters().isDebug()) {
log("MESSAGE_ID restored to: " + messageId);
}
}
@@ -1169,7 +912,7 @@ public abstract class AbstractRedirect extends GenericMailet {
*/
@SuppressWarnings("deprecation")
protected final boolean senderDomainIsValid(Mail mail) throws MessagingException {
- return !getFakeDomainCheck(mail)
+ return !getInitParameters().getFakeDomainCheck()
|| mail.getSender() == null
|| !getMailetContext().getMailServers(mail.getSender().getDomain()).isEmpty();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParameters.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParameters.java b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParameters.java
index 3bf6b60..289d481 100644
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParameters.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/redirect/RedirectMailetInitParameters.java
@@ -43,9 +43,13 @@ public class RedirectMailetInitParameters implements InitParameters {
}
private final GenericMailet mailet;
+ private final Optional<TypeCode> defaultAttachmentType;
+ private final Optional<TypeCode> defaultInLineType;
- private RedirectMailetInitParameters(GenericMailet mailet) {
+ private RedirectMailetInitParameters(GenericMailet mailet, Optional<TypeCode> defaultAttachmentType, Optional<TypeCode> defaultInLineType) {
this.mailet = mailet;
+ this.defaultAttachmentType = defaultAttachmentType;
+ this.defaultInLineType = defaultInLineType;
}
@Override
@@ -60,12 +64,12 @@ public class RedirectMailetInitParameters implements InitParameters {
@Override
public TypeCode getInLineType() {
- return TypeCode.from(mailet.getInitParameter("inline", "unaltered"));
+ return defaultInLineType.or(TypeCode.from(mailet.getInitParameter("inline", "unaltered")));
}
@Override
public TypeCode getAttachmentType() {
- return TypeCode.from(mailet.getInitParameter("attachment", "none"));
+ return defaultAttachmentType.or(TypeCode.from(mailet.getInitParameter("attachment", "none")));
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
index 683da89..658978b 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/ForwardTest.java
@@ -92,6 +92,7 @@ public class ForwardTest {
@Test
public void initShouldThrowWhenNoForwardToParameters() throws Exception {
FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
+ mailetConfig.setProperty("isStatic", "true");
expectedException.expect(MessagingException.class);
forward.init(mailetConfig);
@@ -100,6 +101,7 @@ public class ForwardTest {
@Test
public void initShouldThrowWhenUnparsableForwardToAddress() throws Exception {
FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
+ mailetConfig.setProperty("isStatic", "true");
mailetConfig.setProperty("forwardTo", "user@james@org");
expectedException.expect(MessagingException.class);
@@ -109,6 +111,7 @@ public class ForwardTest {
@Test
public void initShouldThrowWhenForwardToIsEmpty() throws Exception {
FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
+ mailetConfig.setProperty("isStatic", "true");
mailetConfig.setProperty("forwardTo", "");
expectedException.expect(MessagingException.class);
@@ -116,21 +119,6 @@ public class ForwardTest {
}
@Test
- public void getInLineTypeShouldReturnUnaltered() {
- assertThat(forward.getInLineType()).isEqualTo(TypeCode.UNALTERED);
- }
-
- @Test
- public void getAttachmentTypeShouldReturnNone() {
- assertThat(forward.getAttachmentType()).isEqualTo(TypeCode.NONE);
- }
-
- @Test
- public void getMessageShouldReturnEmptyString() {
- assertThat(forward.getMessage()).isEmpty();
- }
-
- @Test
public void getToShouldReturnNull() throws Exception {
assertThat(forward.getTo()).isNull();
}
@@ -151,26 +139,6 @@ public class ForwardTest {
}
@Test
- public void getSubjectShouldReturnNull() throws Exception {
- assertThat(forward.getSubject()).isNull();
- }
-
- @Test
- public void getSubjectPrefixShouldReturnNull() throws Exception {
- assertThat(forward.getSubjectPrefix()).isNull();
- }
-
- @Test
- public void attachErrorShouldReturnFalse() throws Exception {
- assertThat(forward.attachError()).isFalse();
- }
-
- @Test
- public void isReplyShouldReturnFalse() throws Exception {
- assertThat(forward.isReply()).isFalse();
- }
-
- @Test
public void getRecipientsShouldReturnRecipientsWhenForwardtoParameters() throws Exception {
FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
mailetConfig.setProperty("forwardto",
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
index e86287d..e0db8d8 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifyPostmasterTest.java
@@ -68,7 +68,7 @@ public class NotifyPostmasterTest {
@Test
public void getAllowedInitParametersShouldReturnTheParameters() {
- assertThat(notifyPostmaster.getAllowedInitParameters()).containsOnly("debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "attachStackTrace", "to");
+ assertThat(notifyPostmaster.getAllowedInitParameters()).containsOnly("debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to");
}
@Test
@@ -122,30 +122,4 @@ public class NotifyPostmasterTest {
assertThat(notifyPostmaster.getTo()).containsOnly(postmaster.toInternetAddress());
}
-
- @Test
- public void attachErrorShouldReturnFalseWhenDefaultValue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- notifyPostmaster.init(mailetConfig);
-
- assertThat(notifyPostmaster.attachError()).isFalse();
- }
-
- @Test
- public void attachErrorShouldReturnTrueWhenAttachErrorIsTrue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("attachError", "true");
- notifyPostmaster.init(mailetConfig);
-
- assertThat(notifyPostmaster.attachError()).isTrue();
- }
-
- @Test
- public void attachErrorShouldReturnTrueWhenAttachStackTraceIsTrue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("attachStackTrace", "true");
- notifyPostmaster.init(mailetConfig);
-
- assertThat(notifyPostmaster.attachError()).isTrue();
- }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
index beca795..a59196e 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/NotifySenderTest.java
@@ -68,7 +68,7 @@ public class NotifySenderTest {
@Test
public void getAllowedInitParametersShouldReturnTheParameters() {
- assertThat(notifySender.getAllowedInitParameters()).containsOnly("debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "attachStackTrace", "to");
+ assertThat(notifySender.getAllowedInitParameters()).containsOnly("debug", "passThrough", "fakeDomainCheck", "inline", "attachment", "message", "notice", "sender", "sendingAddress", "prefix", "attachError", "to");
}
@Test
@@ -131,30 +131,4 @@ public class NotifySenderTest {
assertThat(notifySender.getTo()).containsOnly(SpecialAddress.SENDER.toInternetAddress());
}
-
- @Test
- public void attachErrorShouldReturnFalseWhenDefaultValue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- notifySender.init(mailetConfig);
-
- assertThat(notifySender.attachError()).isFalse();
- }
-
- @Test
- public void attachErrorShouldReturnTrueWhenAttachErrorIsTrue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("attachError", "true");
- notifySender.init(mailetConfig);
-
- assertThat(notifySender.attachError()).isTrue();
- }
-
- @Test
- public void attachErrorShouldReturnTrueWhenAttachStackTraceIsTrue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("attachStackTrace", "true");
- notifySender.init(mailetConfig);
-
- assertThat(notifySender.attachError()).isTrue();
- }
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/464f6849/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
index e0c93e5..cce7db6 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/RedirectTest.java
@@ -112,49 +112,6 @@ public class RedirectTest {
}
@Test
- public void isStaticShouldReturnFalseWhenDefault() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- redirect.init(mailetConfig);
-
- assertThat(redirect.isStatic()).isFalse();
- }
-
- @Test
- public void isStaticShouldReturnTrueWhenInitParameterIsTrue() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("static", "true");
- redirect.init(mailetConfig);
-
- assertThat(redirect.isStatic()).isTrue();
- }
-
- @Test
- public void isStaticShouldReturnFalseWhenInitParameterIsFalse() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("static", "false");
- redirect.init(mailetConfig);
-
- assertThat(redirect.isStatic()).isFalse();
- }
-
- @Test
- public void getInLineTypeShouldReturnBodyValueWhenDefault() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- redirect.init(mailetConfig);
-
- assertThat(redirect.getInLineType()).isEqualTo(TypeCode.BODY);
- }
-
- @Test
- public void getInLineTypeShouldReturnHeadsValueWhenInlineIsEqualToHeads() throws Exception {
- FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
- mailetConfig.setProperty("inline", "heads");
- redirect.init(mailetConfig);
-
- assertThat(redirect.getInLineType()).isEqualTo(TypeCode.HEADS);
- }
-
- @Test
public void getRecipientsShouldThrowWhenUnparsableRecipientsAddress() throws Exception {
FakeMailetConfig mailetConfig = new FakeMailetConfig(MAILET_NAME, fakeMailContext);
mailetConfig.setProperty("recipients", "user@james@org");
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org