Skip to content

Commit ce7563c

Browse files
authored
Fix tests related to Java 21
* Fix CombinedJavaFormatStepTest * Fix GoogleJavaFormatStepTest * Fix PalantirJavaFormatStepTest * Fix GoogleJavaFormatIntegrationTest * Fix MultiProjectTest * Fix MavenProvisionerTest * Fix PalantirJavaFormatTest * Fix SpecificFilesTest * Fix GoogleJavaFormatTest
1 parent a6495ed commit ce7563c

File tree

9 files changed

+27
-26
lines changed

9 files changed

+27
-26
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void integration() throws IOException {
3131
"spotless {",
3232
" java {",
3333
" target file('test.java')",
34-
" googleJavaFormat('1.10.0')",
34+
" googleJavaFormat('1.17.0')",
3535
" }",
3636
"}");
3737

@@ -41,7 +41,7 @@ void integration() throws IOException {
4141

4242
checkRunsThenUpToDate();
4343
replace("build.gradle",
44-
"googleJavaFormat('1.10.0')",
44+
"googleJavaFormat('1.17.0')",
4545
"googleJavaFormat()");
4646
checkRunsThenUpToDate();
4747
}
@@ -57,7 +57,7 @@ void integrationWithReorderImports() throws IOException {
5757
"spotless {",
5858
" java {",
5959
" target file('test.java')",
60-
" googleJavaFormat('1.12.0').aosp().reorderImports(true)",
60+
" googleJavaFormat('1.17.0').aosp().reorderImports(true)",
6161
" }",
6262
"}");
6363

@@ -67,7 +67,7 @@ void integrationWithReorderImports() throws IOException {
6767

6868
checkRunsThenUpToDate();
6969
replace("build.gradle",
70-
"googleJavaFormat('1.12.0')",
70+
"googleJavaFormat('1.17.0')",
7171
"googleJavaFormat()");
7272
checkRunsThenUpToDate();
7373
}
@@ -83,7 +83,7 @@ void integrationWithSkipJavadocFormatting() throws IOException {
8383
"spotless {",
8484
" java {",
8585
" target file('test.java')",
86-
" googleJavaFormat('1.12.0').skipJavadocFormatting()",
86+
" googleJavaFormat('1.17.0').skipJavadocFormatting()",
8787
" }",
8888
"}");
8989

