Skip to content

Commit 405a05b

Browse files
authored
Fix initialise spring boot integration test
* Fix spring-projects-experimental#457 - Enhance initialize spring boot integration test - Add `application.properties` to multi-module project setup - Fix whitespaces and remove comments in testcode to match textual content with migrated code - Fix file path when comparing testcode and migrated code * Fix spring-projects-experimental#284 - Add version to spring-boot-maven-plugin
1 parent fc72f95 commit 405a05b

File tree

10 files changed

+22
-36
lines changed

10 files changed

+22
-36
lines changed

components/recipe-test-support/src/main/java/org/springframework/sbm/test/RecipeIntegrationTestSupport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ public void andApplyRecipeComparingWithExpected(String recipeName) {
133133
try (Stream<Path> walk = Files.walk(expectedProject)) {
134134
result = walk.filter(Files::isRegularFile)
135135
.map(f -> expectedProject.relativize(f))
136-
.filter(f -> f.toString().startsWith("target/"))
137136
.collect(Collectors.toList());
138137
}
139138

140139
result.stream()
141-
.forEach(r -> assertThat(r).hasSameTextualContentAs(migratedProject.resolve(r)));
140+
.forEach(r -> assertThat(expectedProject.resolve(r)).hasSameTextualContentAs(migratedProject.resolve(r)));
142141
} catch (Exception exception) {
143142
throw new RuntimeException(exception);
144143
}

components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/properties/actions/AddSpringBootApplicationPropertiesAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
package org.springframework.sbm.boot.properties.actions;
1717

1818
import lombok.AllArgsConstructor;
19+
import lombok.Getter;
1920
import lombok.NoArgsConstructor;
21+
import lombok.Setter;
22+
import lombok.experimental.SuperBuilder;
23+
2024
import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties;
2125
import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFilter;
2226
import org.springframework.sbm.build.api.Module;
@@ -27,6 +31,9 @@
2731

2832
@NoArgsConstructor
2933
@AllArgsConstructor
34+
@Getter
35+
@Setter
36+
@SuperBuilder
3037
public class AddSpringBootApplicationPropertiesAction extends AbstractAction {
3138

3239
public static final Path APPLICATION_PROPERTIES_PATH = Path.of("src/main/resources/application.properties");

components/sbm-support-boot/src/main/resources/recipes/initialize-spring-boot-migration.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
plugin:
9292
groupId: org.springframework.boot
9393
artifactId: spring-boot-maven-plugin
94+
version: 2.7.3
9495
condition:
9596
type: org.springframework.sbm.build.migration.conditions.MavenPluginDoesNotExist
9697
plugin:
@@ -108,11 +109,13 @@
108109
<plugin>
109110
<groupId>org.springframework.boot</groupId>
110111
<artifactId>spring-boot-maven-plugin</artifactId>
112+
<version>2.7.3</version>
111113
</plugin>
112114
</plugins>
113115
</build>
114116
115117
- type: org.springframework.sbm.boot.properties.actions.AddSpringBootApplicationPropertiesAction
118+
addDefaultPropertiesFileToTopModules: true
116119
condition:
117120
type: org.springframework.sbm.boot.properties.conditions.NoSpringBootApplicationPropertiesExists
118121
description: Create application.properties file.

components/sbm-support-boot/src/main/resources/templates/minimal-pom-xml.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
-->
88

99
<project xmlns="http://maven.apache.org/POM/4.0.0"
10-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
10+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1212
<groupId>${groupId}</groupId>
1313
<artifactId>${artifactId}</artifactId>
1414
<version>${version}</version>

components/sbm-support-boot/testcode/empty-project/expected/pom.xml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
~ Copyright 2021 - 2022 the original author or authors.
3+
~ Copyright 2021 VMware, Inc.
4+
~ SPDX-License-Identifier: Apache License 2.0
45
~
5-
~ Licensed under the Apache License, Version 2.0 (the "License");
6-
~ you may not use this file except in compliance with the License.
7-
~ You may obtain a copy of the License at
8-
~
9-
~ https://www.apache.org/licenses/LICENSE-2.0
10-
~
11-
~ Unless required by applicable law or agreed to in writing, software
12-
~ distributed under the License is distributed on an "AS IS" BASIS,
13-
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
~ See the License for the specific language governing permissions and
15-
~ limitations under the License.
6+
~ @author: fkrueger
167
-->
178

189
<project xmlns="http://maven.apache.org/POM/4.0.0"
@@ -32,7 +23,7 @@
3223
<dependency>
3324
<groupId>org.springframework.boot</groupId>
3425
<artifactId>spring-boot-dependencies</artifactId>
35-
<version>2.6.3</version>
26+
<version>2.7.3</version>
3627
<type>pom</type>
3728
<scope>import</scope>
3829
</dependency>
@@ -54,6 +45,7 @@
5445
<plugin>
5546
<groupId>org.springframework.boot</groupId>
5647
<artifactId>spring-boot-maven-plugin</artifactId>
48+
<version>2.7.3</version>
5749
</plugin>
5850
</plugins>
5951
</build>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.boot.migrator;
1+
package org.springframework.sbm;
22

33
import org.springframework.boot.SpringApplication;
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +0,0 @@
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-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.boot.migrator;
1+
package org.springframework.sbm;
22

33
import org.junit.jupiter.api.Test;
44
import org.springframework.boot.test.context.SpringBootTest;

components/sbm-support-boot/testcode/multi-module-simple/expected/module1/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
<plugin>
5555
<groupId>org.springframework.boot</groupId>
5656
<artifactId>spring-boot-maven-plugin</artifactId>
57+
<version>2.7.3</version>
5758
</plugin>
5859
</plugins>
5960
</build>

components/sbm-support-boot/testcode/multi-module-simple/expected/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<dependency>
3737
<groupId>org.springframework.boot</groupId>
3838
<artifactId>spring-boot-dependencies</artifactId>
39-
<version>2.6.3</version>
39+
<version>2.7.3</version>
4040
<type>pom</type>
4141
<scope>import</scope>
4242
</dependency>

0 commit comments

Comments
 (0)