|
| 1 | +/* |
| 2 | + * Copyright 2021 - 2022 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.sbm.boot.upgrade_27_30.report.helper; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | +import org.junit.jupiter.api.DisplayName; |
| 20 | +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportTestSupport; |
| 21 | +import org.springframework.sbm.engine.context.ProjectContext; |
| 22 | +import org.springframework.sbm.project.resource.TestProjectContext; |
| 23 | + |
| 24 | +class UpdatedPhasesForGracefulShutdownReportSectionTest { |
| 25 | + @Test |
| 26 | + @DisplayName("Updated Phases for Graceful Shutdown should render") |
| 27 | + void withSingleModuleApplicationShouldRender() { |
| 28 | + ProjectContext context = TestProjectContext |
| 29 | + .buildProjectContext() |
| 30 | + .withSpringBootParentOf("2.7.5") |
| 31 | + .withBuildFileHavingDependencies("org.springframework.boot:spring-boot:2.7.5") |
| 32 | + .build(); |
| 33 | + |
| 34 | + SpringBootUpgradeReportTestSupport.generatedSection("Updated Phases for Graceful Shutdown") |
| 35 | + .fromProjectContext(context) |
| 36 | + .shouldRenderAs(""" |
| 37 | + === Updated Phases for Graceful Shutdown |
| 38 | + |
| 39 | + ==== What Changed |
| 40 | + The phases used by the `SmartLifecycle` implementations for graceful shutdown have been updated. |
| 41 | + Graceful shutdown now begins in phase `SmartLifecycle.DEFAULT_PHASE - 2048` and the web server is stopped in phase `SmartLifecycle.DEFAULT_PHASE - 1024`. |
| 42 | + Any `SmartLifecycle` implementations that were participating in graceful shutdown should be updated accordingly. |
| 43 | + |
| 44 | + ==== Why is the application affected |
| 45 | + Actually, we don't know if the scanned application is really affected by this change. |
| 46 | + But we found a dependency matching regex `org\\.springframework\\.boot\\:spring-boot\\:.*`. |
| 47 | + This indicates that the scanned application might be affected. |
| 48 | + |
| 49 | + ==== Remediation |
| 50 | + [IMPORTANT] |
| 51 | + ==== |
| 52 | + This section has been automatically generated from the https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#updated-phases-for-graceful-shutdown[Spring Boot 3.0 Migration Guide^, role="ext-link"]. + |
| 53 | + **Please consider contributing to issue https://github.com/spring-projects-experimental/spring-boot-migrator/issues/630[#630^, role="ext-link"]** |
| 54 | + ==== |
| 55 | + |
| 56 | +
|
| 57 | + """); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + @DisplayName("Updated Phases for Graceful Shutdown should not render") |
| 62 | + void shouldNotRender() { |
| 63 | + ProjectContext context = TestProjectContext |
| 64 | + .buildProjectContext() |
| 65 | + .build(); |
| 66 | + |
| 67 | + SpringBootUpgradeReportTestSupport.generatedSection("Updated Phases for Graceful Shutdown") |
| 68 | + .fromProjectContext(context) |
| 69 | + .shouldNotRender(); |
| 70 | + } |
| 71 | +} |
0 commit comments