Search in sources :

Example 1 with OddLiteral

use of org.b3log.latke.ioc.drink.annotation.OddLiteral in project latke by b3log.

the class BottleUnitTest method beforeTest.

@BeforeTest
@SuppressWarnings("unchecked")
public void beforeTest() throws Exception {
    System.out.println("before BottleUnitTest");
    Latkes.initRuntimeEnv();
    Lifecycle.startApplication(drinkPackageClasses);
    beanManager = LatkeBeanManagerImpl.getInstance();
    // Creates bean by APIs
    final Configurator configurator = beanManager.getConfigurator();
    configurator.createBean(Mix.class).named("spiritMix").scoped(Singleton.class).qualified(new OddLiteral());
    // Validate after bean configuration
    configurator.validate();
    final LatkeBean<?> wineBottleBean = beanManager.getBean(WineBottle.class);
    assertNotNull(wineBottleBean);
    wineBottle = (WineBottle) beanManager.getReference(wineBottleBean);
    assertNotNull(wineBottle);
    final LatkeBean<?> juiceBottleBean = beanManager.getBean(JuiceBottle.class);
    assertNotNull(juiceBottleBean);
    juiceBottle = (JuiceBottle) beanManager.getReference(juiceBottleBean);
    assertNotNull(juiceBottle);
    final LatkeBean<?> mixBottleBean = beanManager.getBean(MixBottle.class, new HashSet<Annotation>());
    mixBottle = (MixBottle) beanManager.getReference(mixBottleBean);
    assertNotNull(mixBottle);
}
Also used : OddLiteral(org.b3log.latke.ioc.drink.annotation.OddLiteral) Configurator(org.b3log.latke.ioc.config.Configurator) Singleton(org.b3log.latke.ioc.inject.Singleton) Mix(org.b3log.latke.ioc.drink.mix.Mix) Annotation(java.lang.annotation.Annotation) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Configurator (org.b3log.latke.ioc.config.Configurator)1 OddLiteral (org.b3log.latke.ioc.drink.annotation.OddLiteral)1 Mix (org.b3log.latke.ioc.drink.mix.Mix)1 Singleton (org.b3log.latke.ioc.inject.Singleton)1 BeforeTest (org.testng.annotations.BeforeTest)1