From 759f6ea571b1e21178b24b07f83448812853f065 Mon Sep 17 00:00:00 2001 From: Fury_Phoenix <64714532+Phoenix-Starlight@users.noreply.github.com> Date: Sat, 27 Apr 2024 18:44:29 -0700 Subject: [PATCH 1/5] Register ApplicationContext bean with class --- .../micronaut/spring/boot/starter/MicronautImportRegistrar.java | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java b/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java index afa0b8b07..589a3ab89 100644 --- a/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java +++ b/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java @@ -130,6 +130,7 @@ public void registerBeanDefinitions( ppd.setBeanClass(MicronautPostProcess.class); ppd.setInstanceSupplier(() -> new MicronautPostProcess(context)); registry.registerBeanDefinition("micronautPostProcess", ppd); + genericBeanDefinition.setBeanClass(context.getClass()); genericBeanDefinition.setInstanceSupplier(() -> context); genericBeanDefinition.setDestroyMethodName("stop"); registry.registerBeanDefinition( From 0877dfe860814478d2842d566fc3fee536a7ee94 Mon Sep 17 00:00:00 2001 From: Fury_Phoenix <64714532+Phoenix-Starlight@users.noreply.github.com> Date: Mon, 6 May 2024 12:31:13 -0700 Subject: [PATCH 2/5] Assert none of the beans' types are null --- .../spring/boot/starter/EnableMicronautTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java index 4237ea27d..647f3ff29 100644 --- a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java +++ b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java @@ -1,6 +1,8 @@ package io.micronaut.spring.boot.starter; +import java.util.Arrays; import java.util.List; +import java.util.Objects; import io.micronaut.context.ApplicationContext; import io.micronaut.context.annotation.Bean; @@ -15,6 +17,7 @@ import org.springframework.core.env.Environment; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -51,6 +54,11 @@ void testEnableMicronaut() { assertEquals("default", fooBean.getConfiguration().getName()); assertEquals(3, fooBeanList.size()); assertTrue(context.isRunning()); + assertFalse( + Arrays.stream(context.getBeanDefinitionsNames()) + .map(context::getType) + .anyMatch(Objects::isNull) + ); } } From e1ebedf8334160c784df851230efdb151f9cea9f Mon Sep 17 00:00:00 2001 From: Fury_Phoenix <64714532+Phoenix-Starlight@users.noreply.github.com> Date: Wed, 8 May 2024 10:28:18 -0700 Subject: [PATCH 3/5] Fix typo --- .../io/micronaut/spring/boot/starter/EnableMicronautTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java index 647f3ff29..4f2dcaa0e 100644 --- a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java +++ b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java @@ -55,7 +55,7 @@ void testEnableMicronaut() { assertEquals(3, fooBeanList.size()); assertTrue(context.isRunning()); assertFalse( - Arrays.stream(context.getBeanDefinitionsNames()) + Arrays.stream(context.getBeanDefinitionNames()) .map(context::getType) .anyMatch(Objects::isNull) ); From 0b0e3056e2c6b0f5785ee7e72778d13b3962fa43 Mon Sep 17 00:00:00 2001 From: Fury_Phoenix <64714532+Phoenix-Starlight@users.noreply.github.com> Date: Fri, 10 May 2024 07:38:47 -0700 Subject: [PATCH 4/5] Refactor to use Micronaut application context --- .../micronaut/spring/boot/starter/EnableMicronautTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java index 4f2dcaa0e..ac6cc1b0b 100644 --- a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java +++ b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java @@ -55,9 +55,10 @@ void testEnableMicronaut() { assertEquals(3, fooBeanList.size()); assertTrue(context.isRunning()); assertFalse( - Arrays.stream(context.getBeanDefinitionNames()) - .map(context::getType) - .anyMatch(Objects::isNull) + context.getBeanDefinitions() + .stream() + .map(bean -> bean.getBeanType()) + .anyMatch(Objects::isNull) ); } } From 2d7becd3adc18bffb2c7a65d33fcb6a6e2958dd3 Mon Sep 17 00:00:00 2001 From: Fury_Phoenix <64714532+Phoenix-Starlight@users.noreply.github.com> Date: Mon, 13 May 2024 22:04:07 -0700 Subject: [PATCH 5/5] Use correct method to retrieve all bean defs --- .../io/micronaut/spring/boot/starter/EnableMicronautTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java index ac6cc1b0b..e2a4f7d45 100644 --- a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java +++ b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java @@ -55,7 +55,7 @@ void testEnableMicronaut() { assertEquals(3, fooBeanList.size()); assertTrue(context.isRunning()); assertFalse( - context.getBeanDefinitions() + context.getAllBeanDefinitions() .stream() .map(bean -> bean.getBeanType()) .anyMatch(Objects::isNull)