From 8dd32e931b348cf53d3e8567c7a092735ea46253 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Thu, 22 Jul 2010 17:29:43 +0000 Subject: [PATCH] --- .../cdi/InjectorFactoryBuilderTest.java | 4 +++ .../org/wamblee/cdi/SimpleInjectorTest.java | 28 +++++++++++++++++++ .../test/java/org/wamblee/cdi/WeldTest.java | 5 ++++ 3 files changed, 37 insertions(+) diff --git a/support/cdi/src/test/java/org/wamblee/cdi/InjectorFactoryBuilderTest.java b/support/cdi/src/test/java/org/wamblee/cdi/InjectorFactoryBuilderTest.java index 0caeed85..5fdc111e 100644 --- a/support/cdi/src/test/java/org/wamblee/cdi/InjectorFactoryBuilderTest.java +++ b/support/cdi/src/test/java/org/wamblee/cdi/InjectorFactoryBuilderTest.java @@ -17,9 +17,13 @@ package org.wamblee.cdi; import static junit.framework.Assert.*; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.naming.InitialContext; import org.junit.Test; +import org.wamblee.cdi.SimpleInjectorTest.X; +import org.wamblee.cdi.SimpleInjectorTest.Y; import org.wamblee.inject.InjectorFactory; import org.wamblee.inject.InjectorFactoryBuilder; import org.wamblee.test.jndi.StubInitialContextFactory; diff --git a/support/cdi/src/test/java/org/wamblee/cdi/SimpleInjectorTest.java b/support/cdi/src/test/java/org/wamblee/cdi/SimpleInjectorTest.java index d7df81aa..f9e77a5d 100644 --- a/support/cdi/src/test/java/org/wamblee/cdi/SimpleInjectorTest.java +++ b/support/cdi/src/test/java/org/wamblee/cdi/SimpleInjectorTest.java @@ -18,6 +18,8 @@ package org.wamblee.cdi; import static junit.framework.Assert.*; import static org.mockito.Mockito.*; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; import javax.naming.InitialContext; import org.junit.After; @@ -25,6 +27,7 @@ import org.junit.Before; import org.junit.Test; import org.wamblee.inject.Injector; import org.wamblee.inject.InjectorFactory; +import org.wamblee.inject.InjectorFactoryBuilder; import org.wamblee.inject.SimpleInjector; import org.wamblee.test.jndi.StubInitialContextFactory; @@ -87,4 +90,29 @@ public class SimpleInjectorTest extends BaseTestFixture { // verify the custom injector was called. assertSame(singleton, pojo.getSingleton()); } + + @RequestScoped + public static class Y { + + } + public static class X { + @Inject + private Y y; + + } + + @Test + public void testInjectStorage() throws Exception { + X x = new X(); + InjectorFactoryBuilder.setInjectorFactory(null); + InjectorFactoryBuilder.getInjector().inject(x); + } + + @Test + public void testInjectStorage2() { + X x = new X(); + InjectorFactoryBuilder.setInjectorFactory(null); + InjectorFactoryBuilder.getInjector().inject(x); + } + } diff --git a/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java b/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java index 57fa4ad2..64060837 100644 --- a/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java +++ b/support/cdi/src/test/java/org/wamblee/cdi/WeldTest.java @@ -48,4 +48,9 @@ public class WeldTest { assertEquals(1, MySingleton.getInstances()); } + + @Test + public void testAgain() { + testGetSingleton(); + } } -- 2.31.1