X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fcdi%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fcdi%2FInjectorBuilderTest.java;h=daffe9b1e615ee767af569324b6557b84de1dcee;hb=a01c7e2e1823c8792b6de9cc41788611e6631a33;hp=dd1210fbf5b20b89a2ca0dee52fad97a19177ccb;hpb=a5c9a040af910244a90db82e00e9de967a8ea1e6;p=utils diff --git a/support/cdi/src/test/java/org/wamblee/cdi/InjectorBuilderTest.java b/support/cdi/src/test/java/org/wamblee/cdi/InjectorBuilderTest.java index dd1210fb..daffe9b1 100644 --- a/support/cdi/src/test/java/org/wamblee/cdi/InjectorBuilderTest.java +++ b/support/cdi/src/test/java/org/wamblee/cdi/InjectorBuilderTest.java @@ -29,14 +29,13 @@ import org.wamblee.inject.InjectorBuilder; import org.wamblee.test.jndi.StubInitialContextFactory; public class InjectorBuilderTest extends BaseTestFixture { - @Test - public void testCdiInjectorFactoryIsFound() throws Exception { + public void testCdiInjectorFactoryIsFound() throws Exception { BeanManagerSetup setup = new BeanManagerSetup(); setup.initialize(); StubInitialContextFactory.register(); - InitialContext ctx = new InitialContext(); + InitialContext ctx = new InitialContext(); ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager()); try { InjectorFactory factory = InjectorBuilder.getInjectorFactory(); @@ -46,4 +45,23 @@ public class InjectorBuilderTest extends BaseTestFixture { StubInitialContextFactory.unregister(); } } + + @Test + public void testInjectManyTimes() { + int n = 1000; + BeanManagerSetup setup = new BeanManagerSetup(); + setup.initialize(); + BeanManagerLookup.setBeanManager(setup.getBeanManager()); + InjectorBuilder.setInjectorFactory(null); + long t0 = System.currentTimeMillis(); + for (int i = 0; i < n; i++) { + MyPojo pojo = new MyPojo(); + InjectorBuilder.getInjector().inject(pojo); + } + long t1 = System.currentTimeMillis(); + System.out.println(t1 - t0); + System.out.println("Injections per second: " + ((double) n) / + ((double) (t1 - t0)) * ((double) 1000)); + setup.shutdown(); + } }