This is an automated email from the ASF dual-hosted git repository. fmariani pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-upgrade-recipes.git
commit 4d9f49b2c6ca7179cd3ab6704ddf642044bff5cc Author: Croway <federico.mariani.1...@gmail.com> AuthorDate: Wed Feb 26 17:52:44 2025 +0100 Move spring boot related keys in spring boot project --- camel-spring-boot-upgrade-recipes/pom.xml | 17 ++++ .../src/main/resources/META-INF/rewrite/4.10.yaml | 2 +- .../main/resources/META-INF/rewrite/latest.yaml | 2 +- .../resources/META-INF/rewrite/properties.yaml | 39 ++++++++ .../springboot/CamelSpringBootPropertiesTest.java | 96 ++++++++++++++++++ .../src/main/resources/META-INF/rewrite/4.10.yaml | 72 +++++++++++++- .../resources/META-INF/rewrite/properties.yaml | 100 ------------------- .../apache/camel/upgrade/CamelPropertiesTest.java | 108 --------------------- .../apache/camel/upgrade/CamelUpdate410Test.java | 19 ++++ 9 files changed, 244 insertions(+), 211 deletions(-) diff --git a/camel-spring-boot-upgrade-recipes/pom.xml b/camel-spring-boot-upgrade-recipes/pom.xml index 6268177..b39b277 100644 --- a/camel-spring-boot-upgrade-recipes/pom.xml +++ b/camel-spring-boot-upgrade-recipes/pom.xml @@ -22,6 +22,7 @@ <parent> <groupId>org.apache.camel.upgrade</groupId> <artifactId>camel-parent-upgrade-recipes</artifactId> + <relativePath>../pom.xml</relativePath> <version>4.11.0-SNAPSHOT</version> </parent> @@ -42,6 +43,22 @@ <artifactId>camel-upgrade-recipes</artifactId> <version>${project.version}</version> </dependency> + + <dependency> + <groupId>org.openrewrite</groupId> + <artifactId>rewrite-yaml</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openrewrite</groupId> + <artifactId>rewrite-properties</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openrewrite</groupId> + <artifactId>rewrite-test</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml index 4c22e14..0b4523e 100644 --- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml +++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml @@ -28,7 +28,7 @@ recipeList: - org.apache.camel.upgrade.camel45.CamelMigrationRecipe - org.apache.camel.upgrade.camel44.CamelMigrationRecipe - org.apache.camel.upgrade.camel40.CamelMigrationRecipe - - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys + - org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys - org.openrewrite.maven.UpgradeDependencyVersion: groupId: '*camel*' artifactId: 'camel-spring-boot-bom' diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml index ce22485..b5a906e 100644 --- a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml +++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/latest.yaml @@ -30,7 +30,7 @@ recipeList: - org.apache.camel.upgrade.camel40.CamelMigrationRecipe - org.apache.camel.upgrade.UpgradeToJava17 - org.apache.camel.upgrade.JavaVersion17 - - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys + - org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys - org.openrewrite.maven.UpgradeDependencyVersion: groupId: '*camel*' artifactId: 'camel-spring-boot-bom' diff --git a/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml new file mode 100644 index 0000000..a60a43e --- /dev/null +++ b/camel-spring-boot-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml @@ -0,0 +1,39 @@ +--- +# Let's keep it here, yaml recipes cannot be tested across modules +type: specs.openrewrite.org/v1beta/recipe +name: org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys +displayName: Update Camel Spring Boot properties and yaml configurations file +description: Update Camel Spring Boot properties and yaml configurations file. +recipeList: + - org.apache.camel.upgrade.customRecipes.ChangePropertyKeyWithCaseChange: + oldPropertyKey: camel.springboot(.*) + newPrefix: camel.main + exclusions: + - camel.springboot.main-run-controller + - camel.springboot.include-non-singletons + - camel.springboot.warn-on-early-shutdown + - org.openrewrite.yaml.ChangeKey: + oldKeyPath: $.camel.springboot + newKey: main + - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.springboot.routeControllerSuperviseEnabled + newPropertyKey: camel.routecontroller.enabled + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.include-non-singletons + newPropertyKey: camel.springboot.include-non-singletons + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.includeNonSingletons + newPropertyKey: camel.springboot.include-non-singletons + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.mainRunController + newPropertyKey: camel.springboot.main-run-controller + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.main-run-controller + newPropertyKey: camel.springboot.main-run-controller + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.warnOnEarlyShutdown + newPropertyKey: camel.springboot.warn-on-early-shutdown + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.warn-on-early-shutdown + newPropertyKey: camel.springboot.warn-on-early-shutdown \ No newline at end of file diff --git a/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java b/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java new file mode 100644 index 0000000..6e15747 --- /dev/null +++ b/camel-spring-boot-upgrade-recipes/src/test/java/org/apache/camel/upgrade/springboot/CamelSpringBootPropertiesTest.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.upgrade.springboot; + +import org.junit.jupiter.api.Test; +import org.openrewrite.config.Environment; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.properties.Assertions.properties; +import static org.openrewrite.yaml.Assertions.yaml; + +public class CamelSpringBootPropertiesTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.recipe(Environment.builder() + .scanYamlResources() + .build() + .activateRecipes("org.apache.camel.upgrade.UpdateCamelSpringBootPropertiesAndYamlKeys")); + } + + @Test + void propertiesFile() { + rewriteRun( + properties( + """ + camel.main.routeControllerSuperviseEnabled=true + another.ignored.property=true + camel.springboot.name = Foo + camel.springboot.main-run-controller=Should be ignored! + camel.main.routeControllerBackOffMultiplier=5 + camel.springboot.routeControllerInitialDelay = 5000 + camel.springboot.routeControllerBackoffDelay = 5000 + camel.springboot.routeControllerBackoffMaxAttempts = 10 + """, + """ + camel.routecontroller.enabled=true + another.ignored.property=true + camel.main.name = Foo + camel.springboot.main-run-controller=Should be ignored! + camel.routecontroller.backOffMultiplier=5 + camel.routecontroller.initialDelay = 5000 + camel.routecontroller.backOffDelay = 5000 + camel.routecontroller.backOffMaxAttempts = 10 + """ + ) + ); + } + + @Test + void yamlFile() { + rewriteRun( + yaml( + """ + camel: + springboot: + main-run-controller: 'Should be ignored!' + name: 'Foo' + routeControllerBackOffDelay: true + main: + routeControllerBackOffMultiplier: 5 + another: + ignored: + property: true + """, + """ + camel: + main: + name: 'Foo' + routecontroller.backOffMultiplier: 5 + routecontroller.backOffDelay: true + springboot.main-run-controller: 'Should be ignored!' + another: + ignored: + property: true + """ + ) + ); + } + +} diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml index 28383c6..3dbec78 100644 --- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml +++ b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/4.10.yaml @@ -31,6 +31,7 @@ recipeList: - org.apache.camel.upgrade.camel410.XmlDsl410Recipe - org.apache.camel.upgrade.camel410.camelSmb - org.apache.camel.upgrade.camel410.camelAzureFiles + - org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys --- #https://github.com/apache/camel/blob/main/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc#camel-azure-files type: specs.openrewrite.org/v1beta/recipe @@ -50,4 +51,73 @@ description: Renamed constants in camel-smb. recipeList: - org.openrewrite.java.ReplaceConstantWithAnotherConstant: existingFullyQualifiedConstantName: org.apache.camel.component.smb.SmbConstants.SMB_FILE_PATH - fullyQualifiedConstantName: org.apache.camel.component.smb.SmbConstants.FILE_PATH \ No newline at end of file + fullyQualifiedConstantName: org.apache.camel.component.smb.SmbConstants.FILE_PATH +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys +displayName: Update properties and yaml configurations file +description: Update properties and yaml configurations file. +recipeList: + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerInitialDelay + newPropertyKey: camel.routecontroller.initialDelay + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.backlogTracingTemplates + newPropertyKey: camel.trace.backlogTracingTemplates + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerThreadPoolSize + newPropertyKey: camel.routecontroller.threadPoolSize + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackOffMultiplier + newPropertyKey: camel.routecontroller.backOffMultiplier + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.backlogTracing + newPropertyKey: camel.trace.enabled + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerExcludeRoutes + newPropertyKey: camel.routecontroller.excludeRoutes + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackoffMultiplier + newPropertyKey: camel.routecontroller.backOffMultiplier + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.backlogTracingStandby + newPropertyKey: camel.trace.backlogTracingStandby + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackOffMaxAttempts + newPropertyKey: camel.routecontroller.backOffMaxAttempts + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerSuperviseEnabled + newPropertyKey: camel.routecontroller.enabled + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackOffMaxDelay + newPropertyKey: camel.routecontroller.backOffMaxDelay + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackOffDelay + newPropertyKey: camel.routecontroller.backOffDelay + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackoffMaxAttempts + newPropertyKey: camel.routecontroller.backOffMaxAttempts + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackoffDelay + newPropertyKey: camel.routecontroller.backOffDelay + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackOffMaxElapsedTime + newPropertyKey: camel.routecontroller.backOffMaxElapsedTime + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackoffMaxDelay + newPropertyKey: camel.routecontroller.backOffMaxDelay + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerIncludeRoutes + newPropertyKey: camel.routecontroller.includeRoutes + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.routeControllerBackoffMaxElapsedTime + newPropertyKey: camel.routecontroller.backOffMaxElapsedTime + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.backlogTracingTemplates + newPropertyKey: camel.trace.backlogTracingTemplates + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.backlogTracingStandby + newPropertyKey: camel.trace.backlogTracingStandby + - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: + oldPropertyKey: camel.main.backlogTracing + newPropertyKey: camel.trace.enabled \ No newline at end of file diff --git a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml b/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml deleted file mode 100644 index 5f01b55..0000000 --- a/camel-upgrade-recipes/src/main/resources/META-INF/rewrite/properties.yaml +++ /dev/null @@ -1,100 +0,0 @@ -type: specs.openrewrite.org/v1beta/recipe -name: org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys -displayName: Update properties and yaml configurations file -description: Update properties and yaml configurations file. -recipeList: - - org.apache.camel.upgrade.customRecipes.ChangePropertyKeyWithCaseChange: - oldPropertyKey: camel.springboot(.*) - newPrefix: camel.main - exclusions: - - camel.springboot.main-run-controller - - camel.springboot.include-non-singletons - - camel.springboot.warn-on-early-shutdown - - org.openrewrite.yaml.ChangeKey: - oldKeyPath: $.camel.springboot - newKey: main - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerInitialDelay - newPropertyKey: camel.routecontroller.initialDelay - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.backlogTracingTemplates - newPropertyKey: camel.trace.backlogTracingTemplates - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerThreadPoolSize - newPropertyKey: camel.routecontroller.threadPoolSize - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackOffMultiplier - newPropertyKey: camel.routecontroller.backOffMultiplier - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.backlogTracing - newPropertyKey: camel.trace.enabled - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerExcludeRoutes - newPropertyKey: camel.routecontroller.excludeRoutes - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackoffMultiplier - newPropertyKey: camel.routecontroller.backOffMultiplier - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.backlogTracingStandby - newPropertyKey: camel.trace.backlogTracingStandby - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackOffMaxAttempts - newPropertyKey: camel.routecontroller.backOffMaxAttempts - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.springboot.routeControllerSuperviseEnabled - newPropertyKey: camel.routecontroller.enabled - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerSuperviseEnabled - newPropertyKey: camel.routecontroller.enabled - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackOffMaxDelay - newPropertyKey: camel.routecontroller.backOffMaxDelay - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackOffDelay - newPropertyKey: camel.routecontroller.backOffDelay - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackoffMaxAttempts - newPropertyKey: camel.routecontroller.backOffMaxAttempts - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackoffDelay - newPropertyKey: camel.routecontroller.backOffDelay - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackOffMaxElapsedTime - newPropertyKey: camel.routecontroller.backOffMaxElapsedTime - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackoffMaxDelay - newPropertyKey: camel.routecontroller.backOffMaxDelay - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerIncludeRoutes - newPropertyKey: camel.routecontroller.includeRoutes - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.routeControllerBackoffMaxElapsedTime - newPropertyKey: camel.routecontroller.backOffMaxElapsedTime - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.backlogTracingTemplates - newPropertyKey: camel.trace.backlogTracingTemplates - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.backlogTracingStandby - newPropertyKey: camel.trace.backlogTracingStandby - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.backlogTracing - newPropertyKey: camel.trace.enabled - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.include-non-singletons - newPropertyKey: camel.springboot.include-non-singletons - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.includeNonSingletons - newPropertyKey: camel.springboot.include-non-singletons - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.mainRunController - newPropertyKey: camel.springboot.main-run-controller - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.main-run-controller - newPropertyKey: camel.springboot.main-run-controller - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.warnOnEarlyShutdown - newPropertyKey: camel.springboot.warn-on-early-shutdown - - org.apache.camel.upgrade.customRecipes.PropertiesAndYamlKeyUpdate: - oldPropertyKey: camel.main.warn-on-early-shutdown - newPropertyKey: camel.springboot.warn-on-early-shutdown - diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java deleted file mode 100644 index 9aeb8a1..0000000 --- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelPropertiesTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.upgrade; - -import org.junit.jupiter.api.Test; -import org.openrewrite.test.RewriteTest; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; - -import static org.openrewrite.properties.Assertions.properties; -import static org.openrewrite.yaml.Assertions.yaml; - -public class CamelPropertiesTest implements RewriteTest { - - @Test - void propertiesFile() { - rewriteRun( - recipeSpec -> { - try { - recipeSpec.recipe( - new FileInputStream("src/main/resources/META-INF/rewrite/properties.yaml"), - "org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys"); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - }, - properties( - """ - camel.main.routeControllerSuperviseEnabled=true - another.ignored.property=true - camel.springboot.name = Foo - camel.springboot.main-run-controller=Should be ignored! - camel.main.routeControllerBackOffMultiplier=5 - camel.springboot.routeControllerInitialDelay = 5000 - camel.springboot.routeControllerBackoffDelay = 5000 - camel.springboot.routeControllerBackoffMaxAttempts = 10 - """, - """ - camel.routecontroller.enabled=true - another.ignored.property=true - camel.main.name = Foo - camel.springboot.main-run-controller=Should be ignored! - camel.routecontroller.backOffMultiplier=5 - camel.routecontroller.initialDelay = 5000 - camel.routecontroller.backOffDelay = 5000 - camel.routecontroller.backOffMaxAttempts = 10 - """ - ) - ); - } - - @Test - void yamlFile() { - rewriteRun( - recipeSpec -> { - try { - recipeSpec.recipe( - new FileInputStream("src/main/resources/META-INF/rewrite/properties.yaml"), - "org.apache.camel.upgrade.UpdatePropertiesAndYamlKeys"); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } - }, - yaml( - """ - camel: - springboot: - main-run-controller: 'Should be ignored!' - name: 'Foo' - routeControllerBackOffDelay: true - main: - routeControllerBackOffMultiplier: 5 - another: - ignored: - property: true - """, - """ - camel: - main: - name: 'Foo' - routecontroller.backOffMultiplier: 5 - routecontroller.backOffDelay: true - springboot.main-run-controller: 'Should be ignored!' - another: - ignored: - property: true - """ - ) - ); - } - - -} diff --git a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java index e09398f..b2226de 100644 --- a/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java +++ b/camel-upgrade-recipes/src/test/java/org/apache/camel/upgrade/CamelUpdate410Test.java @@ -24,6 +24,7 @@ import org.openrewrite.yaml.Assertions; import static org.openrewrite.java.Assertions.java; import static org.openrewrite.maven.Assertions.pomXml; +import static org.openrewrite.properties.Assertions.properties; import static org.openrewrite.xml.Assertions.xml; public class CamelUpdate410Test implements RewriteTest { @@ -173,4 +174,22 @@ public class CamelUpdate410Test implements RewriteTest { """)); } + @Test + void propertiesFile() { + rewriteRun( + properties( + """ + camel.main.routeControllerSuperviseEnabled=true + another.ignored.property=true + camel.main.routeControllerBackOffMultiplier=5 + """, + """ + camel.routecontroller.enabled=true + another.ignored.property=true + camel.routecontroller.backOffMultiplier=5 + """ + ) + ); + } + }