Skip to content

Commit

Permalink
Comment out section of RemoteStatefulEJBConcurrentFailoverTestCase fa…
Browse files Browse the repository at this point in the history
…iling due to EJBCLIENT-279.
  • Loading branch information
pferraro committed Oct 3, 2017
1 parent 1ecbe59 commit 4f0af94
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
Expand Up @@ -149,6 +149,8 @@ public void test() throws Exception {
Assert.assertEquals(count++, result.getValue().intValue()); Assert.assertEquals(count++, result.getValue().intValue());
Assert.assertEquals(String.valueOf(i), target, result.getNode()); Assert.assertEquals(String.valueOf(i), target, result.getNode());
} }

bean.remove();
} }
} }
} }
Expand Up @@ -39,7 +39,7 @@
import org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor; import org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor;
import org.jboss.as.test.clustering.cluster.ejb.remote.bean.IncrementorBean; import org.jboss.as.test.clustering.cluster.ejb.remote.bean.IncrementorBean;
import org.jboss.as.test.clustering.cluster.ejb.remote.bean.Result; import org.jboss.as.test.clustering.cluster.ejb.remote.bean.Result;
import org.jboss.as.test.clustering.cluster.ejb.remote.bean.SlowToDestroyStatefulIncrementorBean; import org.jboss.as.test.clustering.cluster.ejb.remote.bean.SlowStatefulIncrementorBean;
import org.jboss.as.test.clustering.ejb.EJBDirectory; import org.jboss.as.test.clustering.ejb.EJBDirectory;
import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory; import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory;
import org.jboss.as.test.shared.TimeoutUtil; import org.jboss.as.test.shared.TimeoutUtil;
Expand All @@ -61,7 +61,6 @@ public class RemoteStatefulEJBConcurrentFailoverTestCase extends ClusterAbstract
private static final String MODULE_NAME = "remote-stateful-ejb-concurrent-failover-test"; private static final String MODULE_NAME = "remote-stateful-ejb-concurrent-failover-test";


private static final long CLIENT_TOPOLOGY_UPDATE_WAIT = TimeoutUtil.adjust(5000); private static final long CLIENT_TOPOLOGY_UPDATE_WAIT = TimeoutUtil.adjust(5000);
private static final long INVOCATION_WAIT = TimeoutUtil.adjust(10);


