@Test @SpecAssertion(section = NEW_EE, id = "x") public void testNewBeanHasNoDisposalMethods() throws Exception { FoxLocal fox = getContextualReference(FoxLocal.class); FoxLocal newFox = getContextualReference(FoxLocal.class, New.Literal.of(Fox.class)); @SuppressWarnings("serial") Set<Bean<Litter>> beans = getBeans(Litter.class, new AnnotationLiteral<Tame>() { }); assert beans.size() == 1; Bean<Litter> litterBean = beans.iterator().next(); CreationalContext<Litter> creationalContext = getCurrentManager().createCreationalContext(litterBean); Litter litter = litterBean.create(creationalContext); litterBean.destroy(litter, creationalContext); assert fox.isLitterDisposed(); assert !newFox.isLitterDisposed(); }
@Test @SpecAssertion(section = NEW_EE, id = "m") public void testNewBeanHasSameInitializers() { InitializerSimpleBeanLocal bean = getContextualReference(InitializerSimpleBeanLocal.class); InitializerSimpleBeanLocal newBean = getContextualReference(InitializerSimpleBeanLocal.class, New.Literal.of( InitializerSimpleBean.class)); assert bean != newBean; assert bean.getInitializerCalls() == 2; }
/** * Sets up both the bean and the @New bean with different configurations so that the correct producer method used can be * determined. * * @throws Exception */ @Test @SpecAssertion(section = NEW_EE, id = "v") public void testNewBeanHasNoProducerMethods() throws Exception { FoxLocal fox = getContextualReference(FoxLocal.class); FoxLocal newFox = getContextualReference(FoxLocal.class, New.Literal.of(Fox.class)); fox.setNextLitterSize(3); newFox.setNextLitterSize(5); @SuppressWarnings("serial") Litter theOnlyLitter = getContextualReference(Litter.class, new AnnotationLiteral<Tame>() { }); assert theOnlyLitter.getQuantity() == fox.getNextLitterSize(); }
@Test @SpecAssertion(section = NEW_EE, id = "l") public void testNewBeanHasSameConstructor() { ExplicitConstructor newBean = getContextualReference(ExplicitConstructor.class, New.Literal.of( ExplicitConstructorSessionBean.class)); assert newBean.getConstructorCalls() == 1; assert newBean.getInjectedSimpleBean() != null; }