@@ -1247,6 +1247,29 @@ void addBootstrapperCanRegisterBeans() {
12471247 assertThat (applicationContext .getBean ("test" )).isEqualTo ("boot" );
12481248 }
12491249
1250+ @ Test
1251+ void whenABootstrapperImplementsOnlyTheOldMethodThenItIsCalled () {
1252+ SpringApplication application = new SpringApplication (ExampleConfig .class );
1253+ application .setWebApplicationType (WebApplicationType .NONE );
1254+ OnlyOldMethodTestBootstrapper bootstrapper = new OnlyOldMethodTestBootstrapper ();
1255+ application .addBootstrapper (bootstrapper );
1256+ try (ConfigurableApplicationContext applicationContext = application .run ()) {
1257+ assertThat (bootstrapper .intitialized ).isTrue ();
1258+ }
1259+ }
1260+
1261+ @ Test
1262+ void whenABootstrapperImplementsTheOldMethodAndTheNewMethodThenOnlyTheNewMethodIsCalled () {
1263+ SpringApplication application = new SpringApplication (ExampleConfig .class );
1264+ application .setWebApplicationType (WebApplicationType .NONE );
1265+ BothMethodsTestBootstrapper bootstrapper = new BothMethodsTestBootstrapper ();
1266+ application .addBootstrapper (bootstrapper );
1267+ try (ConfigurableApplicationContext applicationContext = application .run ()) {
1268+ assertThat (bootstrapper .intitialized ).isFalse ();
1269+ assertThat (bootstrapper .initialized ).isTrue ();
1270+ }
1271+ }
1272+
12501273 private <S extends AvailabilityState > ArgumentMatcher <ApplicationEvent > isAvailabilityChangeEventWithState (
12511274 S state ) {
12521275 return (argument ) -> (argument instanceof AvailabilityChangeEvent <?>)
@@ -1720,4 +1743,35 @@ <E extends ApplicationEvent> E getEvent(Class<E> type) {
17201743
17211744 }
17221745
1746+ static class OnlyOldMethodTestBootstrapper implements Bootstrapper {
1747+
1748+ private boolean intitialized ;
1749+
1750+ @ Override
1751+ @ SuppressWarnings ("deprecation" )
1752+ public void intitialize (BootstrapRegistry registry ) {
1753+ this .intitialized = true ;
1754+ }
1755+
1756+ }
1757+
1758+ static class BothMethodsTestBootstrapper implements Bootstrapper {
1759+
1760+ private boolean intitialized ;
1761+
1762+ private boolean initialized ;
1763+
1764+ @ Override
1765+ @ SuppressWarnings ("deprecation" )
1766+ public void intitialize (BootstrapRegistry registry ) {
1767+ this .intitialized = true ;
1768+ }
1769+
1770+ @ Override
1771+ public void initialize (BootstrapRegistry registry ) {
1772+ this .initialized = true ;
1773+ }
1774+
1775+ }
1776+
17231777}
0 commit comments