summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-16 14:16:34 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-16 14:16:34 +0100
commitd3c525c8b85047b7189ba1430f5ad7bb9c1ef79a (patch)
tree9033c5e3501849e429dd93c5819a02113287afed
parent78fc77506d98d85ee889a839098ad9591d8cad88 (diff)
Add failing master test.
Fails because client implementation is not finished.
-rw-r--r--same/src/main/java/com/orbekk/same/ClientServiceImpl.java16
-rw-r--r--same/src/test/java/com/orbekk/same/MasterServiceImplTest.java11
2 files changed, 26 insertions, 1 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
index 954d857..84ee015 100644
--- a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
+++ b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
@@ -3,8 +3,16 @@ package com.orbekk.same;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ClientServiceImpl implements ClientService {
+public class ClientServiceImpl implements ClientService, UrlReceiver {
private Logger logger = LoggerFactory.getLogger(getClass());
+ private ConnectionManager connections;
+ private State state;
+ private String myUrl = null;
+
+ public ClientServiceImpl(State state, ConnectionManager connections) {
+ this.state = state;
+ this.connections = connections;
+ }
@Override
public void notifyNetwork(String networkName, String masterUrl) {
@@ -15,4 +23,10 @@ public class ClientServiceImpl implements ClientService {
public void setState(String component, String data, long revision) {
logger.error("SetState not yet implemented.");
}
+
+ @Override
+ public void setUrl(String myUrl) {
+ logger.info("My URL is {}.", myUrl);
+ this.myUrl = myUrl;
+ }
}
diff --git a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
index 6b33fc0..0f27b98 100644
--- a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
+++ b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
@@ -45,4 +45,15 @@ public class MasterServiceImplTest {
assertTrue(master._performWork());
assertTrue(state.getAndClearUpdatedComponents().isEmpty());
}
+
+ @Test
+ public void clientJoin() {
+ master.setUrl("http://master");
+ ClientServiceImpl client = new ClientServiceImpl(
+ new State("ClientNetwork"), connections);
+ client.setUrl("http://client");
+ connections.clientMap.put("http://client", client);
+ master.joinNetworkRequest("TestNetwork", "http://client");
+ assertTrue(master._performWork());
+ }
}