Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse2017-12-07 01:23:38 +0000
committerDavid Pursehouse2017-12-07 11:02:59 +0000
commit171f84a04117cfd02446f67565073a05128777a4 (patch)
treede60805128113634bc7d92cce426db59a0a96b52 /org.eclipse.jgit.test/exttst
parent5f94e4430800f6e1352733a3ff684e959341984d (diff)
downloadjgit-171f84a04117cfd02446f67565073a05128777a4.tar.gz
jgit-171f84a04117cfd02446f67565073a05128777a4.tar.xz
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')
-rw-r--r--org.eclipse.jgit.test/exttst/org/eclipse/jgit/ignore/CGitVsJGitRandomIgnorePatternTest.java11
-rw-r--r--org.eclipse.jgit.test/exttst/org/eclipse/jgit/patch/EGitPatchHistoryTest.java3
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');
}
}

Back to the top