diff --git a/spring-core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java b/spring-core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java deleted file mode 100644 index c326508253..0000000000 --- a/spring-core/src/test/java/org/springframework/beans/factory/annotation/Autowired.java +++ /dev/null @@ -1,67 +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.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Marks a constructor, field, setter method or config method as to be - * autowired by Spring's dependency injection facilities. - * - *

Only one constructor (at max) of any given bean class may carry this - * annotation, indicating the constructor to autowire when used as a Spring - * bean. Such a constructor does not have to be public. - * - *

Fields are injected right after construction of a bean, before any - * config methods are invoked. Such a config field does not have to be public. - * - *

Config methods may have an arbitrary name and any number of arguments; - * each of those arguments will be autowired with a matching bean in the - * Spring container. Bean property setter methods are effectively just - * a special case of such a general config method. Such config methods - * do not have to be public. - * - *

In the case of multiple argument methods, the 'required' parameter is - * applicable for all arguments. - * - *

In case of a {@link java.util.Collection} or {@link java.util.Map} - * dependency type, the container will autowire all beans matching the - * declared value type. In case of a Map, the keys must be declared as - * type String and will be resolved to the corresponding bean names. - * - *

Please do consult the javadoc for the {@link AutowiredAnnotationBeanPostProcessor} - * class (which, by default, checks for the presence of this annotation). - * - * @author Juergen Hoeller - * @author Mark Fisher - * @since 2.5 - * @see AutowiredAnnotationBeanPostProcessor - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) -public @interface Autowired { - - /** - * Declares whether the annotated dependency is required. - *

Defaults to true. - */ - boolean required() default true; - -} diff --git a/spring-core/src/test/java/org/springframework/beans/factory/annotation/TestAutowired.java b/spring-core/src/test/java/org/springframework/beans/factory/annotation/TestAutowired.java new file mode 100644 index 0000000000..60e4561b52 --- /dev/null +++ b/spring-core/src/test/java/org/springframework/beans/factory/annotation/TestAutowired.java @@ -0,0 +1,34 @@ +/* + * Copyright 2002-2012 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD}) +public @interface TestAutowired { + + /** + * Declares whether the annotated dependency is required. + *

Defaults to true. + */ + boolean required() default true; + +} diff --git a/spring-core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java b/spring-core/src/test/java/org/springframework/beans/factory/annotation/TestQualifier.java similarity index 73% rename from spring-core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java rename to spring-core/src/test/java/org/springframework/beans/factory/annotation/TestQualifier.java index cc1584c843..7fcbf5e118 100644 --- a/spring-core/src/test/java/org/springframework/beans/factory/annotation/Qualifier.java +++ b/spring-core/src/test/java/org/springframework/beans/factory/annotation/TestQualifier.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2012 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. @@ -23,20 +23,11 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * This annotation may be used on a field or parameter as a qualifier for - * candidate beans when autowiring. It may also be used to annotate other - * custom annotations that can then in turn be used as qualifiers. - * - * @author Mark Fisher - * @author Juergen Hoeller - * @since 2.5 - */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE}) @Inherited @Documented -public @interface Qualifier { +public @interface TestQualifier { String value() default ""; diff --git a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java index b9cd47bf17..6f051a16e7 100644 --- a/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java +++ b/spring-core/src/test/java/org/springframework/core/type/AnnotationMetadataTests.java @@ -33,8 +33,8 @@ import java.util.Set; import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.TestAutowired; +import org.springframework.beans.factory.annotation.TestQualifier; import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReaderFactory; @@ -167,10 +167,10 @@ public class AnnotationMetadataTests { } private void doTestMethodAnnotationInfo(AnnotationMetadata classMetadata) { - Set methods = classMetadata.getAnnotatedMethods(Autowired.class.getName()); + Set methods = classMetadata.getAnnotatedMethods(TestAutowired.class.getName()); assertThat(methods.size(), is(1)); for (MethodMetadata methodMetadata : methods) { - assertThat(methodMetadata.isAnnotated(Autowired.class.getName()), is(true)); + assertThat(methodMetadata.isAnnotated(TestAutowired.class.getName()), is(true)); } } @@ -215,8 +215,8 @@ public class AnnotationMetadataTests { @SuppressWarnings({"serial", "unused"}) private static class AnnotatedComponent implements Serializable { - @Autowired - public void doWork(@Qualifier("myColor") java.awt.Color color) { + @TestAutowired + public void doWork(@TestQualifier("myColor") java.awt.Color color) { } public void doSleep() {