Character c = new Wizard(); .... Character c = new Elf();
@Test @SpecAssertion(section = NEW_EE, id = "o") public void testNewBeanHasTheSameInterceptorBindings() { // Method foo() is intercepted assertTrue(getContextualReference(NewSessionBeanConsumer.class).getOrder().ping()); }
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = NEW_EE, id = "yj") }) public void testNewBeanCreatedForObserverMethod(Wizard wizard) { Bean<Hat> bean = getUniqueBean(Hat.class, New.Literal.INSTANCE); checkNewQualifiedBean(bean, Object.class, Hat.class); getCurrentManager().fireEvent(new Wizard()); assertTrue(wizard.getHat().ping()); }
/** * 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(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = NEW_EE, id = "yf") }) public void testNewBeanCreatedForConstructorInjectionPoint(Wizard wizard) { Bean<Spell> bean = getUniqueBean(Spell.class, New.Literal.INSTANCE); checkNewQualifiedBean(bean, Object.class, Spell.class); assertTrue(wizard.getSpell().ping()); }
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = NEW_EE, id = "yb") }) public void testNewBeanCreatedForFieldInjectionPoint(Wizard wizard) { Bean<Tiger> bean = getUniqueBean(Tiger.class, New.Literal.INSTANCE); checkNewQualifiedBean(bean, Object.class, Tiger.class); assertTrue(wizard.getTiger().ping()); }
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = NEW_EE, id = "yh") }) public void testNewBeanCreatedForProducerMethod(Wizard wizard) { Bean<Dragon> bean = getUniqueBean(Dragon.class, New.Literal.INSTANCE); checkNewQualifiedBean(bean, Object.class, Dragon.class); assertTrue(wizard.getDragon().ping()); }
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = NEW_EE, id = "yd") }) public void testNewBeanCreatedForInitializerInjectionPoint(Wizard wizard) { Bean<Staff> bean = getUniqueBean(Staff.class, New.Literal.INSTANCE); checkNewQualifiedBean(bean, Object.class, Staff.class); assertTrue(wizard.getStaff().ping()); }
@Test(dataProvider = ARQUILLIAN_DATA_PROVIDER) @SpecAssertions({ @SpecAssertion(section = NEW_EE, id = "yl") }) public void testNewBeanCreatedForDisposerMethod(DragonProducer producer) { Bean<Fireball> bean = getUniqueBean(Fireball.class, New.Literal.INSTANCE); checkNewQualifiedBean(bean, Object.class, Fireball.class); Bean<Dragon> dragonBean = getUniqueBean(Dragon.class, TameLiteral.INSTANCE); CreationalContext<Dragon> ctx = getCurrentManager().createCreationalContext(dragonBean); Dragon dragon = dragonBean.create(ctx); dragonBean.destroy(dragon, ctx); assertTrue(producer.isDragonDestroyed()); }
@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; }
@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; }
@Tame @Stateful public class Lion implements LionLocal { @Remove public void remove() { } }
@Interceptor @Secure public class OrderInterceptor { @AroundInvoke public Object intercept(InvocationContext ctx) throws Exception { return true; } }
@Stateful @AnimalStereotype public class Monkey implements MonkeyLocal { }
Champion wizard = new Wizard(); Champion warrior = new Warrior(); AttackTypes attackType = AttackTypes.Ranged; System.out.println("can wizard attack? : " + wizard.canAttack(attackType)); System.out.println("can warrior attack? : " + warrior.canAttack(attackType));
public void disposeLitter(@Disposes @Tame Litter litter) { this.litterDisposed = true; }
@Secure @Stateful public class Order implements OrderLocal { @Remove public void remove() { } @Override public boolean ping() { return false; } }
@Produces @Tame public Dragon summon(@New Dragon dragon) { return dragon; }
public void destroyDragon(@Disposes @Tame Dragon dragon, @New Fireball fireball) { isDragonDestroyed = true; }