Search in sources :

Example 1 with CustomEvent

use of org.jboss.weld.environment.se.test.beans.CustomEvent in project core by weld.

the class StartMainObserversTest method testObservers.

@Test
public void testObservers() {
    InitObserverTestBean.reset();
    ObserverTestBean.reset();
    WeldContainer container = startMain.go();
    BeanManager manager = container.getBeanManager();
    manager.fireEvent(new CustomEvent());
    assertTrue(ObserverTestBean.isBuiltInObserved());
    assertTrue(ObserverTestBean.isCustomObserved());
    assertTrue(ObserverTestBean.isInitObserved());
    assertTrue(InitObserverTestBean.isInitObserved());
}
Also used : CustomEvent(org.jboss.weld.environment.se.test.beans.CustomEvent) WeldContainer(org.jboss.weld.environment.se.WeldContainer) BeanManager(javax.enterprise.inject.spi.BeanManager) Test(org.junit.Test)

Example 2 with CustomEvent

use of org.jboss.weld.environment.se.test.beans.CustomEvent in project core by weld.

the class WeldMainTest method testObservers.

/**
 * Test the firing of observers using the alternate API for booting WeldContainer from an SE app.
 */
@Test
public void testObservers() {
    InitObserverTestBean.reset();
    ObserverTestBean.reset();
    Weld weld = new Weld();
    WeldContainer container = weld.initialize();
    container.event().select(CustomEvent.class).fire(new CustomEvent());
    assertTrue(ObserverTestBean.isBuiltInObserved());
    assertTrue(ObserverTestBean.isCustomObserved());
    assertTrue(ObserverTestBean.isInitializedObserved());
    assertFalse(ObserverTestBean.isDestroyedObserved());
    // moved as per WELD-949
    assertTrue(ObserverTestBean.isInitObserved());
    assertTrue(InitObserverTestBean.isInitObserved());
    weld.shutdown();
    assertTrue(ObserverTestBean.isDestroyedObserved());
}
Also used : CustomEvent(org.jboss.weld.environment.se.test.beans.CustomEvent) WeldContainer(org.jboss.weld.environment.se.WeldContainer) Weld(org.jboss.weld.environment.se.Weld) Test(org.junit.Test)

Aggregations

WeldContainer (org.jboss.weld.environment.se.WeldContainer)2 CustomEvent (org.jboss.weld.environment.se.test.beans.CustomEvent)2 Test (org.junit.Test)2 BeanManager (javax.enterprise.inject.spi.BeanManager)1 Weld (org.jboss.weld.environment.se.Weld)1