> {
T withSessionTimeout(@NotNull Integer sessionTimeout);
/**
- * Sets the email address validation restrictions when validating and sending emails using the current Mailer
instance.
+ * Sets the email address validator used when validating and sending emails using the current Mailer
instance.
*
- * Defaults to {@link EmailAddressCriteria#RFC_COMPLIANT} if not overridden with a ({@code null}) value.
+ * Defaults to {@link JMail#strictValidator()}.
*
- * @see EmailAddressCriteria
- * @see #clearEmailAddressCriteria()
- * @see #resetEmailAddressCriteria()
+ * @see EmailValidator
+ * @see #clearEmailValidator()
+ * @see #resetEmailValidator()
*/
- T withEmailAddressCriteria(@NotNull EnumSet emailAddressCriteria);
+ T withEmailValidator(@NotNull EmailValidator emailValidator);
/**
* Signs this all emails by default with an S/MIME signature, so the receiving client
@@ -503,12 +503,12 @@ public interface MailerGenericBuilder> {
T resetSessionTimeout();
/**
- * Resets emailAddressCriteria to {@link EmailAddressCriteria#RFC_COMPLIANT}.
+ * Resets the email validator to {@link JMail#strictValidator()}.
*
- * @see #withEmailAddressCriteria(EnumSet)
- * @see #clearEmailAddressCriteria()
+ * @see #withEmailValidator(EmailValidator)
+ * @see #clearEmailValidator()
*/
- T resetEmailAddressCriteria();
+ T resetEmailValidator();
/**
* Resets the executor services to be used back to the default, created by the Batch module if loaded, or else
@@ -623,12 +623,12 @@ public interface MailerGenericBuilder> {
T clearProxy();
/**
- * Removes all email address criteria, meaning validation won't take place.
+ * Makes the email validator null
, meaning validation won't take place.
*
- * @see #withEmailAddressCriteria(EnumSet)
- * @see #resetEmailAddressCriteria()
+ * @see #withEmailValidator(EmailValidator)
+ * @see #resetEmailValidator()
*/
- T clearEmailAddressCriteria();
+ T clearEmailValidator();
/**
* Removes S/MIME signing, so emails won't be signed by default.
@@ -703,10 +703,10 @@ public interface MailerGenericBuilder> {
Integer getSessionTimeout();
/**
- * @see #withEmailAddressCriteria(EnumSet)
+ * @see #withEmailValidator(EmailValidator)
*/
@Nullable
- EnumSet getEmailAddressCriteria();
+ EmailValidator getEmailValidator();
/**
* @see #signByDefaultWithSmime(Pkcs12Config)
diff --git a/modules/core-module/src/main/java/org/simplejavamail/api/mailer/config/EmailGovernance.java b/modules/core-module/src/main/java/org/simplejavamail/api/mailer/config/EmailGovernance.java
index 0f68041b7..e0805d4d1 100644
--- a/modules/core-module/src/main/java/org/simplejavamail/api/mailer/config/EmailGovernance.java
+++ b/modules/core-module/src/main/java/org/simplejavamail/api/mailer/config/EmailGovernance.java
@@ -1,13 +1,11 @@
package org.simplejavamail.api.mailer.config;
-import org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria;
-import org.jetbrains.annotations.NotNull;
+import com.sanctionco.jmail.EmailValidator;
import org.jetbrains.annotations.Nullable;
import org.simplejavamail.api.email.EmailPopulatingBuilder;
import org.simplejavamail.api.mailer.MailerGenericBuilder;
import java.io.InputStream;
-import java.util.EnumSet;
/**
* Governance for all emails being sent through the current {@link org.simplejavamail.api.mailer.Mailer} instance.
@@ -18,12 +16,12 @@
public interface EmailGovernance {
/**
- * @return The effective validation criteria used for email validation. Returns an empty set if no validation should be done.
- * @see MailerGenericBuilder#withEmailAddressCriteria(EnumSet)
- * @see EmailAddressCriteria
+ * @return The effective email validator used for email validation. Can be null
if no validation should be done.
+ * @see MailerGenericBuilder#withEmailValidator(EmailValidator)
+ * @see EmailValidator
*/
- @NotNull
- EnumSet getEmailAddressCriteria();
+ @Nullable
+ EmailValidator getEmailValidator();
/**
* @see EmailPopulatingBuilder#signWithSmime(Pkcs12Config)
@@ -33,4 +31,4 @@ public interface EmailGovernance {
*/
@Nullable
Pkcs12Config getPkcs12ConfigForSmimeSigning();
-}
+}
\ No newline at end of file
diff --git a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerHelper.java b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerHelper.java
index 9acc4414b..65e4b487b 100644
--- a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerHelper.java
+++ b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/MailerHelper.java
@@ -1,7 +1,6 @@
package org.simplejavamail.mailer;
-import org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria;
-import org.hazlewood.connor.bottema.emailaddress.EmailAddressValidator;
+import com.sanctionco.jmail.EmailValidator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.simplejavamail.MailException;
@@ -16,7 +15,6 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeUtility;
import java.util.Collection;
-import java.util.EnumSet;
import java.util.Map;
import static java.lang.String.format;
@@ -33,7 +31,7 @@ public class MailerHelper {
private static final Logger LOGGER = getLogger(MailerHelper.class);
@SuppressWarnings({ "SameReturnValue" })
- public static boolean validate(@NotNull final Email email, @NotNull final EnumSet emailAddressCriteria)
+ public static boolean validate(@NotNull final Email email, @Nullable final EmailValidator emailValidator)
throws MailException {
LOGGER.debug("validating email...");
@@ -47,30 +45,30 @@ public static boolean validate(@NotNull final Email email, @NotNull final EnumSe
} else if (email.isUseReturnReceiptTo() && email.getReturnReceiptTo() == null) {
throw new MailValidationException(MailValidationException.MISSING_RETURNRECEIPTTO);
} else
- if (!emailAddressCriteria.isEmpty()) {
- if (!EmailAddressValidator.isValid(email.getFromRecipient().getAddress(), emailAddressCriteria)) {
+ if (emailValidator != null) {
+ if (!emailValidator.isValid(email.getFromRecipient().getAddress())) {
throw new MailValidationException(format(MailValidationException.INVALID_SENDER, email));
}
for (final Recipient recipient : email.getRecipients()) {
- if (!EmailAddressValidator.isValid(recipient.getAddress(), emailAddressCriteria)) {
+ if (!emailValidator.isValid(recipient.getAddress())) {
throw new MailValidationException(format(MailValidationException.INVALID_RECIPIENT, email));
}
}
- if (email.getReplyToRecipient() != null && !EmailAddressValidator
- .isValid(email.getReplyToRecipient().getAddress(), emailAddressCriteria)) {
+ if (email.getReplyToRecipient() != null && !emailValidator.isValid(email.getReplyToRecipient().getAddress())) {
throw new MailValidationException(format(MailValidationException.INVALID_REPLYTO, email));
}
- if (email.getBounceToRecipient() != null && !EmailAddressValidator
- .isValid(email.getBounceToRecipient().getAddress(), emailAddressCriteria)) {
+ if (email.getBounceToRecipient() != null && !emailValidator.isValid(email.getBounceToRecipient().getAddress())) {
throw new MailValidationException(format(MailValidationException.INVALID_BOUNCETO, email));
}
- if (email.isUseDispositionNotificationTo() && !EmailAddressValidator
- .isValid(checkNonEmptyArgument(email.getDispositionNotificationTo(), "dispositionNotificationTo").getAddress(), emailAddressCriteria)) {
- throw new MailValidationException(format(MailValidationException.INVALID_DISPOSITIONNOTIFICATIONTO, email));
+ if (email.isUseDispositionNotificationTo()) {
+ if (!emailValidator.isValid(checkNonEmptyArgument(email.getDispositionNotificationTo(), "dispositionNotificationTo").getAddress())) {
+ throw new MailValidationException(format(MailValidationException.INVALID_DISPOSITIONNOTIFICATIONTO, email));
+ }
}
- if (email.isUseReturnReceiptTo() && !EmailAddressValidator
- .isValid(checkNonEmptyArgument(email.getReturnReceiptTo(), "returnReceiptTo").getAddress(), emailAddressCriteria)) {
- throw new MailValidationException(format(MailValidationException.INVALID_RETURNRECEIPTTO, email));
+ if (email.isUseReturnReceiptTo()) {
+ if (!emailValidator.isValid(checkNonEmptyArgument(email.getReturnReceiptTo(), "returnReceiptTo").getAddress())) {
+ throw new MailValidationException(format(MailValidationException.INVALID_RETURNRECEIPTTO, email));
+ }
}
}
diff --git a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/EmailGovernanceImpl.java b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/EmailGovernanceImpl.java
index aa80223f6..ae1b70312 100644
--- a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/EmailGovernanceImpl.java
+++ b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/EmailGovernanceImpl.java
@@ -1,40 +1,37 @@
package org.simplejavamail.mailer.internal;
-import org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria;
-import org.jetbrains.annotations.NotNull;
+import com.sanctionco.jmail.EmailValidator;
import org.jetbrains.annotations.Nullable;
import org.simplejavamail.api.mailer.config.EmailGovernance;
import org.simplejavamail.api.mailer.config.Pkcs12Config;
-import java.util.EnumSet;
-
/**
* @see EmailGovernance
*/
class EmailGovernanceImpl implements EmailGovernance {
- @NotNull private final EnumSet emailAddressCriteria;
+ @Nullable private final EmailValidator emailValidator;
@Nullable private final Pkcs12Config pkcs12ConfigForSmimeSigning;
- EmailGovernanceImpl(@NotNull final EnumSet emailAddressCriteria, @Nullable final Pkcs12Config pkcs12ConfigForSmimeSigning) {
- this.emailAddressCriteria = emailAddressCriteria;
+ EmailGovernanceImpl(@Nullable final EmailValidator emailValidator, @Nullable final Pkcs12Config pkcs12ConfigForSmimeSigning) {
+ this.emailValidator = emailValidator;
this.pkcs12ConfigForSmimeSigning = pkcs12ConfigForSmimeSigning;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("EmailGovernanceImpl{");
- sb.append("emailAddressCriteria=").append(emailAddressCriteria);
+ sb.append("emailValidator=").append(emailValidator);
sb.append(", pkcs12ConfigForSmimeSigning=").append(pkcs12ConfigForSmimeSigning);
sb.append('}');
return sb.toString();
}
/**
- * @see EmailGovernance#getEmailAddressCriteria()
+ * @see EmailGovernance#getEmailValidator()
*/
@Override
- public @NotNull EnumSet getEmailAddressCriteria() {
- return emailAddressCriteria;
+ public @Nullable EmailValidator getEmailValidator() {
+ return emailValidator;
}
/**
diff --git a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerGenericBuilderImpl.java b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerGenericBuilderImpl.java
index d72cd5b9e..698319321 100644
--- a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerGenericBuilderImpl.java
+++ b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerGenericBuilderImpl.java
@@ -1,7 +1,8 @@
package org.simplejavamail.mailer.internal;
+import com.sanctionco.jmail.EmailValidator;
+import com.sanctionco.jmail.JMail;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import org.hazlewood.connor.bottema.emailaddress.EmailAddressCriteria;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.simplejavamail.api.mailer.CustomMailer;
@@ -20,7 +21,6 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -100,10 +100,10 @@ abstract class MailerGenericBuilderImpl> i
private Integer sessionTimeout;
/**
- * @see MailerGenericBuilder#withEmailAddressCriteria(EnumSet)
+ * @see MailerGenericBuilder#withEmailValidator(EmailValidator)
*/
- @NotNull
- private EnumSet emailAddressCriteria;
+ @Nullable
+ private EmailValidator emailValidator;
/**
* @see MailerGenericBuilder#signByDefaultWithSmime(Pkcs12Config)
@@ -237,7 +237,7 @@ abstract class MailerGenericBuilderImpl> i
this.sslHostsToTrust = Arrays.asList(trustedHosts.split(";"));
}
- this.emailAddressCriteria = EmailAddressCriteria.RFC_COMPLIANT.clone();
+ this.emailValidator = JMail.strictValidator();
if (hasProperty(SMIME_SIGNING_KEYSTORE)) {
signByDefaultWithSmime(Pkcs12Config.builder()
@@ -277,7 +277,7 @@ private void validateProxy() {
* For internal use.
*/
EmailGovernance buildEmailGovernance() {
- return new EmailGovernanceImpl(assumeNonNull(getEmailAddressCriteria()), getPkcs12ConfigForSmimeSigning());
+ return new EmailGovernanceImpl(getEmailValidator(), getPkcs12ConfigForSmimeSigning());
}
/**
@@ -399,11 +399,11 @@ public T withSessionTimeout(@NotNull final Integer sessionTimeout) {
}
/**
- * @see MailerGenericBuilder#withEmailAddressCriteria(EnumSet)
+ * @see MailerGenericBuilder#withEmailValidator(EmailValidator)
*/
@Override
- public T withEmailAddressCriteria(@NotNull final EnumSet emailAddressCriteria) {
- this.emailAddressCriteria = emailAddressCriteria.clone();
+ public T withEmailValidator(@NotNull final EmailValidator emailEmailValidator) {
+ this.emailValidator = emailEmailValidator;
return (T) this;
}
@@ -657,11 +657,11 @@ public T resetVerifyingServerIdentity() {
}
/**
- * @see MailerGenericBuilder#resetEmailAddressCriteria()
+ * @see MailerGenericBuilder#resetEmailValidator()
*/
@Override
- public T resetEmailAddressCriteria() {
- return withEmailAddressCriteria(EmailAddressCriteria.RFC_COMPLIANT);
+ public T resetEmailValidator() {
+ return withEmailValidator(JMail.strictValidator());
}
/**
@@ -762,11 +762,12 @@ public T clearProxy() {
}
/**
- * @see MailerGenericBuilder#clearEmailAddressCriteria()
+ * @see MailerGenericBuilder#clearEmailValidator()
*/
@Override
- public T clearEmailAddressCriteria() {
- return withEmailAddressCriteria(EnumSet.noneOf(EmailAddressCriteria.class));
+ public T clearEmailValidator() {
+ this.emailValidator = null;
+ return (T) this;
}
/**
@@ -866,12 +867,12 @@ public Integer getSessionTimeout() {
}
/**
- * @see MailerGenericBuilder#getEmailAddressCriteria()
+ * @see MailerGenericBuilder#getEmailValidator()
*/
@Override
- @NotNull
- public EnumSet getEmailAddressCriteria() {
- return emailAddressCriteria;
+ @Nullable
+ public EmailValidator getEmailValidator() {
+ return emailValidator;
}
/**
diff --git a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerImpl.java b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerImpl.java
index 9b5941f7d..346f56cde 100644
--- a/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerImpl.java
+++ b/modules/simple-java-mail/src/main/java/org/simplejavamail/mailer/internal/MailerImpl.java
@@ -1,5 +1,6 @@
package org.simplejavamail.mailer.internal;
+import com.sanctionco.jmail.EmailValidator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.simplejavamail.MailException;
@@ -21,7 +22,6 @@
import org.slf4j.LoggerFactory;
import javax.mail.Session;
-import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -69,7 +69,7 @@ public class MailerImpl implements Mailer {
private final AtomicInteger smtpConnectionCounter = new AtomicInteger();
/**
- * @see org.simplejavamail.api.mailer.MailerGenericBuilder#withEmailAddressCriteria(EnumSet)
+ * @see org.simplejavamail.api.mailer.MailerGenericBuilder#withEmailValidator(EmailValidator)
*/
@NotNull
private final EmailGovernance emailGovernance;
@@ -346,7 +346,7 @@ public final AsyncResponse sendMail(final Email email, @SuppressWarnings("SamePa
@SuppressWarnings({"SameReturnValue"})
public boolean validate(@NotNull final Email email)
throws MailException {
- return MailerHelper.validate(email, emailGovernance.getEmailAddressCriteria());
+ return MailerHelper.validate(email, emailGovernance.getEmailValidator());
}
/**
diff --git a/modules/simple-java-mail/src/test/java/org/simplejavamail/config/ConfigLoaderTest.java b/modules/simple-java-mail/src/test/java/org/simplejavamail/config/ConfigLoaderTest.java
index df2a8aab5..cdff2b705 100644
--- a/modules/simple-java-mail/src/test/java/org/simplejavamail/config/ConfigLoaderTest.java
+++ b/modules/simple-java-mail/src/test/java/org/simplejavamail/config/ConfigLoaderTest.java
@@ -7,7 +7,6 @@
import testutil.ConfigLoaderTestHelper;
import java.io.ByteArrayInputStream;
-import java.util.AbstractMap;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashMap;
import java.util.Map;
@@ -64,8 +63,8 @@ public void valueOrProperty()
ConfigLoaderTestHelper.setResolvedProperties(properties);
assertThat(ConfigLoader.valueOrProperty("value", TRANSPORT_STRATEGY)).isEqualTo("value");
- assertThat(ConfigLoader.valueOrProperty(null, TRANSPORT_STRATEGY)).isEqualTo("preconfiguredValue");
- assertThat(ConfigLoader.valueOrProperty(null, SMTP_HOST)).isNull();
+ assertThat(ConfigLoader.valueOrProperty((String) null, TRANSPORT_STRATEGY)).isEqualTo("preconfiguredValue");
+ assertThat(ConfigLoader.valueOrProperty((String) null, SMTP_HOST)).isNull();
}
@Test
@@ -109,9 +108,6 @@ public void valueOrPropertyDefaultValueEmptyDefault()
@Test
public void overridefromSystemVariables() {
- Map properties = new HashMap<>();
- properties.put(TRANSPORT_STRATEGY, "preconfiguredValue");
-
assertThat(ConfigLoader.valueOrPropertyAsString("value", PROXY_USERNAME, "backup")).isEqualTo("value");
assertThat(ConfigLoader.valueOrPropertyAsString(null, PROXY_USERNAME, "backup")).isEqualTo("username proxy"); // from config file
// cannot be tested:
@@ -149,10 +145,10 @@ public void getProperty()
properties.put(DEFAULT_BCC_NAME, null);
ConfigLoaderTestHelper.setResolvedProperties(properties);
- assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isEqualTo("preconfiguredValue1");
- assertThat(ConfigLoader.getProperty(DEFAULT_FROM_ADDRESS)).isEqualTo("preconfiguredValue2");
- assertThat(ConfigLoader.getProperty(DEFAULT_BCC_NAME)).isNull();
- assertThat(ConfigLoader.getProperty(PROXY_HOST)).isNull();
+ assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isEqualTo("preconfiguredValue1");
+ assertThat(ConfigLoader.getProperty(DEFAULT_FROM_ADDRESS)).isEqualTo("preconfiguredValue2");
+ assertThat(ConfigLoader.getProperty(DEFAULT_BCC_NAME)).isNull();
+ assertThat(ConfigLoader.getProperty(PROXY_HOST)).isNull();
}
@Test
@@ -174,41 +170,41 @@ public void parsePropertyValue() {
@Test
public void loadPropertiesFromFileClassPath() {
ConfigLoader.loadProperties("simplejavamail.properties", false);
- assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
- assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isSameAs(SMTPS);
-
- assertThat(ConfigLoader.getProperty(SMTP_HOST)).isEqualTo("smtp.default.com");
- assertThat(ConfigLoader.getProperty(SMTP_PORT)).isEqualTo(25);
- assertThat(ConfigLoader.getProperty(SMTP_USERNAME)).isEqualTo("username");
- assertThat(ConfigLoader.getProperty(SMTP_PASSWORD)).isEqualTo("password");
-
- assertThat(ConfigLoader.getProperty(PROXY_HOST)).isEqualTo("proxy.default.com");
- assertThat(ConfigLoader.getProperty(PROXY_PORT)).isEqualTo(1080);
- assertThat(ConfigLoader.getProperty(PROXY_USERNAME)).isEqualTo("username proxy");
- assertThat(ConfigLoader.getProperty(PROXY_PASSWORD)).isEqualTo("password proxy");
- assertThat(ConfigLoader.getProperty(PROXY_SOCKS5BRIDGE_PORT)).isEqualTo(1081);
-
- assertThat(ConfigLoader.getProperty(DEFAULT_FROM_NAME)).isEqualTo("From Default");
- assertThat(ConfigLoader.getProperty(DEFAULT_FROM_ADDRESS)).isEqualTo("from@default.com");
- assertThat(ConfigLoader.getProperty(DEFAULT_REPLYTO_NAME)).isEqualTo("Reply-To Default");
- assertThat(ConfigLoader.getProperty(DEFAULT_REPLYTO_ADDRESS)).isEqualTo("reply-to@default.com");
- assertThat(ConfigLoader.getProperty(DEFAULT_TO_NAME)).isEqualTo("To Default");
- assertThat(ConfigLoader.getProperty(DEFAULT_TO_ADDRESS)).isEqualTo("to@default.com");
- assertThat(ConfigLoader.getProperty(DEFAULT_CC_NAME)).isEqualTo("CC Default");
- assertThat(ConfigLoader.getProperty(DEFAULT_CC_ADDRESS)).isEqualTo("cc@default.com");
- assertThat(ConfigLoader.getProperty(DEFAULT_BCC_NAME)).isEqualTo("BCC Default");
- assertThat(ConfigLoader.getProperty(DEFAULT_BCC_ADDRESS)).isEqualTo("bcc@default.com");
- assertThat(ConfigLoader.getProperty(DEFAULT_SUBJECT)).isEqualTo("Default Subject");
-
- assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEYSTORE)).isEqualTo("src/test/resources/pkcs12/smime_keystore.pkcs12");
- assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEYSTORE_PASSWORD)).isEqualTo("letmein");
- assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEY_ALIAS)).isEqualTo("smime_test_user_alias");
- assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEY_PASSWORD)).isEqualTo("letmein");
- assertThat(ConfigLoader.getProperty(SMIME_ENCRYPTION_CERTIFICATE)).isEqualTo("src/test/resources/pkcs12/smime_test_user.pem.standard.crt");
-
- assertThat(ConfigLoader.getProperty(EMBEDDEDIMAGES_DYNAMICRESOLUTION_BASE_DIR)).isEqualTo("");
- assertThat(ConfigLoader.getProperty(EMBEDDEDIMAGES_DYNAMICRESOLUTION_BASE_URL)).isEqualTo("");
- assertThat(ConfigLoader.getProperty(EMBEDDEDIMAGES_DYNAMICRESOLUTION_BASE_CLASSPATH)).isEqualTo("");
+ assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
+ assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isSameAs(SMTPS);
+
+ assertThat(ConfigLoader.getProperty(SMTP_HOST)).isEqualTo("smtp.default.com");
+ assertThat(ConfigLoader.getProperty(SMTP_PORT)).isEqualTo(25);
+ assertThat(ConfigLoader.getProperty(SMTP_USERNAME)).isEqualTo("username");
+ assertThat(ConfigLoader.getProperty(SMTP_PASSWORD)).isEqualTo("password");
+
+ assertThat(ConfigLoader.getProperty(PROXY_HOST)).isEqualTo("proxy.default.com");
+ assertThat(ConfigLoader.getProperty(PROXY_PORT)).isEqualTo(1080);
+ assertThat(ConfigLoader.getProperty(PROXY_USERNAME)).isEqualTo("username proxy");
+ assertThat(ConfigLoader.getProperty(PROXY_PASSWORD)).isEqualTo("password proxy");
+ assertThat(ConfigLoader.getProperty(PROXY_SOCKS5BRIDGE_PORT)).isEqualTo(1081);
+
+ assertThat(ConfigLoader.getProperty(DEFAULT_FROM_NAME)).isEqualTo("From Default");
+ assertThat(ConfigLoader.getProperty(DEFAULT_FROM_ADDRESS)).isEqualTo("from@default.com");
+ assertThat(ConfigLoader.getProperty(DEFAULT_REPLYTO_NAME)).isEqualTo("Reply-To Default");
+ assertThat(ConfigLoader.getProperty(DEFAULT_REPLYTO_ADDRESS)).isEqualTo("reply-to@default.com");
+ assertThat(ConfigLoader.getProperty(DEFAULT_TO_NAME)).isEqualTo("To Default");
+ assertThat(ConfigLoader.getProperty(DEFAULT_TO_ADDRESS)).isEqualTo("to@default.com");
+ assertThat(ConfigLoader.getProperty(DEFAULT_CC_NAME)).isEqualTo("CC Default");
+ assertThat(ConfigLoader.getProperty(DEFAULT_CC_ADDRESS)).isEqualTo("cc@default.com");
+ assertThat(ConfigLoader.getProperty(DEFAULT_BCC_NAME)).isEqualTo("BCC Default");
+ assertThat(ConfigLoader.getProperty(DEFAULT_BCC_ADDRESS)).isEqualTo("bcc@default.com");
+ assertThat(ConfigLoader.getProperty(DEFAULT_SUBJECT)).isEqualTo("Default Subject");
+
+ assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEYSTORE)).isEqualTo("src/test/resources/pkcs12/smime_keystore.pkcs12");
+ assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEYSTORE_PASSWORD)).isEqualTo("letmein");
+ assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEY_ALIAS)).isEqualTo("smime_test_user_alias");
+ assertThat(ConfigLoader.getProperty(SMIME_SIGNING_KEY_PASSWORD)).isEqualTo("letmein");
+ assertThat(ConfigLoader.getProperty(SMIME_ENCRYPTION_CERTIFICATE)).isEqualTo("src/test/resources/pkcs12/smime_test_user.pem.standard.crt");
+
+ assertThat(ConfigLoader.getProperty(EMBEDDEDIMAGES_DYNAMICRESOLUTION_BASE_DIR)).isEqualTo("");
+ assertThat(ConfigLoader.getProperty(EMBEDDEDIMAGES_DYNAMICRESOLUTION_BASE_URL)).isEqualTo("");
+ assertThat(ConfigLoader.getProperty(EMBEDDEDIMAGES_DYNAMICRESOLUTION_BASE_CLASSPATH)).isEqualTo("");
}
@Test
@@ -222,11 +218,11 @@ public void loadPropertiesAddingMode() {
ConfigLoader.loadProperties(new ByteArrayInputStream(s2.getBytes()), true);
// some checks from the config file
- assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
- assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isEqualTo(TransportStrategy.SMTPS);
+ assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
+ assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isEqualTo(TransportStrategy.SMTPS);
// now check if the extra properties were added
- assertThat(ConfigLoader.getProperty(DEFAULT_TO_NAME)).isEqualTo("To Default");
- assertThat(ConfigLoader.getProperty(DEFAULT_TO_ADDRESS)).isEqualTo("to@default.com");
+ assertThat(ConfigLoader.getProperty(DEFAULT_TO_NAME)).isEqualTo("To Default");
+ assertThat(ConfigLoader.getProperty(DEFAULT_TO_ADDRESS)).isEqualTo("to@default.com");
}
@Test
@@ -240,13 +236,13 @@ public void loadPropertiesFromInputStream() {
+ "simplejavamail.custom.sslfactory.class=teh_class\n";
ConfigLoader.loadProperties(new ByteArrayInputStream(s.getBytes()), false);
- assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
- assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isSameAs(SMTPS);
- assertThat(ConfigLoader.getProperty(SMTP_HOST)).isEqualTo("smtp.default.com");
- assertThat(ConfigLoader.getProperty(SMTP_PORT)).isEqualTo(25);
- assertThat(ConfigLoader.getProperty(SMTP_USERNAME)).isEqualTo("username");
- assertThat(ConfigLoader.getProperty(SMTP_PASSWORD)).isEqualTo("password");
- assertThat(ConfigLoader.getProperty(CUSTOM_SSLFACTORY_CLASS)).isEqualTo("teh_class");
+ assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
+ assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isSameAs(SMTPS);
+ assertThat(ConfigLoader.getProperty(SMTP_HOST)).isEqualTo("smtp.default.com");
+ assertThat(ConfigLoader.getProperty(SMTP_PORT)).isEqualTo(25);
+ assertThat(ConfigLoader.getProperty(SMTP_USERNAME)).isEqualTo("username");
+ assertThat(ConfigLoader.getProperty(SMTP_PASSWORD)).isEqualTo("password");
+ assertThat(ConfigLoader.getProperty(CUSTOM_SSLFACTORY_CLASS)).isEqualTo("teh_class");
}
@Test
@@ -263,13 +259,13 @@ public void loadPropertiesFromProperties() {
source.put("simplejavamail.extraproperties.b", "B");
ConfigLoader.loadProperties(source, false);
- assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
- assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isSameAs(SMTPS);
- assertThat(ConfigLoader.getProperty(SMTP_HOST)).isEqualTo("smtp.default.com");
- assertThat(ConfigLoader.getProperty(SMTP_PORT)).isEqualTo(25);
- assertThat(ConfigLoader.getProperty(SMTP_USERNAME)).isEqualTo("username");
- assertThat(ConfigLoader.getProperty(SMTP_PASSWORD)).isEqualTo("password");
- assertThat(ConfigLoader.getProperty(CUSTOM_SSLFACTORY_CLASS)).isEqualTo("teh_class");
+ assertThat(ConfigLoader.getProperty(JAVAXMAIL_DEBUG)).isEqualTo(true);
+ assertThat(ConfigLoader.getProperty(TRANSPORT_STRATEGY)).isSameAs(SMTPS);
+ assertThat(ConfigLoader.getProperty(SMTP_HOST)).isEqualTo("smtp.default.com");
+ assertThat(ConfigLoader.getProperty(SMTP_PORT)).isEqualTo(25);
+ assertThat(ConfigLoader.getProperty(SMTP_USERNAME)).isEqualTo("username");
+ assertThat(ConfigLoader.getProperty(SMTP_PASSWORD)).isEqualTo("password");
+ assertThat(ConfigLoader.getProperty(CUSTOM_SSLFACTORY_CLASS)).isEqualTo("teh_class");
assertThat(ConfigLoader.