Polish "Support @Order on [CommandLine|Application]Runner @Bean definitions"
See gh-37905
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -670,11 +670,11 @@ class SpringApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void runFunctionalCommandLineRunnersAndApplicationRunners() {
|
||||
SpringApplication application = new SpringApplication(FunctionalRunnerConfig.class);
|
||||
void runCommandLineRunnersAndApplicationRunnersUsingOrderOnBeanDefinitions() {
|
||||
SpringApplication application = new SpringApplication(BeanDefinitionOrderRunnerConfig.class);
|
||||
application.setWebApplicationType(WebApplicationType.NONE);
|
||||
this.context = application.run("arg");
|
||||
FunctionalRunnerConfig config = this.context.getBean(FunctionalRunnerConfig.class);
|
||||
BeanDefinitionOrderRunnerConfig config = this.context.getBean(BeanDefinitionOrderRunnerConfig.class);
|
||||
assertThat(config.runners).containsExactly("runnerA", "runnerB", "runnerC");
|
||||
}
|
||||
|
||||
@@ -1585,12 +1585,12 @@ class SpringApplicationTests {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class FunctionalRunnerConfig {
|
||||
static class BeanDefinitionOrderRunnerConfig {
|
||||
|
||||
List<String> runners = new ArrayList<>();
|
||||
private final List<String> runners = new ArrayList<>();
|
||||
|
||||
@Bean
|
||||
@Order // default is LOWEST_PRECEDENCE
|
||||
@Order
|
||||
CommandLineRunner runnerC() {
|
||||
return (args) -> this.runners.add("runnerC");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user