diff --git a/java/com.sap.sse.mail.replication.test/.classpath b/java/com.sap.sse.mail.replication.test/.classpath
new file mode 100755
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/java/com.sap.sse.mail.replication.test/.project b/java/com.sap.sse.mail.replication.test/.project
new file mode 100755
index 00000000000..51fa2fe50fb
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/.project
@@ -0,0 +1,28 @@
+
+
+ com.sap.sse.mail.replication.test
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/java/com.sap.sse.mail.replication.test/.settings/org.eclipse.jdt.core.prefs b/java/com.sap.sse.mail.replication.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 00000000000..0c68a61dca8
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/java/com.sap.sse.mail.replication.test/.settings/org.eclipse.pde.core.prefs b/java/com.sap.sse.mail.replication.test/.settings/org.eclipse.pde.core.prefs
new file mode 100755
index 00000000000..f29e940a005
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/java/com.sap.sse.mail.replication.test/META-INF/MANIFEST.MF b/java/com.sap.sse.mail.replication.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..29aa5418f08
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/META-INF/MANIFEST.MF
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test
+Bundle-SymbolicName: com.sap.sse.mail.replication.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: SAP
+Fragment-Host: com.sap.sse.mail
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: org.junit4;bundle-version="4.8.2",
+ com.rabbitmq.client,
+ com.sap.sse.replication.testsupport
diff --git a/java/com.sap.sse.mail.replication.test/build.properties b/java/com.sap.sse.mail.replication.test/build.properties
new file mode 100755
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/java/com.sap.sse.mail.replication.test/pom.xml b/java/com.sap.sse.mail.replication.test/pom.xml
new file mode 100755
index 00000000000..eb287b53335
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.test/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+
+ root
+ com.sap.sailing
+ 1.0.0-SNAPSHOT
+
+ com.sap.sse.mail.replication.test
+ eclipse-plugin
+
diff --git a/java/com.sap.sse.mail.replication.testsupport/.classpath b/java/com.sap.sse.mail.replication.testsupport/.classpath
new file mode 100755
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/java/com.sap.sse.mail.replication.testsupport/.project b/java/com.sap.sse.mail.replication.testsupport/.project
new file mode 100755
index 00000000000..1d1e9965612
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/.project
@@ -0,0 +1,28 @@
+
+
+ com.sap.sse.mail.replication.testsupport
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/java/com.sap.sse.mail.replication.testsupport/.settings/org.eclipse.jdt.core.prefs b/java/com.sap.sse.mail.replication.testsupport/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 00000000000..0c68a61dca8
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/java/com.sap.sse.mail.replication.testsupport/.settings/org.eclipse.pde.core.prefs b/java/com.sap.sse.mail.replication.testsupport/.settings/org.eclipse.pde.core.prefs
new file mode 100755
index 00000000000..f29e940a005
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/java/com.sap.sse.mail.replication.testsupport/META-INF/MANIFEST.MF b/java/com.sap.sse.mail.replication.testsupport/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..84cf686c18a
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Test
+Bundle-SymbolicName: com.sap.sse.mail.replication.testsupport
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: SAP
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Require-Bundle: com.sap.sse.replication,
+ com.sap.sse.replication.testsupport,
+ com.sap.sse.mail,
+ com.sap.sse,
+ com.sap.sse.common,
+ org.hamcrest;bundle-version="1.1.0",
+ org.junit4;bundle-version="4.8.2",
+ org.mockito.mockito-core;bundle-version="1.10.14",
+ com.sun.mail.javax.mail;bundle-version="1.4.5"
+Export-Package: com.sap.sse.mail.replication.testsupport
diff --git a/java/com.sap.sse.mail.replication.testsupport/build.properties b/java/com.sap.sse.mail.replication.testsupport/build.properties
new file mode 100755
index 00000000000..34d2e4d2dad
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/java/com.sap.sse.mail.replication.testsupport/pom.xml b/java/com.sap.sse.mail.replication.testsupport/pom.xml
new file mode 100755
index 00000000000..2ed85a10b24
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+
+ root
+ com.sap.sailing
+ 1.0.0-SNAPSHOT
+
+ com.sap.sse.mail.replication.testsupport
+ eclipse-plugin
+
diff --git a/java/com.sap.sse.mail.replication.testsupport/src/com/sap/sse/mail/replication/testsupport/AbstractMailReplicationTest.java b/java/com.sap.sse.mail.replication.testsupport/src/com/sap/sse/mail/replication/testsupport/AbstractMailReplicationTest.java
new file mode 100644
index 00000000000..3777cff986a
--- /dev/null
+++ b/java/com.sap.sse.mail.replication.testsupport/src/com/sap/sse/mail/replication/testsupport/AbstractMailReplicationTest.java
@@ -0,0 +1,59 @@
+package com.sap.sse.mail.replication.testsupport;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+
+import com.sap.sse.common.mail.MailException;
+import com.sap.sse.mail.MailService;
+import com.sap.sse.mail.impl.MailServiceImpl;
+import com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp;
+import com.sap.sse.replication.testsupport.AbstractServerWithSingleServiceReplicationTest;
+
+public class AbstractMailReplicationTest extends AbstractServerWithSingleServiceReplicationTest {
+ public AbstractMailReplicationTest() {
+ super(new MailServerReplicationTestSetUp());
+ }
+
+ public static final Map numberOfMailsSent = new HashMap<>();
+
+ @Before
+ public void setUp() {
+ numberOfMailsSent.clear();
+ }
+
+ public static MailServiceImpl createMailCountingService(final boolean canSendMail) {
+ return new MailServiceImpl(null) {
+ @Override
+ protected void internalSendMail(String toAddress, String subject, ContentSetter contentSetter)
+ throws MailException {
+ if (canSendMail) {
+ Integer old = numberOfMailsSent.get(this);
+ numberOfMailsSent.put(this, old == null ? 1 : old + 1);
+ }
+ }
+ };
+ }
+
+ public static class MailServerReplicationTestSetUp extends AbstractServerReplicationTestSetUp {
+ public MailServerReplicationTestSetUp() {
+ super();
+ }
+
+ public MailServerReplicationTestSetUp(int servletPort) {
+ super(servletPort);
+ }
+
+ @Override
+ protected MailServiceImpl createNewMaster() throws MailException {
+ return createMailCountingService(true);
+ }
+
+ @Override
+ protected MailServiceImpl createNewReplica() throws MailException {
+ return createMailCountingService(false);
+ }
+ }
+
+}
diff --git a/java/com.sap.sse.mail/META-INF/MANIFEST.MF b/java/com.sap.sse.mail/META-INF/MANIFEST.MF
index ccf3a8d0850..d5aff706f24 100755
--- a/java/com.sap.sse.mail/META-INF/MANIFEST.MF
+++ b/java/com.sap.sse.mail/META-INF/MANIFEST.MF
@@ -6,7 +6,8 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: SAP
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Activator: com.sap.sse.mail.impl.Activator
-Export-Package: com.sap.sse.mail
+Export-Package: com.sap.sse.mail,
+ com.sap.sse.mail.impl
Import-Package: javax.mail,
javax.mail.internet,
org.osgi.framework
diff --git a/java/com.sap.sse.mail/src/com/sap/sse/mail/impl/MailServiceImpl.java b/java/com.sap.sse.mail/src/com/sap/sse/mail/impl/MailServiceImpl.java
index 7ef047c3a5c..4ac702b4ef6 100644
--- a/java/com.sap.sse.mail/src/com/sap/sse/mail/impl/MailServiceImpl.java
+++ b/java/com.sap.sse.mail/src/com/sap/sse/mail/impl/MailServiceImpl.java
@@ -6,6 +6,7 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.MalformedURLException;
+import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -26,9 +27,8 @@ import com.sap.sse.replication.OperationExecutionListener;
import com.sap.sse.replication.OperationWithResult;
import com.sap.sse.replication.ReplicationMasterDescriptor;
import com.sap.sse.replication.impl.OperationWithResultWithIdWrapper;
-import com.sap.sse.util.ClearStateTestSupport;
-public class MailServiceImpl implements ReplicableMailService, ClearStateTestSupport {
+public class MailServiceImpl implements ReplicableMailService {
private static final Logger logger = Logger.getLogger(MailServiceImpl.class.getName());
private Properties mailProperties;
@@ -39,7 +39,7 @@ public class MailServiceImpl implements ReplicableMailService, ClearStateTestSup
*/
private ReplicationMasterDescriptor replicatingFromMaster;
private final ConcurrentHashMap, OperationExecutionListener> operationExecutionListeners;
- private Set> operationsSentToMasterForReplication;
+ private final Set> operationsSentToMasterForReplication = new HashSet<>();
private ThreadLocal currentlyFillingFromInitialLoadOrApplyingOperationReceivedFromMaster = ThreadLocal
.withInitial(() -> false);
@@ -56,12 +56,17 @@ public class MailServiceImpl implements ReplicableMailService, ClearStateTestSup
}
}
- private static interface ContentSetter {
+ protected static interface ContentSetter {
void setContent(MimeMessage msg) throws MessagingException;
}
- private void internalSendMail(String toAddress, String subject, ContentSetter contentSetter) throws MailException {
- if (mailProperties != null && mailProperties.containsKey("mail.transport.protocol")) {
+ private boolean canSendMail() {
+ return mailProperties != null && mailProperties.containsKey("mail.transport.protocol");
+ }
+
+ //protected for testing purposes
+ protected void internalSendMail(String toAddress, String subject, ContentSetter contentSetter) throws MailException {
+ if (canSendMail()) {
if (toAddress != null) {
Session session = Session.getInstance(mailProperties, new SMTPAuthenticator());
MimeMessage msg = new MimeMessage(session);
@@ -201,9 +206,4 @@ public class MailServiceImpl implements ReplicableMailService, ClearStateTestSup
this.currentlyFillingFromInitialLoadOrApplyingOperationReceivedFromMaster
.set(currentlyFillingFromInitialLoadOrApplyingOperationReceivedFromMaster);
}
-
- @Override
- public void clearState() throws Exception {
- mailProperties.clear();
- }
}
diff --git a/java/com.sap.sse.security.replication.test/META-INF/MANIFEST.MF b/java/com.sap.sse.security.replication.test/META-INF/MANIFEST.MF
index a73b2c7998e..69111890757 100644
--- a/java/com.sap.sse.security.replication.test/META-INF/MANIFEST.MF
+++ b/java/com.sap.sse.security.replication.test/META-INF/MANIFEST.MF
@@ -6,10 +6,14 @@ Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: SAP
Fragment-Host: com.sap.sse.security
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.junit4;bundle-version="4.8.2",
+Require-Bundle: org.hamcrest;bundle-version="1.1.0",
+ org.junit4;bundle-version="4.8.2",
com.sap.sse.security.userstore.mongodb,
com.sap.sse.mongodb,
com.rabbitmq.client,
org.mongodb.mongo-java-driver;bundle-version="2.13.0",
com.sap.sse.replication.testsupport,
- com.sap.sse.mail.replication.testsupport
+ com.sap.sse.mail.replication.testsupport,
+ org.objenesis;bundle-version="2.1.0",
+ org.mockito.mockito-core;bundle-version="1.10.14"
+Import-Package: org.osgi.util.tracker;version="1.5.1"
diff --git a/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/AbstractSecurityReplicationTest.java b/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/AbstractSecurityReplicationTest.java
index af5d80c108d..97fec10c49c 100755
--- a/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/AbstractSecurityReplicationTest.java
+++ b/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/AbstractSecurityReplicationTest.java
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.net.MalformedURLException;
import com.sap.sse.mongodb.MongoDBService;
+import com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp;
import com.sap.sse.replication.testsupport.AbstractServerWithSingleServiceReplicationTest;
import com.sap.sse.security.SecurityService;
import com.sap.sse.security.impl.SecurityServiceImpl;
@@ -11,10 +12,10 @@ import com.sap.sse.security.userstore.mongodb.UserStoreImpl;
public abstract class AbstractSecurityReplicationTest extends AbstractServerWithSingleServiceReplicationTest {
public AbstractSecurityReplicationTest() {
- super(new ServerReplicationTestSetUp());
+ super(new SecurityServerReplicationTestSetUp());
}
- private static class ServerReplicationTestSetUp extends com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp {
+ public static class SecurityServerReplicationTestSetUp extends AbstractServerReplicationTestSetUp {
private MongoDBService mongoDBService;
@Override
diff --git a/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SecurityReplicationLeadingToEmailReplicationTest.java b/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SecurityReplicationLeadingToEmailReplicationTest.java
new file mode 100644
index 00000000000..87faef2348c
--- /dev/null
+++ b/java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/SecurityReplicationLeadingToEmailReplicationTest.java
@@ -0,0 +1,148 @@
+package com.sap.sse.security.replication.test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.osgi.util.tracker.ServiceTracker;
+
+import com.sap.sse.common.mail.MailException;
+import com.sap.sse.mail.MailService;
+import com.sap.sse.mail.impl.MailServiceImpl;
+import com.sap.sse.mail.replication.testsupport.AbstractMailReplicationTest;
+import com.sap.sse.replication.testsupport.AbstractServerWithMultipleServicesReplicationTest;
+import com.sap.sse.security.SecurityService;
+import com.sap.sse.security.impl.SecurityServiceImpl;
+import com.sap.sse.security.shared.UserManagementException;
+import com.sap.sse.security.userstore.mongodb.UserStoreImpl;
+
+/**
+ * See if transitively triggered email operation ultimately behaves well and results in only one outbound email.
+ *
+ * @author Fredrik Teschke
+ */
+public class SecurityReplicationLeadingToEmailReplicationTest extends AbstractServerWithMultipleServicesReplicationTest {
+ private static final SecurityServerReplicationTestSetUp securitySetUp = new SecurityServerReplicationTestSetUp();
+ private static final MailServerReplicationTestSetUp mailSetUp = new MailServerReplicationTestSetUp();
+
+ private static MailServiceImpl masterMailService;
+ private static MailServiceImpl replicaMailService;
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ masterMailService = AbstractMailReplicationTest.createMailCountingService(true);
+ replicaMailService = AbstractMailReplicationTest.createMailCountingService(false);
+ super.setUp();
+ }
+
+ private static class SecurityServerReplicationTestSetUp extends
+ AbstractSecurityReplicationTest.SecurityServerReplicationTestSetUp {
+ @Override
+ protected SecurityServiceImpl createNewMaster() throws MalformedURLException, IOException, InterruptedException {
+ @SuppressWarnings("unchecked")
+ ServiceTracker trackerMock = mock(ServiceTracker.class);
+ doReturn(masterMailService).when(trackerMock).getService();
+ SecurityServiceImpl result = new SecurityServiceImpl(trackerMock, new UserStoreImpl());
+ result.clearReplicaState();
+ return result;
+ }
+
+ @Override
+ protected SecurityServiceImpl createNewReplica() {
+ @SuppressWarnings("unchecked")
+ ServiceTracker trackerMock = mock(ServiceTracker.class);
+ doReturn(replicaMailService).when(trackerMock).getService();
+ SecurityServiceImpl result = new SecurityServiceImpl(trackerMock, new UserStoreImpl());
+ return result;
+ }
+ }
+
+ private static class MailServerReplicationTestSetUp extends AbstractMailReplicationTest.MailServerReplicationTestSetUp {
+ private static final int SERVLET_PORT = 9991;
+
+ public MailServerReplicationTestSetUp() {
+ super(SERVLET_PORT);
+ }
+
+ @Override
+ protected MailServiceImpl createNewMaster() throws MailException {
+ return masterMailService;
+ }
+
+ @Override
+ protected MailServiceImpl createNewReplica() throws MailException {
+ return replicaMailService;
+ }
+ }
+
+ public SecurityReplicationLeadingToEmailReplicationTest() {
+ testSetUps.add(securitySetUp);
+ testSetUps.add(mailSetUp);
+ }
+
+ /**
+ * See if sending an email (triggered by creating the user on the master) results in only one mail being sent
+ * (on the master).
+ */
+ @Test
+ public void triggerEmailSendByAddingUserOnMaster()
+ throws UserManagementException, MailException, IllegalAccessException, InterruptedException {
+ SecurityService masterSecurityService = securitySetUp.getMaster();
+
+ final String username = "Ernie";
+ final String email = "ernie@sesame-street.com";
+ final String password = "BertMyFriend";
+ final String validationBaseURL = null; //so that validation email is not sent
+
+ masterSecurityService.createSimpleUser(username, email, password, validationBaseURL);
+
+ masterSecurityService.sendMail(username, "subject", "body");
+
+ securitySetUp.getReplicaReplicator().waitUntilQueueIsEmpty();
+ mailSetUp.getReplicaReplicator().waitUntilQueueIsEmpty();
+ Thread.sleep(3000);
+
+ assertThat("mail was not sent on replica",
+ AbstractMailReplicationTest.numberOfMailsSent.get(replicaMailService), equalTo(null));
+ assertThat("mail was sent on master",
+ AbstractMailReplicationTest.numberOfMailsSent.get(masterMailService), equalTo(1));
+ }
+
+
+ /**
+ * Try the other way round - have to ignore for now, no replication test seems to try applying
+ * operations on the replica.
+ */
+ @Test
+ @Ignore
+ public void triggerEmailSendByAddingUserOnReplica()
+ throws UserManagementException, MailException, IllegalAccessException, InterruptedException {
+ SecurityService replicaSecurityService = securitySetUp.getReplica();
+
+ final String username = "Ernie";
+ final String email = "ernie@sesame-street.com";
+ final String password = "BertMyFriend";
+ final String validationBaseURL = null; //so that validation email is not sent
+
+ replicaSecurityService.createSimpleUser(username, email, password, validationBaseURL);
+
+ replicaSecurityService.sendMail(username, "subject", "body");
+
+ securitySetUp.getReplicaReplicator().waitUntilQueueIsEmpty();
+ mailSetUp.getReplicaReplicator().waitUntilQueueIsEmpty();
+ Thread.sleep(3000);
+
+ assertThat("mail was not sent on replica",
+ AbstractMailReplicationTest.numberOfMailsSent.get(replicaMailService), equalTo(null));
+ assertThat("mail was sent on master",
+ AbstractMailReplicationTest.numberOfMailsSent.get(masterMailService), equalTo(1));
+ }
+}
diff --git a/java/com.sap.sse.security/src/com/sap/sse/security/impl/SecurityServiceImpl.java b/java/com.sap.sse.security/src/com/sap/sse/security/impl/SecurityServiceImpl.java
index 00ba1efcd8a..9424aed58a4 100644
--- a/java/com.sap.sse.security/src/com/sap/sse/security/impl/SecurityServiceImpl.java
+++ b/java/com.sap.sse.security/src/com/sap/sse/security/impl/SecurityServiceImpl.java
@@ -185,6 +185,10 @@ public class SecurityServiceImpl extends RemoteServiceServlet implements Replica
}
}
}
+
+ private MailService getMailService() {
+ return mailServiceTracker == null ? null : mailServiceTracker.getService();
+ }
@Override
public void sendMail(String username, String subject, String body) throws MailException {
@@ -192,7 +196,12 @@ public class SecurityServiceImpl extends RemoteServiceServlet implements Replica
if (user != null) {
final String toAddress = user.getEmail();
if (toAddress != null) {
- mailServiceTracker.getService().sendMail(username, subject, body);
+ MailService mailService = getMailService();
+ if (mailService == null) {
+ logger.warning(String.format("Could not send mail to user %s: no MailService found", username));
+ } else {
+ getMailService().sendMail(username, subject, body);
+ }
}
}
}
diff --git a/java/pom.xml b/java/pom.xml
index d3fbc338c41..6cc686d9d16 100755
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -16,7 +16,9 @@
com.sap.sse
com.sap.sse.common
com.sap.sse.shared.android
- com.sap.sse.mail
+ com.sap.sse.mail
+ com.sap.sse.mail.replication.test
+ com.sap.sse.mail.replicadtion.testsupport
com.sap.sse.mongodb
com.sap.sse.gwt
com.sap.sse.gwt.adminconsole