public void test() throws Exception {
ContextSelector<EJBClientContext> selector = EJBClientContextSelector.setup(CLIENT_PROPERTIES);
try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
ClusterTopologyRetriever bean = directory.lookupStateless(ClusterTopologyRetrieverBean.class, ClusterTopologyRetriever.class);
ClusterTopology topology = bean.getClusterTopology();
assertEquals(2, topology.getNodes().size());
assertTrue(topology.getNodes().toString(), topology.getNodes().contains(NODE_1));
assertTrue(topology.getNodes().toString(), topology.getNodes().contains(NODE_2));
assertFalse(topology.getRemoteNodes().toString() + " should not contain " + topology.getLocalNode(), topology.getRemoteNodes().contains(topology.getLocalNode()));
undeploy(DEPLOYMENT_2);
topology = bean.getClusterTopology();
assertEquals(1, topology.getNodes().size());
assertTrue(topology.getNodes().contains(NODE_1));
assertEquals(NODE_1, topology.getLocalNode());
assertTrue(topology.getRemoteNodes().toString(), topology.getRemoteNodes().isEmpty());
deploy(DEPLOYMENT_2);
Thread.sleep(VIEW_CHANGE_WAIT);
topology = bean.getClusterTopology();
assertEquals(2, topology.getNodes().size());
assertTrue(topology.getNodes().contains(NODE_1));
assertTrue(topology.getNodes().contains(NODE_2));
assertFalse(topology.getRemoteNodes().toString() + " should not contain " + topology.getLocalNode(), topology.getRemoteNodes().contains(topology.getLocalNode()));
stop(CONTAINER_1);
topology = bean.getClusterTopology();
assertEquals(1, topology.getNodes().size());
assertTrue(topology.getNodes().contains(NODE_2));
assertEquals(NODE_2, topology.getLocalNode());
assertTrue(topology.getRemoteNodes().toString(), topology.getRemoteNodes().isEmpty());
start(CONTAINER_1);
Thread.sleep(VIEW_CHANGE_WAIT);
topology = bean.getClusterTopology();
assertEquals(topology.getNodes().toString(), 2, topology.getNodes().size());
assertTrue(topology.getNodes().toString() + " should contain " + NODE_1, topology.getNodes().contains(NODE_1));
assertTrue(topology.getNodes().toString() + " should contain " + NODE_2, topology.getNodes().contains(NODE_2));
assertFalse(topology.getRemoteNodes().toString() + " should not contain " + topology.getLocalNode(), topology.getRemoteNodes().contains(topology.getLocalNode()));
} finally {