summaryrefslogtreecommitdiff
path: root/same/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'same/src/test')
-rw-r--r--same/src/test/java/com/orbekk/same/FunctionalTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/same/src/test/java/com/orbekk/same/FunctionalTest.java b/same/src/test/java/com/orbekk/same/FunctionalTest.java
index 3707581..215efd9 100644
--- a/same/src/test/java/com/orbekk/same/FunctionalTest.java
+++ b/same/src/test/java/com/orbekk/same/FunctionalTest.java
@@ -1,6 +1,8 @@
package com.orbekk.same;
import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
@@ -95,4 +97,26 @@ public class FunctionalTest {
assertThat(x1.get(), is("TestValue1"));
assertThat(x2.get(), is("TestValue1"));
}
+
+ @Test public void clientBecomesMaster() {
+ String newMasterUrl = "http://newMaster/MasterService.json";
+ final Master newMaster = Master.create(connections,
+ broadcaster, newMasterUrl, "TestMaster");
+ connections.masterMap.put(newMasterUrl, newMaster.getService());
+ joinClients();
+ MasterController controller = new MasterController() {
+ @Override
+ public void enableMaster(State lastKnownState) {
+ newMaster.resumeFrom(lastKnownState);
+ }
+ @Override
+ public void disableMaster() {
+ }
+ };
+ client1.setMasterController(controller);
+ client1.startMasterElection();
+ newMaster.performWork();
+ assertThat(client1.masterUrl, is(newMasterUrl));
+ assertThat(client2.masterUrl, is(newMasterUrl));
+ }
}