File tree Expand file tree Collapse file tree 4 files changed +99
-1
lines changed
spring-context/src/test/java/org/springframework/context/annotation Expand file tree Collapse file tree 4 files changed +99
-1
lines changed Original file line number Diff line number Diff line change 11/*
2- * Copyright 2002-2017 the original author or authors.
2+ * Copyright 2002-2020 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.
4242
4343import org .springframework .beans .factory .annotation .AnnotatedGenericBeanDefinition ;
4444import org .springframework .beans .factory .config .BeanDefinition ;
45+ import org .springframework .context .annotation .componentscan .gh24375 .MyComponent ;
4546import org .springframework .context .index .CandidateComponentsTestClassLoader ;
4647import org .springframework .core .env .ConfigurableEnvironment ;
4748import org .springframework .core .env .StandardEnvironment ;
@@ -501,6 +502,15 @@ public void testIntegrationWithAnnotationConfigApplicationContext_metaProfile()
501502 }
502503 }
503504
505+ @ Test
506+ public void gh24375 () {
507+ ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider (true );
508+ Set <BeanDefinition > components = provider .findCandidateComponents (MyComponent .class .getPackage ().getName ());
509+ assertEquals (1 , components .size ());
510+ assertEquals (MyComponent .class .getName (), components .iterator ().next ().getBeanClassName ());
511+ }
512+
513+
504514 private boolean containsBeanClass (Set <BeanDefinition > candidates , Class <?> beanClass ) {
505515 for (BeanDefinition candidate : candidates ) {
506516 if (beanClass .getName ().equals (candidate .getBeanClassName ())) {
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2002-2020 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+ * https://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 .context .annotation .componentscan .gh24375 ;
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+ import org .springframework .core .annotation .AliasFor ;
25+
26+ @ Target (ElementType .TYPE )
27+ @ Retention (RetentionPolicy .RUNTIME )
28+ public @interface A {
29+
30+ @ AliasFor ("value" )
31+ B other () default @ B ;
32+
33+ @ AliasFor ("other" )
34+ B value () default @ B ;
35+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2002-2020 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+ * https://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 .context .annotation .componentscan .gh24375 ;
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+ @ Target (ElementType .ANNOTATION_TYPE )
25+ @ Retention (RetentionPolicy .RUNTIME )
26+ public @interface B {
27+
28+ String name () default "" ;
29+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2002-2020 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+ * https://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 .context .annotation .componentscan .gh24375 ;
18+
19+ import org .springframework .stereotype .Component ;
20+
21+ @ Component
22+ @ A (other = @ B )
23+ public class MyComponent {
24+ }
You can’t perform that action at this time.
0 commit comments