use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.
the class RemoteStatefulEJBConcurrentFailoverTestCase method test.
public void test(Lifecycle lifecycle) throws Exception {
try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
Incrementor bean = directory.lookupStateful(SlowStatefulIncrementorBean.class, Incrementor.class);
AtomicInteger count = new AtomicInteger();
// Allow sufficient time for client to receive full topology
Thread.sleep(CLIENT_TOPOLOGY_UPDATE_WAIT);
String target = bean.increment().getNode();
count.incrementAndGet();
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
try {
CountDownLatch latch = new CountDownLatch(1);
Future<?> future = executor.scheduleWithFixedDelay(new IncrementTask(bean, count, latch), 0, 1, TimeUnit.MILLISECONDS);
latch.await();
lifecycle.stop(target);
future.cancel(false);
try {
future.get();
} catch (CancellationException e) {
// Ignore
}
bean.remove();
lifecycle.start(target);
latch = new CountDownLatch(1);
future = executor.scheduleWithFixedDelay(new LookupTask(directory, SlowStatefulIncrementorBean.class, latch), 0, 1, TimeUnit.MILLISECONDS);
latch.await();
lifecycle.stop(target);
future.cancel(false);
try {
future.get();
} catch (CancellationException e) {
// Ignore
}
lifecycle.start(target);
} finally {
executor.shutdownNow();
}
}
}
use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.
the class CommandDispatcherTestCase method test.
@Test
public void test() throws Exception {
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());
}
}
use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.
the class RegistryTestCase method test.
@Test
public void test() throws Exception {
try (EJBDirectory context = new RemoteEJBDirectory(MODULE_NAME)) {
RegistryRetriever bean = context.lookupStateless(RegistryRetrieverBean.class, RegistryRetriever.class);
Collection<String> names = bean.getNodes();
assertEquals(1, names.size());
assertTrue(names.toString(), names.contains(NODE_1));
}
}
use of org.jboss.as.test.clustering.ejb.EJBDirectory in project wildfly by wildfly.
the class ServiceProviderRegistrationTestCase method test.
@Test
public void test() throws Exception {
try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
ServiceProviderRetriever bean = directory.lookupStateless(ServiceProviderRetrieverBean.class, ServiceProviderRetriever.class);
Collection<String> names = bean.getProviders();
assertEquals(1, names.size());
assertTrue(names.toString(), names.contains(NODE_1));
}
}
Aggregations