Replace Charset.defaultCharset() with StandardCharsets.UTF_8 in tests

Resolves #4417

(cherry picked from commit 14b6c66543)
This commit is contained in:
Shaoqiang Lu
2023-07-16 12:13:16 +08:00
committed by Mahmoud Ben Hassine
parent 7812c00c6c
commit 1b08c26d3f
3 changed files with 7 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 the original author or authors.
* Copyright 2016-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.junit.jupiter.api.Test;
@@ -266,7 +266,7 @@ class FlatFileItemWriterBuilderTests {
WritableResource output = new FileSystemResource(File.createTempFile("foo", "txt"));
String encoding = Charset.defaultCharset().name();
String encoding = StandardCharsets.UTF_8.name();
FlatFileItemWriter<Foo> writer = new FlatFileItemWriterBuilder<Foo>().name("foo")
.resource(output)

View File

@@ -19,7 +19,6 @@ package org.springframework.batch.item.json;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -334,7 +333,7 @@ abstract class JsonFileItemWriterFunctionalTests {
}
private String getContent(File file) throws IOException {
return Files.readString(file.toPath(), Charset.defaultCharset());
return Files.readString(file.toPath());
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2018-2022 the original author or authors.
* Copyright 2018-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
package org.springframework.batch.item.json.builder;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import org.junit.jupiter.api.BeforeEach;
@@ -112,7 +112,7 @@ class JsonFileItemWriterBuilderTests {
boolean transactional = true;
boolean shouldDeleteIfEmpty = true;
boolean shouldDeleteIfExists = true;
String encoding = Charset.defaultCharset().name();
String encoding = StandardCharsets.UTF_8.name();
String lineSeparator = "#";
FlatFileHeaderCallback headerCallback = Mockito.mock();
FlatFileFooterCallback footerCallback = Mockito.mock();