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()`
This commit is contained in:
@@ -238,7 +238,7 @@ subprojects { subproject ->
|
||||
def years = "$beginningYear-$now"
|
||||
def sourceCode = file.text
|
||||
sourceCode = sourceCode.replaceFirst(/20\d\d(-20\d\d)?/, years)
|
||||
file.write(sourceCode)
|
||||
file.text = sourceCode
|
||||
println "Copyright updated for file: $file"
|
||||
}
|
||||
break
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version=5.2.0.BUILD-SNAPSHOT
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
org.gradle.jvmargs=-Xmx1536m -Dfile.encoding=UTF-8
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFile
|
||||
|
||||
static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
static final String SAMPLE_CONTENT = "HelloWorld\n????";
|
||||
static final String SAMPLE_CONTENT = "HelloWorld\näöüß";
|
||||
|
||||
T transformer;
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFile
|
||||
|
||||
|
||||
@Before
|
||||
public void setUpCommonTestdata() throws Exception {
|
||||
public void setUpCommonTestData() throws Exception {
|
||||
sourceFile = File.createTempFile("anyFile", ".txt");
|
||||
sourceFile.deleteOnExit();
|
||||
FileCopyUtils.copy(SAMPLE_CONTENT.getBytes(DEFAULT_ENCODING),
|
||||
@@ -57,7 +57,7 @@ public abstract class AbstractFilePayloadTransformerTests<T extends AbstractFile
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDownCommonTestdata() {
|
||||
public void tearDownCommonTestData() {
|
||||
if (sourceFile.exists()) {
|
||||
sourceFile.delete();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class FileToStringTransformerTests extends
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.getPayload())
|
||||
.isInstanceOf(String.class)
|
||||
.isEqualTo(SAMPLE_CONTENT);
|
||||
.isNotEqualTo(SAMPLE_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user