diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-16 13:48:50 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-16 13:48:50 +0100 |
commit | 6dfa7d41a075cdfef29d73982012de42bdfc446b (patch) | |
tree | 414d2080bb6a3e620cdc96e965c493b692e684f7 | |
parent | 3c798bcdad4a6eef767a736c541115d9b5129478 (diff) |
Fix failing test.
Uses test component to avoid NullPointerException.
4 files changed, 19 insertions, 4 deletions
diff --git a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java index 6093fa4..3731542 100644 --- a/same/src/main/java/com/orbekk/same/MasterServiceImpl.java +++ b/same/src/main/java/com/orbekk/same/MasterServiceImpl.java @@ -43,7 +43,6 @@ public class MasterServiceImpl implements MasterService, UrlReceiver, Runnable { boolean worked = false; for (final String component : state.getAndClearUpdatedComponents()) { logger.info("Broadcasting new component {}", state.show(component)); - broadcaster.broadcast(participants(), new ServiceOperation() { @Override public void run(ClientService client) { client.setState(component, state.getDataOf(component), diff --git a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java index 78efb99..6b33fc0 100644 --- a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java +++ b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java @@ -6,11 +6,14 @@ import java.util.List; import org.codehaus.jackson.type.TypeReference; import org.junit.Test; +import org.junit.Before; public class MasterServiceImplTest { private State state = new State("TestNetwork"); - private MasterServiceImpl master = new MasterServiceImpl(state, null, - null); + private TestConnectionManager connections = new TestConnectionManager(); + private TestBroadcaster broadcaster = new TestBroadcaster(connections); + private MasterServiceImpl master = new MasterServiceImpl(state, + connections, broadcaster); @Test public void setsMasterUrl() { diff --git a/same/src/test/java/com/orbekk/same/TestBroadcaster.java b/same/src/test/java/com/orbekk/same/TestBroadcaster.java index b76a44f..434b107 100644 --- a/same/src/test/java/com/orbekk/same/TestBroadcaster.java +++ b/same/src/test/java/com/orbekk/same/TestBroadcaster.java @@ -1,9 +1,14 @@ package com.orbekk.same; import java.util.List; +import org.junit.Ignore; +@Ignore public class TestBroadcaster implements Broadcaster { - private ConnectionManager connections; + public ConnectionManager connections; + + public TestBroadcaster() { + } public TestBroadcaster(ConnectionManager connections) { this.connections = connections; diff --git a/same/src/test/java/com/orbekk/same/TestConnectionManager.java b/same/src/test/java/com/orbekk/same/TestConnectionManager.java index 544bab5..a41ec48 100644 --- a/same/src/test/java/com/orbekk/same/TestConnectionManager.java +++ b/same/src/test/java/com/orbekk/same/TestConnectionManager.java @@ -1,11 +1,19 @@ package com.orbekk.same; +import java.util.Map; +import java.util.HashMap; +import org.junit.Ignore; + +@Ignore public class TestConnectionManager implements ConnectionManager { public Map<String, ClientService> clientMap = new HashMap<String, ClientService>(); public Map<String, MasterService> masterMap = new HashMap<String, MasterService>(); + public TestConnectionManager() { + } + public ClientService getClient(String url) { return clientMap.get(url); } |