Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#537 add test case for UpgradeSpringBoot_3_3 expecting java, spring and spring cloud version updates #539

Conversation

timbuethe
Copy link
Contributor

@timbuethe timbuethe commented Jun 16, 2024

What's changed?

  • set up Spring Boot 3.3 source sets and tests
  • add test case for UpgradeSpringBoot_3_3 expecting java, spring and spring cloud version updates

What's your motivation?

This should reproduce issue #537

Any additional context

…a, spring and spring cloud version updates
@timtebeek timtebeek self-requested a review June 16, 2024 10:23
@timtebeek timtebeek added bug Something isn't working dependencies Pull requests that update a dependency file boot-3.3 labels Jun 16, 2024
@timtebeek
Copy link
Contributor

timtebeek commented Jun 18, 2024

Thanks a lot for reducing the issue you had down to a runnable unit test! Should help in debugging this; I suspect it's something to do with transitive dependencies, seeing how the behavior changes with or without Mockito if I understood #537 correctly. As a quick first step we might see if pull forward, or pushing backwards in recipe order any Mockito upgrade might already provide relief. 🤔

Might take me a bit of time to dive into this one in detail, but let me know if you've learned anything from running this test already.

@timtebeek
Copy link
Contributor

Thanks again @timbuethe ; I've tried it out locally as we've just had some changes upstream in openrewrite/rewrite. I had to apply some small formatting fixes to your test, and make it expect two cycles of changes (that one's questionable), but with these the test passes locally.

diff --git a/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java b/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
index aac5066..dcd0f05 100644
--- a/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
+++ b/src/testWithSpringBoot_3_3/java/org/openrewrite/java/spring/boot3/SpringCloudVersionUpgradeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2023 the original author or authors.
+ * Copyright 2024 the original author or authors.
  * <p>
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,16 +26,16 @@ import static org.openrewrite.maven.Assertions.pomXml;
 
 class SpringCloudVersionUpgradeTest implements RewriteTest {
 
-
     @Override
     public void defaults(RecipeSpec spec) {
         spec
+          .expectedCyclesThatMakeChanges(2)
           .recipe(Environment.builder()
             .scanRuntimeClasspath("org.openrewrite.java.spring")
             .build()
             .activateRecipes("org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3")
           ).parser(JavaParser.fromJavaVersion()
-            .classpath( "jaxb-api"));
+            .classpath("jaxb-api"));
     }
 
     @Test
@@ -45,82 +45,81 @@ class SpringCloudVersionUpgradeTest implements RewriteTest {
             //language=xml
             pomXml(
               """
-                 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-                     <modelVersion>4.0.0</modelVersion>
+                <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+                         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+                    <modelVersion>4.0.0</modelVersion>
                 
-                     <groupId>com.example</groupId>
-                     <artifactId>fooservice</artifactId>
-                     <version>1.0-SNAPSHOT</version>
+                    <groupId>com.example</groupId>
+                    <artifactId>fooservice</artifactId>
+                    <version>1.0-SNAPSHOT</version>
                 
-                     <name>FooService</name>
+                    <name>FooService</name>
                 
-                     <parent>
-                         <groupId>org.springframework.boot</groupId>
-                         <artifactId>spring-boot-starter-parent</artifactId>
-                         <version>2.2.2.RELEASE</version>
-                         <relativePath/>
-                     </parent>
+                    <parent>
+                        <groupId>org.springframework.boot</groupId>
+                        <artifactId>spring-boot-starter-parent</artifactId>
+                        <version>2.2.2.RELEASE</version>
+                        <relativePath/>
+                    </parent>
                 
-                     <properties>
-                         <java.version>11</java.version>
-                         <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
-                         <mockito.version>2.18.3</mockito.version>
-                     </properties>
+                    <properties>
+                        <java.version>11</java.version>
+                        <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
+                        <mockito.version>2.18.3</mockito.version>
+                    </properties>
                 
-                     <dependencyManagement>
-                         <dependencies>
-                             <dependency>
-                                 <groupId>org.springframework.cloud</groupId>
-                                 <artifactId>spring-cloud-dependencies</artifactId>
-                                 <version>${spring-cloud.version}</version>
-                                 <type>pom</type>
-                                 <scope>import</scope>
-                             </dependency>
-                         </dependencies>
-                     </dependencyManagement>
+                    <dependencyManagement>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.springframework.cloud</groupId>
+                                <artifactId>spring-cloud-dependencies</artifactId>
+                                <version>${spring-cloud.version}</version>
+                                <type>pom</type>
+                                <scope>import</scope>
+                            </dependency>
+                        </dependencies>
+                    </dependencyManagement>
                 </project>
                 """,
               """
                 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-                     <modelVersion>4.0.0</modelVersion>
+                         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+                    <modelVersion>4.0.0</modelVersion>
                 
-                     <groupId>com.example</groupId>
-                     <artifactId>fooservice</artifactId>
-                     <version>1.0-SNAPSHOT</version>
+                    <groupId>com.example</groupId>
+                    <artifactId>fooservice</artifactId>
+                    <version>1.0-SNAPSHOT</version>
                 
-                     <name>FooService</name>
+                    <name>FooService</name>
                 
-                     <parent>
-                         <groupId>org.springframework.boot</groupId>
-                         <artifactId>spring-boot-starter-parent</artifactId>
-                         <version>3.3.0</version>
-                         <relativePath/>
-                     </parent>
+                    <parent>
+                        <groupId>org.springframework.boot</groupId>
+                        <artifactId>spring-boot-starter-parent</artifactId>
+                        <version>3.3.1</version>
+                        <relativePath/>
+                    </parent>
                 
-                     <properties>
+                    <properties>
                         <java.version>17</java.version>
                         <spring-cloud.version>2023.0.2</spring-cloud.version>
                         <mockito.version>2.18.3</mockito.version>
-                     </properties>
+                    </properties>
                 
-                     <dependencyManagement>
-                         <dependencies>
-                             <dependency>
-                                 <groupId>org.springframework.cloud</groupId>
-                                 <artifactId>spring-cloud-dependencies</artifactId>
-                                 <version>${spring-cloud.version}</version>
-                                 <type>pom</type>
-                                 <scope>import</scope>
-                             </dependency>
-                         </dependencies>
-                     </dependencyManagement>
+                    <dependencyManagement>
+                        <dependencies>
+                            <dependency>
+                                <groupId>org.springframework.cloud</groupId>
+                                <artifactId>spring-cloud-dependencies</artifactId>
+                                <version>${spring-cloud.version}</version>
+                                <type>pom</type>
+                                <scope>import</scope>
+                            </dependency>
+                        </dependencies>
+                    </dependencyManagement>
                 </project>
                 """
             )
           )
         );
     }
-
 }

@timtebeek
Copy link
Contributor

I could not push these changes up to freenowtech:537-upgradespringboot_3_3-setting-wrong-spring-cloud-version, which makes it somewhat harder to polish this test addition for adoption. Are you already seeing improvements locally when you use
our snapshot versions?

@timtebeek timtebeek marked this pull request as draft June 20, 2024 12:25
@timtebeek timtebeek added the question Further information is requested label Jun 20, 2024
@timtebeek timtebeek removed their request for review June 20, 2024 12:26
@timbuethe
Copy link
Contributor Author

Hey @timtebeek,
thanks for your time an effort. I applied your patch and merged latest changes to the branch. If you want to make more changes, feel free to copy the file or branch to your repository. I will try the snapshot version and report back.

@timtebeek timtebeek self-requested a review July 28, 2024 20:57
@timtebeek timtebeek marked this pull request as ready for review July 28, 2024 20:59
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @timbuethe ! Good to have a first explicit 3.3 test to validate the migration works as expected. I'll polish some more on the main branch for simplicity.

@timtebeek timtebeek merged commit d054d16 into openrewrite:main Jul 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boot-3.3 bug Something isn't working dependencies Pull requests that update a dependency file question Further information is requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants