diff --git a/build.gradle.kts b/build.gradle.kts index 0863889bf..279fac51b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { group = "org.openrewrite.recipe" description = "Eliminate legacy Spring patterns and migrate between major Spring Boot versions. Automatically." -val springBootVersions: List = listOf("1_5", "2_1", "2_2", "2_3", "2_4", "2_5", "2_6", "2_7", "3_0") +val springBootVersions: List = listOf("1_5", "2_1", "2_2", "2_3", "2_4", "2_5", "2_6", "2_7", "3_0", "3_2") val springSecurityVersions: List = listOf("5_7", "5_8", "6_2") val sourceSetNames: Map> = mapOf( @@ -109,7 +109,6 @@ recipeDependencies { val rewriteVersion = rewriteRecipe.rewriteVersion.get() -var springBoot3Version = "3.0.0-RC1" dependencies { implementation("org.openrewrite:rewrite-java:${rewriteVersion}") implementation("org.openrewrite:rewrite-xml:${rewriteVersion}") @@ -205,8 +204,8 @@ dependencies { "testWithSpringBoot_2_7RuntimeOnly"("org.springframework.security:spring-security-ldap:5.7.+") "testWithSpringBoot_2_7RuntimeOnly"("org.apache.tomcat.embed:tomcat-embed-core:9.0.+") - "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.boot:spring-boot-starter:${springBoot3Version}") - "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.boot:spring-boot-starter-test:${springBoot3Version}") + "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.boot:spring-boot-starter:3.0+") + "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.boot:spring-boot-starter-test:3.0+") "testWithSpringBoot_3_0RuntimeOnly"("org.springframework:spring-context:6.0.+") "testWithSpringBoot_3_0RuntimeOnly"("org.springframework:spring-web:6.0.+") "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.batch:spring-batch-core:5.+") @@ -216,6 +215,9 @@ dependencies { "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.security:spring-security-web:6.0.+") "testWithSpringBoot_3_0RuntimeOnly"("org.springframework.security:spring-security-ldap:6.0.+") + "testWithSpringBoot_3_2RuntimeOnly"("org.springframework.boot:spring-boot-starter:3.2+") + "testWithSpringBoot_3_2RuntimeOnly"("org.springframework.boot:spring-boot-starter-test:3.2+") + "testWithSpringSecurity_5_7RuntimeOnly"("org.springframework:spring-context:5.3.+") "testWithSpringSecurity_5_7RuntimeOnly"("org.springframework.boot:spring-boot-starter:2.7.+") "testWithSpringSecurity_5_7RuntimeOnly"("org.springframework.boot:spring-boot:2.7.+") diff --git a/src/testWithSpringBoot_3_2/java/org/openrewrite/java/spring/boot3/.editorconfig b/src/testWithSpringBoot_3_2/java/org/openrewrite/java/spring/boot3/.editorconfig new file mode 100644 index 000000000..a4824935e --- /dev/null +++ b/src/testWithSpringBoot_3_2/java/org/openrewrite/java/spring/boot3/.editorconfig @@ -0,0 +1,5 @@ +root = true + +[*.java] +indent_size = 4 +ij_continuation_indent_size = 2 diff --git a/src/testWithSpringBoot_3_2/java/org/openrewrite/java/spring/boot3/EnableVirtualThreadsTest.java b/src/testWithSpringBoot_3_2/java/org/openrewrite/java/spring/boot3/EnableVirtualThreadsTest.java new file mode 100644 index 000000000..7917754b6 --- /dev/null +++ b/src/testWithSpringBoot_3_2/java/org/openrewrite/java/spring/boot3/EnableVirtualThreadsTest.java @@ -0,0 +1,83 @@ +/* + * Copyright 2021 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. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.java.spring.boot3; + +import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.properties.Assertions.properties; +import static org.openrewrite.yaml.Assertions.yaml; + +class EnableVirtualThreadsTest implements RewriteTest { + @Override + public void defaults(RecipeSpec spec) { + spec.recipeFromResources("org.openrewrite.java.spring.boot3.EnableVirtualThreads"); + } + + @Test + @DocumentExample + void enableVirtualThreadsProperties() { + rewriteRun( + //language=properties + properties( + "", + """ + spring.threads.virtual.enabled=true + """, + s -> s.path("src/main/resources/application.properties") + ) + ); + } + + @Test + @DocumentExample + void enableVirtualThreadsYaml() { + rewriteRun( + //language=yaml + yaml( + "", + """ + spring: + threads.virtual.enabled: true + """, + s -> s.path("src/main/resources/application.yml") + ) + ); + } + + @Test + void dontEnableVirtualThreadsIfDisabled() { + rewriteRun( + //language=properties + properties( + """ + spring.threads.virtual.enabled=false + """, + s -> s.path("src/main/resources/application.properties") + ), + //language=yaml + yaml( + """ + spring: + threads.virtual.enabled: false + """, + s -> s.path("src/main/resources/application.yml") + ) + ); + } +}