import static junit.framework.Assert.*;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
public class CdiInjectorTest {
-
- @Test
- public void testInject() {
- fail();
+ private BeanManagerSetup manager;
+
+ @Before
+ public void setUp() {
+ manager = new BeanManagerSetup();
+ manager.initialize();
+ }
+
+ @After
+ public void tearDown() {
+ manager.shutdown();
}
@Test
+ public void testInject() {
+ CdiInjector injector = new CdiInjector(manager.getBeanManager(), MyPojo.class);
+ MyPojo pojo = new MyPojo();
+ injector.inject(pojo);
+ assertNotNull(pojo.getSingleton());
+ }
+
+ @Test(expected = IllegalArgumentException.class)
public void testWrongType() {
- fail();
+ CdiInjector injector = new CdiInjector(manager.getBeanManager(), String.class);
+ MyPojo pojo = new MyPojo();
+ injector.inject(pojo);
}
@Test
public void testNullObject() {
- fail();
+ CdiInjector injector = new CdiInjector(manager.getBeanManager(), MyPojo.class);
+ injector.inject(null);
+
+ // ok should simply ignore.
}
}