X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fcdi%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fcdi%2FCdiInjectorTest.java;h=c1ee4f922dc6fd2daad26231898ead92184c206b;hb=1902eba20bf25bdc602af57b4af2c3a91fdee07d;hp=53d7df913176c607803afcb1f2d4b0b233c64b94;hpb=44b948e9c1e69f5b2abdee2c037d3935003ecf08;p=utils diff --git a/support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorTest.java b/support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorTest.java index 53d7df91..c1ee4f92 100644 --- a/support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorTest.java +++ b/support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorTest.java @@ -17,23 +17,47 @@ package org.wamblee.cdi; import static junit.framework.Assert.*; +import org.junit.After; +import org.junit.Before; import org.junit.Test; -public class CdiInjectorTest { - +public class CdiInjectorTest extends BaseTestFixture { - @Test - public void testInject() { - fail(); + private BeanManagerSetup manager; + + @Before + public void setUp() throws Exception { + super.setUp(); + manager = new BeanManagerSetup(); + manager.initialize(); + } + + @After + public void tearDown() throws Exception { + manager.shutdown(); + super.tearDown(); } @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. } }