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;
13 public class WeldTest {
15 private BeanManagerSetup setup;
19 setup = new BeanManagerSetup();
25 public void tearDown() {
30 public void testGetSingleton() {
31 AnnotatedType<MyPojo> type = setup.getBeanManager()
32 .createAnnotatedType(MyPojo.class);
33 InjectionTarget<MyPojo> target = setup.getBeanManager()
34 .createInjectionTarget(type);
35 CreationalContext<MyPojo> ctx = setup.getBeanManager()
36 .createCreationalContext(null);
38 MyPojo pojo = new MyPojo();
40 target.inject(pojo, ctx);
42 MySingleton obj = pojo.getSingleton();
46 MyPojo pojo2 = new MyPojo();
47 target.inject(pojo2, ctx);
49 // Objects will not be the same as they are contextual references to the
51 // assertSame(pojo2, pojo);
53 assertEquals(1, MySingleton.getInstances());
57 public void testAgain() {