From e3b0e4fe89a23ad98dbc9346fd23240da7aff47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=8A=B9=EC=9D=80?= Date: Mon, 26 Dec 2022 20:46:18 +0900 Subject: [PATCH] 2022-12-26-Mon-20:46 --- .../beandefinition/BeanDefinitionTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/test/java/hello/core/beandefinition/BeanDefinitionTest.java diff --git a/src/test/java/hello/core/beandefinition/BeanDefinitionTest.java b/src/test/java/hello/core/beandefinition/BeanDefinitionTest.java new file mode 100644 index 0000000..1e3fec5 --- /dev/null +++ b/src/test/java/hello/core/beandefinition/BeanDefinitionTest.java @@ -0,0 +1,28 @@ +package hello.core.beandefinition; + +import hello.core.order.AppConfig; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.support.GenericXmlApplicationContext; + +public class BeanDefinitionTest { + + //AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class); + GenericXmlApplicationContext ac = new GenericXmlApplicationContext("appConfig.xml"); + + @Test + @DisplayName("Bean 설정 메타정보 확인") + void findApplicationBean() { + String[] beanDefinitionNames = ac.getBeanDefinitionNames(); + for (String beanDefinitionName : beanDefinitionNames) { + BeanDefinition beanDefinition = ac.getBeanDefinition(beanDefinitionName); + + if (beanDefinition.getRole() == BeanDefinition.ROLE_APPLICATION) { + System.out.println("beanDefinitionName = " + beanDefinitionName + + " beanDefinition = " + beanDefinition); + } + } + } +}