diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-07 10:23:38 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2017-12-07 20:02:59 +0900 |
commit | 171f84a04117cfd02446f67565073a05128777a4 (patch) | |
tree | de60805128113634bc7d92cce426db59a0a96b52 /org.eclipse.jgit.test/exttst/org/eclipse/jgit | |
parent | 5f94e4430800f6e1352733a3ff684e959341984d (diff) | |
download | jgit-171f84a04117cfd02446f67565073a05128777a4.tar.gz jgit-171f84a04117cfd02446f67565073a05128777a4.zip |
Use constants from StandardCharsets instead of hard-coded strings
Instead of hard-coding the charset strings "US-ASCII", "UTF-8", and
"ISO-8859-1", use the corresponding constants from StandardCharsets.
UnsupportedEncodingException is not thrown when the StandardCharset
constants are used, so remove the now redundant handling.
Because the encoding names are no longer hard-coded strings, also
remove redundant $NON-NLS warning suppressions.
Also replace existing usages of the constants with static imports.
Change-Id: I0a4510d3d992db5e277f009a41434276f95bda4e
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/exttst/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java | 11 | ||||
-rw-r--r-- | org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java | 3 |
2 files changed, 7 insertions, 7 deletions
diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java index e5a80aeefa..03b34acc05 100644 --- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java +++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java @@ -42,13 +42,14 @@ */ package org.eclipse.jgit.ignore; +import static java.nio.charset.StandardCharsets.UTF_8; + import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.StandardOpenOption; import java.util.Arrays; @@ -153,13 +154,11 @@ public class CGitVsJGitRandomIgnorePatternTest { private String pattern; - public CGitIgnoreRule(File gitDir, String pattern) - throws UnsupportedEncodingException, IOException { + public CGitIgnoreRule(File gitDir, String pattern) throws IOException { this.gitDir = gitDir; this.pattern = pattern; Files.write(FileUtils.toPath(new File(gitDir, ".gitignore")), - (pattern + "\n").getBytes("UTF-8"), - StandardOpenOption.CREATE, + (pattern + "\n").getBytes(UTF_8), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE); } @@ -189,7 +188,7 @@ public class CGitVsJGitRandomIgnorePatternTest { Process proc = Runtime.getRuntime().exec(command, new String[0], gitDir); OutputStream out = proc.getOutputStream(); - out.write((path + "\n").getBytes("UTF-8")); + out.write((path + "\n").getBytes(UTF_8)); out.flush(); out.close(); return proc; diff --git a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java index 7c0ea44c35..586505cfe8 100644 --- a/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java +++ b/org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.patch; +import static java.nio.charset.StandardCharsets.ISO_8859_1; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -218,7 +219,7 @@ public class EGitPatchHistoryTest { commitId = line.substring("commit ".length()); buf = new TemporaryBuffer.LocalFile(null); } else if (buf != null) { - buf.write(line.getBytes("ISO-8859-1")); + buf.write(line.getBytes(ISO_8859_1)); buf.write('\n'); } } |