Remove bean cycles

- Shuffle things around into different auto-config and configuration
  classes and use other tricks like ObjectProvider to work around
  boot 2.6.x imposing bean cycle checks.
- This is first set of changes to work around this issue, not
  to make things perfect. Further refactoring work is needed
  making code base more boot 2.x friendly as things are based
  on boot 1.5.x times.
- Fixes #324
This commit is contained in:
Janne Valkealahti
2021-12-17 15:25:50 +00:00
parent 2de3dd0334
commit e14f4a3f32
19 changed files with 367 additions and 195 deletions

View File

@@ -8,6 +8,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.shell.CommandRegistry;
import org.springframework.shell.MethodTarget;
import org.springframework.shell.Shell;
import org.springframework.shell.jline.InteractiveShellApplicationRunner;
@@ -23,8 +24,7 @@ import static org.springframework.util.ReflectionUtils.findMethod;
*
* @author Sualeh Fatehi
*/
@SpringBootTest(properties = { InteractiveShellApplicationRunner.SPRING_SHELL_INTERACTIVE_ENABLED + "=" + false,
"spring.main.allow-circular-references=true" })
@SpringBootTest(properties = { InteractiveShellApplicationRunner.SPRING_SHELL_INTERACTIVE_ENABLED + "=" + false })
@ContextConfiguration(classes = TestCalculatorStateConfig.class)
public class CalculatorCommandsIntegrationTest extends BaseCalculatorTest {
@@ -33,6 +33,9 @@ public class CalculatorCommandsIntegrationTest extends BaseCalculatorTest {
@Autowired
private Shell shell;
@Autowired
private CommandRegistry commandRegistry;
@Autowired
private CalculatorState state;
@@ -45,7 +48,7 @@ public class CalculatorCommandsIntegrationTest extends BaseCalculatorTest {
final String command = "add";
final String commandMethod = "add";
final MethodTarget commandTarget = lookupCommand(shell, command);
final MethodTarget commandTarget = lookupCommand(commandRegistry, command);
assertThat(commandTarget).isNotNull();
assertThat(commandTarget.getGroup()).isEqualTo("Calculator Commands");
assertThat(commandTarget.getHelp()).isEqualTo("Add two integers");
@@ -67,7 +70,7 @@ public class CalculatorCommandsIntegrationTest extends BaseCalculatorTest {
final String command = "add-to-memory";
final String commandMethod = "addToMemory";
final MethodTarget commandTarget = lookupCommand(shell, command);
final MethodTarget commandTarget = lookupCommand(commandRegistry, command);
assertThat(commandTarget).isNotNull();
assertThat(commandTarget.getGroup()).isEqualTo("Calculator Commands");
assertThat(commandTarget.getHelp()).isEqualTo("Add an integer to the value in memory");