Search in sources :

Example 1 with ActionSequence

use of org.jboss.weld.test.util.ActionSequence in project core by weld.

the class ResourceInjectionTest method testResourceInjectionOrdering.

@SuppressWarnings("unchecked")
@Test
public void testResourceInjectionOrdering(BeanManager beanManager) {
    ActionSequence.reset();
    Bean<Alpha> bean = (Bean<Alpha>) beanManager.resolve(beanManager.getBeans(Alpha.class));
    CreationalContext<Alpha> ctx = beanManager.createCreationalContext(bean);
    Alpha instance = bean.create(ctx);
    bean.destroy(instance, ctx);
    ActionSequence sequence = ActionSequence.getSequence();
    assertEquals(4, sequence.getData().size());
    assertTrue(sequence.beginsWith(Charlie.class.getName() + String.class.getName(), Bravo.class.getName() + SessionBean.class.getName()));
}
Also used : ActionSequence(org.jboss.weld.test.util.ActionSequence) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 2 with ActionSequence

use of org.jboss.weld.test.util.ActionSequence in project core by weld.

the class PersistenceInjectionTest method testResourceInjectionOrdering.

@SuppressWarnings("unchecked")
@Test
public void testResourceInjectionOrdering(BeanManager beanManager) {
    ActionSequence.reset();
    Bean<Alpha> bean = (Bean<Alpha>) beanManager.resolve(beanManager.getBeans(Alpha.class));
    CreationalContext<Alpha> ctx = beanManager.createCreationalContext(bean);
    Alpha instance = bean.create(ctx);
    bean.destroy(instance, ctx);
    ActionSequence sequence = ActionSequence.getSequence();
    assertEquals(4, sequence.getData().size());
    assertTrue(sequence.beginsWith(Charlie.class.getName() + EntityManager.class.getName(), Bravo.class.getName() + EntityManagerFactory.class.getName()));
}
Also used : EntityManager(javax.persistence.EntityManager) ActionSequence(org.jboss.weld.test.util.ActionSequence) EntityManagerFactory(javax.persistence.EntityManagerFactory) Bean(javax.enterprise.inject.spi.Bean) Test(org.junit.Test)

Example 3 with ActionSequence

use of org.jboss.weld.test.util.ActionSequence in project core by weld.

the class ConversationContextDestroyedOnSessionTimeoutTest method testConversationContextDestroyedCorrectly.

@Test
public void testConversationContextDestroyedCorrectly() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
    WebClient client = new WebClient();
    client.setThrowExceptionOnFailingStatusCode(false);
    String cid = client.getPage(contextPath + "/init").getWebResponse().getContentAsString();
    ActionSequence sequence = new ActionSequence();
    sequence.add(Foo.class.getSimpleName() + "pingStart");
    sequence.add(SessionListener.class.getSimpleName() + "destroyed");
    sequence.add(Foo.class.getSimpleName() + "destroy");
    sequence.add(Foo.class.getSimpleName() + "pingEnd");
    assertEquals(sequence.dataToCsv(), client.getPage(contextPath + "/test" + "?cid=" + cid).getWebResponse().getContentAsString().trim());
}
Also used : ActionSequence(org.jboss.weld.test.util.ActionSequence) WebClient(com.gargoylesoftware.htmlunit.WebClient) Test(org.junit.Test)

Example 4 with ActionSequence

use of org.jboss.weld.test.util.ActionSequence in project core by weld.

the class InstanceIteratorTest method testIteration.

@Test
public void testIteration() {
    ActionSequence.reset();
    Bean<Master> bean = Utils.getBean(beanManager, Master.class);
    CreationalContext<Master> ctx = beanManager.createCreationalContext(bean);
    Master master = bean.create(ctx);
    master.iterate();
    bean.destroy(master, ctx);
    ActionSequence init = ActionSequence.getSequence("init");
    assertNotNull(init);
    assertEquals(2, init.getData().size());
    assertTrue(init.containsAll(Alpha.class.getName(), Bravo.class.getName()));
    ActionSequence destroy = ActionSequence.getSequence("destroy");
    assertNotNull(destroy);
    assertEquals(2, destroy.getData().size());
    assertTrue(destroy.containsAll(Alpha.class.getName(), Bravo.class.getName()));
}
Also used : ActionSequence(org.jboss.weld.test.util.ActionSequence) Test(org.junit.Test)

Aggregations

ActionSequence (org.jboss.weld.test.util.ActionSequence)4 Test (org.junit.Test)4 Bean (javax.enterprise.inject.spi.Bean)2 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 EntityManager (javax.persistence.EntityManager)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1