use of org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology in project wildfly by wildfly.
the class CommandDispatcherTestCase method test.
@Test
public void test() throws Exception {
// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using CLIENT_PROPERTIES and ensure the EJB client context is reset
// to its original state at the end of the test
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()));
}
}
use of org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology in project wildfly by wildfly.
the class CommandDispatcherTestCase method test.
@Test
public void test() throws Exception {
JBossEJBProperties properties = JBossEJBProperties.fromClassPath(CommandDispatcherTestCase.class.getClassLoader(), CLIENT_PROPERTIES);
properties.runCallable(() -> {
try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
ClusterTopologyRetriever bean = directory.lookupStateless(ClusterTopologyRetrieverBean.class, ClusterTopologyRetriever.class);
ClusterTopology topology = bean.getClusterTopology();
assertEquals(1, topology.getNodes().size());
assertTrue(topology.getNodes().toString(), topology.getNodes().contains(NODE_1));
assertTrue(topology.getRemoteNodes().toString() + " should be empty", topology.getRemoteNodes().isEmpty());
}
return null;
});
}
Aggregations