From 008f40dcd76f7eedc0360f94dd42d2d12e3a8793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjetil=20=C3=98rbekk?= Date: Fri, 13 Jan 2012 12:12:37 +0100 Subject: Add support for JSON state. Use Jackson for serialization and deserialization of JSON objects. --- .../com/orbekk/same/MasterServiceImplTest.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'same/src/test/java/com') 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 participants = + state.getParsedData(".participants", + new TypeReference>() { }); + assertEquals(participants.size(), 0); + participants.add("http://SomeUrl/"); + state.updateFromObject(".participants", participants, 1); + } + + @Test + public void joinNetworkAddsClient() { + master.joinNetworkRequest("TestNetwork", "http://clientUrl"); + List participants = state.getList(".participants"); + assertTrue(participants.contains("http://clientUrl")); + } } -- cgit v1.2.3