Search in sources :

Example 1 with ArtificalLiteral

use of org.b3log.latke.ioc.moon.annotation.ArtificalLiteral in project latke by b3log.

the class MoonUnitTest method beforeTest.

@BeforeTest
@SuppressWarnings("unchecked")
public void beforeTest() throws Exception {
    System.out.println("before MoonUnitTest");
    Latkes.initRuntimeEnv();
    beanManager = LatkeBeanManagerImpl.getInstance();
    Lifecycle.startApplication(moonPackageClasses);
    final Set<Annotation> moonQualifiers = new HashSet<Annotation>();
    moonQualifiers.add(new NamedLiteral("moon"));
    final LatkeBean<?> moonBean = beanManager.getBean(Moon.class, moonQualifiers);
    moon = (Moon) beanManager.getReference(moonBean);
    assertNotNull(moon);
    final Set<Annotation> artificalMoonQualifiers = new HashSet<Annotation>();
    artificalMoonQualifiers.add(new ArtificalLiteral());
    final LatkeBean<?> artificalMoonBean = beanManager.getBean(ArtificalMoon.class, artificalMoonQualifiers);
    artificalMoon = (ArtificalMoon) beanManager.getReference(artificalMoonBean);
    assertNotNull(artificalMoon);
    final Set<Annotation> waterMoonQualifiers = new HashSet<Annotation>();
    waterMoonQualifiers.add(new ArtificalLiteral());
    waterMoonQualifiers.add(new WaterLiteral());
    final LatkeBean<?> waterMoonBean = beanManager.getBean(WaterMoon.class, waterMoonQualifiers);
    waterMoon = (WaterMoon) beanManager.getReference(waterMoonBean);
    assertNotNull(waterMoon);
}
Also used : WaterLiteral(org.b3log.latke.ioc.moon.annotation.WaterLiteral) ArtificalLiteral(org.b3log.latke.ioc.moon.annotation.ArtificalLiteral) NamedLiteral(org.b3log.latke.ioc.literal.NamedLiteral) Annotation(java.lang.annotation.Annotation) HashSet(java.util.HashSet) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

Annotation (java.lang.annotation.Annotation)1 HashSet (java.util.HashSet)1 NamedLiteral (org.b3log.latke.ioc.literal.NamedLiteral)1 ArtificalLiteral (org.b3log.latke.ioc.moon.annotation.ArtificalLiteral)1 WaterLiteral (org.b3log.latke.ioc.moon.annotation.WaterLiteral)1 BeforeTest (org.testng.annotations.BeforeTest)1