mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-15 16:51:07 +00:00
Merge branch 'ftes-mail-move-to-sse' into jbross-email-invitation
Conflicts: java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/AbstractServerReplicationTest.java java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/ConnectionResetAndReconnectTest.java java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/PrematureOperationReceiptTest.java java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/RaceLogReplicationTest.java java/com.sap.sailing.server.replication.test/src/com/sap/sailing/server/replication/test/RegattaLogReplicationTest.java java/com.sap.sse.security.replication.test/META-INF/MANIFEST.MF java/com.sap.sse.security.replication.test/src/com/sap/sse/security/replication/test/AbstractSecurityReplicationTest.java
This commit is contained in:
commit
f60733698e
29 files changed
+473
-76
No files matched your search
+5
@@ -14,6 +14,11 @@ import com.sap.sse.mongodb.MongoDBService;
|
||||
public abstract class AbstractServerReplicationTest extends com.sap.sse.replication.testsupport.AbstractServerWithSingleServiceReplicationTest<RacingEventService, RacingEventServiceImpl> {
|
||||
protected ServerReplicationTestSetUp testSetUp;
|
||||
|
||||
protected AbstractServerReplicationTest(ServerReplicationTestSetUp testSetUp) {
|
||||
super(testSetUp);
|
||||
this.testSetUp = testSetUp;
|
||||
}
|
||||
|
||||
public AbstractServerReplicationTest() {
|
||||
super(new ServerReplicationTestSetUp());
|
||||
testSetUp = (ServerReplicationTestSetUp) super.testSetUp;
|
||||
|
||||
+6
-4
@@ -12,7 +12,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
@@ -33,6 +32,10 @@ import com.sap.sse.replication.impl.ReplicationMasterDescriptorImpl;
|
||||
public class ConnectionResetAndReconnectTest extends AbstractServerReplicationTest {
|
||||
static final Logger logger = Logger.getLogger(ConnectionResetAndReconnectTest.class.getName());
|
||||
|
||||
public ConnectionResetAndReconnectTest() {
|
||||
super(new ServerReplicationTestSetUp());
|
||||
}
|
||||
|
||||
public static boolean forceStopDelivery = false;
|
||||
|
||||
static class QueuingConsumerTest extends QueueingConsumer {
|
||||
@@ -81,9 +84,8 @@ public class ConnectionResetAndReconnectTest extends AbstractServerReplicationTe
|
||||
|
||||
}
|
||||
|
||||
protected static class ServerReplicationTestSetUp extends
|
||||
private static class ServerReplicationTestSetUp extends
|
||||
com.sap.sailing.server.replication.test.AbstractServerReplicationTest.ServerReplicationTestSetUp {
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
try {
|
||||
@@ -106,7 +108,7 @@ public class ConnectionResetAndReconnectTest extends AbstractServerReplicationTe
|
||||
/* until here both instances should have the same in-memory state.
|
||||
* now lets add an event on master and stop the messaging queue. */
|
||||
stopMessagingExchange();
|
||||
testSetUp.getReplicaReplicator().startToReplicateFrom(testSetUp.getMasterDescriptor());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
Event event = addEventOnMaster();
|
||||
Thread.sleep(1000); // wait for master queue to get filled
|
||||
assertNull(replica.getEvent(event.getId()));
|
||||
|
||||
+12
-11
@@ -15,20 +15,21 @@ import com.sap.sailing.server.operationaltransformation.CreateFlexibleLeaderboar
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
||||
import com.sap.sse.replication.impl.ReplicationReceiver;
|
||||
import com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp.ReplicationServiceTestImpl;
|
||||
|
||||
public class PrematureOperationReceiptTest extends AbstractServerReplicationTest {
|
||||
private ReplicationReceiver replicator;
|
||||
private static ReplicationReceiver replicator;
|
||||
|
||||
public PrematureOperationReceiptTest() {
|
||||
super(new ServerReplicationTestSetUp());
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the test DB. Sets up master and replica, starts the JMS message broker and registers the replica with the master.
|
||||
*/
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
Pair<ReplicationServiceTestImpl<RacingEventService>, ReplicationMasterDescriptor> result =
|
||||
basicSetUp(/* dropDB */ true, /* master=null means create a new one */ null, /* replica=null means create a new one */ null);
|
||||
replicator = replicaReplicator.startToReplicateFromButDontYetFetchInitialLoad(result.getB(), /* startReplicatorSuspended */ true);
|
||||
private static class ServerReplicationTestSetUp extends AbstractServerReplicationTest.ServerReplicationTestSetUp {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
Pair<ReplicationServiceTestImpl<RacingEventService>, ReplicationMasterDescriptor> result =
|
||||
basicSetUp(/* dropDB */ true, /* master=null means create a new one */ null, /* replica=null means create a new one */ null);
|
||||
replicator = replicaReplicator.startToReplicateFromButDontYetFetchInitialLoad(result.getB(), /* startReplicatorSuspended */ true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-24
@@ -38,36 +38,23 @@ import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.operationaltransformation.AddColumnToLeaderboard;
|
||||
import com.sap.sailing.server.operationaltransformation.AddColumnToSeries;
|
||||
import com.sap.sailing.server.operationaltransformation.CreateRegattaLeaderboard;
|
||||
import com.sap.sailing.server.operationaltransformation.RenameLeaderboard;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
||||
import com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp.ReplicationServiceTestImpl;
|
||||
|
||||
public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog, RaceLogEvent, RaceLogEventVisitor> {
|
||||
|
||||
private Pair<ReplicationServiceTestImpl<RacingEventService>, ReplicationMasterDescriptor> replicationDescriptorPair;
|
||||
|
||||
private RaceLogEvent raceLogEvent;
|
||||
private RaceLogEvent anotherRaceLogEvent;
|
||||
private AbstractLogEventAuthor author = new LogEventAuthorImpl("Test Author", 1);
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
public void createEvents() throws Exception {
|
||||
raceLogEvent = RaceLogEventFactory.INSTANCE.createRaceStatusEvent(new MillisecondsTimePoint(1), author, 42, RaceLogRaceStatus.UNKNOWN);
|
||||
anotherRaceLogEvent = RaceLogEventFactory.INSTANCE.createRaceStatusEvent(new MillisecondsTimePoint(2), author, 42, RaceLogRaceStatus.UNKNOWN);
|
||||
try {
|
||||
replicationDescriptorPair = basicSetUp(/* dropDB */ true, null, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,7 +65,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
final String raceColumnName = "R1";
|
||||
Regatta regatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RaceLog masterLog = setupRaceColumn(regatta, seriesName, raceColumnName, fleetName);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(seriesName, fleetName, raceColumnName, regatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog);
|
||||
}
|
||||
@@ -92,7 +79,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
Regatta masterRegatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RaceLog masterLog = setupRaceColumn(masterRegatta, seriesName, raceColumnName, fleetName);
|
||||
masterLog.add(raceLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(seriesName, fleetName, raceColumnName, masterRegatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog);
|
||||
}
|
||||
@@ -105,7 +92,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
final String raceColumnName = "R1";
|
||||
Regatta masterRegatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RaceLog masterLog = setupRaceColumn(masterRegatta, seriesName, raceColumnName, fleetName);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(seriesName, fleetName, raceColumnName, masterRegatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog, raceLogEvent);
|
||||
}
|
||||
@@ -117,7 +104,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
final String raceColumnName = "R1";
|
||||
FlexibleLeaderboard masterLeaderboard = setupFlexibleLeaderboard(leaderboardName);
|
||||
RaceLog masterLog = setupRaceColumn(leaderboardName, fleetName, raceColumnName);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(fleetName, raceColumnName, masterLeaderboard);
|
||||
addAndValidateEventIds(masterLog, replicaLog, raceLogEvent);
|
||||
}
|
||||
@@ -131,7 +118,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
Regatta masterRegatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RaceLog masterLog = setupRaceColumn(masterRegatta, seriesName, raceColumnName, fleetName);
|
||||
masterLog.add(raceLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(seriesName, fleetName, raceColumnName, masterRegatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog, anotherRaceLogEvent);
|
||||
}
|
||||
@@ -146,7 +133,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
RaceLog masterLog = setupRaceColumn(masterRegatta, seriesName, raceColumnName, fleetName);
|
||||
raceLogEvent = RaceLogEventFactory.INSTANCE.createCourseDesignChangedEvent(MillisecondsTimePoint.now(), author, 43, createCourseData());
|
||||
masterLog.add(raceLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(seriesName, fleetName, raceColumnName, masterRegatta);
|
||||
anotherRaceLogEvent = RaceLogEventFactory.INSTANCE.createCourseDesignChangedEvent(MillisecondsTimePoint.now(), author, 43, createCourseData());
|
||||
addAndValidateEventIds(masterLog, replicaLog, anotherRaceLogEvent);
|
||||
@@ -161,7 +148,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
FlexibleLeaderboard masterLeaderboard = setupFlexibleLeaderboard(leaderboardName);
|
||||
RaceLog masterLog = setupRaceColumn(leaderboardName, fleetName, raceColumnName);
|
||||
masterLog.add(raceLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(fleetName, raceColumnName, masterLeaderboard);
|
||||
addAndValidateEventIds(masterLog, replicaLog, anotherRaceLogEvent);
|
||||
}
|
||||
@@ -175,7 +162,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
RaceLog masterLog = setupRaceColumn(leaderboardName, fleetName, raceColumnName);
|
||||
raceLogEvent = RaceLogEventFactory.INSTANCE.createCourseDesignChangedEvent(MillisecondsTimePoint.now(), author, 43, createCourseData());
|
||||
masterLog.add(raceLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(fleetName, raceColumnName, masterLeaderboard);
|
||||
anotherRaceLogEvent = RaceLogEventFactory.INSTANCE.createCourseDesignChangedEvent(MillisecondsTimePoint.now(), author, 43, createCourseData());
|
||||
addAndValidateEventIds(masterLog, replicaLog, anotherRaceLogEvent);
|
||||
@@ -204,7 +191,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
final String raceColumnName = "R1";
|
||||
FlexibleLeaderboard masterLeaderboard = setupFlexibleLeaderboard(leaderboardName);
|
||||
RaceLog masterLog = setupRaceColumn(leaderboardName, fleetName, raceColumnName);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
masterLog.add(raceLogEvent);
|
||||
RenameLeaderboard renameOperation = new RenameLeaderboard(leaderboardName, leaderboardName + "new");
|
||||
master.apply(renameOperation);
|
||||
@@ -226,7 +213,7 @@ public class RaceLogReplicationTest extends AbstractLogReplicationTest<RaceLog,
|
||||
Regatta masterRegatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RaceLog masterLog = setupRaceColumn(masterRegatta, seriesName, raceColumnName, fleetName);
|
||||
masterLog.add(raceLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RaceLog replicaLog = getReplicaLog(seriesName, fleetName, raceColumnName, masterRegatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog);
|
||||
|
||||
|
||||
+5
-18
@@ -17,17 +17,11 @@ import com.sap.sailing.domain.base.impl.RegattaImpl;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.test.TrackBasedTest;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util.Pair;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.replication.ReplicationMasterDescriptor;
|
||||
import com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp.ReplicationServiceTestImpl;
|
||||
|
||||
public class RegattaLogReplicationTest extends
|
||||
AbstractLogReplicationTest<RegattaLog, RegattaLogEvent, RegattaLogEventVisitor> {
|
||||
|
||||
private Pair<ReplicationServiceTestImpl<RacingEventService>, ReplicationMasterDescriptor> replicationDescriptorPair;
|
||||
|
||||
private RegattaLogEvent regattaLogEvent;
|
||||
// private RegattaLogEvent anotherRegattaLogEvent;
|
||||
@@ -38,17 +32,10 @@ public class RegattaLogReplicationTest extends
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
public void createEvent() throws Exception {
|
||||
final Competitor competitor = TrackBasedTest.createCompetitor("Test Competitor");
|
||||
regattaLogEvent = new RegattaLogRegisterCompetitorEventImpl(t(0), author, t(0), 0, competitor);
|
||||
// anotherRegattaLogEvent = new RegattaLogRegisterCompetitorEventImpl(t(1), author, t(1), 1, null);
|
||||
try {
|
||||
replicationDescriptorPair = basicSetUp(/* dropDB */ true, null, null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,7 +45,7 @@ public class RegattaLogReplicationTest extends
|
||||
final String fleetName = "Default";
|
||||
Regatta regatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RegattaLog masterLog = regatta.getRegattaLog();
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RegattaLog replicaLog = getReplicaLog(regatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog);
|
||||
}
|
||||
@@ -71,7 +58,7 @@ public class RegattaLogReplicationTest extends
|
||||
Regatta regatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RegattaLog masterLog = regatta.getRegattaLog();
|
||||
masterLog.add(regattaLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RegattaLog replicaLog = getReplicaLog(regatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog);
|
||||
}
|
||||
@@ -84,7 +71,7 @@ public class RegattaLogReplicationTest extends
|
||||
Regatta masterRegatta = setupRegatta(RegattaImpl.getDefaultName(regattaName, BOAT_CLASS_NAME_49er), seriesName, fleetName, BOAT_CLASS_NAME_49er);
|
||||
RegattaLog masterLog = masterRegatta.getRegattaLog();
|
||||
masterLog.add(regattaLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RegattaLog replicaLog = getReplicaLog(masterRegatta);
|
||||
addAndValidateEventIds(masterLog, replicaLog, regattaLogEvent);
|
||||
}
|
||||
@@ -95,7 +82,7 @@ public class RegattaLogReplicationTest extends
|
||||
FlexibleLeaderboard masterLeaderboard = setupFlexibleLeaderboard(leaderboardName);
|
||||
RegattaLog masterLog = masterLeaderboard.getRegattaLog();
|
||||
masterLog.add(regattaLogEvent);
|
||||
replicationDescriptorPair.getA().startToReplicateFrom(replicationDescriptorPair.getB());
|
||||
replicaReplicator.startToReplicateFrom(masterDescriptor);
|
||||
RegattaLog replicaLog = getReplicaLog(masterLeaderboard);
|
||||
addAndValidateEventIds(masterLog, replicaLog, regattaLogEvent);
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.sap.sse.mail.replication.test</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
||||
@@ -0,0 +1,13 @@
|
||||
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.hamcrest;bundle-version="1.1.0",
|
||||
org.junit4;bundle-version="4.8.2",
|
||||
com.rabbitmq.client,
|
||||
com.sap.sse.replication.testsupport,
|
||||
com.sap.sse.mail.replication.testsupport
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>root</artifactId>
|
||||
<groupId>com.sap.sailing</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.sap.sse.mail.replication.test</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.sap.sse.mail.replication.test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sse.common.mail.MailException;
|
||||
import com.sap.sse.mail.replication.testsupport.AbstractMailServiceReplicationTest;
|
||||
|
||||
public class SimpleMailServiceReplicationTest extends AbstractMailServiceReplicationTest {
|
||||
@Test
|
||||
public void testReplicationOfSendMail() throws InterruptedException,
|
||||
IllegalAccessException, MailException {
|
||||
master.sendMail("test@ing.me", "oh what a beatiful mail", "to be sent on this day");
|
||||
|
||||
replicaReplicator.waitUntilQueueIsEmpty();
|
||||
Thread.sleep(3000);
|
||||
|
||||
assertThat("mail was not sent on replica",
|
||||
AbstractMailServiceReplicationTest.numberOfMailsSent.get(replica), equalTo(null));
|
||||
assertThat("mail was sent on master",
|
||||
AbstractMailServiceReplicationTest.numberOfMailsSent.get(master), equalTo(1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.sap.sse.mail.replication.testsupport</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
+7
@@ -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
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
pluginProject.extensions=false
|
||||
resolve.requirebundle=false
|
||||
@@ -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
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>root</artifactId>
|
||||
<groupId>com.sap.sailing</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>com.sap.sse.mail.replication.testsupport</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
+59
@@ -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 AbstractMailServiceReplicationTest extends AbstractServerWithSingleServiceReplicationTest<MailService, MailServiceImpl> {
|
||||
public AbstractMailServiceReplicationTest() {
|
||||
super(new MailServerReplicationTestSetUp());
|
||||
}
|
||||
|
||||
public static final Map<MailServiceImpl, Integer> numberOfMailsSent = new HashMap<>();
|
||||
|
||||
@Before
|
||||
public void clearNumberOfMailsSent() {
|
||||
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<MailService, MailServiceImpl> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<ReplicableMailService>, OperationExecutionListener<ReplicableMailService>> operationExecutionListeners;
|
||||
private Set<OperationWithResultWithIdWrapper<?, ?>> operationsSentToMasterForReplication;
|
||||
private final Set<OperationWithResultWithIdWrapper<?, ?>> operationsSentToMasterForReplication = new HashSet<>();
|
||||
private ThreadLocal<Boolean> 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);
|
||||
@@ -213,9 +218,4 @@ public class MailServiceImpl implements ReplicableMailService, ClearStateTestSup
|
||||
this.currentlyFillingFromInitialLoadOrApplyingOperationReceivedFromMaster
|
||||
.set(currentlyFillingFromInitialLoadOrApplyingOperationReceivedFromMaster);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearState() throws Exception {
|
||||
mailProperties.clear();
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -51,7 +51,15 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
|
||||
protected ReplicationServiceTestImpl<ReplicableInterface> replicaReplicator;
|
||||
private ReplicaDescriptor replicaDescriptor;
|
||||
private ReplicationServiceImpl masterReplicator;
|
||||
protected ReplicationMasterDescriptor masterDescriptor;
|
||||
protected ReplicationMasterDescriptor masterDescriptor;
|
||||
|
||||
protected AbstractServerReplicationTestSetUp() {
|
||||
servletPort = DEFAULT_SERVLET_PORT;
|
||||
}
|
||||
|
||||
protected AbstractServerReplicationTestSetUp(int servletPort) {
|
||||
this.servletPort = servletPort;
|
||||
}
|
||||
|
||||
protected AbstractServerReplicationTestSetUp() {
|
||||
servletPort = DEFAULT_SERVLET_PORT;
|
||||
|
||||
@@ -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"
|
||||
+3
-2
@@ -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<SecurityService, SecurityServiceImpl> {
|
||||
public AbstractSecurityReplicationTest() {
|
||||
super(new ServerReplicationTestSetUp());
|
||||
super(new SecurityServerReplicationTestSetUp());
|
||||
}
|
||||
|
||||
private static class ServerReplicationTestSetUp extends com.sap.sse.replication.testsupport.AbstractServerReplicationTestSetUp<SecurityService, SecurityServiceImpl> {
|
||||
public static class SecurityServerReplicationTestSetUp extends AbstractServerReplicationTestSetUp<SecurityService, SecurityServiceImpl> {
|
||||
private MongoDBService mongoDBService;
|
||||
|
||||
@Override
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
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.AbstractMailServiceReplicationTest;
|
||||
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 final SecurityServerReplicationTestSetUp securitySetUp = new SecurityServerReplicationTestSetUp();
|
||||
private final MailServerReplicationTestSetUp mailSetUp = new MailServerReplicationTestSetUp();
|
||||
|
||||
private MailServiceImpl masterMailService;
|
||||
private MailServiceImpl replicaMailService;
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
masterMailService = AbstractMailServiceReplicationTest.createMailCountingService(true);
|
||||
replicaMailService = AbstractMailServiceReplicationTest.createMailCountingService(false);
|
||||
AbstractMailServiceReplicationTest.numberOfMailsSent.clear();
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
private class SecurityServerReplicationTestSetUp extends
|
||||
AbstractSecurityReplicationTest.SecurityServerReplicationTestSetUp {
|
||||
@Override
|
||||
protected SecurityServiceImpl createNewMaster() throws MalformedURLException, IOException, InterruptedException {
|
||||
@SuppressWarnings("unchecked")
|
||||
ServiceTracker<MailService, MailService> 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<MailService, MailService> trackerMock = mock(ServiceTracker.class);
|
||||
doReturn(replicaMailService).when(trackerMock).getService();
|
||||
SecurityServiceImpl result = new SecurityServiceImpl(trackerMock, new UserStoreImpl());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private class MailServerReplicationTestSetUp extends AbstractMailServiceReplicationTest.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 {
|
||||
//TODO IllegalStateExceptions thrown, probably because the two replication services per instance share the
|
||||
//same message queue, but don't know about each other (unlike actual OSGi setup, where there is only
|
||||
//one replication service per instance that nows all Replicables)
|
||||
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",
|
||||
AbstractMailServiceReplicationTest.numberOfMailsSent.get(replicaMailService), equalTo(null));
|
||||
assertThat("mail was sent on master",
|
||||
AbstractMailServiceReplicationTest.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",
|
||||
AbstractMailServiceReplicationTest.numberOfMailsSent.get(replicaMailService), equalTo(null));
|
||||
assertThat("mail was sent on master",
|
||||
AbstractMailServiceReplicationTest.numberOfMailsSent.get(masterMailService), equalTo(1));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -16,7 +16,9 @@
|
||||
<module>com.sap.sse</module>
|
||||
<module>com.sap.sse.common</module>
|
||||
<module>com.sap.sse.shared.android</module>
|
||||
<module>com.sap.sse.mail</module>
|
||||
<module>com.sap.sse.mail</module>
|
||||
<module>com.sap.sse.mail.replication.test</module>
|
||||
<module>com.sap.sse.mail.replication.testsupport</module>
|
||||
<module>com.sap.sse.mongodb</module>
|
||||
<module>com.sap.sse.gwt</module>
|
||||
<module>com.sap.sse.gwt.adminconsole</module>
|
||||
|
||||
Reference in new issue
Block a user