Search in sources :

Example 81 with InSequence

use of org.jboss.arquillian.junit.InSequence in project javaee7-samples by javaee-samples.

the class FileWatcherTest method should_react_on_deletion_of_existing_text_file.

@Test
@InSequence(3)
public void should_react_on_deletion_of_existing_text_file() throws Exception {
    // given
    File tempFile = new File("/tmp", "test.txt");
    tempFile.delete();
    // when
    await().atMost(TEN_SECONDS).with().pollInterval(FIVE_HUNDRED_MILLISECONDS).until(fileEventObserved());
    // then
    assertThat(tempFile.getName()).isEqualTo(observedFileEvent.getFile().getName());
    assertThat(DELETED).isEqualTo(observedFileEvent.getType());
}
Also used : File(java.io.File) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 82 with InSequence

use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.

the class EjbRemoteSuspendTestCase method testSuspendedCallRejected.

@Test
@InSequence(1)
public void testSuspendedCallRejected() throws Exception {
    final Echo localEcho = (Echo) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + EchoBean.class.getSimpleName() + "!" + Echo.class.getName() + "?stateful");
    final String message = "Silence!";
    String echo = localEcho.echo(message);
    Assert.assertEquals(message, echo);
    ModelNode op = new ModelNode();
    op.get(ModelDescriptionConstants.OP).set("suspend");
    managementClient.getControllerClient().execute(op);
    try {
        long fin = System.currentTimeMillis() + TimeoutUtil.adjust(5000);
        while (true) {
            echo = localEcho.echo(message);
            if (System.currentTimeMillis() > fin)
                Assert.fail("call should have been rejected");
            Thread.sleep(300);
        }
    } catch (NoSuchEJBException expected) {
    } catch (Exception e) {
        Assert.fail(e.getMessage() + " thrown but NoSuchEJBException was expected");
    } finally {
        op = new ModelNode();
        op.get(ModelDescriptionConstants.OP).set("resume");
        managementClient.getControllerClient().execute(op);
        //we need to make sure the module availbility message has been recieved
        //(this is why we have InSequence, so avoid two sleep() calls)
        //otherwise the test might fail intermittently if the message has not been recieved when the
        //next test is started
        //this is a somewhat weird construct, basically we just wait up to 5 seconds for the connection
        //to become usable again
        long fin = System.currentTimeMillis() + 5000;
        while (true) {
            try {
                localEcho.echo(message);
                break;
            } catch (Exception e) {
                if (System.currentTimeMillis() > fin) {
                    throw e;
                }
            }
            Thread.sleep(300);
        }
    }
}
Also used : NoSuchEJBException(javax.ejb.NoSuchEJBException) ModelNode(org.jboss.dmr.ModelNode) NoSuchEJBException(javax.ejb.NoSuchEJBException) NamingException(javax.naming.NamingException) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 83 with InSequence

use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.

the class EjbRemoteSuspendTestCase method testStatefulEjbCreationRejected.

@Test
@InSequence(2)
public void testStatefulEjbCreationRejected() throws Exception {
    ModelNode op = new ModelNode();
    op.get(ModelDescriptionConstants.OP).set("suspend");
    managementClient.getControllerClient().execute(op);
    try {
        long fin = System.currentTimeMillis() + TimeoutUtil.adjust(5000);
        while (true) {
            Echo localEcho = (Echo) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + EchoBean.class.getSimpleName() + "!" + Echo.class.getName() + "?stateful");
            if (System.currentTimeMillis() > fin)
                Assert.fail("call should have been rejected");
            Thread.sleep(300);
        }
    } catch (NamingException expected) {
    } finally {
        op = new ModelNode();
        op.get(ModelDescriptionConstants.OP).set("resume");
        managementClient.getControllerClient().execute(op);
    }
}
Also used : NamingException(javax.naming.NamingException) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 84 with InSequence

use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.

the class ServletRunAsTestCase method runDestroyMethodInStopServer.

/**
     * Restart server for invoking HttpServlet.destroy() method during stopping server. It also hit Servlet for initialization
     * of Servlet before server is restarted.
     *
     * @param url
     * @throws Exception
     */
@Test
@InSequence(10)
@OperateOnDeployment(DEPLOYMENT)
public void runDestroyMethodInStopServer(@ArquillianResource URL url) throws Exception {
    deployer.deploy(DEPLOYMENT);
    URL servletUrl = new URL(url.toExternalForm() + RunAsAdminServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, CORRECT_ROLE_AND_STOP_SERVER.getAbsolutePath()));
    Utils.makeCall(servletUrl.toURI(), HTTP_OK);
    servletUrl = new URL(url.toExternalForm() + RunAsUserServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, INCORRECT_ROLE_AND_STOP_SERVER.getAbsolutePath()));
    Utils.makeCall(servletUrl.toURI(), HTTP_OK);
    ServerReload.executeReloadAndWaitForCompletion(managementClient.getControllerClient(), 50000);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 85 with InSequence

use of org.jboss.arquillian.junit.InSequence in project wildfly by wildfly.

the class ServletRunAsTestCase method runServletWithCorrectRole.

/**
     * Access Servlet which uses RunAs with correct role needed for secured EJB invocation.
     * <p>
     * This method will run init() and doGet() method and stores results.
     *
     * @param url
     * @throws Exception
     */
@Test
@InSequence(1)
@OperateOnDeployment(DEPLOYMENT)
public void runServletWithCorrectRole(@ArquillianResource URL url) throws Exception {
    final URL servletUrl = new URL(url.toExternalForm() + RunAsAdminServlet.SERVLET_PATH.substring(1) + "?" + Utils.encodeQueryParam(CallProtectedEjbServlet.FILE_PARAM, CORRECT_ROLE_AND_UNDEPLOY.getAbsolutePath()));
    correctRoleResult = Utils.makeCall(servletUrl.toURI(), HTTP_OK);
}
Also used : URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) 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