@Test public void testInitVersionListAndVersionChange() throws Throwable { final QNodeHandler handler = new QNodeHandler(); SploutConfiguration config = SploutConfiguration.getTestConfig(); try { HazelcastInstance hz = Hazelcast.newHazelcastInstance(HazelcastConfigBuilder.build(config)); CoordinationStructures coord = new CoordinationStructures(hz); handler.init(config); Map<String, Long> versionsBeingServed = new HashMap<String, Long>(); versionsBeingServed.put("t1", 0l); coord .getVersionsBeingServed() .put(CoordinationStructures.KEY_FOR_VERSIONS_BEING_SERVED, versionsBeingServed); versionsBeingServed.put("t2", 1l); coord .getVersionsBeingServed() .put(CoordinationStructures.KEY_FOR_VERSIONS_BEING_SERVED, versionsBeingServed); new TestUtils.NotWaitingForeverCondition() { @Override public boolean endCondition() { return handler.getContext().getCurrentVersionsMap().get("t1") != null && handler.getContext().getCurrentVersionsMap().get("t1") == 0l && handler.getContext().getCurrentVersionsMap().get("t2") != null && handler.getContext().getCurrentVersionsMap().get("t2") == 1l; } }.waitAtMost(5000); versionsBeingServed.put("t2", 0l); versionsBeingServed.put("t1", 1l); coord .getVersionsBeingServed() .put(CoordinationStructures.KEY_FOR_VERSIONS_BEING_SERVED, versionsBeingServed); new TestUtils.NotWaitingForeverCondition() { @Override public boolean endCondition() { return handler.getContext().getCurrentVersionsMap().get("t1") != null && handler.getContext().getCurrentVersionsMap().get("t1") == 1l && handler.getContext().getCurrentVersionsMap().get("t2") != null && handler.getContext().getCurrentVersionsMap().get("t2") == 0l; } }.waitAtMost(5000); versionsBeingServed.put("t2", 1l); versionsBeingServed.put("t1", 0l); coord .getVersionsBeingServed() .put(CoordinationStructures.KEY_FOR_VERSIONS_BEING_SERVED, versionsBeingServed); Thread.sleep(100); Assert.assertEquals(0l, (long) handler.getContext().getCurrentVersionsMap().get("t1")); Assert.assertEquals(1l, (long) handler.getContext().getCurrentVersionsMap().get("t2")); } finally { handler.close(); Hazelcast.shutdownAll(); } }