use of org.jboss.cdi.tck.util.ActionSequence in project cdi-tck by eclipse-ee4j.
the class ApplicationShutdownLifecycleTest method testShutdown.
/**
* Note that this test method depends on (must be run after)
*
* @throws Exception
*/
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER)
@SpecAssertions({ @SpecAssertion(section = SHUTDOWN, id = "a"), @SpecAssertion(section = SHUTDOWN, id = "b"), @SpecAssertion(section = REQUEST_CONTEXT_EE, id = "ja"), @SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "ga"), @SpecAssertion(section = BEFORE_SHUTDOWN, id = "a") })
public void testShutdown(@ArquillianResource @OperateOnDeployment(FOO) URL fooContext, @ArquillianResource @OperateOnDeployment(INFO) URL infoContext) throws Exception {
// Init foo - set info archive deployment url
WebClient webClient = new WebClient();
webClient.getPage(fooContext + "init?url=" + URLEncoder.encode(infoContext.toExternalForm(), "UTF-8"));
// Undeploy foo
deployer.undeploy(FOO);
// 1. Destroy contexts (the order is not set)
// 2. BeforeShutdown event
TextPage info = webClient.getPage(infoContext + "info?action=get");
ActionSequence actual = ActionSequence.buildFromCsvData(info.getContent());
assertTrue(actual.endsWith(BeforeShutdown.class.getName()));
actual.assertDataContainsAll(RequestScoped.class.getName(), SessionScoped.class.getName(), ApplicationScoped.class.getName(), ConversationScoped.class.getName(), Foo.class.getName(), Bar.class.getName(), Baz.class.getName(), Qux.class.getName());
// Undeploy info
deployer.undeploy(INFO);
}
use of org.jboss.cdi.tck.util.ActionSequence in project cdi-tck by eclipse-ee4j.
the class SessionContextTest method testSessionContextDestroyedWhenHttpSessionInvalidated.
/**
* Test that the session context is destroyed at the very end of any request
* in which invalidate() was called, after all filters and
* ServletRequestListeners have been called.
*
* @throws Exception
*/
@Test(groups = INTEGRATION)
@SpecAssertion(section = SESSION_CONTEXT_EE, id = "ca")
public void testSessionContextDestroyedWhenHttpSessionInvalidated() throws Exception {
WebClient webClient = new WebClient();
TextPage firstRequestResult = webClient.getPage(contextPath + "introspect");
assertNotNull(firstRequestResult.getContent());
String sessionBeanId = firstRequestResult.getContent();
// Invalidate the session
webClient.getPage(contextPath + "introspect?mode=invalidate");
// Make a second request and make sure the same context is not there
TextPage secondRequestResult = webClient.getPage(contextPath + "introspect");
assertNotNull(secondRequestResult.getContent());
assertNotEquals(secondRequestResult.getContent(), sessionBeanId);
// Verify context is destroyed after all filters and
// ServletRequestListeners
TextPage verifyResult = webClient.getPage(contextPath + "introspect?mode=verify");
ActionSequence correctSequence = new ActionSequence().add(IntrospectServlet.class.getName()).add(IntrospectHttpSessionListener.class.getName()).add(IntrospectFilter.class.getName()).add(IntrospectServletRequestListener.class.getName()).add(SimpleSessionBean.class.getName());
assertEquals(verifyResult.getContent(), correctSequence.toString());
}
use of org.jboss.cdi.tck.util.ActionSequence in project cdi-tck by eclipse-ee4j.
the class LifecycleEventOrderingTest method testEventsWereFiredInCorrectOrderForManagedBean.
@Test
@SpecAssertion(section = BEAN_DISCOVERY_STEPS, id = "e")
@SpecAssertion(section = BEAN_DISCOVERY_STEPS, id = "f")
@SpecAssertion(section = BEAN_DISCOVERY_STEPS, id = "h")
@SpecAssertion(section = BEAN_DISCOVERY_STEPS, id = "i")
public void testEventsWereFiredInCorrectOrderForManagedBean() {
ActionSequence producerEventsSeq = ActionSequence.getSequence(ProductManagement.BEAN_SEQ);
producerEventsSeq.assertDataEquals("PIP", "PIT", "PBA", "PB");
}
use of org.jboss.cdi.tck.util.ActionSequence in project cdi-tck by eclipse-ee4j.
the class ActionSequenceTest method testStringValues.
@Test
public void testStringValues() {
ActionSequence seq = null;
try {
seq = new ActionSequence("The best sequence");
fail();
} catch (IllegalArgumentException expected) {
}
seq = new ActionSequence();
seq.add("01254_55757.dd");
seq.add(ActionSequence.class.getName());
seq.add("org.jboss.weld.Proxy$Foo");
seq.add("-$");
seq.add(UUID.randomUUID().toString());
try {
seq.add("^$loop");
fail();
} catch (IllegalArgumentException expected) {
}
try {
seq.add("My test");
fail();
} catch (IllegalArgumentException expected) {
}
}
use of org.jboss.cdi.tck.util.ActionSequence in project cdi-tck by eclipse-ee4j.
the class ActionSequenceTest method testAssertDataContainsAll.
@Test
public void testAssertDataContainsAll() {
ActionSequence.reset();
ActionSequence seq = new ActionSequence();
Set<String> set = new HashSet<String>();
set.add("1");
set.add("2");
set.add("3");
for (String s : set) {
seq.add(s);
}
seq.add("4");
seq.assertDataContainsAll(set);
try {
seq.assertDataContainsAll("1", "2", "5");
fail();
} catch (Throwable expected) {
}
try {
ActionSequence.assertSequenceDataContainsAll(set);
fail();
} catch (Throwable expected) {
// should fail because there is no default sequence
}
}
Aggregations