Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement