From d49bf8e59c72c6fdbaccdf572bfcb63cf283b306 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 8 May 2025 10:36:48 +0100 Subject: [PATCH] Tidy up tests in spring-boot-autoconfigure-all See gh-46071 --- .../services/javax.cache.spi.CachingProvider | 4 --- .../src/test/resources/jndi.properties | 5 --- .../boot/autoconfigure/jdbc/another.sql | 4 --- .../boot/autoconfigure/jdbc/data.sql | 1 - .../boot/autoconfigure/jdbc/encoding-data.sql | 2 -- .../autoconfigure/jdbc/encoding-schema.sql | 4 --- .../autoconfigure/jdbc/lexical-schema-aaa.sql | 4 --- .../autoconfigure/jdbc/lexical-schema-bbb.sql | 2 -- .../boot/autoconfigure/jdbc/schema.sql | 4 --- .../src/test/resources/simple-jndi | 0 ...icationAdminJmxAutoConfigurationTests.java | 23 ------------ .../ConditionalOnMissingFilterBeanTests.java | 3 +- .../ContainerImageMetadataTests.java | 0 .../TemplateAvailabilityProvidersTests.java | 36 +++++++++++++++++-- .../template/TemplateRuntimeHintsTests.java | 4 ++- .../web/format/WebConversionServiceTests.java | 0 ...gApplicationAdminMXBeanRegistrarTests.java | 15 ++++++++ 17 files changed, 52 insertions(+), 59 deletions(-) delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/META-INF/services/javax.cache.spi.CachingProvider delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/jndi.properties delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/data.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-data.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-schema.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-bbb.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql delete mode 100644 spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/simple-jndi rename spring-boot-project/{spring-boot-autoconfigure-all => spring-boot-autoconfigure}/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java (81%) rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet => spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition}/ConditionalOnMissingFilterBeanTests.java (97%) rename spring-boot-project/{spring-boot-autoconfigure-all => spring-boot-autoconfigure}/src/test/java/org/springframework/boot/autoconfigure/container/ContainerImageMetadataTests.java (100%) rename spring-boot-project/{spring-boot-autoconfigure-all => spring-boot-autoconfigure}/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java (83%) rename spring-boot-project/{spring-boot-autoconfigure-all => spring-boot-autoconfigure}/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java (91%) rename spring-boot-project/{spring-boot-autoconfigure-all => spring-boot-autoconfigure}/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java (100%) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/META-INF/services/javax.cache.spi.CachingProvider b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/META-INF/services/javax.cache.spi.CachingProvider deleted file mode 100644 index a9ea8c43aa2..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/META-INF/services/javax.cache.spi.CachingProvider +++ /dev/null @@ -1,4 +0,0 @@ -# -# Test JSR 107 provider for testing purposes only. -# -org.springframework.boot.autoconfigure.cache.support.MockCachingProvider \ No newline at end of file diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/jndi.properties b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/jndi.properties deleted file mode 100644 index 8d34127a669..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/jndi.properties +++ /dev/null @@ -1,5 +0,0 @@ -java.naming.factory.initial = org.osjava.sj.SimpleJndiContextFactory -org.osjava.sj.delimiter = / -org.osjava.sj.jndi.shared = true -org.osjava.sj.root = src/test/resources/simple-jndi -org.osjava.sj.jndi.ignoreClose = true \ No newline at end of file diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql deleted file mode 100644 index b4974a01bbf..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/another.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE SPAM ( - id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, - name VARCHAR(30) -); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/data.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/data.sql deleted file mode 100644 index 068d7392cbc..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/data.sql +++ /dev/null @@ -1 +0,0 @@ -INSERT INTO FOO VALUES (1, 'Andy'); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-data.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-data.sql deleted file mode 100644 index 030efbf6780..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-data.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO BAR(id, name) VALUES (1, 'bar'); -INSERT INTO BAR(id, name) VALUES (2, 'ばー'); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-schema.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-schema.sql deleted file mode 100644 index 21284cab1d5..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/encoding-schema.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE BAR ( - id INTEGER PRIMARY KEY, - name VARCHAR(30) -); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql deleted file mode 100644 index 5d4523e1e17..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-aaa.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE FOO ( - id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, - todrop VARCHAR(30) -); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-bbb.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-bbb.sql deleted file mode 100644 index bd6b7221ec5..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/lexical-schema-bbb.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE FOO DROP COLUMN todrop; -ALTER TABLE FOO ADD COLUMN name VARCHAR(30); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql deleted file mode 100644 index 1014a04db4a..00000000000 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/org/springframework/boot/autoconfigure/jdbc/schema.sql +++ /dev/null @@ -1,4 +0,0 @@ -CREATE TABLE FOO ( - id INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, - name VARCHAR(30) -); diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/simple-jndi b/spring-boot-project/spring-boot-autoconfigure-all/src/test/resources/simple-jndi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java similarity index 81% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java index bd1b133045f..22c6bc55173 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfigurationTests.java @@ -33,9 +33,6 @@ import org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar; import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration; -import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext; -import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -108,21 +105,6 @@ class SpringApplicationAdminJmxAutoConfigurationTests { }); } - @Test - void registerWithSimpleWebApp() throws Exception { - try (ConfigurableApplicationContext context = new SpringApplicationBuilder() - .sources(TomcatServletWebServerAutoConfiguration.class, DispatcherServletAutoConfiguration.class, - MultipleMBeanExportersConfiguration.class, SpringApplicationAdminJmxAutoConfiguration.class) - .run("--" + ENABLE_ADMIN_PROP, "--server.port=0")) { - assertThat(context).isInstanceOf(ServletWebServerApplicationContext.class); - assertThat(this.server.getAttribute(createDefaultObjectName(), "EmbeddedWebApplication")) - .isEqualTo(Boolean.TRUE); - int expected = ((ServletWebServerApplicationContext) context).getWebServer().getPort(); - String actual = getProperty(createDefaultObjectName(), "local.server.port"); - assertThat(actual).isEqualTo(String.valueOf(expected)); - } - } - @Test void onlyRegisteredOnceWhenThereIsAChildContext() { SpringApplicationBuilder parentBuilder = new SpringApplicationBuilder().web(WebApplicationType.NONE) @@ -151,11 +133,6 @@ class SpringApplicationAdminJmxAutoConfigurationTests { } } - private String getProperty(ObjectName objectName, String key) throws Exception { - return (String) this.server.invoke(objectName, "getProperty", new Object[] { key }, - new String[] { String.class.getName() }); - } - @Configuration(proxyBeanMethods = false) static class MultipleMBeanExportersConfiguration { diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ConditionalOnMissingFilterBeanTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingFilterBeanTests.java similarity index 97% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ConditionalOnMissingFilterBeanTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingFilterBeanTests.java index 12b4c65b950..f305be13d22 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ConditionalOnMissingFilterBeanTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/condition/ConditionalOnMissingFilterBeanTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.web.servlet; +package org.springframework.boot.autoconfigure.condition; import java.io.IOException; import java.util.function.Consumer; @@ -26,7 +26,6 @@ import jakarta.servlet.ServletRequest; import jakarta.servlet.ServletResponse; import org.junit.jupiter.api.Test; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingFilterBean; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/container/ContainerImageMetadataTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/container/ContainerImageMetadataTests.java similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/container/ContainerImageMetadataTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/container/ContainerImageMetadataTests.java diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java similarity index 83% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java index b3c9951bad5..d23c162d9ed 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProvidersTests.java @@ -16,6 +16,10 @@ package org.springframework.boot.autoconfigure.template; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.Collection; import java.util.Collections; @@ -25,7 +29,9 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.boot.testsupport.classpath.resources.WithResource; import org.springframework.context.ApplicationContext; +import org.springframework.core.env.Environment; import org.springframework.core.io.ResourceLoader; import org.springframework.mock.env.MockEnvironment; @@ -71,11 +77,14 @@ class TemplateAvailabilityProvidersTests { } @Test + @SuppressWarnings("rawtypes") + @WithTestTemplateAvailabilityProvider void createWhenUsingApplicationContextShouldLoadProviders() { ApplicationContext applicationContext = mock(ApplicationContext.class); - given(applicationContext.getClassLoader()).willReturn(this.classLoader); + given(applicationContext.getClassLoader()).willReturn(Thread.currentThread().getContextClassLoader()); TemplateAvailabilityProviders providers = new TemplateAvailabilityProviders(applicationContext); - assertThat(providers.getProviders()).isNotEmpty(); + assertThat(providers.getProviders()).extracting((provider) -> (Class) provider.getClass()) + .containsExactly(TestTemplateAvailabilityProvider.class); then(applicationContext).should().getClassLoader(); } @@ -86,8 +95,10 @@ class TemplateAvailabilityProvidersTests { } @Test + @WithTestTemplateAvailabilityProvider void createWhenUsingClassLoaderShouldLoadProviders() { - TemplateAvailabilityProviders providers = new TemplateAvailabilityProviders(this.classLoader); + TemplateAvailabilityProviders providers = new TemplateAvailabilityProviders( + Thread.currentThread().getContextClassLoader()); assertThat(providers.getProviders()).isNotEmpty(); } @@ -187,4 +198,23 @@ class TemplateAvailabilityProvidersTests { .isTemplateAvailable(this.view, this.environment, this.classLoader, this.resourceLoader); } + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + @WithResource(name = "META-INF/spring.factories", + content = "org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=" + + "org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvidersTests$TestTemplateAvailabilityProvider") + @interface WithTestTemplateAvailabilityProvider { + + } + + static class TestTemplateAvailabilityProvider implements TemplateAvailabilityProvider { + + @Override + public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader, + ResourceLoader resourceLoader) { + return false; + } + + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java similarity index 91% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java index b7d8b93e84b..d876214ee41 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/template/TemplateRuntimeHintsTests.java @@ -25,6 +25,7 @@ import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; import org.springframework.beans.factory.aot.AotServices; import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.testsupport.classpath.resources.WithResource; import org.springframework.core.io.ClassPathResource; import static org.assertj.core.api.Assertions.assertThat; @@ -46,8 +47,9 @@ class TemplateRuntimeHintsTests { } @Test + @WithResource(name = "templates/test.html") void contributeWhenTemplateLocationExists() { - RuntimeHints runtimeHints = contribute(getClass().getClassLoader()); + RuntimeHints runtimeHints = contribute(Thread.currentThread().getContextClassLoader()); assertThat(TEST_PREDICATE.test(runtimeHints)).isTrue(); } diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java similarity index 100% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java rename to spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/format/WebConversionServiceTests.java diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java index d49a94e91fe..55aa79829f2 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/admin/SpringApplicationAdminMXBeanRegistrarTests.java @@ -17,6 +17,7 @@ package org.springframework.boot.admin; import java.lang.management.ManagementFactory; +import java.util.Map; import javax.management.InstanceNotFoundException; import javax.management.MBeanServer; @@ -34,6 +35,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.core.env.MapPropertySource; import org.springframework.test.util.ReflectionTestUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -111,6 +113,19 @@ class SpringApplicationAdminMXBeanRegistrarTests { assertThat(getProperty(objectName, "does.not.exist.test")).isNull(); } + @Test + void whenEnvironmentContainsServerPortsPropertySourceEmbeddedWebApplicationIsDetected() { + final ObjectName objectName = createObjectName(OBJECT_NAME); + SpringApplication application = new SpringApplication(Config.class); + application.setWebApplicationType(WebApplicationType.NONE); + application.addInitializers((context) -> context.getEnvironment() + .getPropertySources() + .addLast(new MapPropertySource("server.ports", Map.of("local.server.port", "8910")))); + this.context = application.run("--foo.bar=blam"); + assertThat(isApplicationReady(objectName)).isTrue(); + assertThat(isApplicationEmbeddedWebApplication(objectName)).isTrue(); + } + @Test void shutdownApp() { final ObjectName objectName = createObjectName(OBJECT_NAME);