Created
March 13, 2019 19:08
-
-
Save ljnelson/15f0dfe964941538020d9f8fde4fd805 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ApplicationScoped | |
public class TransactionScopeLifecycleEventsTest { | |
private static boolean initializedObserved; | |
private AutoCloseable container; | |
@Before | |
public void setUp() throws Exception { | |
this.tearDown(); | |
final Weld weld = new Weld() | |
.addExtension(new TransactionExtension()) | |
.addBeanClass(this.getClass()); | |
this.container = weld.initialize(); | |
} | |
@After | |
public void tearDown() throws Exception { | |
if (this.container != null) { | |
this.container.close(); | |
this.container = null; | |
} | |
} | |
private static void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event, | |
final TransactionScopeLifecycleEventsTest self) throws SystemException { | |
self.doSomethingTransactional(); | |
} | |
@Transactional | |
void doSomethingTransactional() throws SystemException { | |
} | |
void transactionScopeActivated(@Observes @Initialized(TransactionScoped.class) final Object event) { | |
assertNotNull(event); | |
initializedObserved = true; | |
} | |
@Test | |
public void testIt() throws Exception { | |
assert initializedObserved; | |
initializedObserved = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment