(no commit message)
[utils] / support / cdi / src / test / java / org / wamblee / cdi / CdiInjectorTest.java
index 53d7df913176c607803afcb1f2d4b0b233c64b94..21133fa70361619436d347185a79757cffd3531a 100644 (file)
@@ -17,23 +17,45 @@ package org.wamblee.cdi;
 
 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. 
     }
 }