@@ -1247,6 +1247,29 @@ void addBootstrapperCanRegisterBeans() {
1247
1247
assertThat (applicationContext .getBean ("test" )).isEqualTo ("boot" );
1248
1248
}
1249
1249
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
+
1250
1273
private <S extends AvailabilityState > ArgumentMatcher <ApplicationEvent > isAvailabilityChangeEventWithState (
1251
1274
S state ) {
1252
1275
return (argument ) -> (argument instanceof AvailabilityChangeEvent <?>)
@@ -1720,4 +1743,35 @@ <E extends ApplicationEvent> E getEvent(Class<E> type) {
1720
1743
1721
1744
}
1722
1745
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
+
1723
1777
}
0 commit comments