diff --git a/org.springframework.context/.classpath b/org.springframework.context/.classpath
index 79ec3419eb0..360c7a532c0 100644
--- a/org.springframework.context/.classpath
+++ b/org.springframework.context/.classpath
@@ -19,6 +19,8 @@
+
+
diff --git a/org.springframework.context/ivy.xml b/org.springframework.context/ivy.xml
index 5faa9fc91ad..5e1c267b909 100644
--- a/org.springframework.context/ivy.xml
+++ b/org.springframework.context/ivy.xml
@@ -51,6 +51,8 @@
+
+
diff --git a/org.springframework.context/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java b/org.springframework.context/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java
new file mode 100644
index 00000000000..74d6b48540e
--- /dev/null
+++ b/org.springframework.context/src/test/java/org/springframework/beans/factory/parsing/CollectingReaderEventListener.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2002-2007 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.springframework.beans.factory.parsing;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.core.CollectionFactory;
+
+/**
+ * @author Rob Harrop
+ * @author Juergen Hoeller
+ */
+public class CollectingReaderEventListener implements ReaderEventListener {
+
+ private final List defaults = new LinkedList();
+
+ private final Map componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8);
+
+ private final Map aliasMap = CollectionFactory.createLinkedMapIfPossible(8);
+
+ private final List imports = new LinkedList();
+
+
+ public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
+ this.defaults.add(defaultsDefinition);
+ }
+
+ public List getDefaults() {
+ return Collections.unmodifiableList(this.defaults);
+ }
+
+ public void componentRegistered(ComponentDefinition componentDefinition) {
+ this.componentDefinitions.put(componentDefinition.getName(), componentDefinition);
+ }
+
+ public ComponentDefinition getComponentDefinition(String name) {
+ return (ComponentDefinition) this.componentDefinitions.get(name);
+ }
+
+ public ComponentDefinition[] getComponentDefinitions() {
+ Collection collection = this.componentDefinitions.values();
+ return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]);
+ }
+
+ public void aliasRegistered(AliasDefinition aliasDefinition) {
+ List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName());
+ if(aliases == null) {
+ aliases = new ArrayList();
+ this.aliasMap.put(aliasDefinition.getBeanName(), aliases);
+ }
+ aliases.add(aliasDefinition);
+ }
+
+ public List getAliases(String beanName) {
+ List aliases = (List) this.aliasMap.get(beanName);
+ return aliases == null ? null : Collections.unmodifiableList(aliases);
+ }
+
+ public void importProcessed(ImportDefinition importDefinition) {
+ this.imports.add(importDefinition);
+ }
+
+ public List getImports() {
+ return Collections.unmodifiableList(this.imports);
+ }
+
+}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java b/org.springframework.context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java
similarity index 92%
rename from org.springframework.testsuite/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java
rename to org.springframework.context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java
index 406198b3848..d8c1aa13902 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java
+++ b/org.springframework.context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java
@@ -16,8 +16,10 @@
package org.springframework.ejb.config;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertTrue;
+import org.junit.Before;
+import org.junit.Test;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.parsing.CollectingReaderEventListener;
import org.springframework.beans.factory.parsing.ComponentDefinition;
@@ -28,8 +30,9 @@ import org.springframework.core.io.ClassPathResource;
/**
* @author Torsten Juergeleit
* @author Juergen Hoeller
+ * @author Chris Beams
*/
-public class JeeNamespaceHandlerEventTests extends TestCase {
+public class JeeNamespaceHandlerEventTests {
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
@@ -38,22 +41,26 @@ public class JeeNamespaceHandlerEventTests extends TestCase {
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
+ @Before
public void setUp() throws Exception {
this.reader = new XmlBeanDefinitionReader(this.beanFactory);
this.reader.setEventListener(this.eventListener);
this.reader.loadBeanDefinitions(new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
}
+ @Test
public void testJndiLookupComponentEventReceived() {
ComponentDefinition component = this.eventListener.getComponentDefinition("simple");
assertTrue(component instanceof BeanComponentDefinition);
}
+ @Test
public void testLocalSlsbComponentEventReceived() {
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleLocalEjb");
assertTrue(component instanceof BeanComponentDefinition);
}
+ @Test
public void testRemoteSlsbComponentEventReceived() {
ComponentDefinition component = this.eventListener.getComponentDefinition("simpleRemoteEjb");
assertTrue(component instanceof BeanComponentDefinition);
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java b/org.springframework.context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java
similarity index 96%
rename from org.springframework.testsuite/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java
rename to org.springframework.context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java
index a5681fa7737..b51d691d664 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java
+++ b/org.springframework.context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java
@@ -16,8 +16,10 @@
package org.springframework.ejb.config;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
import org.springframework.beans.ITestBean;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -32,12 +34,14 @@ import org.springframework.jndi.JndiObjectFactoryBean;
/**
* @author Rob Harrop
* @author Juergen Hoeller
+ * @author Chris Beams
*/
-public class JeeNamespaceHandlerTests extends TestCase {
+public class JeeNamespaceHandlerTests {
private ConfigurableListableBeanFactory beanFactory;
- protected void setUp() throws Exception {
+ @Before
+ public void setUp() throws Exception {
GenericApplicationContext ctx = new GenericApplicationContext();
new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(
new ClassPathResource("jeeNamespaceHandlerTests.xml", getClass()));
@@ -46,6 +50,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
this.beanFactory.getBeanNamesForType(ITestBean.class);
}
+ @Test
public void testSimpleDefinition() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple");
assertEquals(JndiObjectFactoryBean.class.getName(), beanDefinition.getBeanClassName());
@@ -53,6 +58,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
assertPropertyValue(beanDefinition, "resourceRef", "true");
}
+ @Test
public void testComplexDefinition() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex");
assertEquals(JndiObjectFactoryBean.class.getName(), beanDefinition.getBeanClassName());
@@ -66,18 +72,21 @@ public class JeeNamespaceHandlerTests extends TestCase {
assertPropertyValue(beanDefinition, "defaultObject", "myValue");
}
+ @Test
public void testWithEnvironment() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withEnvironment");
assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar");
assertPropertyValue(beanDefinition, "defaultObject", new RuntimeBeanReference("myBean"));
}
+ @Test
public void testWithReferencedEnvironment() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("withReferencedEnvironment");
assertPropertyValue(beanDefinition, "jndiEnvironment", new RuntimeBeanReference("myEnvironment"));
assertFalse(beanDefinition.getPropertyValues().contains("environmentRef"));
}
+ @Test
public void testSimpleLocalSlsb() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleLocalEjb");
assertEquals(LocalStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
@@ -85,6 +94,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyLocalBean");
}
+ @Test
public void testSimpleRemoteSlsb() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simpleRemoteEjb");
assertEquals(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
@@ -92,6 +102,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
assertPropertyValue(beanDefinition, "jndiName", "ejb/MyRemoteBean");
}
+ @Test
public void testComplexLocalSlsb() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexLocalEjb");
assertEquals(LocalStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
@@ -103,6 +114,7 @@ public class JeeNamespaceHandlerTests extends TestCase {
assertPropertyValue(beanDefinition, "jndiEnvironment", "foo=bar");
}
+ @Test
public void testComplexRemoteSlsb() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complexRemoteEjb");
assertEquals(SimpleRemoteStatelessSessionProxyFactoryBean.class.getName(), beanDefinition.getBeanClassName());
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/ejb/config/jeeNamespaceHandlerTests.xml b/org.springframework.context/src/test/java/org/springframework/ejb/config/jeeNamespaceHandlerTests.xml
similarity index 100%
rename from org.springframework.testsuite/src/test/java/org/springframework/ejb/config/jeeNamespaceHandlerTests.xml
rename to org.springframework.context/src/test/java/org/springframework/ejb/config/jeeNamespaceHandlerTests.xml
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/ejb/support/EjbSupportTests.java b/org.springframework.context/src/test/java/org/springframework/ejb/support/EjbSupportTests.java
similarity index 89%
rename from org.springframework.testsuite/src/test/java/org/springframework/ejb/support/EjbSupportTests.java
rename to org.springframework.context/src/test/java/org/springframework/ejb/support/EjbSupportTests.java
index 426fdfb45b2..0603dee0049 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/ejb/support/EjbSupportTests.java
+++ b/org.springframework.context/src/test/java/org/springframework/ejb/support/EjbSupportTests.java
@@ -16,6 +16,8 @@
package org.springframework.ejb.support;
+import static org.easymock.EasyMock.*;
+
import java.rmi.RemoteException;
import javax.ejb.CreateException;
@@ -26,7 +28,6 @@ import javax.jms.Message;
import javax.naming.NamingException;
import junit.framework.TestCase;
-import org.easymock.MockControl;
import org.springframework.beans.BeansException;
import org.springframework.beans.FatalBeanException;
@@ -40,14 +41,14 @@ import org.springframework.mock.jndi.SimpleNamingContextBuilder;
/**
* @author Rod Johnson
* @author Juergen Hoeller
+ * @author Chris Beams
* @since 21.05.2003
*/
public class EjbSupportTests extends TestCase {
public void testSfsb() throws CreateException {
- MockControl mc = MockControl.createControl(SessionContext.class);
- SessionContext sc = (SessionContext) mc.getMock();
- mc.replay();
+ SessionContext sc = createMock(SessionContext.class);
+ replay(sc);
final BeanFactory bf = new StaticListableBeanFactory();
BeanFactoryLocator bfl = new BeanFactoryLocator() {
@@ -65,6 +66,7 @@ public class EjbSupportTests extends TestCase {
};
// Basically the test is what needed to be implemented here!
+ @SuppressWarnings("serial")
class MySfsb extends AbstractStatefulSessionBean {
public void ejbCreate() throws CreateException {
loadBeanFactory();
@@ -92,13 +94,13 @@ public class EjbSupportTests extends TestCase {
public void testHelpfulNamingLookupMessage() throws NamingException, CreateException {
SimpleNamingContextBuilder.emptyActivatedContextBuilder();
- MockControl mc = MockControl.createControl(SessionContext.class);
- SessionContext sc = (SessionContext) mc.getMock();
- mc.replay();
+ SessionContext sc = createMock(SessionContext.class);
+ replay(sc);
// Leave with default XmlBeanFactoryLoader
// Basically the test is what needed to be implemented here!
+ @SuppressWarnings("serial")
AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
public void onEjbCreate() {
}
@@ -116,9 +118,8 @@ public class EjbSupportTests extends TestCase {
}
public void testSlsb() throws Exception {
- MockControl mc = MockControl.createControl(SessionContext.class);
- SessionContext sc = (SessionContext) mc.getMock();
- mc.replay();
+ SessionContext sc = createMock(SessionContext.class);
+ replay(sc);
final BeanFactory bf = new StaticListableBeanFactory();
BeanFactoryLocator bfl = new BeanFactoryLocator() {
@@ -134,6 +135,7 @@ public class EjbSupportTests extends TestCase {
}
};
+ @SuppressWarnings("serial")
AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
protected void onEjbCreate() throws CreateException {
assertTrue(getBeanFactory() == bf);
@@ -161,9 +163,8 @@ public class EjbSupportTests extends TestCase {
}
public void testJmsMdb() throws Exception {
- MockControl mc = MockControl.createControl(MessageDrivenContext.class);
- MessageDrivenContext sc = (MessageDrivenContext) mc.getMock();
- mc.replay();
+ MessageDrivenContext sc = createMock(MessageDrivenContext.class);
+ replay(sc);
final BeanFactory bf = new StaticListableBeanFactory();
BeanFactoryLocator bfl = new BeanFactoryLocator() {
@@ -179,6 +180,7 @@ public class EjbSupportTests extends TestCase {
}
};
+ @SuppressWarnings("serial")
AbstractJmsMessageDrivenBean mdb = new AbstractJmsMessageDrivenBean() {
protected void onEjbCreate() {
assertTrue(getBeanFactory() == bf);
@@ -195,15 +197,15 @@ public class EjbSupportTests extends TestCase {
}
public void testCannotLoadBeanFactory() throws Exception {
- MockControl mc = MockControl.createControl(SessionContext.class);
- SessionContext sc = (SessionContext) mc.getMock();
- mc.replay();
+ SessionContext sc = createMock(SessionContext.class);
+ replay(sc);
BeanFactoryLocator bfl = new BeanFactoryLocator() {
public BeanFactoryReference useBeanFactory(String factoryKey) throws FatalBeanException {
throw new BootstrapException("", null);
}};
+ @SuppressWarnings("serial")
AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
protected void onEjbCreate() throws CreateException {
}