Search in sources :

Example 86 with InSequence

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));
}
Also used : WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 87 with InSequence

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();
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 88 with InSequence

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

Example 89 with InSequence

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");
}
Also used : Incrementor(org.jboss.as.test.clustering.cluster.ejb.remote.bean.Incrementor) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBException(javax.ejb.EJBException) RemoteEJBDirectory(org.jboss.as.test.clustering.ejb.RemoteEJBDirectory) EJBDirectory(org.jboss.as.test.clustering.ejb.EJBDirectory) NamingException(javax.naming.NamingException) CancellationException(java.util.concurrent.CancellationException) EJBException(javax.ejb.EJBException) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 90 with InSequence

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();
}
Also used : Timer(javax.ejb.Timer) TimerConfig(javax.ejb.TimerConfig) InitialContext(javax.naming.InitialContext) Date(java.util.Date) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

InSequence (org.jboss.arquillian.junit.InSequence)157 Test (org.junit.Test)157 Faker (com.github.javafaker.Faker)21 Simple (org.apache.deltaspike.data.test.ee7.domain.Simple)18 ModelNode (org.jboss.dmr.ModelNode)14 URL (java.net.URL)13 HttpResponse (org.apache.http.HttpResponse)10 TakeOffer (io.bisq.api.model.TakeOffer)9 HttpGet (org.apache.http.client.methods.HttpGet)8 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)8 OfferToCreate (io.bisq.api.model.OfferToCreate)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 PartitionManager (org.picketlink.idm.PartitionManager)7 Response (javax.ws.rs.core.Response)6 IdentityManager (org.picketlink.idm.IdentityManager)6 StringTokenizer (java.util.StringTokenizer)5 RouteBuilder (org.apache.camel.builder.RouteBuilder)5 House (org.apache.deltaspike.data.test.ee7.domain.House)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)5