Search in sources :

Example 26 with SpecAssertion

use of org.jboss.test.audit.annotations.SpecAssertion in project cdi-tck by eclipse-ee4j.

the class ApplicationContextSharedTest method testApplicationContextShared.

@OperateOnDeployment("TEST")
@Test
@SpecAssertion(section = APPLICATION_CONTEXT_EE, id = "e")
public void testApplicationContextShared() throws Exception {
    FMSModelIII.reset();
    FMS flightManagementSystem = getContextualReference(FMS.class);
    flightManagementSystem.climb();
    Timer timer = new Timer().setDelay(20, TimeUnit.SECONDS).addStopCondition(new StopCondition() {

        public boolean isSatisfied() {
            return FMSModelIII.isClimbed();
        }
    }).start();
    flightManagementSystem.descend();
    timer.addStopCondition(new StopCondition() {

        public boolean isSatisfied() {
            return FMSModelIII.isDescended();
        }
    }, true).start();
    assertTrue(flightManagementSystem.isSameBean());
}
Also used : Timer(org.jboss.cdi.tck.util.Timer) StopCondition(org.jboss.cdi.tck.util.Timer.StopCondition) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) AbstractTest(org.jboss.cdi.tck.AbstractTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 27 with SpecAssertion

use of org.jboss.test.audit.annotations.SpecAssertion in project cdi-tck by eclipse-ee4j.

the class DestroyForSameCreationalContext2Test method testDestroyForSameCreationalContextOnly.

@Test
@SpecAssertion(section = CONTEXT, id = "r")
public void testDestroyForSameCreationalContextOnly() {
    // Check that the mock cc is called (via cc.release()) when we request a context destroyed
    // Note that this is an indirect effect
    Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
    Context requestContext = getCurrentManager().getContext(RequestScoped.class);
    // We also test this directly using a custom contextual, and ensuring that the same contextual is passed to both methods
    DummyContextual contextual = new DummyContextual();
    sessionContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
    destroyContext(sessionContext);
    assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
    // Also test the request context
    contextual = new DummyContextual();
    requestContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
    destroyContext(requestContext);
    assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
}
Also used : Context(jakarta.enterprise.context.spi.Context) AbstractTest(org.jboss.cdi.tck.AbstractTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 28 with SpecAssertion

use of org.jboss.test.audit.annotations.SpecAssertion in project cdi-tck by eclipse-ee4j.

the class ProcessInjectionPointFiredTest method testDisposerMethodInjectionPoint.

@Test
@SpecAssertion(section = BEAN_DISCOVERY_STEPS, id = "je")
public void testDisposerMethodInjectionPoint() {
    InjectionPoint deltaIp = extension.getDisposerDeltaIp();
    assertNotNull(deltaIp);
    verifyType(deltaIp, Delta.class);
}
Also used : InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) AbstractTest(org.jboss.cdi.tck.AbstractTest) Test(org.testng.annotations.Test) SpecAssertion(org.jboss.test.audit.annotations.SpecAssertion)

Example 29 with SpecAssertion

use of org.jboss.test.audit.annotations.SpecAssertion in project cdi-tck by eclipse-ee4j.

the class SessionContextTest method testSessionContextSharedBetweenServletRequestsInSameHttpSession.

@Test(groups = INTEGRATION)
@SpecAssertion(section = SESSION_CONTEXT_EE, id = "b")
public void testSessionContextSharedBetweenServletRequestsInSameHttpSession() throws Exception {
    WebClient webClient = new WebClient();
    TextPage firstRequestResult = webClient.getPage(contextPath + "introspect");
    assertNotNull(firstRequestResult.getContent());
    String sessionBeanId = firstRequestResult.getContent();
    assertNotNull(sessionBeanId);
    // Make a second request and make sure the same context is used
    TextPage secondRequestResult = webClient.getPage(contextPath + "introspect");
    assertNotNull(secondRequestResult.getContent());
    assertEquals(secondRequestResult.getContent(), sessionBeanId);
}
Also used : 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 30 with SpecAssertion

use of org.jboss.test.audit.annotations.SpecAssertion 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)

Aggregations

SpecAssertion (org.jboss.test.audit.annotations.SpecAssertion)943 Test (org.testng.annotations.Test)893 AbstractTCKTest (org.hibernate.beanvalidation.tck.tests.AbstractTCKTest)595 ConstraintViolation (jakarta.validation.ConstraintViolation)265 Validator (jakarta.validation.Validator)216 AbstractTest (org.jboss.cdi.tck.AbstractTest)212 WebClient (com.gargoylesoftware.htmlunit.WebClient)190 Method (java.lang.reflect.Method)152 TextPage (com.gargoylesoftware.htmlunit.TextPage)80 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)73 Test (org.junit.Test)49 MethodDescriptor (jakarta.validation.metadata.MethodDescriptor)44 BeanDescriptor (jakarta.validation.metadata.BeanDescriptor)40 ConstructorDescriptor (jakarta.validation.metadata.ConstructorDescriptor)38 NotNull (jakarta.validation.constraints.NotNull)35 ValidatorFactory (jakarta.validation.ValidatorFactory)32 PropertyDescriptor (jakarta.validation.metadata.PropertyDescriptor)31 Context (jakarta.enterprise.context.spi.Context)30 SeContainer (jakarta.enterprise.inject.se.SeContainer)30 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)28