diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/Scope.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/Scope.java
index ea590097fd3..9da178b2ef8 100644
--- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/Scope.java
+++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/config/Scope.java
@@ -69,7 +69,7 @@ public interface Scope {
* object if it is not present in the underlying storage mechanism
* @return the desired object (never null)
*/
- Object get(String name, ObjectFactory objectFactory);
+ Object get(String name, ObjectFactory> objectFactory);
/**
* Remove the object with the given name from the underlying scope.
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
similarity index 82%
rename from org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
rename to org.springframework.beans/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
index cdfb2955de0..6fa8ab241ba 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/CommonsLogFactoryBeanTests.java
@@ -16,36 +16,38 @@
package org.springframework.beans.factory.config;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
import org.apache.commons.logging.Log;
-import org.springframework.test.AssertThrows;
+import org.junit.Test;
/**
* Unit tests for the {@link CommonsLogFactoryBean} class.
*
* @author Rick Evans
+ * @author Chris Beams
*/
-public final class CommonsLogFactoryBeanTests extends TestCase {
+public final class CommonsLogFactoryBeanTests {
+ @Test
public void testIsSingleton() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
assertTrue(factory.isSingleton());
}
+ @Test
public void testGetObjectTypeDefaultsToPlainResourceInterfaceifLookupResourceIsNotSupplied() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
assertEquals(Log.class, factory.getObjectType());
}
+ @Test(expected=IllegalArgumentException.class)
public void testWhenLogNameIsMissing() throws Exception {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
- factory.afterPropertiesSet();
- }
- }.runTest();
+ CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
+ factory.afterPropertiesSet();
}
+ @Test
public void testSunnyDayPath() throws Exception {
CommonsLogFactoryBean factory = new CommonsLogFactoryBean();
factory.setLogName("The Tin Drum");
diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java
new file mode 100644
index 00000000000..9672a627919
--- /dev/null
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2002-2008 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.config;
+import static org.easymock.EasyMock.*;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+
+/**
+ * @author Rick Evans
+ * @author Juergen Hoeller
+ * @author Chris Beams
+ */
+public class CustomScopeConfigurerTests {
+
+ private static final String FOO_SCOPE = "fooScope";
+ private ConfigurableListableBeanFactory factory;
+
+ @Before
+ public void setUp() {
+ factory = new DefaultListableBeanFactory();
+ }
+
+ @Test
+ public void testWithNoScopes() throws Exception {
+ Scope scope = createMock(Scope.class);
+ replay(scope);
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.postProcessBeanFactory(factory);
+ verify(scope);
+ }
+
+ @Test
+ public void testSunnyDayWithBonaFideScopeInstance() throws Exception {
+ Scope scope = createMock(Scope.class);
+ replay(scope);
+ factory.registerScope(FOO_SCOPE, scope);
+ Map scopes = new HashMap();
+ scopes.put(FOO_SCOPE, scope);
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.setScopes(scopes);
+ figurer.postProcessBeanFactory(factory);
+ verify(scope);
+ }
+
+ @Test
+ public void testSunnyDayWithBonaFideScopeClass() throws Exception {
+ Map scopes = new HashMap();
+ scopes.put(FOO_SCOPE, NoOpScope.class);
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.setScopes(scopes);
+ figurer.postProcessBeanFactory(factory);
+ assertTrue(factory.getRegisteredScope(FOO_SCOPE) instanceof NoOpScope);
+ }
+
+ @Test
+ public void testSunnyDayWithBonaFideScopeClassname() throws Exception {
+ Map scopes = new HashMap();
+ scopes.put(FOO_SCOPE, NoOpScope.class.getName());
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.setScopes(scopes);
+ figurer.postProcessBeanFactory(factory);
+ assertTrue(factory.getRegisteredScope(FOO_SCOPE) instanceof NoOpScope);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testWhereScopeMapHasNullScopeValueInEntrySet() throws Exception {
+ Map scopes = new HashMap();
+ scopes.put(FOO_SCOPE, null);
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.setScopes(scopes);
+ figurer.postProcessBeanFactory(factory);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testWhereScopeMapHasNonScopeInstanceInEntrySet() throws Exception {
+ Map scopes = new HashMap();
+ scopes.put(FOO_SCOPE, this); // <-- not a valid value...
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.setScopes(scopes);
+ figurer.postProcessBeanFactory(factory);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(expected=ClassCastException.class)
+ public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() throws Exception {
+ Map scopes = new HashMap();
+ scopes.put(this, new NoOpScope()); // <-- not a valid value (the key)...
+ CustomScopeConfigurer figurer = new CustomScopeConfigurer();
+ figurer.setScopes(scopes);
+ figurer.postProcessBeanFactory(factory);
+ }
+
+}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/NoOpScope.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/NoOpScope.java
similarity index 94%
rename from org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/NoOpScope.java
rename to org.springframework.beans/src/test/java/org/springframework/beans/factory/config/NoOpScope.java
index fd92462e12d..fcb144605e2 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/NoOpScope.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/NoOpScope.java
@@ -23,7 +23,7 @@ import org.springframework.beans.factory.ObjectFactory;
*/
public class NoOpScope implements Scope {
- public Object get(String name, ObjectFactory objectFactory) {
+ public Object get(String name, ObjectFactory> objectFactory) {
throw new UnsupportedOperationException();
}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
similarity index 60%
rename from org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
rename to org.springframework.beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
index 26c41b74688..1d013c30c66 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java
@@ -16,35 +16,39 @@
package org.springframework.beans.factory.config;
+import static org.junit.Assert.*;
+
import java.util.LinkedList;
import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Before;
+import org.junit.Test;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.support.GenericApplicationContext;
/**
* Simple test to illustrate and verify scope usage.
*
* @author Rod Johnson
* @author Juergen Hoeller
+ * @author Chris Beams
*/
-public class SimpleScopeTests extends TestCase {
+public class SimpleScopeTests {
- private GenericApplicationContext applicationContext;
+ private DefaultListableBeanFactory beanFactory;
- protected void setUp() {
- applicationContext = new GenericApplicationContext();
+ @Before
+ public void setUp() {
+ beanFactory = new DefaultListableBeanFactory();
Scope scope = new NoOpScope() {
private int index;
- private List objects = new LinkedList(); {
+ private List objects = new LinkedList(); {
objects.add(new TestBean());
objects.add(new TestBean());
}
- public Object get(String name, ObjectFactory objectFactory) {
+ public Object get(String name, ObjectFactory> objectFactory) {
if (index >= objects.size()) {
index = 0;
}
@@ -52,24 +56,23 @@ public class SimpleScopeTests extends TestCase {
}
};
- applicationContext.getBeanFactory().registerScope("myScope", scope);
+ beanFactory.registerScope("myScope", scope);
- String[] scopeNames = applicationContext.getBeanFactory().getRegisteredScopeNames();
+ String[] scopeNames = beanFactory.getRegisteredScopeNames();
assertEquals(1, scopeNames.length);
assertEquals("myScope", scopeNames[0]);
- assertSame(scope, applicationContext.getBeanFactory().getRegisteredScope("myScope"));
+ assertSame(scope, beanFactory.getRegisteredScope("myScope"));
- XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(applicationContext);
+ XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(beanFactory);
xbdr.loadBeanDefinitions("org/springframework/beans/factory/config/simpleScope.xml");
-
- applicationContext.refresh();
}
+ @Test
public void testCanGetScopedObject() {
- TestBean tb1 = (TestBean) applicationContext.getBean("usesScope");
- TestBean tb2 = (TestBean) applicationContext.getBean("usesScope");
+ TestBean tb1 = (TestBean) beanFactory.getBean("usesScope");
+ TestBean tb2 = (TestBean) beanFactory.getBean("usesScope");
assertNotSame(tb1, tb2);
- TestBean tb3 = (TestBean) applicationContext.getBean("usesScope");
+ TestBean tb3 = (TestBean) beanFactory.getBean("usesScope");
assertSame(tb3, tb1);
}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/simpleScope.xml b/org.springframework.beans/src/test/java/org/springframework/beans/factory/config/simpleScope.xml
similarity index 100%
rename from org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/simpleScope.xml
rename to org.springframework.beans/src/test/java/org/springframework/beans/factory/config/simpleScope.xml
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java
similarity index 67%
rename from org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java
rename to org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java
index e102aa9f178..c578c4ee0cd 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java
@@ -16,22 +16,19 @@
package org.springframework.beans.factory.parsing;
-import junit.framework.TestCase;
-import org.springframework.test.AssertThrows;
+import org.junit.Test;
/**
* Unit tests for the {@link ConstructorArgumentEntry} class.
*
* @author Rick Evans
+ * @author Chris Beams
*/
-public final class ConstructorArgumentEntryTests extends TestCase {
+public final class ConstructorArgumentEntryTests {
- public void testCtorBailsOnNegativeCtorIndexArgument() throws Exception {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- new ConstructorArgumentEntry(-1);
- }
- }.runTest();
+ @Test(expected=IllegalArgumentException.class)
+ public void testCtorBailsOnNegativeCtorIndexArgument() {
+ new ConstructorArgumentEntry(-1);
}
}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java
similarity index 52%
rename from org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java
rename to org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java
index f41d11304bb..e111f224f21 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java
@@ -16,53 +16,40 @@
package org.springframework.beans.factory.parsing;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.easymock.AbstractMatcher;
-import org.easymock.MockControl;
+import static org.easymock.EasyMock.*;
+import org.apache.commons.logging.Log;
+import org.junit.Test;
import org.springframework.core.io.DescriptiveResource;
-import org.springframework.test.AssertThrows;
/**
* @author Rick Evans
* @author Juergen Hoeller
+ * @author Chris Beams
*/
-public final class FailFastProblemReporterTests extends TestCase {
+public final class FailFastProblemReporterTests {
+ @Test(expected=BeanDefinitionParsingException.class)
public void testError() throws Exception {
- new AssertThrows(BeanDefinitionParsingException.class) {
- public void test() throws Exception {
- FailFastProblemReporter reporter = new FailFastProblemReporter();
- reporter.error(new Problem("VGER", new Location(new DescriptiveResource("here")),
- null, new IllegalArgumentException()));
- }
- }.runTest();
+ FailFastProblemReporter reporter = new FailFastProblemReporter();
+ reporter.error(new Problem("VGER", new Location(new DescriptiveResource("here")),
+ null, new IllegalArgumentException()));
}
+ @Test
public void testWarn() throws Exception {
- IllegalArgumentException rootCause = new IllegalArgumentException();
Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")),
null, new IllegalArgumentException());
- MockControl mockLog = MockControl.createControl(Log.class);
- Log log = (Log) mockLog.getMock();
- log.warn(null, rootCause);
- mockLog.setMatcher(new AbstractMatcher() {
- public boolean matches(Object[] expected, Object[] actual) {
- Assert.assertEquals(2, actual.length);
- Assert.assertTrue(actual[1] instanceof IllegalArgumentException);
- return true;
- }
- });
- mockLog.replay();
+ Log log = createMock(Log.class);
+ log.warn(anyObject(), isA(IllegalArgumentException.class));
+ replay(log);
FailFastProblemReporter reporter = new FailFastProblemReporter();
reporter.setLogger(log);
reporter.warning(problem);
- mockLog.verify();
+ verify(log);
}
}
diff --git a/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java b/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java
new file mode 100644
index 00000000000..7109aafb7e0
--- /dev/null
+++ b/org.springframework.beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java
@@ -0,0 +1,28 @@
+package org.springframework.beans.factory.parsing;
+
+import org.junit.Test;
+
+/**
+ * Unit tests for the {@link PropertyEntry} class.
+ *
+ * @author Rick Evans
+ * @author Chris Beams
+ */
+public final class PropertyEntryTests {
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testCtorBailsOnNullPropertyNameArgument() throws Exception {
+ new PropertyEntry(null);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testCtorBailsOnEmptyPropertyNameArgument() throws Exception {
+ new PropertyEntry("");
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testCtorBailsOnWhitespacedPropertyNameArgument() throws Exception {
+ new PropertyEntry("\t ");
+ }
+
+}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/BeanFactoryPostProcessorTests.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/BeanFactoryPostProcessorTests.java
index 71382d98470..c138517f52d 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/BeanFactoryPostProcessorTests.java
+++ b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/BeanFactoryPostProcessorTests.java
@@ -16,8 +16,9 @@
package org.springframework.beans.factory.config;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+import org.junit.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.TestBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
@@ -27,10 +28,12 @@ import org.springframework.context.support.StaticApplicationContext;
/**
* @author Colin Sampaleanu
* @author Juergen Hoeller
+ * @author Chris Beams
* @since 02.10.2003
*/
-public class BeanFactoryPostProcessorTests extends TestCase {
+public class BeanFactoryPostProcessorTests {
+ @Test
public void testRegisteredBeanFactoryPostProcessor() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@@ -42,6 +45,7 @@ public class BeanFactoryPostProcessorTests extends TestCase {
assertTrue(bfpp.wasCalled);
}
+ @Test
public void testDefinedBeanFactoryPostProcessor() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@@ -52,6 +56,7 @@ public class BeanFactoryPostProcessorTests extends TestCase {
assertTrue(bfpp.wasCalled);
}
+ @Test
public void testMultipleDefinedBeanFactoryPostProcessors() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerSingleton("tb1", TestBean.class);
@@ -68,6 +73,7 @@ public class BeanFactoryPostProcessorTests extends TestCase {
assertTrue(bfpp.wasCalled);
}
+ @Test
public void testBeanFactoryPostProcessorNotExecutedByBeanFactory() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
bf.registerBeanDefinition("tb1", new RootBeanDefinition(TestBean.class));
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java
deleted file mode 100644
index 19658c85814..00000000000
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2002-2008 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.config;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-import org.easymock.MockControl;
-
-import org.springframework.beans.factory.support.DefaultListableBeanFactory;
-import org.springframework.mock.easymock.AbstractScalarMockTemplate;
-import org.springframework.test.AssertThrows;
-
-/**
- * @author Rick Evans
- * @author Juergen Hoeller
- */
-public class CustomScopeConfigurerTests extends TestCase {
-
- private static final String FOO_SCOPE = "fooScope";
-
-
- public void testWithNoScopes() throws Exception {
- new ConfigurableListableBeanFactoryMockTemplate() {
- protected void doTest(ConfigurableListableBeanFactory factory) {
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.postProcessBeanFactory(factory);
- }
- }.test();
- }
-
- public void testSunnyDayWithBonaFideScopeInstance() throws Exception {
- MockControl mockScope = MockControl.createControl(Scope.class);
- final Scope scope = (Scope) mockScope.getMock();
- mockScope.replay();
- new ConfigurableListableBeanFactoryMockTemplate() {
- public void setupExpectations(MockControl mockControl, ConfigurableListableBeanFactory factory) {
- factory.registerScope(FOO_SCOPE, scope);
- }
- protected void doTest(ConfigurableListableBeanFactory factory) {
- Map scopes = new HashMap();
- scopes.put(FOO_SCOPE, scope);
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.setScopes(scopes);
- figurer.postProcessBeanFactory(factory);
- }
- }.test();
- mockScope.verify();
- }
-
- public void testSunnyDayWithBonaFideScopeClass() throws Exception {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- Map scopes = new HashMap();
- scopes.put(FOO_SCOPE, NoOpScope.class);
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.setScopes(scopes);
- figurer.postProcessBeanFactory(factory);
- assertTrue(factory.getRegisteredScope(FOO_SCOPE) instanceof NoOpScope);
- }
-
- public void testSunnyDayWithBonaFideScopeClassname() throws Exception {
- DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
- Map scopes = new HashMap();
- scopes.put(FOO_SCOPE, NoOpScope.class.getName());
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.setScopes(scopes);
- figurer.postProcessBeanFactory(factory);
- assertTrue(factory.getRegisteredScope(FOO_SCOPE) instanceof NoOpScope);
- }
-
- public void testWhereScopeMapHasNullScopeValueInEntrySet() throws Exception {
- new ConfigurableListableBeanFactoryMockTemplate() {
- protected void doTest(final ConfigurableListableBeanFactory factory) {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- Map scopes = new HashMap();
- scopes.put(FOO_SCOPE, null);
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.setScopes(scopes);
- figurer.postProcessBeanFactory(factory);
- }
- }.runTest();
- }
- }.test();
- }
-
- public void testWhereScopeMapHasNonScopeInstanceInEntrySet() throws Exception {
- new ConfigurableListableBeanFactoryMockTemplate() {
- protected void doTest(final ConfigurableListableBeanFactory factory) {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- Map scopes = new HashMap();
- scopes.put(FOO_SCOPE, this); // <-- not a valid value...
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.setScopes(scopes);
- figurer.postProcessBeanFactory(factory);
- }
- }.runTest();
- }
- }.test();
- }
-
- public void testWhereScopeMapHasNonStringTypedScopeNameInKeySet() throws Exception {
- new ConfigurableListableBeanFactoryMockTemplate() {
- protected void doTest(final ConfigurableListableBeanFactory factory) {
- new AssertThrows(ClassCastException.class) {
- public void test() throws Exception {
- Map scopes = new HashMap();
- scopes.put(this, new NoOpScope()); // <-- not a valid value (the key)...
- CustomScopeConfigurer figurer = new CustomScopeConfigurer();
- figurer.setScopes(scopes);
- figurer.postProcessBeanFactory(factory);
- }
- }.runTest();
- }
- }.test();
- }
-
-
- private abstract class ConfigurableListableBeanFactoryMockTemplate extends AbstractScalarMockTemplate {
-
- public ConfigurableListableBeanFactoryMockTemplate() {
- super(ConfigurableListableBeanFactory.class);
- }
-
- public final void setupExpectations(MockControl mockControl, Object mockObject) throws Exception {
- setupExpectations(mockControl, (ConfigurableListableBeanFactory) mockObject);
- }
-
- public final void doTest(Object mockObject) throws Exception {
- doTest((ConfigurableListableBeanFactory) mockObject);
- }
-
- public void setupExpectations(MockControl mockControl, ConfigurableListableBeanFactory factory) throws Exception {
- }
-
- protected abstract void doTest(ConfigurableListableBeanFactory factory) throws Exception;
- }
-
-}
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java
index 6b53cfe7d0c..92cc460f482 100644
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java
+++ b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java
@@ -37,6 +37,7 @@ import org.springframework.beans.TestBean;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.support.ChildBeanDefinition;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.ManagedSet;
diff --git a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java b/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java
deleted file mode 100644
index d94a8cebf7f..00000000000
--- a/org.springframework.testsuite/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.springframework.beans.factory.parsing;
-
-import junit.framework.TestCase;
-import org.springframework.test.AssertThrows;
-
-/**
- * Unit tests for the {@link PropertyEntry} class.
- *
- * @author Rick Evans
- */
-public final class PropertyEntryTests extends TestCase {
-
- public void testCtorBailsOnNullPropertyNameArgument() throws Exception {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- new PropertyEntry(null);
- }
- }.runTest();
- }
-
- public void testCtorBailsOnEmptyPropertyNameArgument() throws Exception {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- new PropertyEntry("");
- }
- }.runTest();
- }
-
- public void testCtorBailsOnWhitespacedPropertyNameArgument() throws Exception {
- new AssertThrows(IllegalArgumentException.class) {
- public void test() throws Exception {
- new PropertyEntry("\t ");
- }
- }.runTest();
- }
-
-}