summaryrefslogtreecommitdiff
path: root/same/src/test
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-13 12:12:37 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-13 12:12:37 +0100
commit008f40dcd76f7eedc0360f94dd42d2d12e3a8793 (patch)
tree0a8ebfb744a3d9f3b937ad0834458993c1204899 /same/src/test
parent2413c4cf76f82983dc1bde5fb3dc2ce3e1afdf15 (diff)
Add support for JSON state.
Use Jackson for serialization and deserialization of JSON objects.
Diffstat (limited to 'same/src/test')
-rw-r--r--same/src/test/java/com/orbekk/same/MasterServiceImplTest.java22
1 files changed, 21 insertions, 1 deletions
diff --git a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
index 826471e..9d8a134 100644
--- a/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
+++ b/same/src/test/java/com/orbekk/same/MasterServiceImplTest.java
@@ -2,10 +2,13 @@ package com.orbekk.same;
import static org.junit.Assert.*;
+import java.util.List;
+
+import org.codehaus.jackson.type.TypeReference;
import org.junit.Test;
public class MasterServiceImplTest {
- private State state = new State();
+ private State state = new State("TestNetwork");
private MasterServiceImpl master = new MasterServiceImpl(state);
@Test
@@ -14,4 +17,21 @@ public class MasterServiceImplTest {
assertEquals("http://10.0.0.54:10050/MasterService.json",
state.getDataOf(".masterUrl"));
}
+
+ @Test
+ public void testJsonState() {
+ List<String> participants =
+ state.getParsedData(".participants",
+ new TypeReference<List<String>>() { });
+ assertEquals(participants.size(), 0);
+ participants.add("http://SomeUrl/");
+ state.updateFromObject(".participants", participants, 1);
+ }
+
+ @Test
+ public void joinNetworkAddsClient() {
+ master.joinNetworkRequest("TestNetwork", "http://clientUrl");
+ List<String> participants = state.getList(".participants");
+ assertTrue(participants.contains("http://clientUrl"));
+ }
}