1 package org.wamblee.cdi;
3 import static junit.framework.Assert.*;
5 import javax.enterprise.context.spi.CreationalContext;
6 import javax.enterprise.inject.spi.AnnotatedType;
7 import javax.enterprise.inject.spi.InjectionTarget;
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.wamblee.test.cdi.BeanManagerSetup;
14 public class WeldTest {
16 private BeanManagerSetup setup;
20 setup = new BeanManagerSetup();
26 public void tearDown() {
31 public void testGetSingleton() {
32 AnnotatedType<MyPojo> type = setup.getBeanManager()
33 .createAnnotatedType(MyPojo.class);
34 InjectionTarget<MyPojo> target = setup.getBeanManager()
35 .createInjectionTarget(type);
36 CreationalContext<MyPojo> ctx = setup.getBeanManager()
37 .createCreationalContext(null);
39 MyPojo pojo = new MyPojo();
41 target.inject(pojo, ctx);
43 MySingleton obj = pojo.getSingleton();
47 MyPojo pojo2 = new MyPojo();
48 target.inject(pojo2, ctx);
50 // Objects will not be the same as they are contextual references to the
52 // assertSame(pojo2, pojo);
54 assertEquals(1, MySingleton.getInstances());
58 public void testAgain() {