diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-07 08:29:51 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-07 09:04:36 +0900 |
commit | 0b4e781f7c2c46d0abe0437c63d9656bc1842cd0 (patch) | |
tree | 5d7e231e4da9a04ddd8950bd7220ac5b5065ee07 /org.eclipse.jgit.junit/src | |
parent | 2c5b721161e40cdcfa76548739117ea198ed8942 (diff) | |
download | jgit-0b4e781f7c2c46d0abe0437c63d9656bc1842cd0.tar.gz jgit-0b4e781f7c2c46d0abe0437c63d9656bc1842cd0.zip |
Use StandardCharsets.UTF_8 in tests
Replace hard-coded "UTF-8" string with the constant.
Change-Id: Ie812add2df28e984090563ec7c6e2c0366616424
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src')
3 files changed, 8 insertions, 4 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java index 4ba2606fb3..782d402f92 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java @@ -45,6 +45,8 @@ package org.eclipse.jgit.junit; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -250,7 +252,7 @@ public abstract class JGitTestUtil { public static void write(final File f, final String body) throws IOException { FileUtils.mkdirs(f.getParentFile(), true); - Writer w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8"); + Writer w = new OutputStreamWriter(new FileOutputStream(f), UTF_8); try { w.write(body); } finally { @@ -270,7 +272,7 @@ public abstract class JGitTestUtil { */ public static String read(final File file) throws IOException { final byte[] body = IO.readFully(file); - return new String(body, 0, body.length, "UTF-8"); + return new String(body, 0, body.length, UTF_8); } /** diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index 9dac11e5bc..568bc3b0e1 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -45,6 +45,7 @@ package org.eclipse.jgit.junit; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; @@ -351,7 +352,7 @@ public abstract class LocalDiskRepositoryTestCase { if (0 != (includedOptions & CONTENT)) { sb.append(", content:" + new String(repo.open(entry.getObjectId(), - Constants.OBJ_BLOB).getCachedBytes(), "UTF-8")); + Constants.OBJ_BLOB).getCachedBytes(), UTF_8)); } if (0 != (includedOptions & ASSUME_UNCHANGED)) sb.append(", assume-unchanged:" diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java index 8f44620b80..afc2c445cf 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java @@ -46,6 +46,7 @@ package org.eclipse.jgit.junit; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.File; @@ -198,7 +199,7 @@ public abstract class RepositoryTestCase extends LocalDiskRepositoryTestCase { protected static void checkFile(File f, final String checkData) throws IOException { try (Reader r = new InputStreamReader(new FileInputStream(f), - "UTF-8")) { + UTF_8)) { if (checkData.length() > 0) { char[] data = new char[checkData.length()]; assertEquals(data.length, r.read(data)); |