use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.
the class ClusteredJPA2LCTestCase method testEntityCacheReplication.
/**
* We have a replicated entity cache between two nodes. Cache an entity on node0 and then verify that
* node1 sees the cached entity as well. Then try evicting it (synchronously inside a JTA transaction)
* on one node and see if it's been evicted on the other node as well. Finally, try caching it again.
*
* The two nodes don't actually have a shared database instance, but that doesn't matter for this test.
*/
@Test
@InSequence(0)
public void testEntityCacheReplication(@ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) URL url0, @ArquillianResource @OperateOnDeployment(DEPLOYMENT_2) URL url1) throws Exception {
final WebTarget node0 = getWebTarget(url0);
final WebTarget node1 = getWebTarget(url1);
final String entityId = "1";
createEntity(node0, entityId);
Assert.assertTrue(isInCache(node0, entityId));
Assert.assertTrue(isInCache(node1, entityId));
evictFromCache(node1, entityId);
Assert.assertFalse(isInCache(node0, entityId));
Assert.assertFalse(isInCache(node1, entityId));
addToCache(node0, entityId);
Assert.assertTrue(isInCache(node0, entityId));
Assert.assertTrue(isInCache(node1, entityId));
}
use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.
the class ClusteredJPA2LCTestCase method tearDown.
@Test
@InSequence(Integer.MAX_VALUE)
public void tearDown() throws IOException {
final ModelNode removeOp = new ModelNode();
removeOp.get(ADDRESS).set(CACHE_ADDRESS);
removeOp.get(OP).set(REMOVE_OPERATION);
if (client0 != null) {
client0.execute(removeOp);
client0.close();
}
if (client1 != null) {
client1.execute(removeOp);
client1.close();
}
if (restClient != null) {
restClient.close();
}
}
use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.
the class RemoteFailoverTestCase method testStatefulFailover.
@InSequence(2)
@Test
public void testStatefulFailover() 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 context = new RemoteEJBDirectory(MODULE_NAME)) {
Incrementor bean = context.lookupStateful(StatefulIncrementorBean.class, Incrementor.class);
Result<Integer> result = bean.increment();
String target = result.getNode();
int count = 1;
Assert.assertEquals(count++, result.getValue().intValue());
// Bean should retain weak affinity for this node
for (int i = 0; i < COUNT; ++i) {
result = bean.increment();
Assert.assertEquals(count++, result.getValue().intValue());
Assert.assertEquals(String.valueOf(i), target, result.getNode());
}
undeploy(this.findDeployment(target));
result = bean.increment();
// Bean should failover to other node
String failoverTarget = result.getNode();
Assert.assertEquals(count++, result.getValue().intValue());
Assert.assertNotEquals(target, failoverTarget);
deploy(this.findDeployment(target));
// Allow sufficient time for client to receive new topology
Thread.sleep(CLIENT_TOPOLOGY_UPDATE_WAIT);
result = bean.increment();
String failbackTarget = result.getNode();
Assert.assertEquals(count++, result.getValue().intValue());
// Bean should retain weak affinity for this node
Assert.assertEquals(failoverTarget, failbackTarget);
result = bean.increment();
// Bean may have acquired new weak affinity
target = result.getNode();
Assert.assertEquals(count++, result.getValue().intValue());
// Bean should retain weak affinity for this node
for (int i = 0; i < COUNT; ++i) {
result = bean.increment();
Assert.assertEquals(count++, result.getValue().intValue());
Assert.assertEquals(String.valueOf(i), target, result.getNode());
}
stop(this.findContainer(target));
result = bean.increment();
// Bean should failover to other node
failoverTarget = result.getNode();
Assert.assertEquals(count++, result.getValue().intValue());
Assert.assertNotEquals(target, failoverTarget);
start(this.findContainer(target));
// Allow sufficient time for client to receive new topology
Thread.sleep(CLIENT_TOPOLOGY_UPDATE_WAIT);
result = bean.increment();
failbackTarget = result.getNode();
Assert.assertEquals(count++, result.getValue().intValue());
// Bean should retain weak affinity for this node
Assert.assertEquals(failoverTarget, failbackTarget);
result = bean.increment();
// Bean may have acquired new weak affinity
target = result.getNode();
Assert.assertEquals(count++, result.getValue().intValue());
// Bean should retain weak affinity for this node
for (int i = 0; i < COUNT; ++i) {
result = bean.increment();
Assert.assertEquals(count++, result.getValue().intValue());
Assert.assertEquals(String.valueOf(i), target, result.getNode());
}
}
}
use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.
the class RemoteFailoverTestCase method testClientException.
/**
* Test for WFLY-5788.
*/
@InSequence(5)
@Test
public void testClientException() 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 context = new RemoteEJBDirectory(MODULE_NAME)) {
Incrementor bean = context.lookupStateful(InfinispanExceptionThrowingIncrementorBean.class, Incrementor.class);
bean.increment();
} catch (Exception ejbException) {
assertTrue("Expected exception wrapped in EJBException", ejbException instanceof EJBException);
assertNull("Cause of EJBException has not been removed", ejbException.getCause());
return;
}
fail("Expected EJBException but didn't catch it");
}
use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.
the class SimpleTimerServiceTestCase method testIntervalTimer.
@Test
@InSequence(3)
public void testIntervalTimer() throws NamingException {
InitialContext ctx = new InitialContext();
TimerConfig timerConfig = new TimerConfig();
timerConfig.setInfo(INFO_MSG_FOR_CHECK);
AnnotationTimerServiceBean bean1 = (AnnotationTimerServiceBean) ctx.lookup("java:module/" + AnnotationTimerServiceBean.class.getSimpleName());
bean1.resetTimerServiceCalled();
long ts = (new Date()).getTime() + TIMER_INIT_TIME_MS;
Timer timer1 = bean1.getTimerService().createIntervalTimer(new Date(ts), TIMER_TIMEOUT_TIME_MS, timerConfig);
Assert.assertTrue(AnnotationTimerServiceBean.awaitTimerCall());
bean1.resetTimerServiceCalled();
Assert.assertTrue(AnnotationTimerServiceBean.awaitTimerCall());
timer1.cancel();
TimedObjectTimerServiceBean bean2 = (TimedObjectTimerServiceBean) ctx.lookup("java:module/" + TimedObjectTimerServiceBean.class.getSimpleName());
bean2.resetTimerServiceCalled();
Timer timer2 = bean2.getTimerService().createIntervalTimer(TIMER_INIT_TIME_MS, TIMER_TIMEOUT_TIME_MS, timerConfig);
Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
bean2.resetTimerServiceCalled();
Assert.assertTrue(TimedObjectTimerServiceBean.awaitTimerCall());
timer2.cancel();
}
Aggregations