From 171f84a04117cfd02446f67565073a05128777a4 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Thu, 7 Dec 2017 10:23:38 +0900 Subject: 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 --- .../tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java | 4 ++-- .../tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'org.eclipse.jgit.lfs.test/tst') diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java index 4827d3d113..2ace2e3ce6 100644 --- a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java +++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LFSPointerTest.java @@ -43,11 +43,11 @@ package org.eclipse.jgit.lfs.lib; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.nio.charset.StandardCharsets; import org.eclipse.jgit.lfs.LfsPointer; import org.junit.Test; @@ -66,6 +66,6 @@ public class LFSPointerTest { baos.close(); assertEquals("version https://git-lfs.github.com/spec/v1\noid sha256:" + s + "\nsize 4\n", - baos.toString(StandardCharsets.UTF_8.name())); + baos.toString(UTF_8.name())); } } diff --git a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java index 31ab783e2a..d6dd3aa607 100644 --- a/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java +++ b/org.eclipse.jgit.lfs.test/tst/org/eclipse/jgit/lfs/lib/LongObjectIdTest.java @@ -43,6 +43,7 @@ package org.eclipse.jgit.lfs.lib; +import static java.nio.charset.StandardCharsets.US_ASCII; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -54,7 +55,6 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.ByteBuffer; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Locale; @@ -270,7 +270,7 @@ public class LongObjectIdTest { public void testCopyFromStringByte() { AnyLongObjectId id1 = LongObjectIdTestUtils.hash("test"); byte[] buf = new byte[64]; - Charset cs = StandardCharsets.US_ASCII; + Charset cs = US_ASCII; cs.encode(id1.name()).get(buf); AnyLongObjectId id2 = LongObjectId.fromString(buf, 0); assertEquals("objects should be equals", id1, id2); -- cgit v1.2.3