Examples of AlterableContext


Examples of javax.enterprise.context.spi.AlterableContext

    @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER)
    @SpecAssertions({ @SpecAssertion(section = "6.2", id = "t") })
    public void testNothingHappensIfNoInstanceToDestroy(ApplicationScopedComponent application) {
        Bean<?> bean = getUniqueBean(ApplicationScopedComponent.class);
        AlterableContext context = (AlterableContext) getCurrentManager().getContext(bean.getScope());

        AbstractComponent.reset();
        application.setValue("value");
        context.destroy(bean);
        assertTrue(AbstractComponent.isDestroyed());

        context.destroy(bean); // make sure subsequent calls do not raise exception
        context.destroy(bean);
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

    private <T extends AbstractComponent> void testComponent(Class<T> javaClass) {
        Bean<?> bean = getUniqueBean(javaClass);
        @SuppressWarnings("unchecked")
        T reference = (T) getCurrentManager().getReference(bean, javaClass, getCurrentManager().createCreationalContext(bean));
        AlterableContext context = (AlterableContext) getCurrentManager().getContext(bean.getScope());

        for (String string : VALUES) {
            assertNull(reference.getValue());
            reference.setValue(string);
            assertEquals(reference.getValue(), string);

            AbstractComponent.reset();
            context.destroy(bean);
            assertTrue(AbstractComponent.isDestroyed());
            assertNull(reference.getValue(), reference.getValue());
        }
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

        } catch (NoSuchEJBException expected) {
        }

        // try to destroy the bean
        Bean<?> contextual = manager.resolve(manager.getBeans(StatefulBean.class));
        AlterableContext context = (AlterableContext) manager.getContext(ApplicationScoped.class);
        context.destroy(contextual);

        assertEquals("pong", bean.ping());
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

    }

    @Test
    public void testNothingHappensIfNoInstanceToDestroy(ApplicationScopedComponent application) {
        Bean<?> bean = manager.resolve(manager.getBeans(ApplicationScopedComponent.class));
        AlterableContext context = (AlterableContext) manager.getContext(bean.getScope());

        AbstractComponent.reset();
        application.setValue("value");
        context.destroy(bean);
        assertTrue(AbstractComponent.isDestroyed());

        context.destroy(bean); // make sure subsequent calls do not raise exception
        context.destroy(bean);
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

    private <T extends AbstractComponent> void testComponent(Class<T> javaClass) {
        Bean<?> bean = manager.resolve(manager.getBeans(javaClass));
        @SuppressWarnings("unchecked")
        T reference = (T) manager.getReference(bean, javaClass, manager.createCreationalContext(bean));
        AlterableContext context = (AlterableContext) manager.getContext(bean.getScope());

        for (String string : VALUES) {
            assertNull(reference.getValue());
            reference.setValue(string);
            assertEquals(string, reference.getValue());

            AbstractComponent.reset();
            context.destroy(bean);
            assertTrue(AbstractComponent.isDestroyed());
            assertNull(reference.getValue(), reference.getValue());
        }
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

    }

    @Test
    public void testNothingHappensIfNoInstanceToDestroy(ApplicationScopedComponent application) {
        Bean<?> bean = manager.resolve(manager.getBeans(ApplicationScopedComponent.class));
        AlterableContext context = (AlterableContext) manager.getContext(bean.getScope());

        AbstractComponent.reset();
        application.setValue("value");
        context.destroy(bean);
        assertTrue(AbstractComponent.isDestroyed());

        context.destroy(bean); // make sure subsequent calls do not raise exception
        context.destroy(bean);
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

            if (proxy.getHandler() instanceof ProxyMethodHandler) {
                ProxyMethodHandler handler = (ProxyMethodHandler) proxy.getHandler();
                Bean<?> bean = handler.getBean();
                Context context = getBeanManager().getContext(bean.getScope());
                if (context instanceof AlterableContext) {
                    AlterableContext alterableContext = (AlterableContext) context;
                    alterableContext.destroy(bean);
                    return;
                } else {
                    throw BeanLogger.LOG.destroyUnsupported(context);
                }
            }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

  /**
   * {@inheritDoc}
   * @see Beans#destroy(Bean)
   */
  public static <T> void destroy(BeanManager beanManager, Bean<T> bean) {
    AlterableContext context = (AlterableContext) beanManager.getContext(bean.getScope());
    context.destroy(bean);
  }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

    @Test(dataProvider = ARQUILLIAN_DATA_PROVIDER)
    @SpecAssertions({ @SpecAssertion(section = CONTEXT, id = "t") })
    public void testNothingHappensIfNoInstanceToDestroy(ApplicationScopedComponent application) {
        Bean<?> bean = getUniqueBean(ApplicationScopedComponent.class);
        AlterableContext context = (AlterableContext) getCurrentManager().getContext(bean.getScope());

        AbstractComponent.reset();
        application.setValue("value");
        context.destroy(bean);
        assertTrue(AbstractComponent.isDestroyed());

        context.destroy(bean); // make sure subsequent calls do not raise exception
        context.destroy(bean);
    }
View Full Code Here

Examples of javax.enterprise.context.spi.AlterableContext

    private <T extends AbstractComponent> void testComponent(Class<T> javaClass) {
        Bean<?> bean = getUniqueBean(javaClass);
        @SuppressWarnings("unchecked")
        T reference = (T) getCurrentManager().getReference(bean, javaClass, getCurrentManager().createCreationalContext(bean));
        AlterableContext context = (AlterableContext) getCurrentManager().getContext(bean.getScope());

        for (String string : VALUES) {
            assertNull(reference.getValue());
            reference.setValue(string);
            assertEquals(reference.getValue(), string);

            AbstractComponent.reset();
            context.destroy(bean);
            assertTrue(AbstractComponent.isDestroyed());
            assertNull(reference.getValue(), reference.getValue());
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.