@@ -93,7 +93,7 @@ void integrationWithSkipJavadocFormatting() throws IOException {
9393

9494
checkRunsThenUpToDate();
9595
replace("build.gradle",
96-
"googleJavaFormat('1.12.0')",
96+
"googleJavaFormat('1.17.0')",
9797
"googleJavaFormat()");
9898
checkRunsThenUpToDate();
9999
}

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/MultiProjectTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void createSubproject(String name) throws IOException {
4747
"spotless {",
4848
" java {",
4949
" target file('test.java')",
50-
" googleJavaFormat('1.16.0')",
50+
" googleJavaFormat('1.17.0')",
5151
" }",
5252
"}");
5353
setFile(name + "/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
@@ -71,7 +71,7 @@ public void hasRootSpotless() throws IOException {
7171
"spotless {",
7272
" java {",
7373
" target file('test.java')",
74-
" googleJavaFormat('1.16.0')",
74+
" googleJavaFormat('1.17.0')",
7575
" }",
7676
"}");
7777
setFile("test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
@@ -88,7 +88,7 @@ public void predeclaredFails() throws IOException {
8888
"spotless { predeclareDeps() }");
8989
createNSubprojects();
9090
Assertions.assertThat(gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput())
91-
.contains("Add a step with [com.google.googlejavaformat:google-java-format:1.16.0] into the `spotlessPredeclare` block in the root project.");
91+
.contains("Add a step with [com.google.googlejavaformat:google-java-format:1.17.0] into the `spotlessPredeclare` block in the root project.");
9292
}
9393

9494
@Test
@@ -100,7 +100,7 @@ public void predeclaredSucceeds() throws IOException {
100100
"repositories { mavenCentral() }",
101101
"spotless { predeclareDeps() }",
102102
"spotlessPredeclare {",
103-
" java { googleJavaFormat('1.16.0') }",
103+
" java { googleJavaFormat('1.17.0') }",
104104
"}");
105105
createNSubprojects();
106106
gradleRunner().withArguments("spotlessApply").build();
@@ -115,7 +115,7 @@ public void predeclaredFromBuildscriptSucceeds() throws IOException {
115115
"repositories { mavenCentral() }",
116116
"spotless { predeclareDepsFromBuildscript() }",
117117
"spotlessPredeclare {",
118-
" java { googleJavaFormat('1.16.0') }",
118+
" java { googleJavaFormat('1.17.0') }",
119119
"}");
120120
createNSubprojects();
121121
gradleRunner().withArguments("spotlessApply").build();
@@ -129,7 +129,7 @@ public void predeclaredOrdering() throws IOException {
129129
"}",
130130
"repositories { mavenCentral() }",
131131
"spotlessPredeclare {",
132-
" java { googleJavaFormat('1.16.0') }",
132+
" java { googleJavaFormat('1.17.0') }",
133133
"}",
134134
"spotless { predeclareDepsFromBuildscript() }");
135135
createNSubprojects();
@@ -145,7 +145,7 @@ public void predeclaredUndeclared() throws IOException {
145145
"}",
146146
"repositories { mavenCentral() }",
147147
"spotlessPredeclare {",
148-
" java { googleJavaFormat('1.16.0') }",
148+
" java { googleJavaFormat('1.17.0') }",
149149
"}");
150150
createNSubprojects();
151151
Assertions.assertThat(gradleRunner().withArguments("spotlessApply").buildAndFail().getOutput())

plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenProvisionerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void testMultipleDependenciesExcludingTransitives() throws Exception {
3333
void testSingleDependencyIncludingTransitives() throws Exception {
3434
writePomWithJavaSteps(
3535
"<googleJavaFormat>",
36-
" <version>1.10.0</version>",
3736
"</googleJavaFormat>");
3837
assertResolveDependenciesWorks();
3938
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/SpecificFilesTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ private void integration(String patterns, boolean firstFormatted, boolean second
5858
" <include>src/**/java/**/*.java</include>",
5959
"</includes>",
6060
"<googleJavaFormat>",
61-
" <version>1.10.0</version>",
6261
"</googleJavaFormat>");
6362

6463
setFile(testFile(1)).toResource(fixture(false));

plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GoogleJavaFormatTest extends MavenIntegrationHarness {
2424
void specificVersionDefaultStyle() throws Exception {
2525
writePomWithJavaSteps(
2626
"<googleJavaFormat>",
27-
" <version>1.10.0</version>",
27+
" <version>1.17.0</version>",
2828
"</googleJavaFormat>");
2929

3030
runTest("java/googlejavaformat/JavaCodeFormatted.test");
@@ -34,7 +34,7 @@ void specificVersionDefaultStyle() throws Exception {
3434
void specificVersionSpecificStyle() throws Exception {
3535
writePomWithJavaSteps(
3636
"<googleJavaFormat>",
37-
" <version>1.10.0</version>",
37+
" <version>1.17.0</version>",
3838
" <style>AOSP</style>",
3939
"</googleJavaFormat>");
4040

@@ -45,7 +45,7 @@ void specificVersionSpecificStyle() throws Exception {
4545
void specificVersionReflowLongStrings() throws Exception {
4646
writePomWithJavaSteps(
4747
"<googleJavaFormat>",
48-
" <version>1.10.0</version>",
48+
" <version>1.17.0</version>",
4949
" <reflowLongStrings>true</reflowLongStrings>",
5050
"</googleJavaFormat>");
5151

@@ -56,7 +56,7 @@ void specificVersionReflowLongStrings() throws Exception {
5656
void specificVersionReorderImports() throws Exception {
5757
writePomWithJavaSteps(
5858
"<googleJavaFormat>",
59-
" <version>1.12.0</version>",
59+
" <version>1.17.0</version>",
6060
" <style>AOSP</style>",
6161
" <reorderImports>true</reorderImports>",
6262
"</googleJavaFormat>");
@@ -68,7 +68,7 @@ void specificVersionReorderImports() throws Exception {
6868
void specificVersionSkipJavadocFormatting() throws Exception {
6969
writePomWithJavaSteps(
7070
"<googleJavaFormat>",
71-
" <version>1.12.0</version>",
71+
" <version>1.17.0</version>",
7272
" <formatJavadoc>false</formatJavadoc>",
7373
"</googleJavaFormat>");
7474

plugin-maven/src/test/java/com/diffplug/spotless/maven/java/PalantirJavaFormatTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void specificVersionDefaultStyle() throws Exception {
3434
void specificJava11Version2() throws Exception {
3535
writePomWithJavaSteps(
3636
"<palantirJavaFormat>",
37-
" <version>2.10.0</version>",
37+
" <version>2.38.0</version>",
3838
"</palantirJavaFormat>");
3939

4040
runTest("java/palantirjavaformat/JavaCodeFormatted.test");

testlib/src/test/java/com/diffplug/spotless/combined/CombinedJavaFormatStepTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CombinedJavaFormatStepTest extends ResourceHarness {
3434

3535
@Test
3636
void checkIssue1679() {
37-
FormatterStep gjf = GoogleJavaFormatStep.create("1.15.0", "AOSP", mavenCentral());
37+
FormatterStep gjf = GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultVersion(), "AOSP", mavenCentral());
3838
FormatterStep indentWithSpaces = IndentStep.Type.SPACE.create();
3939
FormatterStep importOrder = ImportOrderStep.forJava().createFrom();
4040
FormatterStep removeUnused = RemoveUnusedImportsStep.create(mavenCentral());

testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static org.junit.jupiter.api.condition.JRE.JAVA_13;
1919
import static org.junit.jupiter.api.condition.JRE.JAVA_15;
2020
import static org.junit.jupiter.api.condition.JRE.JAVA_16;
21+
import static org.junit.jupiter.api.condition.JRE.JAVA_20;
2122

2223
import org.junit.jupiter.api.Test;
2324
import org.junit.jupiter.api.condition.EnabledForJreRange;
@@ -52,7 +53,7 @@ void behavior18() throws Exception {
5253

5354
@Test
5455
void behavior() throws Exception {
55-
FormatterStep step = GoogleJavaFormatStep.create("1.10.0", TestProvisioner.mavenCentral());
56+
FormatterStep step = GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultVersion(), TestProvisioner.mavenCentral());
5657
StepHarness.forStep(step)
5758
.testResource("java/googlejavaformat/JavaCodeUnformatted.test", "java/googlejavaformat/JavaCodeFormatted.test")
5859
.testResource("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test", "java/googlejavaformat/JavaCodeWithLicenseFormatted.test")
@@ -79,7 +80,7 @@ void versionBelowOneDotTenIsNotAllowed() throws Exception {
7980

8081
@Test
8182
void behaviorWithAospStyle() throws Exception {
82-
FormatterStep step = GoogleJavaFormatStep.create("1.10.0", "AOSP", TestProvisioner.mavenCentral());
83+
FormatterStep step = GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultVersion(), "AOSP", TestProvisioner.mavenCentral());
8384
StepHarness.forStep(step)
8485
.testResource("java/googlejavaformat/JavaCodeUnformatted.test", "java/googlejavaformat/JavaCodeFormattedAOSP.test")
8586
.testResource("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test", "java/googlejavaformat/JavaCodeWithLicenseFormattedAOSP.test")
@@ -111,7 +112,7 @@ void behaviorWithSkipFormatJavadoc() throws Exception {
111112

112113
@Test
113114
void behaviorWithCustomGroupArtifact() throws Exception {
114-
FormatterStep step = GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultGroupArtifact(), "1.10.0", GoogleJavaFormatStep.defaultStyle(), TestProvisioner.mavenCentral(), false);
115+
FormatterStep step = GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultGroupArtifact(), GoogleJavaFormatStep.defaultVersion(), GoogleJavaFormatStep.defaultStyle(), TestProvisioner.mavenCentral(), false);
115116
StepHarness.forStep(step)
116117
.testResource("java/googlejavaformat/JavaCodeUnformatted.test", "java/googlejavaformat/JavaCodeFormatted.test")
117118
.testResource("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test", "java/googlejavaformat/JavaCodeWithLicenseFormatted.test")
@@ -133,6 +134,7 @@ void behaviorWithReorderImports() throws Exception {
133134
}
134135

135136
@Test
137+
@EnabledForJreRange(max = JAVA_20)
136138
void equality() throws Exception {
137139
new SerializableEqualityTester() {
138140
String version = "1.10.0";
@@ -163,6 +165,7 @@ protected FormatterStep create() {
163165
}
164166

165167
@Test
168+
@EnabledForJreRange(max = JAVA_20)
166169
void equalityGroupArtifact() throws Exception {
167170
new SerializableEqualityTester() {
168171
String groupArtifact = GoogleJavaFormatStep.defaultGroupArtifact();

testlib/src/test/java/com/diffplug/spotless/java/PalantirJavaFormatStepTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void jvm13Features() throws Exception {
3838

3939
@Test
4040
void behavior2() throws Exception {
41-
FormatterStep step = PalantirJavaFormatStep.create("2.28.0", TestProvisioner.mavenCentral());
41+
FormatterStep step = PalantirJavaFormatStep.create(TestProvisioner.mavenCentral());
4242
StepHarness.forStep(step)
4343
.testResource("java/palantirjavaformat/JavaCodeUnformatted.test", "java/palantirjavaformat/JavaCodeFormatted.test")
4444
.testResource("java/palantirjavaformat/JavaCodeWithLicenseUnformatted.test", "java/palantirjavaformat/JavaCodeWithLicenseFormatted.test")

0 commit comments

Comments
 (0)