21
21
import org .mockito .ArgumentCaptor ;
22
22
import org .mockito .Mockito ;
23
23
import org .springframework .context .ApplicationEventPublisher ;
24
+ import org .springframework .sbm .GitHubIssue ;
24
25
import org .springframework .sbm .build .api .BuildFile ;
25
26
import org .springframework .sbm .build .api .DependenciesChangedEvent ;
26
27
import org .springframework .sbm .build .api .Dependency ;
@@ -2655,26 +2656,27 @@ void hasParentWithParentShouldReturnParent() {
2655
2656
2656
2657
@ Test
2657
2658
void upgradeParentVersion () {
2658
- String pomXml =
2659
- "<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n " +
2660
- "<project xmlns=\" http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" \n " +
2661
- " xsi:schemaLocation=\" http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd\" >\n " +
2662
- " <modelVersion>4.0.0</modelVersion>\n " +
2663
- " <parent>\n " +
2664
- " <groupId>org.springframework.boot</groupId>\n " +
2665
- " <artifactId>spring-boot-starter-parent</artifactId>\n " +
2666
- " <version>2.4.12</version>\n " +
2667
- " <relativePath/> <!-- lookup parent from repository -->\n " +
2668
- " </parent>\n " +
2669
- " <groupId>com.example</groupId>\n " +
2670
- " <artifactId>spring-boot-24-to-25-example</artifactId>\n " +
2671
- " <version>0.0.1-SNAPSHOT</version>\n " +
2672
- " <name>spring-boot-2.4-to-2.5-example</name>\n " +
2673
- " <description>spring-boot-2.4-to-2.5-example</description>\n " +
2674
- " <properties>\n " +
2675
- " <java.version>11</java.version>\n " +
2676
- " </properties>\n " +
2677
- "</project>\n " ;
2659
+ String pomXml = """
2660
+ <?xml version="1.0" encoding="UTF-8"?>
2661
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2662
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2663
+ <modelVersion>4.0.0</modelVersion>
2664
+ <parent>
2665
+ <groupId>org.springframework.boot</groupId>
2666
+ <artifactId>spring-boot-starter-parent</artifactId>
2667
+ <version>2.4.12</version>
2668
+ <relativePath/> <!-- lookup parent from repository -->
2669
+ </parent>
2670
+ <groupId>com.example</groupId>
2671
+ <artifactId>spring-boot-24-to-25-example</artifactId>
2672
+ <version>0.0.1-SNAPSHOT</version>
2673
+ <name>spring-boot-2.4-to-2.5-example</name>
2674
+ <description>spring-boot-2.4-to-2.5-example</description>
2675
+ <properties>
2676
+ <java.version>11</java.version>
2677
+ </properties>
2678
+ </project>
2679
+ """ ;
2678
2680
2679
2681
BuildFile openRewriteMavenBuildFile = TestProjectContext .buildProjectContext ().withMavenRootBuildFileSource (pomXml ).build ().getBuildFile ();
2680
2682
@@ -2683,4 +2685,25 @@ void upgradeParentVersion() {
2683
2685
assertThat (openRewriteMavenBuildFile .getParentPomDeclaration ()).isNotEmpty ();
2684
2686
assertThat (openRewriteMavenBuildFile .getParentPomDeclaration ().get ().getVersion ()).isEqualTo ("2.5.6" );
2685
2687
}
2688
+
2689
+ @ GitHubIssue ("https://github.com/spring-projects-experimental/spring-boot-migrator/issues/55" )
2690
+ @ Test
2691
+ void parsingPomWithEmptyPropertiesSectionShouldSucceed () {
2692
+ String pomXml = """
2693
+ <?xml version="1.0" encoding="UTF-8"?>
2694
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2695
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2696
+ <modelVersion>4.0.0</modelVersion>
2697
+ <groupId>org.springframework.boot</groupId>
2698
+ <artifactId>spring-boot-starter-parent</artifactId>
2699
+ <version>2.4.12</version>
2700
+ <properties>
2701
+
2702
+ </properties>
2703
+ </project>
2704
+ """ ;
2705
+
2706
+ ProjectContext projectContext = TestProjectContext .buildProjectContext ().withMavenRootBuildFileSource (pomXml ).build ();
2707
+ assertThat (projectContext .getApplicationModules ().getRootModule ().getBuildFile ()).isNotNull ();
2708
+ }
2686
2709
}
0 commit comments