Skip to content

Commit

Permalink
Polish "Support @order on [CommandLine|Application]Runner @bean defin…
Browse files Browse the repository at this point in the history
…itions"

See gh-37905
  • Loading branch information
wilkinsona committed Oct 18, 2023
1 parent 8ac597c commit 04307aa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,11 +670,11 @@ void runCommandLineRunnersAndApplicationRunners() {
}

@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");
}

Expand Down Expand Up @@ -1585,12 +1585,12 @@ TestCommandLineRunner runnerA() {
}

@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");
}
Expand Down

0 comments on commit 04307aa

Please sign in to comment.