Skip to content

Commit b5b4615

Browse files
committed
Rename test versions of @qualified and @Autowired
Avoid Eclipse classpath conflicts between test versions of @qualified and @Autowired living in spring-core and actual versions living in spring-beans.
1 parent f582974 commit b5b4615

File tree

4 files changed

+42
-84
lines changed

4 files changed

+42
-84
lines changed

spring-core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java

Lines changed: 0 additions & 67 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2002-2012 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.beans.factory.annotation;
18+
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
@Retention(RetentionPolicy.RUNTIME)
25+
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
26+
public @interface TestAutowired {
27+
28+
/**
29+
* Declares whether the annotated dependency is required.
30+
* <p>Defaults to <code>true</code>.
31+
*/
32+
boolean required() default true;
33+
34+
}

spring-core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java renamed to spring-core/src/test/java/org/springframework/beans/factory/annotation/TestQualifier.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2008 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,20 +23,11 @@
2323
import java.lang.annotation.RetentionPolicy;
2424
import java.lang.annotation.Target;
2525

26-
/**
27-
* This annotation may be used on a field or parameter as a qualifier for
28-
* candidate beans when autowiring. It may also be used to annotate other
29-
* custom annotations that can then in turn be used as qualifiers.
30-
*
31-
* @author Mark Fisher
32-
* @author Juergen Hoeller
33-
* @since 2.5
34-
*/
3526
@Retention(RetentionPolicy.RUNTIME)
3627
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE})
3728
@Inherited
3829
@Documented
39-
public @interface Qualifier {
30+
public @interface TestQualifier {
4031

4132
String value() default "";
4233

spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333

3434
import org.junit.Test;
3535

36-
import org.springframework.beans.factory.annotation.Autowired;
37-
import org.springframework.beans.factory.annotation.Qualifier;
36+
import org.springframework.beans.factory.annotation.TestAutowired;
37+
import org.springframework.beans.factory.annotation.TestQualifier;
3838
import org.springframework.core.annotation.AnnotationAttributes;
3939
import org.springframework.core.type.classreading.MetadataReader;
4040
import org.springframework.core.type.classreading.MetadataReaderFactory;
@@ -167,10 +167,10 @@ private void doTestAnnotationInfo(AnnotationMetadata metadata) {
167167
}
168168

169169
private void doTestMethodAnnotationInfo(AnnotationMetadata classMetadata) {
170-
Set<MethodMetadata> methods = classMetadata.getAnnotatedMethods(Autowired.class.getName());
170+
Set<MethodMetadata> methods = classMetadata.getAnnotatedMethods(TestAutowired.class.getName());
171171
assertThat(methods.size(), is(1));
172172
for (MethodMetadata methodMetadata : methods) {
173-
assertThat(methodMetadata.isAnnotated(Autowired.class.getName()), is(true));
173+
assertThat(methodMetadata.isAnnotated(TestAutowired.class.getName()), is(true));
174174
}
175175
}
176176

@@ -215,8 +215,8 @@ public static enum SomeEnum {
215215
@SuppressWarnings({"serial", "unused"})
216216
private static class AnnotatedComponent implements Serializable {
217217

218-
@Autowired
219-
public void doWork(@Qualifier("myColor") java.awt.Color color) {
218+
@TestAutowired
219+
public void doWork(@TestQualifier("myColor") java.awt.Color color) {
220220
}
221221

222222
public void doSleep() {

0 commit comments

Comments
 (0)