(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 16 Jul 2010 11:27:43 +0000 (11:27 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 16 Jul 2010 11:27:43 +0000 (11:27 +0000)
support/cdi/src/test/java/org/wamblee/cdi/BaseTestFixture.java [new file with mode: 0644]
support/cdi/src/test/java/org/wamblee/cdi/BeanManagerLookupTest.java
support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorFactoryTest.java
support/cdi/src/test/java/org/wamblee/cdi/CdiInjectorTest.java
support/cdi/src/test/java/org/wamblee/cdi/InjectorFactoryBuilderTest.java
support/cdi/src/test/java/org/wamblee/cdi/SimpleInjectorTest.java

diff --git a/support/cdi/src/test/java/org/wamblee/cdi/BaseTestFixture.java b/support/cdi/src/test/java/org/wamblee/cdi/BaseTestFixture.java
new file mode 100644 (file)
index 0000000..dd3abc4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2005-2010 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wamblee.cdi;
+
+import org.junit.After;
+import org.junit.Before;
+
+public class BaseTestFixture {
+
+    @Before
+    public void setUp() throws Exception { 
+        BeanManagerLookup.setBeanManager(null);
+    }
+    
+
+    @After
+    public void tearDown() throws Exception { 
+        BeanManagerLookup.setBeanManager(null);
+    }
+    
+}
index c1fd7cb18b1ce877779c03f11b6086a7ad261ac6..f73f706626fbed73464a8a28c5d5c1a26ba82d09 100644 (file)
@@ -16,6 +16,7 @@
 package org.wamblee.cdi;
 
 import static junit.framework.Assert.*;
+import static org.mockito.Mockito.*;
 
 import javax.enterprise.inject.spi.BeanManager;
 import javax.naming.InitialContext;
@@ -23,10 +24,8 @@ import javax.naming.InitialContext;
 import org.junit.Test;
 import org.wamblee.support.jndi.StubInitialContextFactory;
 
-import static org.mockito.Mockito.*;
-
-public class BeanManagerLookupTest {
-
+public class BeanManagerLookupTest extends BaseTestFixture {
+  
     @Test
     public void testLookupInJndi() throws Exception {
         BeanManagerSetup setup = new BeanManagerSetup();
index 76931da41e7c70fd8a593d06193b34fd6dcf6017..5461d5c03e11b6d499cc6ba2688538bf592b396a 100644 (file)
@@ -23,19 +23,21 @@ import org.wamblee.inject.InjectorFactory;
 
 import static junit.framework.TestCase.*;
 
-public class CdiInjectorFactoryTest {
+public class CdiInjectorFactoryTest extends BaseTestFixture {
 
     private BeanManagerSetup manager;
 
     @Before
-    public void setUp() {
+    public void setUp() throws Exception {
+        super.setUp();
         manager = new BeanManagerSetup();
         manager.initialize();
     }
 
     @After
-    public void tearDown() {
+    public void tearDown() throws Exception {
         manager.shutdown();
+        super.tearDown();
     }
 
     @Test
index 21133fa70361619436d347185a79757cffd3531a..c1ee4f922dc6fd2daad26231898ead92184c206b 100644 (file)
@@ -21,19 +21,21 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-public class CdiInjectorTest {
+public class CdiInjectorTest extends BaseTestFixture {
     
     private BeanManagerSetup manager; 
     
     @Before
-    public void setUp() { 
+    public void setUp() throws Exception { 
+        super.setUp();
         manager = new BeanManagerSetup();
         manager.initialize(); 
     }
     
     @After
-    public void tearDown() { 
+    public void tearDown() throws Exception 
         manager.shutdown();
+        super.tearDown();
     }
     
     @Test
index 97c85bf132ba78e3408a809eb28a5087d3a90cd8..cc5f8b227079e2cd4a83ea08cdaea7167c2396a7 100644 (file)
@@ -24,8 +24,7 @@ import org.wamblee.inject.InjectorFactory;
 import org.wamblee.inject.InjectorFactoryBuilder;
 import org.wamblee.support.jndi.StubInitialContextFactory;
 
-public class InjectorFactoryBuilderTest {
-    
+public class InjectorFactoryBuilderTest extends BaseTestFixture {
     
 
     @Test
index 2a3b124297c47b7dab8a3de95946f0027d2bd49a..61cdfb86cd08048615ece0a36dfda670e4e9fca8 100644 (file)
@@ -28,24 +28,26 @@ import org.wamblee.inject.InjectorFactory;
 import org.wamblee.inject.SimpleInjector;
 import org.wamblee.support.jndi.StubInitialContextFactory;
 
-public class SimpleInjectorTest {
+public class SimpleInjectorTest extends BaseTestFixture {
 
     private BeanManagerSetup setup;
 
     @Before
     public void setUp() throws Exception {
+        super.setUp();
         setup = new BeanManagerSetup();
         setup.initialize();
         StubInitialContextFactory.register();
         InitialContext ctx = new InitialContext();
         ctx.bind(BeanManagerLookup.BEAN_MANAGER_JNDI, setup.getBeanManager());
-        MySingleton.reset();
+        MySingleton.reset();        
     }
 
     @After
-    public void tearDown() {
+    public void tearDown() throws Exception {
         StubInitialContextFactory.unregister();
         setup.shutdown();
+        super.tearDown();
     }
 
     @Test