Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2016-05-31 19:37:18 -0400
committerMatthias Sohn2016-12-19 17:44:32 -0500
commit71c94927d9b13928cc9648279063db6fd874cee2 (patch)
tree861d51ff1f703938f392219659e80fb9557df95b /org.eclipse.egit.core.test/src
parent39f20f98314562a7f457081d36c6d79ff6122665 (diff)
downloadegit-71c94927d9b13928cc9648279063db6fd874cee2.tar.gz
egit-71c94927d9b13928cc9648279063db6fd874cee2.tar.xz
egit-71c94927d9b13928cc9648279063db6fd874cee2.zip
[findbugs] Do not rely on default character encoding
Change-Id: I5025874ef929e574459975d5a5c3108c4e1e4d6d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/merge/VariantsTestCase.java7
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java2
2 files changed, 6 insertions, 3 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/merge/VariantsTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/merge/VariantsTestCase.java
index 2e2a9e7cb..dfb545bb8 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/merge/VariantsTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/internal/merge/VariantsTestCase.java
@@ -11,6 +11,7 @@ package org.eclipse.egit.core.internal.merge;
import static org.junit.Assert.assertEquals;
import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Scanner;
import org.eclipse.core.resources.IFile;
@@ -75,7 +76,8 @@ public abstract class VariantsTestCase extends GitTestCase {
IFile targetFile, String newContents, String commitMessage)
throws Exception {
targetFile.setContents(
- new ByteArrayInputStream(newContents.getBytes()),
+ new ByteArrayInputStream(
+ newContents.getBytes(StandardCharsets.UTF_8)),
IResource.FORCE, new NullProgressMonitor());
testRepository.addToIndex(targetFile);
return testRepository.commit(commitMessage);
@@ -89,7 +91,8 @@ public abstract class VariantsTestCase extends GitTestCase {
protected void assertContentEquals(IStorage storage, String expectedContents)
throws Exception {
- try (Scanner scanner = new Scanner(storage.getContents())) {
+ try (Scanner scanner = new Scanner(storage.getContents(),
+ StandardCharsets.UTF_8.name())) {
scanner.useDelimiter("\\A");
String fileContent = "";
if (scanner.hasNext()) {
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
index 4b3a623aa..564a6e3cb 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/models/ModelTestCase.java
@@ -80,7 +80,7 @@ public abstract class ModelTestCase extends GitTestCase {
protected void assertContentEquals(IFile file, String expectedContents)
throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(
- file.getContents()));
+ file.getContents(), file.getCharset()));
StringBuilder contentsBuilder = new StringBuilder();
String line = reader.readLine();
while (line != null) {

Back to the top