diff --git a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java
index e23164bcf1f..1f8f95a4a7d 100644
--- a/org.springframework.test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java
+++ b/org.springframework.test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import javax.annotation.Resource;
import javax.inject.Inject;
+import javax.inject.Named;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -50,9 +51,10 @@ import org.springframework.test.context.support.GenericXmlContextLoader;
*
* - {@link ContextConfiguration @ContextConfiguration}
* - {@link Autowired @Autowired}
- * - {@link Inject @Inject}
* - {@link Qualifier @Qualifier}
* - {@link Resource @Resource}
+ * - {@link Inject @Inject}
+ * - {@link Named @Named}
* - {@link ApplicationContextAware}
* - {@link BeanNameAware}
* - {@link InitializingBean}
@@ -115,6 +117,10 @@ public class SpringJUnit4ClassRunnerAppCtxTests implements ApplicationContextAwa
@Qualifier("quux")
protected String quux;
+ @Inject
+ @Named("quux")
+ protected String namedQuux;
+
// ------------------------------------------------------------------------|
@@ -164,6 +170,10 @@ public class SpringJUnit4ClassRunnerAppCtxTests implements ApplicationContextAwa
public final void verifyAnnotationAutowiredAndInjectedFields() {
assertNull("The nonrequiredLong field should NOT have been autowired.", this.nonrequiredLong);
assertEquals("The quux field should have been autowired via @Autowired and @Qualifier.", "Quux", this.quux);
+ assertEquals("The namedFoo field should have been injected via @Inject and @Named.", "Quux", this.namedQuux);
+ assertSame("@Autowired/@Qualifier and @Inject/@Named quux should be the same object.", this.quux,
+ this.namedQuux);
+
assertNotNull("The pet field should have been autowired.", this.autowiredPet);
assertNotNull("The pet field should have been injected.", this.injectedPet);
assertEquals("Fido", this.autowiredPet.getName());
@@ -178,12 +188,12 @@ public class SpringJUnit4ClassRunnerAppCtxTests implements ApplicationContextAwa
}
@Test
- public final void verifyResourceAnnotationWiredFields() {
- assertEquals("The foo field should have been wired via @Resource.", "Foo", this.foo);
+ public final void verifyResourceAnnotationInjectedFields() {
+ assertEquals("The foo field should have been injected via @Resource.", "Foo", this.foo);
}
@Test
- public final void verifyResourceAnnotationWiredMethods() {
+ public final void verifyResourceAnnotationInjectedMethods() {
assertEquals("The bar method should have been wired via @Resource.", "Bar", this.bar);
}