use of org.jboss.as.test.clustering.ejb.RemoteEJBDirectory in project wildfly by wildfly.
the class RemoteEJBClientStatefulFailoverTestBase method beforeClass.
@BeforeClass
public static void beforeClass() throws NamingException {
directory = new RemoteEJBDirectory(ARCHIVE_NAME);
singletonDirectory = new RemoteEJBDirectory(ARCHIVE_NAME_SINGLE);
}
use of org.jboss.as.test.clustering.ejb.RemoteEJBDirectory in project wildfly by wildfly.
the class RemoteStatelessFailoverTestCase method init.
@BeforeClass
public static void init() throws NamingException {
directoryAnnotation = new RemoteEJBDirectory(ARCHIVE_NAME);
directoryDD = new RemoteEJBDirectory(ARCHIVE_NAME_DD);
deployed.put(DEPLOYMENT_1, false);
deployed.put(DEPLOYMENT_2, false);
deployed.put(DEPLOYMENT_1_DD, false);
deployed.put(DEPLOYMENT_2_DD, false);
started.put(CONTAINER_1, false);
started.put(CONTAINER_2, false);
List<String> deployments1 = new ArrayList<String>();
deployments1.add(DEPLOYMENT_1);
deployments1.add(DEPLOYMENT_1_DD);
container2deployment.put(CONTAINER_1, deployments1);
List<String> deployments2 = new ArrayList<String>();
deployments2.add(DEPLOYMENT_2);
deployments2.add(DEPLOYMENT_2_DD);
container2deployment.put(CONTAINER_2, deployments2);
}
use of org.jboss.as.test.clustering.ejb.RemoteEJBDirectory 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.ejb.RemoteEJBDirectory in project wildfly by wildfly.
the class RemoteFailoverTestCase method testConcurrentFailover.
public void testConcurrentFailover(Lifecycle lifecycle) 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)) {
Incrementor bean = directory.lookupStateful(SlowToDestroyStatefulIncrementorBean.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, INVOCATION_WAIT, TimeUnit.MILLISECONDS);
latch.await();
lifecycle.stop(target);
future.cancel(false);
try {
future.get();
} catch (CancellationException e) {
// Ignore
}
lifecycle.start(target);
latch = new CountDownLatch(1);
future = executor.scheduleWithFixedDelay(new LookupTask(directory, SlowToDestroyStatefulIncrementorBean.class, latch), 0, INVOCATION_WAIT, 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.RemoteEJBDirectory in project wildfly by wildfly.
the class ServiceProviderRegistrationTestCase 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)) {
ServiceProviderRetriever bean = directory.lookupStateless(ServiceProviderRetrieverBean.class, ServiceProviderRetriever.class);
Collection<String> names = bean.getProviders();
assertEquals(2, names.size());
assertTrue(names.toString(), names.contains(NODE_1));
assertTrue(names.toString(), names.contains(NODE_2));
undeploy(DEPLOYMENT_1);
names = bean.getProviders();
assertEquals(1, names.size());
assertTrue(names.contains(NODE_2));
deploy(DEPLOYMENT_1);
names = bean.getProviders();
assertEquals(2, names.size());
assertTrue(names.contains(NODE_1));
assertTrue(names.contains(NODE_2));
stop(CONTAINER_2);
names = bean.getProviders();
assertEquals(1, names.size());
assertTrue(names.contains(NODE_1));
start(CONTAINER_2);
names = bean.getProviders();
assertEquals(2, names.size());
assertTrue(names.contains(NODE_1));
assertTrue(names.contains(NODE_2));
}
}
Aggregations