bug5221: adjusted AbstractServerReplicationTestSetUp such that it handles the POST requests for replication operations properly now

This commit is contained in:
Axel Uhl committed 2020-07-07 01:13:46 +02:00
1 parent 4939e892e3
commit 5a6f14e810
3 files changed
+2 -4

No files matched your search

@@ -49,7 +49,6 @@ public abstract class AbstractServerReplicationTest extends com.sap.sse.replicat
return new RacingEventServiceImpl((final RaceLogAndTrackedRaceResolver raceLogResolver)-> {
return new ConstructorParameters() {
private final DomainFactory baseDomainFactory = new DomainFactoryImpl(raceLogResolver);
@Override public DomainObjectFactory getDomainObjectFactory() { return PersistenceFactory.INSTANCE.getDomainObjectFactory(mongoDBService, baseDomainFactory); }
@Override public MongoObjectFactory getMongoObjectFactory() { return mongoObjectFactory; }
@Override public DomainFactory getBaseDomainFactory() { return baseDomainFactory; }
@@ -71,7 +70,6 @@ public abstract class AbstractServerReplicationTest extends com.sap.sse.replicat
PersistenceFactory.INSTANCE.getDomainObjectFactory(mongoDBService,
// replica gets its own base DomainFactory:
new DomainFactoryImpl(raceLogResolver));
@Override public DomainObjectFactory getDomainObjectFactory() { return domainObjectFactory; }
@Override public MongoObjectFactory getMongoObjectFactory() { return mongoObjectFactory; }
@Override public DomainFactory getBaseDomainFactory() { return domainObjectFactory.getBaseDomainFactory(); }
@@ -44,6 +44,7 @@ public interface OperationsToMasterSender<S, O extends OperationWithResult<S, ?>
final OperationWithResultWithIdWrapper<S, T> operationWithResultWithIdWrapper = new OperationWithResultWithIdWrapper<S, T>(operation);
addOperationSentToMasterForReplication(operationWithResultWithIdWrapper);
URL url = masterDescriptor.getSendReplicaInitiatedOperationToMasterURL(this.getId().toString());
// TODO shouldn't this also use the HttpUrlConnectionHelper?
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Content-Type", "application/octet-stream");
String optionalBearerToken = masterDescriptor.getBearerToken();
@@ -177,7 +177,6 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
ReplicationInstancesManager rim = new ReplicationInstancesManager();
masterReplicator = new ReplicationServiceImpl(exchangeName, exchangeHost, 0, rim, new SingletonReplicablesProvider(this.master));
replicaDescriptor = new ReplicaDescriptorImpl(InetAddress.getLocalHost(), serverUuid, "", new String[] { this.master.getId().toString() });
// connect to exchange host and local server running as master
// master server and exchange host can be two different hosts
ReplicationServiceTestImpl<ReplicableInterface> replicaReplicator = new ReplicationServiceTestImpl<ReplicableInterface>(exchangeName, exchangeHost, rim, replicaDescriptor,
@@ -305,7 +304,7 @@ public abstract class AbstractServerReplicationTestSetUp<ReplicableInterface ext
String request = readLine(inputStream);
logger.info("received request "+request);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
if (request.startsWith("POST /replication/replication")) {
if (request.equals("POST /replication/replication")) {
final ReplicationServlet servlet = new ReplicationServlet(new SingletonReplicablesProvider(master), /* replicationServiceTracker */ null);
final HttpServletRequest requestMock = Mockito.mock(HttpServletRequest.class);
Mockito.when(requestMock.getInputStream()).thenReturn(new ServletInputStream() {