X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fcdi%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fcdi%2FWeldTest.java;h=d2aa8a5516e63e0817e229f6a30b37f5d35f1810;hb=d76c1c5b113e82739f8e0ae92288ba120d747111;hp=640608377a282edbca17c34ed9f940058f2245ae;hpb=3e8de23e00da80d5506c750a28e7d25f261eda92;p=utils diff --git a/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java b/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java index 64060837..d2aa8a55 100644 --- a/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java +++ b/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java @@ -11,46 +11,50 @@ import org.junit.Before; import org.junit.Test; public class WeldTest { - - private BeanManagerSetup setup; - + + private BeanManagerSetup setup; + @Before public void setUp() { - setup = new BeanManagerSetup(); - setup.initialize(); + setup = new BeanManagerSetup(); + setup.initialize(); MySingleton.reset(); } - + @After - public void tearDown() { + public void tearDown() { setup.shutdown(); } - + @Test - public void testGetSingleton() { - AnnotatedType type = setup.getBeanManager().createAnnotatedType(MyPojo.class); - InjectionTarget target = setup.getBeanManager().createInjectionTarget(type); - CreationalContext ctx = setup.getBeanManager().createCreationalContext(null); - - MyPojo pojo = new MyPojo(); - - target.inject(pojo, ctx); - - MySingleton obj = pojo.getSingleton(); - + public void testGetSingleton() { + AnnotatedType type = setup.getBeanManager() + .createAnnotatedType(MyPojo.class); + InjectionTarget target = setup.getBeanManager() + .createInjectionTarget(type); + CreationalContext ctx = setup.getBeanManager() + .createCreationalContext(null); + + MyPojo pojo = new MyPojo(); + + target.inject(pojo, ctx); + + MySingleton obj = pojo.getSingleton(); + assertNotNull(obj); - - MyPojo pojo2 = new MyPojo(); - target.inject(pojo2, ctx); - - // Objects will not be the same as they are contextual references to the same object. + + MyPojo pojo2 = new MyPojo(); + target.inject(pojo2, ctx); + + // Objects will not be the same as they are contextual references to the + // same object. // assertSame(pojo2, pojo); assertEquals(1, MySingleton.getInstances()); } - + @Test - public void testAgain() { + public void testAgain() { testGetSingleton(); } }