diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-13 11:25:25 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-13 11:25:25 +0100 |
commit | 2413c4cf76f82983dc1bde5fb3dc2ce3e1afdf15 (patch) | |
tree | 2a9a1bac84c36750af7c18eb2c15be40af11e060 | |
parent | a3389e3e7782f56650760b07bb2f452e78406459 (diff) |
Add new Client and Master interfaces.
Begin implementing Master interface.
4 files changed, 62 insertions, 0 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientService.java b/same/src/main/java/com/orbekk/same/ClientService.java new file mode 100644 index 0000000..f5e668f --- /dev/null +++ b/same/src/main/java/com/orbekk/same/ClientService.java @@ -0,0 +1,7 @@ +package com.orbekk.same; + +public interface ClientService { + void notifyNetwork(String networkName, String masterUrl); + + void setState(String component, long revision, String data); +} diff --git a/same/src/main/java/com/orbekk/same/MasterService.java b/same/src/main/java/com/orbekk/same/MasterService.java new file mode 100644 index 0000000..f1ef24a --- /dev/null +++ b/same/src/main/java/com/orbekk/same/MasterService.java @@ -0,0 +1,6 @@ +package com.orbekk.same; + +public interface MasterService { + void joinNetworkRequest(String networkName, String clientUrl); + boolean updateStateRequest(String component, String newData, long revision); +} diff --git a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java new file mode 100644 index 0000000..64cde2f --- /dev/null +++ b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java @@ -0,0 +1,32 @@ +package com.orbekk.same; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MasterServiceImpl implements MasterService, UrlReceiver { + private Logger logger = LoggerFactory.getLogger(getClass()); + private State state; + + public MasterServiceImpl(State initialState) { + state = initialState; + } + + @Override + public void joinNetworkRequest(String networkName, String clientUrl) { + // TODO Auto-generated method stub + + } + + @Override + public boolean updateStateRequest(String component, String newData, long revision) { + // TODO Auto-generated method stub + return false; + } + + @Override + public void setUrl(String url) { + String myUrl = url + "MasterService.json"; + logger.info("Master URL is " + myUrl); + state.update(".masterUrl", myUrl, 0); + } +} diff --git a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java new file mode 100644 index 0000000..826471e --- /dev/null +++ b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java @@ -0,0 +1,17 @@ +package com.orbekk.same; + +import static org.junit.Assert.*; + +import org.junit.Test; + +public class MasterServiceImplTest { + private State state = new State(); + private MasterServiceImpl master = new MasterServiceImpl(state); + + @Test + public void setsMasterUrl() { + master.setUrl("http://10.0.0.54:10050/"); + assertEquals("http://10.0.0.54:10050/MasterService.json", + state.getDataOf(".masterUrl")); + } +} |