Search in sources :

Example 1 with RemoteEJBDirectory

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);
}
Also used : RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) BeforeClass(org.junit.BeforeClass)

Example 2 with RemoteEJBDirectory

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);
}
Also used : ArrayList(java.util.ArrayList) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) BeforeClass(org.junit.BeforeClass)

Example 3 with RemoteEJBDirectory

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()));
    }
}
Also used : ClusterTopologyRetriever(org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) ClusterTopology(org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) Test(org.junit.Test)

Example 4 with RemoteEJBDirectory

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();
        }
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CancellationException(java.util.concurrent.CancellationException) Incrementor(org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) CountDownLatch(java.util.concurrent.CountDownLatch) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory)

Example 5 with RemoteEJBDirectory

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));
    }
}
Also used : ServiceProviderRetriever(org.jboss.as.test.clustering.cluster.provider.bean.ServiceProviderRetriever) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) Test(org.junit.Test)

Aggregations

RemoteEJBDirectory (org.jboss.as.test.clustering.ejb.RemoteEJBDirectory)13 EJBDirectory (org.jboss.as.test.clustering.ejb.EJBDirectory)10 Test (org.junit.Test)8 Incrementor (org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 JBossEJBProperties (org.jboss.ejb.client.legacy.JBossEJBProperties)3 BeforeClass (org.junit.BeforeClass)3 ArrayList (java.util.ArrayList)2 CancellationException (java.util.concurrent.CancellationException)2 InSequence (org.jboss.arquillian.junit.InSequence)2 ClusterTopology (org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopology)2 ClusterTopologyRetriever (org.jboss.as.test.clustering.cluster.dispatcher.bean.ClusterTopologyRetriever)2 ServiceProviderRetriever (org.jboss.as.test.clustering.cluster.provider.bean.ServiceProviderRetriever)2 RegistryRetriever (org.jboss.as.test.clustering.cluster.registry.bean.RegistryRetriever)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 EJBException (javax.ejb.EJBException)1 NamingException (javax.naming.NamingException)1