From aedd909ef66e0d84de167e30d80ab13f2bab5f13 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Tue, 22 Aug 2023 11:40:44 +0200 Subject: [PATCH] Test status quo for component name lookups for Jakarta annotations --- .../scannable/JakartaManagedBeanComponent.java | 4 ++-- .../annotation/AnnotationBeanNameGeneratorTests.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/spring-context/src/test/java/example/scannable/JakartaManagedBeanComponent.java b/spring-context/src/test/java/example/scannable/JakartaManagedBeanComponent.java index ffeb6c29e0a..6140ea0dce3 100644 --- a/spring-context/src/test/java/example/scannable/JakartaManagedBeanComponent.java +++ b/spring-context/src/test/java/example/scannable/JakartaManagedBeanComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -19,6 +19,6 @@ package example.scannable; /** * @author Sam Brannen */ -@jakarta.annotation.ManagedBean +@jakarta.annotation.ManagedBean("myJakartaManagedBeanComponent") public class JakartaManagedBeanComponent { } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java index 0c5e3dca871..c2d9c70efa6 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java @@ -22,6 +22,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import example.scannable.DefaultNamedComponent; +import example.scannable.JakartaManagedBeanComponent; +import example.scannable.JakartaNamedComponent; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; @@ -63,6 +65,16 @@ class AnnotationBeanNameGeneratorTests { assertGeneratedName(ComponentWithName.class, "walden"); } + @Test + void generateBeanNameWithJakartaNamedComponent() { + assertGeneratedName(JakartaNamedComponent.class, "myJakartaNamedComponent"); + } + + @Test + void generateBeanNameWithJakartaManagedBeanComponent() { + assertGeneratedName(JakartaManagedBeanComponent.class, "myJakartaManagedBeanComponent"); + } + @Test void generateBeanNameWithCustomStereotypeComponent() { assertGeneratedName(DefaultNamedComponent.class, "thoreau");