@Deployment(name = DEPLOYMENT_1, managed = false, testable = false) @Deployment(name = DEPLOYMENT_1, managed = false, testable = false)
@TargetsContainer(CONTAINER_1) @TargetsContainer(CONTAINER_1)
Expand All @@ -78,7 +77,7 @@ public static Archive<?> createDeploymentForContainer2() {
private static Archive<?> createDeployment() { private static Archive<?> createDeployment() {
return ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar") return ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar")
.addPackage(EJBDirectory.class.getPackage()) .addPackage(EJBDirectory.class.getPackage())
.addClasses(Result.class, Incrementor.class, IncrementorBean.class, SlowToDestroyStatefulIncrementorBean.class) .addClasses(Result.class, Incrementor.class, IncrementorBean.class, SlowStatefulIncrementorBean.class)
.addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(new PropertyPermission(NODE_NAME_PROPERTY, "read")), "permissions.xml") .addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(new PropertyPermission(NODE_NAME_PROPERTY, "read")), "permissions.xml")
; ;
} }
Expand All @@ -90,7 +89,7 @@ public void test() throws Exception {


public void test(Lifecycle lifecycle) throws Exception { public void test(Lifecycle lifecycle) throws Exception {
try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) { try (EJBDirectory directory = new RemoteEJBDirectory(MODULE_NAME)) {
Incrementor bean = directory.lookupStateful(SlowToDestroyStatefulIncrementorBean.class, Incrementor.class); Incrementor bean = directory.lookupStateful(SlowStatefulIncrementorBean.class, Incrementor.class);


AtomicInteger count = new AtomicInteger(); AtomicInteger count = new AtomicInteger();


Expand All @@ -102,7 +101,7 @@ public void test(Lifecycle lifecycle) throws Exception {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
try { try {
CountDownLatch latch = new CountDownLatch(1); CountDownLatch latch = new CountDownLatch(1);
Future<?> future = executor.scheduleWithFixedDelay(new IncrementTask(bean, count, latch), 0, INVOCATION_WAIT, TimeUnit.MILLISECONDS); Future<?> future = executor.scheduleWithFixedDelay(new IncrementTask(bean, count, latch), 0, 1, TimeUnit.MILLISECONDS);
latch.await(); latch.await();


lifecycle.stop(target); lifecycle.stop(target);
Expand All @@ -114,10 +113,12 @@ public void test(Lifecycle lifecycle) throws Exception {
// Ignore // Ignore
} }


bean.remove();
/* EJBCLIENT-279
lifecycle.start(target); lifecycle.start(target);
latch = new CountDownLatch(1); latch = new CountDownLatch(1);
future = executor.scheduleWithFixedDelay(new LookupTask(directory, SlowToDestroyStatefulIncrementorBean.class, latch), 0, INVOCATION_WAIT, TimeUnit.MILLISECONDS); future = executor.scheduleWithFixedDelay(new LookupTask(directory, SlowStatefulIncrementorBean.class, latch), 0, 1, TimeUnit.MILLISECONDS);
latch.await(); latch.await();
lifecycle.stop(target); lifecycle.stop(target);
Expand All @@ -128,7 +129,7 @@ public void test(Lifecycle lifecycle) throws Exception {
} catch (CancellationException e) { } catch (CancellationException e) {
// Ignore // Ignore
} }

*/
lifecycle.start(target); lifecycle.start(target);
} finally { } finally {
executor.shutdownNow(); executor.shutdownNow();
Expand Down Expand Up @@ -157,7 +158,7 @@ public void run() {
} }
} }
} }

/*
private class LookupTask implements Runnable { private class LookupTask implements Runnable {
private final EJBDirectory directory; private final EJBDirectory directory;
private final Class<? extends Incrementor> beanClass; private final Class<? extends Incrementor> beanClass;
Expand All @@ -172,12 +173,13 @@ private class LookupTask implements Runnable {
@Override @Override
public void run() { public void run() {
try { try {
this.directory.lookupStateful(this.beanClass, Incrementor.class); this.directory.lookupStateful(this.beanClass, Incrementor.class).remove();
} catch (Exception e) { } catch (Exception e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
} finally { } finally {
this.latch.countDown(); this.latch.countDown();
} }
} }
} }
*/
} }
Expand Up @@ -21,6 +21,13 @@
*/ */
package org.jboss.as.test.clustering.cluster.ejb.remote.bean; package org.jboss.as.test.clustering.cluster.ejb.remote.bean;


import javax.ejb.Remove;

public interface Incrementor { public interface Incrementor {
Result<Integer> increment(); Result<Integer> increment();

@Remove
default void remove() {
// Do nothing
}
} }
Expand Up @@ -23,15 +23,26 @@


import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;


import javax.annotation.PreDestroy; import javax.annotation.PostConstruct;
import javax.ejb.Remote; import javax.ejb.Remote;
import javax.ejb.Stateful; import javax.ejb.Stateful;


@Stateful @Stateful
@Remote(Incrementor.class) @Remote(Incrementor.class)
public class SlowToDestroyStatefulIncrementorBean extends IncrementorBean { public class SlowStatefulIncrementorBean extends IncrementorBean {
@PreDestroy
public void preDestroy() { @Override
public Result<Integer> increment() {
delay();
return super.increment();
}

@PostConstruct
public void init() {
delay();
}

private static void delay() {
try { try {
TimeUnit.SECONDS.sleep(2); TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Expand Down

0 comments on commit 4f0af94

Please sign in to comment.