--- /dev/null
+/*
+ * 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);
+ }
+
+}
package org.wamblee.cdi;
import static junit.framework.Assert.*;
+import static org.mockito.Mockito.*;
import javax.enterprise.inject.spi.BeanManager;
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();
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
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
import org.wamblee.inject.InjectorFactoryBuilder;
import org.wamblee.support.jndi.StubInitialContextFactory;
-public class InjectorFactoryBuilderTest {
-
+public class InjectorFactoryBuilderTest extends BaseTestFixture {
@Test
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