Search in sources :

Example 1 with ActionSequence

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);
}
Also used : SessionScoped(jakarta.enterprise.context.SessionScoped) ActionSequence(org.jboss.cdi.tck.util.ActionSequence) ConversationScoped(jakarta.enterprise.context.ConversationScoped) TextPage(com.gargoylesoftware.htmlunit.TextPage) RequestScoped(jakarta.enterprise.context.RequestScoped) ApplicationScoped(jakarta.enterprise.context.ApplicationScoped) WebClient(com.gargoylesoftware.htmlunit.WebClient) SpecAssertions(org.jboss.test.audit.annotations.SpecAssertions) Test(org.testng.annotations.Test) AbstractTest(org.jboss.cdi.tck.AbstractTest)

Example 2 with ActionSequence

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());
}
Also used : ActionSequence(org.jboss.cdi.tck.util.ActionSequence) TextPage(com.gargoylesoftware.htmlunit.TextPage) WebClient(com.gargoylesoftware.htmlunit.WebClient) AbstractTest(org.jboss.cdi.tck.AbstractTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 3 with ActionSequence

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");
}
Also used : ActionSequence(org.jboss.cdi.tck.util.ActionSequence) AbstractTest(org.jboss.cdi.tck.AbstractTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 4 with ActionSequence

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) {
    }
}
Also used : ActionSequence(org.jboss.cdi.tck.util.ActionSequence) Test(org.testng.annotations.Test)

Example 5 with ActionSequence

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
    }
}
Also used : ActionSequence(org.jboss.cdi.tck.util.ActionSequence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

ActionSequence (org.jboss.cdi.tck.util.ActionSequence)26 Test (org.testng.annotations.Test)26 AbstractTest (org.jboss.cdi.tck.AbstractTest)18 SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)16 TextPage (com.gargoylesoftware.htmlunit.TextPage)8 WebClient (com.gargoylesoftware.htmlunit.WebClient)8 ApplicationScoped (jakarta.enterprise.context.ApplicationScoped)2 ConversationScoped (jakarta.enterprise.context.ConversationScoped)2 RequestScoped (jakarta.enterprise.context.RequestScoped)2 SessionScoped (jakarta.enterprise.context.SessionScoped)2 HashSet (java.util.HashSet)2 SpecAssertions (org.jboss.test.audit.annotations.SpecAssertions)2