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<MyPojo> type = setup.getBeanManager().createAnnotatedType(MyPojo.class);
- InjectionTarget<MyPojo> target = setup.getBeanManager().createInjectionTarget(type);
- CreationalContext<MyPojo> ctx = setup.getBeanManager().createCreationalContext(null);
-
- MyPojo pojo = new MyPojo();
-
- target.inject(pojo, ctx);
-
- MySingleton obj = pojo.getSingleton();
-
+ public void testGetSingleton() {
+ AnnotatedType<MyPojo> type = setup.getBeanManager()
+ .createAnnotatedType(MyPojo.class);
+ InjectionTarget<MyPojo> target = setup.getBeanManager()
+ .createInjectionTarget(type);
+ CreationalContext<MyPojo> 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() {
+ testGetSingleton();
+ }
}