Skip to content

Commit 872302d

Browse files
committed
Add -Dfile.encoding=UTF-8 into gradle.properties
To avoid wrong encoding during reading and writing files by the `updateCopyrights` Gradle task, it is better to have an explicit `-Dfile.encoding=UTF-8` before starting JVM. * Fix `AbstractFilePayloadTransformerTests` for non-standard symbols in the test data * fix broken test `FileToStringTransformerTests.transform_withWrongEncoding_notMatching()`
1 parent d21e8f0 commit 872302d

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ subprojects { subproject ->
238238
def years = "$beginningYear-$now"
239239
def sourceCode = file.text
240240
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
241-
file.write(sourceCode)
241+
file.text = sourceCode
242242
println "Copyright updated for file: $file"
243243
}
244244
break

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
version=5.2.0.BUILD-SNAPSHOT
2-
org.gradle.jvmargs=-Xmx1536m
2+
org.gradle.jvmargs=-Xmx1536m -Dfile.encoding=UTF-8

spring-integration-file/src/test/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFile
3838

3939
static final String DEFAULT_ENCODING = "UTF-8";
4040

41-
static final String SAMPLE_CONTENT = "HelloWorld\n????";
41+
static final String SAMPLE_CONTENT = "HelloWorld\näöüß";
4242

4343
T transformer;
4444

@@ -48,7 +48,7 @@ public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFile
4848

4949

5050
@Before
51-
public void setUpCommonTestdata() throws Exception {
51+
public void setUpCommonTestData() throws Exception {
5252
sourceFile = File.createTempFile("anyFile", ".txt");
5353
sourceFile.deleteOnExit();
5454
FileCopyUtils.copy(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING),
@@ -57,7 +57,7 @@ public void setUpCommonTestdata() throws Exception {
5757
}
5858

5959
@After
60-
public void tearDownCommonTestdata() {
60+
public void tearDownCommonTestData() {
6161
if (sourceFile.exists()) {
6262
sourceFile.delete();
6363
}

spring-integration-file/src/test/java/org/springframework/integration/file/transformer/FileToStringTransformerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void transform_withWrongEncoding_notMatching() {
5252
assertThat(result).isNotNull();
5353
assertThat(result.getPayload())
5454
.isInstanceOf(String.class)
55-
.isEqualTo(SAMPLE_CONTENT);
55+
.isNotEqualTo(SAMPLE_CONTENT);
5656
}
5757

5858
}

0 commit comments

Comments
 (0)