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/ClientServiceImplTest.java15
-rw-r--r--same/src/test/java/com/orbekk/same/MasterServiceImplTest.java12
2 files changed, 16 insertions, 11 deletions
diff --git a/same/src/test/java/com/orbekk/same/ClientServiceImplTest.java b/same/src/test/java/com/orbekk/same/ClientServiceImplTest.java
index 4523fe1..5f04485 100644
--- a/same/src/test/java/com/orbekk/same/ClientServiceImplTest.java
+++ b/same/src/test/java/com/orbekk/same/ClientServiceImplTest.java
@@ -10,24 +10,25 @@ public class ClientServiceImplTest {
private TestConnectionManager connections = new TestConnectionManager();
private TestBroadcaster broadcaster = new TestBroadcaster();
private ClientServiceImpl client = new ClientServiceImpl(state, connections);
+ private ClientService clientS = client.getService();
- @Test public void testSetState() {
- client.setState("TestState", "Test data", 100);
+ @Test public void testSetState() throws Exception {
+ clientS.setState("TestState", "Test data", 100);
assertEquals(100, state.getRevision("TestState"));
assertEquals("Test data", state.getDataOf("TestState"));
}
- @Test public void testNetworkListener() {
+ @Test public void testNetworkListener() throws Exception {
NetworkNotificationListener listener =
mock(NetworkNotificationListener.class);
client.setNetworkListener(listener);
- client.notifyNetwork("MyNetwork", "MasterUrl");
+ clientS.notifyNetwork("MyNetwork", "MasterUrl");
verify(listener).notifyNetwork("MyNetwork", "MasterUrl");
}
- @Test public void discover() {
- client.setState(".masterUrl", "master", 1);
- ClientServiceImpl mockClient = mock(ClientServiceImpl.class);
+ @Test public void discover() throws Exception {
+ clientS.setState(".masterUrl", "master", 1);
+ ClientService mockClient = mock(ClientService.class);
connections.clientMap.put("mockClient/ClientService.json",
mockClient);
client.discover("mockClient/");
diff --git a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
index a309e38..daa55a2 100644
--- a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
+++ b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
@@ -75,8 +75,9 @@ public class MasterServiceImplTest {
master.setUrl("http://master/");
ClientServiceImpl client = new ClientServiceImpl(
new State("ClientNetwork"), connections);
+ ClientService clientS = client.getService();
client.setUrl("http://client/");
- connections.clientMap.put("http://client/ClientService.json", client);
+ connections.clientMap.put("http://client/ClientService.json", clientS);
client.joinNetwork("http://master");
assertTrue(master._performWork());
assertTrue(state.getList(".participants").contains("http://client/ClientService.json"));
@@ -88,12 +89,14 @@ public class MasterServiceImplTest {
master.setUrl("http://master/");
ClientServiceImpl client1 = new ClientServiceImpl(
new State("ClientNetwork"), connections);
+ ClientService client1S = client1.getService();
client1.setUrl("http://client/");
- connections.clientMap.put("http://client/ClientService.json", client1);
+ connections.clientMap.put("http://client/ClientService.json", client1S);
ClientServiceImpl client2 = new ClientServiceImpl(
new State("ClientNetwork"), connections);
+ ClientService client2S = client2.getService();
client2.setUrl("http://client2/");
- connections.clientMap.put("http://client2/ClientService.json", client2);
+ connections.clientMap.put("http://client2/ClientService.json", client2S);
client1.joinNetwork("http://master");
client2.joinNetwork("http://master");
@@ -122,8 +125,9 @@ public class MasterServiceImplTest {
master.setUrl("http://master/");
ClientServiceImpl client = new ClientServiceImpl(
new State("ClientNetwork"), connections);
+ ClientService clientS = client.getService();
client.setUrl("http://client/");
- connections.clientMap.put("http://client/ClientService.json", client);
+ connections.clientMap.put("http://client/ClientService.json", clientS);
client.joinNetwork("http://master");
assertTrue(master._performWork());
assertTrue(state.getList(".participants").contains("http://client/ClientService.json"));