diff --git a/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java b/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java
index 3653d55e4c..124b9985c9 100644
--- a/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java
+++ b/org.springframework.test/src/main/java/org/springframework/test/context/support/DelegatingSmartContextLoader.java
@@ -64,7 +64,7 @@ public class DelegatingSmartContextLoader implements SmartContextLoader {
*/
public void processContextConfiguration(ContextConfigurationAttributes configAttributes) {
- final boolean hasResources = configAttributes.hasResources();
+ final boolean originallyHadResources = configAttributes.hasResources();
for (SmartContextLoader loader : candidates) {
if (logger.isDebugEnabled()) {
@@ -75,7 +75,7 @@ public class DelegatingSmartContextLoader implements SmartContextLoader {
// If the original locations and classes were not empty, there's no
// need to bother with default generation checks; just let each
// loader process the configuration.
- if (hasResources) {
+ if (originallyHadResources) {
loader.processContextConfiguration(configAttributes);
}
// Otherwise, if the loader claims to generate defaults, let it
@@ -91,7 +91,7 @@ public class DelegatingSmartContextLoader implements SmartContextLoader {
// If any loader claims to generate defaults but none actually did,
// throw an exception.
- if (generatesDefaults() && !configAttributes.hasResources()) {
+ if (originallyHadResources && generatesDefaults() && !configAttributes.hasResources()) {
throw new IllegalStateException(String.format("None of the SmartContextLoader candidates %s "
+ "was able to generate defaults for context configuration [%s].", candidates, configAttributes));
}
diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java
index a9a28e8460..ddb846d4f5 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/expression/ExpressionUsageTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2006 the original author or authors.
+ * Copyright 2002-2011 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.
@@ -13,49 +13,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.springframework.test.context.expression;
-import static junit.framework.Assert.*;
+import static junit.framework.Assert.assertEquals;
import java.util.Properties;
+
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Andy Clement
* @author Dave Syer
*/
+@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
-public class ExpressionUsageTests extends AbstractJUnit4SpringContextTests {
+public class ExpressionUsageTests {
- @Test
- public void testSpr5906() throws Exception {
- Properties props = (Properties)applicationContext.getBean("derived");
-
- // verify the property values have been evaluated as expressions
- assertEquals("Dave",props.getProperty("user.name"));
- assertEquals("Andy",props.getProperty("username"));
-
- // verify the property keys have been evaluated as expressions
- assertEquals("exists",props.getProperty("Dave"));
- assertEquals("exists also",props.getProperty("Andy"));
- }
-
- public static class Foo {
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- }
+ @Autowired
+ @Qualifier("derived")
+ private Properties props;
@Autowired
@Qualifier("andy2")
@@ -65,10 +47,37 @@ public class ExpressionUsageTests extends AbstractJUnit4SpringContextTests {
@Qualifier("andy")
private Foo andy;
+
+ @Test
+ public void testSpr5906() throws Exception {
+ // verify the property values have been evaluated as expressions
+ assertEquals("Dave", props.getProperty("user.name"));
+ assertEquals("Andy", props.getProperty("username"));
+
+ // verify the property keys have been evaluated as expressions
+ assertEquals("exists", props.getProperty("Dave"));
+ assertEquals("exists also", props.getProperty("Andy"));
+ }
+
@Test
public void testSpr5847() throws Exception {
assertEquals("Andy", andy2.getName());
assertEquals("Andy", andy.getName());
}
-}
\ No newline at end of file
+
+ public static class Foo {
+
+ private String name;
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+}
diff --git a/org.springframework.test/src/test/resources/log4j.xml b/org.springframework.test/src/test/resources/log4j.xml
index e5aee2dde7..d9a255f08a 100644
--- a/org.springframework.test/src/test/resources/log4j.xml
+++ b/org.springframework.test/src/test/resources/log4j.xml
@@ -27,6 +27,9 @@
+
+
+