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());
}
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);
}
}
}
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);
}
}
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);
}
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);
}
Aggregations