diff options
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
27 files changed, 197 insertions, 197 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java index 1e3a39aad8..bb303cc411 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/EolStreamTypeUtilTest.java @@ -42,7 +42,7 @@ package org.eclipse.jgit.api; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_CRLF; import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.AUTO_LF; import static org.eclipse.jgit.lib.CoreConfig.EolStreamType.DIRECT; @@ -150,8 +150,8 @@ public class EolStreamTypeUtilTest { EolStreamType streamTypeWithBinaryCheck, String output, String expectedConversion) throws Exception { ByteArrayOutputStream b; - byte[] outputBytes = output.getBytes(UTF_8); - byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8); + byte[] outputBytes = output.getBytes(CHARSET); + byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET); // test using output text and assuming it was declared TEXT b = new ByteArrayOutputStream(); @@ -277,8 +277,8 @@ public class EolStreamTypeUtilTest { private void testCheckin(EolStreamType streamTypeText, EolStreamType streamTypeWithBinaryCheck, String input, String expectedConversion) throws Exception { - byte[] inputBytes = input.getBytes(UTF_8); - byte[] expectedConversionBytes = expectedConversion.getBytes(UTF_8); + byte[] inputBytes = input.getBytes(CHARSET); + byte[] expectedConversionBytes = expectedConversion.getBytes(CHARSET); // test using input text and assuming it was declared TEXT try (InputStream in = EolStreamTypeUtil.wrapInputStream( diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java index 6e06e9545a..e234aa339c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.api; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import java.util.List; @@ -88,7 +88,7 @@ public class NotesCommandTest extends RepositoryTestCase { git.notesAdd().setObjectId(commit2).setMessage("data").call(); Note note = git.notesShow().setObjectId(commit2).call(); String content = new String(db.open(note.getData()).getCachedBytes(), - UTF_8); + CHARSET); assertEquals(content, "data"); git.notesRemove().setObjectId(commit2).call(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java index 9461c42500..0b0e3bf3ea 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.api; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -592,7 +592,7 @@ public class PullCommandTest extends RepositoryTestCase { private static void writeToFile(File actFile, String string) throws IOException { try (FileOutputStream fos = new FileOutputStream(actFile)) { - fos.write(string.getBytes(UTF_8)); + fos.write(string.getBytes(CHARSET)); } } @@ -606,7 +606,7 @@ public class PullCommandTest extends RepositoryTestCase { bos.write(buffer, 0, read); read = fis.read(buffer); } - String content = new String(bos.toByteArray(), UTF_8); + String content = new String(bos.toByteArray(), CHARSET); assertEquals(string, content); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java index 913b4ac434..b349c66cab 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.api; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -396,7 +396,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase { private static void writeToFile(File actFile, String string) throws IOException { try (FileOutputStream fos = new FileOutputStream(actFile)) { - fos.write(string.getBytes(UTF_8)); + fos.write(string.getBytes(CHARSET)); } } @@ -410,7 +410,7 @@ public class PullCommandWithRebaseTest extends RepositoryTestCase { bos.write(buffer, 0, read); read = fis.read(buffer); } - String content = new String(bos.toByteArray(), UTF_8); + String content = new String(bos.toByteArray(), CHARSET); assertEquals(string, content); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index 2bf91aeed8..96e7091ae1 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.api; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; @@ -1464,7 +1464,7 @@ public class RebaseCommandTest extends RepositoryTestCase { assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]); PersonIdent parsedIdent = git.rebase().parseAuthor( - convertedAuthor.getBytes(UTF_8)); + convertedAuthor.getBytes(CHARSET)); assertEquals(ident.getName(), parsedIdent.getName()); assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress()); // this is rounded to the last second @@ -1481,7 +1481,7 @@ public class RebaseCommandTest extends RepositoryTestCase { assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]); parsedIdent = git.rebase().parseAuthor( - convertedAuthor.getBytes(UTF_8)); + convertedAuthor.getBytes(CHARSET)); assertEquals(ident.getName(), parsedIdent.getName()); assertEquals(ident.getEmailAddress(), parsedIdent.getEmailAddress()); assertEquals(123456789000L, parsedIdent.getWhen().getTime()); @@ -2104,7 +2104,7 @@ public class RebaseCommandTest extends RepositoryTestCase { int count = 0; File todoFile = getTodoFile(); try (BufferedReader br = new BufferedReader(new InputStreamReader( - new FileInputStream(todoFile), UTF_8))) { + new FileInputStream(todoFile), CHARSET))) { String line = br.readLine(); while (line != null) { int firstBlank = line.indexOf(' '); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java index 0f13a68b25..32f34213ec 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/AbstractDiffTestCase.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.diff; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -240,6 +240,6 @@ public abstract class AbstractDiffTestCase { r.append(text.charAt(i)); r.append('\n'); } - return new RawText(r.toString().getBytes(UTF_8)); + return new RawText(r.toString().getBytes(CHARSET)); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java index 6ad59b9e56..69e40777cc 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/RawTextTest.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.diff; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -136,8 +136,8 @@ public class RawTextTest { e = c.reduceCommonStartEnd(t("abQxy"), t("abRxy"), e); assertEquals(new Edit(2, 3, 2, 3), e); - RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(UTF_8)); - RawText b = new RawText("p\na b \nR\n c d \n".getBytes(UTF_8)); + RawText a = new RawText("p\na b\nQ\nc d\n".getBytes(CHARSET)); + RawText b = new RawText("p\na b \nR\n c d \n".getBytes(CHARSET)); e = new Edit(0, 4, 0, 4); e = RawTextComparator.WS_IGNORE_ALL.reduceCommonStartEnd(a, b, e); assertEquals(new Edit(2, 3, 2, 3), e); @@ -149,14 +149,14 @@ public class RawTextTest { RawText b; Edit e; - a = new RawText("R\n y\n".getBytes(UTF_8)); - b = new RawText("S\n\n y\n".getBytes(UTF_8)); + a = new RawText("R\n y\n".getBytes(CHARSET)); + b = new RawText("S\n\n y\n".getBytes(CHARSET)); e = new Edit(0, 2, 0, 3); e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e); assertEquals(new Edit(0, 1, 0, 2), e); - a = new RawText("S\n\n y\n".getBytes(UTF_8)); - b = new RawText("R\n y\n".getBytes(UTF_8)); + a = new RawText("S\n\n y\n".getBytes(CHARSET)); + b = new RawText("R\n y\n".getBytes(CHARSET)); e = new Edit(0, 3, 0, 2); e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e); assertEquals(new Edit(0, 2, 0, 1), e); @@ -167,8 +167,8 @@ public class RawTextTest { RawText a; RawText b; Edit e; - a = new RawText("start".getBytes(UTF_8)); - b = new RawText("start of line".getBytes(UTF_8)); + a = new RawText("start".getBytes(CHARSET)); + b = new RawText("start of line".getBytes(CHARSET)); e = new Edit(0, 1, 0, 1); e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e); assertEquals(new Edit(0, 1, 0, 1), e); @@ -179,8 +179,8 @@ public class RawTextTest { RawText a; RawText b; Edit e; - a = new RawText("start".getBytes(UTF_8)); - b = new RawText("start of\nlastline".getBytes(UTF_8)); + a = new RawText("start".getBytes(CHARSET)); + b = new RawText("start of\nlastline".getBytes(CHARSET)); e = new Edit(0, 1, 0, 2); e = RawTextComparator.DEFAULT.reduceCommonStartEnd(a, b, e); assertEquals(new Edit(0, 1, 0, 2), e); @@ -239,6 +239,6 @@ public class RawTextTest { r.append(text.charAt(i)); r.append('\n'); } - return new RawText(r.toString().getBytes(UTF_8)); + return new RawText(r.toString().getBytes(CHARSET)); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java index f168e83284..51a6f8121c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/diff/SimilarityIndexTest.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.diff; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -82,7 +82,7 @@ public class SimilarityIndexTest { + "A\n" // + "B\n" // + "B\n" // - + "B\n").getBytes(UTF_8); + + "B\n").getBytes(CHARSET); SimilarityIndex si = new SimilarityIndex(); si.hash(new ByteArrayInputStream(in), in.length, false); assertEquals(2, si.size()); @@ -130,12 +130,12 @@ public class SimilarityIndexTest { + "D\r\n" // + "B\r\n"; SimilarityIndex src = new SimilarityIndex(); - byte[] bytes1 = text.getBytes(UTF_8); + byte[] bytes1 = text.getBytes(CHARSET); src.hash(new ByteArrayInputStream(bytes1), bytes1.length, true); src.sort(); SimilarityIndex dst = new SimilarityIndex(); - byte[] bytes2 = text.replace("\r", "").getBytes(UTF_8); + byte[] bytes2 = text.replace("\r", "").getBytes(CHARSET); dst.hash(new ByteArrayInputStream(bytes2), bytes2.length, true); dst.sort(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java index dec17623fc..80d4329858 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.dircache; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.junit.Assert.assertEquals; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -236,7 +236,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { private static Map<String, CGitIndexRecord> readLsFiles() throws Exception { final LinkedHashMap<String, CGitIndexRecord> r = new LinkedHashMap<>(); try (BufferedReader br = new BufferedReader(new InputStreamReader( - new FileInputStream(pathOf("gitgit.lsfiles")), UTF_8))) { + new FileInputStream(pathOf("gitgit.lsfiles")), CHARSET))) { String line; while ((line = br.readLine()) != null) { final CGitIndexRecord cr = new CGitIndexRecord(line); @@ -249,7 +249,7 @@ public class DirCacheCGitCompatabilityTest extends LocalDiskRepositoryTestCase { private static Map<String, CGitLsTreeRecord> readLsTree() throws Exception { final LinkedHashMap<String, CGitLsTreeRecord> r = new LinkedHashMap<>(); try (BufferedReader br = new BufferedReader(new InputStreamReader( - new FileInputStream(pathOf("gitgit.lstree")), UTF_8))) { + new FileInputStream(pathOf("gitgit.lstree")), CHARSET))) { String line; while ((line = br.readLine()) != null) { final CGitLsTreeRecord cr = new CGitLsTreeRecord(line); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java index c9673a6882..69a48cc4b5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/ManifestParserTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.gitrepo; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -82,7 +82,7 @@ public class ManifestParserTest { ManifestParser parser = new ManifestParser( null, null, "master", baseUrl, null, null); - parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8))); + parser.read(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET))); // Unfiltered projects should have them all. results.clear(); results.add("foo"); @@ -136,7 +136,7 @@ public class ManifestParserTest { baseUrl, null, null); try { parser.read(new ByteArrayInputStream( - xmlContent.toString().getBytes(UTF_8))); + xmlContent.toString().getBytes(CHARSET))); fail("ManifestParser did not throw exception for missing fetch"); } catch (IOException e) { assertTrue(e.getCause() instanceof SAXException); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index 2253a0421f..6f6dd5f46f 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.gitrepo; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; @@ -214,7 +214,7 @@ public class RepoCommandTest extends RepositoryTestCase { RevCommit commit = cmd .setInputStream(new ByteArrayInputStream( - xmlContent.toString().getBytes(UTF_8))) + xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(repos) .setURI("platform/") .setTargetURI("platform/superproject") @@ -225,7 +225,7 @@ public class RepoCommandTest extends RepositoryTestCase { String firstIdStr = commit.getId().name() + ":" + ".gitmodules"; commit = new RepoCommand(dest) .setInputStream(new ByteArrayInputStream( - xmlContent.toString().getBytes(UTF_8))) + xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(repos) .setURI("platform/") .setTargetURI("platform/superproject") @@ -266,7 +266,7 @@ public class RepoCommandTest extends RepositoryTestCase { repos.put("platform/base", child); RevCommit commit = cmd - .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8))) + .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(repos) .setURI("platform/") .setTargetURI("platform/superproject") @@ -308,7 +308,7 @@ public class RepoCommandTest extends RepositoryTestCase { RevCommit commit = new RepoCommand(dest) .setInputStream(new ByteArrayInputStream( - xmlContent.toString().getBytes(UTF_8))) + xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(new IndexedRepos()) .setURI("platform/") .setTargetURI("platform/superproject") @@ -358,7 +358,7 @@ public class RepoCommandTest extends RepositoryTestCase { repos.put("plugins/cookbook", child); RevCommit commit = cmd - .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8))) + .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(repos) .setURI("") .setTargetURI("gerrit") @@ -412,7 +412,7 @@ public class RepoCommandTest extends RepositoryTestCase { repos.put(repoUrl, child); RevCommit commit = cmd - .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8))) + .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(repos) .setURI(baseUrl) .setTargetURI("gerrit") @@ -469,7 +469,7 @@ public class RepoCommandTest extends RepositoryTestCase { repos.put(repoUrl, child); RevCommit commit = cmd - .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(UTF_8))) + .setInputStream(new ByteArrayInputStream(xmlContent.toString().getBytes(CHARSET))) .setRemoteReader(repos) .setURI(baseUrl) .setTargetURI(abs + "/superproject") diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java index 17c7ef1392..80595feff5 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/ignore/IgnoreNodeTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.ignore; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -765,6 +765,6 @@ public class IgnoreNodeTest extends RepositoryTestCase { for (String line : rules) { data.append(line + "\n"); } - return new ByteArrayInputStream(data.toString().getBytes(UTF_8)); + return new ByteArrayInputStream(data.toString().getBytes(CHARSET)); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java index d5d3857ca4..26c11c7eb7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/indexdiff/IndexDiffWithSymlinkTest.java @@ -41,7 +41,7 @@ */ package org.eclipse.jgit.indexdiff; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -128,7 +128,7 @@ public class IndexDiffWithSymlinkTest extends LocalDiskRepositoryTestCase { File restoreScript = new File(testDir, name + ".sh"); try (OutputStream out = new BufferedOutputStream( new FileOutputStream(restoreScript)); - Writer writer = new OutputStreamWriter(out, UTF_8)) { + Writer writer = new OutputStreamWriter(out, CHARSET)) { writer.write("echo `which git` 1>&2\n"); writer.write("echo `git --version` 1>&2\n"); writer.write("git init " + name + " && \\\n"); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java index 52861ecd53..592d0c8671 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/RefUpdateTest.java @@ -45,7 +45,7 @@ package org.eclipse.jgit.internal.storage.file; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -252,7 +252,7 @@ public class RefUpdateTest extends SampleDataRepositoryTestCase { ObjectId blobId; try (ObjectInserter ins = bareRepo.newObjectInserter()) { - blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(UTF_8)); + blobId = ins.insert(Constants.OBJ_BLOB, "contents".getBytes(CHARSET)); ins.flush(); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java index d7505af4cf..b5d6485604 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/T0003_BasicTest.java @@ -47,7 +47,7 @@ package org.eclipse.jgit.internal.storage.file; import static java.nio.charset.StandardCharsets.ISO_8859_1; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -522,7 +522,7 @@ public class T0003_BasicTest extends SampleDataRepositoryTestCase { 4294967295000L, 60)); commit.setCommitter(new PersonIdent("Joe Hacker", "joe2@example.com", 4294967295000L, 60)); - commit.setEncoding(UTF_8); + commit.setEncoding(CHARSET); commit.setMessage("\u00dcbergeeks"); ObjectId cid = insertCommit(commit); assertEquals("4680908112778718f37e686cbebcc912730b3154", cid.name()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java index b7027f3272..965899e7a0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/junit/TestRepositoryTest.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.junit; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -418,6 +418,6 @@ public class TestRepositoryTest { RevObject obj = tr.get(rw.parseTree(treeish), path); assertSame(RevBlob.class, obj.getClass()); ObjectLoader loader = rw.getObjectReader().open(obj); - return new String(loader.getCachedBytes(), UTF_8); + return new String(loader.getCachedBytes(), CHARSET); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java index f1c62d4be2..22c66cec16 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ObjectCheckerTest.java @@ -45,7 +45,7 @@ package org.eclipse.jgit.lib; import static java.lang.Integer.valueOf; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.junit.JGitTestUtil.concat; import static org.eclipse.jgit.lib.Constants.OBJECT_ID_LENGTH; import static org.eclipse.jgit.lib.Constants.OBJ_BAD; @@ -1454,7 +1454,7 @@ public class ObjectCheckerTest { StringBuilder b = new StringBuilder(); entry(b, "100644 A"); entry(b, "100644 a"); - byte[] data = b.toString().getBytes(UTF_8); + byte[] data = b.toString().getBytes(CHARSET); checker.setSafeForWindows(true); assertCorrupt("duplicate entry names", OBJ_TREE, data); assertSkipListAccepts(OBJ_TREE, data); @@ -1468,7 +1468,7 @@ public class ObjectCheckerTest { StringBuilder b = new StringBuilder(); entry(b, "100644 A"); entry(b, "100644 a"); - byte[] data = b.toString().getBytes(UTF_8); + byte[] data = b.toString().getBytes(CHARSET); checker.setSafeForMacOS(true); assertCorrupt("duplicate entry names", OBJ_TREE, data); assertSkipListAccepts(OBJ_TREE, data); @@ -1482,7 +1482,7 @@ public class ObjectCheckerTest { StringBuilder b = new StringBuilder(); entry(b, "100644 \u0065\u0301"); entry(b, "100644 \u00e9"); - byte[] data = b.toString().getBytes(UTF_8); + byte[] data = b.toString().getBytes(CHARSET); checker.setSafeForMacOS(true); assertCorrupt("duplicate entry names", OBJ_TREE, data); assertSkipListAccepts(OBJ_TREE, data); @@ -1496,7 +1496,7 @@ public class ObjectCheckerTest { StringBuilder b = new StringBuilder(); entry(b, "100644 A"); checker.setSafeForMacOS(true); - checker.checkTree(b.toString().getBytes(UTF_8)); + checker.checkTree(b.toString().getBytes(CHARSET)); } @Test diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java index 9322a4734e..9734ac851c 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/merge/ResolveMergerTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.merge; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -756,7 +756,7 @@ public class ResolveMergerTest extends RepositoryTestCase { } binary[50] = '\0'; - writeTrashFile("file", new String(binary, UTF_8)); + writeTrashFile("file", new String(binary, CHARSET)); git.add().addFilepattern("file").call(); RevCommit first = git.commit().setMessage("added file").call(); @@ -764,7 +764,7 @@ public class ResolveMergerTest extends RepositoryTestCase { int idx = LINELEN * 1200 + 1; byte save = binary[idx]; binary[idx] = '@'; - writeTrashFile("file", new String(binary, UTF_8)); + writeTrashFile("file", new String(binary, CHARSET)); binary[idx] = save; git.add().addFilepattern("file").call(); @@ -773,7 +773,7 @@ public class ResolveMergerTest extends RepositoryTestCase { git.checkout().setCreateBranch(true).setStartPoint(first).setName("side").call(); binary[LINELEN * 1500 + 1] = '!'; - writeTrashFile("file", new String(binary, UTF_8)); + writeTrashFile("file", new String(binary, CHARSET)); git.add().addFilepattern("file").call(); RevCommit sideCommit = git.commit().setAll(true) .setMessage("modified file l 1500").call(); @@ -935,7 +935,7 @@ public class ResolveMergerTest extends RepositoryTestCase { merger.getMergeResults().get("file"); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { fmt.formatMerge(out, merger.getMergeResults().get("file"), - "BASE", "OURS", "THEIRS", UTF_8.name()); + "BASE", "OURS", "THEIRS", CHARSET.name()); String expected = "<<<<<<< OURS\n" + "1master\n" + "=======\n" @@ -943,7 +943,7 @@ public class ResolveMergerTest extends RepositoryTestCase { + ">>>>>>> THEIRS\n" + "2\n" + "3"; - assertEquals(expected, new String(out.toByteArray(), UTF_8)); + assertEquals(expected, new String(out.toByteArray(), CHARSET)); } } } @@ -1328,6 +1328,6 @@ public class ResolveMergerTest extends RepositoryTestCase { if (obj == null) { return null; } - return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), UTF_8); + return new String(rw.getObjectReader().open(obj, OBJ_BLOB).getBytes(), CHARSET); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java index 65375c7ae0..8da199f7c6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/patch/GetTextTest.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.patch; import static java.nio.charset.StandardCharsets.ISO_8859_1; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -83,7 +83,7 @@ public class GetTextTest { @Test public void testGetText_Convert() throws IOException { final Charset csOld = ISO_8859_1; - final Charset csNew = UTF_8; + final Charset csNew = CHARSET; final Patch p = parseTestPatchFile(); assertTrue(p.getErrors().isEmpty()); assertEquals(1, p.getFiles().size()); @@ -103,7 +103,7 @@ public class GetTextTest { @Test public void testGetText_DiffCc() throws IOException { final Charset csOld = ISO_8859_1; - final Charset csNew = UTF_8; + final Charset csNew = CHARSET; final Patch p = parseTestPatchFile(); assertTrue(p.getErrors().isEmpty()); assertEquals(1, p.getFiles().size()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java index 88f240bb1f..9fc96212c7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevCommitParseTest.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.revwalk; import static java.nio.charset.StandardCharsets.ISO_8859_1; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -114,7 +114,7 @@ public class RevCommitParseTest extends RepositoryTestCase { assertNull(c.getTree()); assertNull(c.parents); - c.parseCanonical(rw, body.toString().getBytes(UTF_8)); + c.parseCanonical(rw, body.toString().getBytes(CHARSET)); assertNotNull(c.getTree()); assertEquals(treeId, c.getTree().getId()); assertSame(rw.lookupTree(treeId), c.getTree()); @@ -148,7 +148,7 @@ public class RevCommitParseTest extends RepositoryTestCase { final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); - c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); + c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); return c; } @@ -161,7 +161,7 @@ public class RevCommitParseTest extends RepositoryTestCase { final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); - c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); + c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); assertEquals("", c.getFullMessage()); assertEquals("", c.getShortMessage()); @@ -176,7 +176,7 @@ public class RevCommitParseTest extends RepositoryTestCase { final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); - c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); + c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); assertEquals(new PersonIdent("", "a_u_thor@example.com", 1218123387000l, 7), c.getAuthorIdent()); assertEquals(new PersonIdent("", "", 1218123390000l, -5), c.getCommitterIdent()); @@ -185,13 +185,13 @@ public class RevCommitParseTest extends RepositoryTestCase { @Test public void testParse_implicit_UTF8_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); - b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8)); - b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); + b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); + b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET)); + b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -205,13 +205,13 @@ public class RevCommitParseTest extends RepositoryTestCase { @Test public void testParse_implicit_mixed_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); + b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1)); - b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); + b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -260,14 +260,14 @@ public class RevCommitParseTest extends RepositoryTestCase { @Test public void testParse_explicit_bad_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); + b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(ISO_8859_1)); - b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); - b.write("encoding EUC-JP\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Hi\n".getBytes(UTF_8)); + b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); + b.write("encoding EUC-JP\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Hi\n".getBytes(CHARSET)); final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -291,14 +291,14 @@ public class RevCommitParseTest extends RepositoryTestCase { @Test public void testParse_explicit_bad_encoded2() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); - b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(UTF_8)); - b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); - b.write("encoding ISO-8859-1\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Hi\n".getBytes(UTF_8)); + b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); + b.write("author F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n".getBytes(CHARSET)); + b.write("committer C O. Miter <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); + b.write("encoding ISO-8859-1\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Hi\n".getBytes(CHARSET)); final RevCommit c; c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -313,13 +313,13 @@ public class RevCommitParseTest extends RepositoryTestCase { public void testParse_incorrectUtf8Name() throws Exception { ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" - .getBytes(UTF_8)); - b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET)); b.write("committer co <c@example.com> 1218123390 -0500\n" - .getBytes(UTF_8)); - b.write("encoding 'utf8'\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("encoding 'utf8'\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); RevCommit c = new RevCommit( id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); @@ -338,12 +338,12 @@ public class RevCommitParseTest extends RepositoryTestCase { @Test public void testParse_illegalEncoding() throws Exception { ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); - b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8)); - b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); - b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("message\n".getBytes(UTF_8)); + b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); + b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET)); + b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); + b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("message\n".getBytes(CHARSET)); RevCommit c = new RevCommit( id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); @@ -365,12 +365,12 @@ public class RevCommitParseTest extends RepositoryTestCase { @Test public void testParse_unsupportedEncoding() throws Exception { ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); - b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(UTF_8)); - b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(UTF_8)); - b.write("encoding it_IT.UTF8\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("message\n".getBytes(UTF_8)); + b.write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); + b.write("author au <a@example.com> 1218123387 +0700\n".getBytes(CHARSET)); + b.write("committer co <c@example.com> 1218123390 -0500\n".getBytes(CHARSET)); + b.write("encoding it_IT.UTF8\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("message\n".getBytes(CHARSET)); RevCommit c = new RevCommit( id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java index 38bd371b90..8e9507961b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevTagParseTest.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.revwalk; import static java.nio.charset.StandardCharsets.ISO_8859_1; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -98,7 +98,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertNull(c.getObject()); assertNull(c.getTagName()); - c.parseCanonical(rw, b.toString().getBytes(UTF_8)); + c.parseCanonical(rw, b.toString().getBytes(CHARSET)); assertNotNull(c.getObject()); assertEquals(id, c.getObject().getId()); assertSame(rw.lookupAny(id, typeCode), c.getObject()); @@ -141,7 +141,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertNull(c.getObject()); assertNull(c.getTagName()); - c.parseCanonical(rw, body.toString().getBytes(UTF_8)); + c.parseCanonical(rw, body.toString().getBytes(CHARSET)); assertNotNull(c.getObject()); assertEquals(treeId, c.getObject().getId()); assertSame(rw.lookupTree(treeId), c.getObject()); @@ -189,7 +189,7 @@ public class RevTagParseTest extends RepositoryTestCase { assertNull(c.getObject()); assertNull(c.getTagName()); - c.parseCanonical(rw, body.toString().getBytes(UTF_8)); + c.parseCanonical(rw, body.toString().getBytes(CHARSET)); assertNotNull(c.getObject()); assertEquals(treeId, c.getObject().getId()); assertSame(rw.lookupTree(treeId), c.getObject()); @@ -213,7 +213,7 @@ public class RevTagParseTest extends RepositoryTestCase { final RevTag c; c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); - c.parseCanonical(new RevWalk(db), b.toString().getBytes(UTF_8)); + c.parseCanonical(new RevWalk(db), b.toString().getBytes(CHARSET)); return c; } @@ -221,17 +221,17 @@ public class RevTagParseTest extends RepositoryTestCase { public void testParse_implicit_UTF8_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" - .getBytes(UTF_8)); - b.write("type tree\n".getBytes(UTF_8)); - b.write("tag v1.2.3.4.5\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("type tree\n".getBytes(CHARSET)); + b.write("tag v1.2.3.4.5\n".getBytes(CHARSET)); b .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n" - .getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); final RevTag c; c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -246,15 +246,15 @@ public class RevTagParseTest extends RepositoryTestCase { public void testParse_implicit_mixed_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" - .getBytes(UTF_8)); - b.write("type tree\n".getBytes(UTF_8)); - b.write("tag v1.2.3.4.5\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("type tree\n".getBytes(CHARSET)); + b.write("tag v1.2.3.4.5\n".getBytes(CHARSET)); b.write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n" .getBytes(ISO_8859_1)); - b.write("\n".getBytes(UTF_8)); - b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); + b.write("\n".getBytes(CHARSET)); + b.write("Sm\u00f6rg\u00e5sbord\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); final RevTag c; c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -307,17 +307,17 @@ public class RevTagParseTest extends RepositoryTestCase { public void testParse_explicit_bad_encoded() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" - .getBytes(UTF_8)); - b.write("type tree\n".getBytes(UTF_8)); - b.write("tag v1.2.3.4.5\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("type tree\n".getBytes(CHARSET)); + b.write("tag v1.2.3.4.5\n".getBytes(CHARSET)); b .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n" .getBytes(ISO_8859_1)); - b.write("encoding EUC-JP\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Hi\n".getBytes(UTF_8)); + b.write("encoding EUC-JP\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Hi\n".getBytes(CHARSET)); final RevTag c; c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -342,17 +342,17 @@ public class RevTagParseTest extends RepositoryTestCase { public void testParse_explicit_bad_encoded2() throws Exception { final ByteArrayOutputStream b = new ByteArrayOutputStream(); b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n" - .getBytes(UTF_8)); - b.write("type tree\n".getBytes(UTF_8)); - b.write("tag v1.2.3.4.5\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("type tree\n".getBytes(CHARSET)); + b.write("tag v1.2.3.4.5\n".getBytes(CHARSET)); b .write("tagger F\u00f6r fattare <a_u_thor@example.com> 1218123387 +0700\n" - .getBytes(UTF_8)); - b.write("encoding ISO-8859-1\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("\u304d\u308c\u3044\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("Hi\n".getBytes(UTF_8)); + .getBytes(CHARSET)); + b.write("encoding ISO-8859-1\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("\u304d\u308c\u3044\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("Hi\n".getBytes(CHARSET)); final RevTag c; c = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); c.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -365,13 +365,13 @@ public class RevTagParseTest extends RepositoryTestCase { @Test public void testParse_illegalEncoding() throws Exception { ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); - b.write("type tree\n".getBytes(UTF_8)); - b.write("tag v1.0\n".getBytes(UTF_8)); - b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8)); - b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("message\n".getBytes(UTF_8)); + b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); + b.write("type tree\n".getBytes(CHARSET)); + b.write("tag v1.0\n".getBytes(CHARSET)); + b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET)); + b.write("encoding utf-8logoutputencoding=gbk\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("message\n".getBytes(CHARSET)); RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); t.parseCanonical(new RevWalk(db), b.toByteArray()); @@ -384,13 +384,13 @@ public class RevTagParseTest extends RepositoryTestCase { @Test public void testParse_unsupportedEncoding() throws Exception { ByteArrayOutputStream b = new ByteArrayOutputStream(); - b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(UTF_8)); - b.write("type tree\n".getBytes(UTF_8)); - b.write("tag v1.0\n".getBytes(UTF_8)); - b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(UTF_8)); - b.write("encoding it_IT.UTF8\n".getBytes(UTF_8)); - b.write("\n".getBytes(UTF_8)); - b.write("message\n".getBytes(UTF_8)); + b.write("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes(CHARSET)); + b.write("type tree\n".getBytes(CHARSET)); + b.write("tag v1.0\n".getBytes(CHARSET)); + b.write("tagger t <t@example.com> 1218123387 +0700\n".getBytes(CHARSET)); + b.write("encoding it_IT.UTF8\n".getBytes(CHARSET)); + b.write("\n".getBytes(CHARSET)); + b.write("message\n".getBytes(CHARSET)); RevTag t = new RevTag(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); t.parseCanonical(new RevWalk(db), b.toByteArray()); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java index 7f0d60295c..0dea5ce97b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.storage.file; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.util.FileUtils.pathToString; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -105,7 +105,7 @@ public class FileBasedConfigTest { @Test public void testUTF8withoutBOM() throws IOException, ConfigInvalidException { - final File file = createFile(CONTENT1.getBytes(UTF_8)); + final File file = createFile(CONTENT1.getBytes(CHARSET)); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); config.load(); assertEquals(ALICE, config.getString(USER, null, NAME)); @@ -121,7 +121,7 @@ public class FileBasedConfigTest { bos1.write(0xEF); bos1.write(0xBB); bos1.write(0xBF); - bos1.write(CONTENT1.getBytes(UTF_8)); + bos1.write(CONTENT1.getBytes(CHARSET)); final File file = createFile(bos1.toByteArray()); final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED); @@ -135,7 +135,7 @@ public class FileBasedConfigTest { bos2.write(0xEF); bos2.write(0xBB); bos2.write(0xBF); - bos2.write(CONTENT2.getBytes(UTF_8)); + bos2.write(CONTENT2.getBytes(CHARSET)); assertArrayEquals(bos2.toByteArray(), IO.readFully(file)); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java index 658b971acb..d30ac840a6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/BundleWriterTest.java @@ -45,7 +45,7 @@ package org.eclipse.jgit.transport; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -199,7 +199,7 @@ public class BundleWriterTest extends SampleDataRepositoryTestCase { Ref ref = repo.exactRef(refName); assertNotNull(ref); assertEquals(id, ref.getObjectId()); - assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), UTF_8)); + assertEquals(data, new String(repo.open(id, OBJ_BLOB).getBytes(), CHARSET)); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java index cb04f83fb5..2251a3dc66 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/WalkEncryptionTest.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.transport; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListPBE; import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.cryptoCipherListTrans; import static org.eclipse.jgit.transport.WalkEncryptionTest.Util.folderDelete; @@ -360,7 +360,7 @@ public class WalkEncryptionTest { * @throws Exception */ static String textRead(File file) throws Exception { - return new String(Files.readAllBytes(file.toPath()), UTF_8); + return new String(Files.readAllBytes(file.toPath()), CHARSET); } /** @@ -371,7 +371,7 @@ public class WalkEncryptionTest { * @throws Exception */ static void textWrite(File file, String text) throws Exception { - Files.write(file.toPath(), text.getBytes(UTF_8)); + Files.write(file.toPath(), text.getBytes(CHARSET)); } static void verifyFileContent(File fileOne, File fileTwo) @@ -741,7 +741,7 @@ public class WalkEncryptionTest { AmazonS3 s3 = new AmazonS3(props); String file = JGIT_USER + "-" + UUID.randomUUID().toString(); String path = JGIT_REMOTE_DIR + "/" + file; - s3.put(bucket, path, file.getBytes(UTF_8)); + s3.put(bucket, path, file.getBytes(CHARSET)); s3.delete(bucket, path); } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java index e8566d2438..a748b52215 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RawSubStringPatternTest.java @@ -42,7 +42,7 @@ */ package org.eclipse.jgit.util; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -93,7 +93,7 @@ public class RawSubStringPatternTest extends RepositoryTestCase { } private static RawCharSequence raw(String text) { - byte[] bytes = text.getBytes(UTF_8); + byte[] bytes = text.getBytes(CHARSET); return new RawCharSequence(bytes, 0, bytes.length); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java index 38199d8aaf..8b955bae68 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoLFInputStreamTest.java @@ -44,7 +44,7 @@ package org.eclipse.jgit.util.io; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import java.io.ByteArrayInputStream; @@ -129,6 +129,6 @@ public class AutoLFInputStreamTest { } private static byte[] asBytes(String in) { - return in.getBytes(UTF_8); + return in.getBytes(CHARSET); } } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java index e6045a91bd..3c612e1bdd 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/sha1/SHA1Test.java @@ -43,7 +43,7 @@ package org.eclipse.jgit.util.sha1; -import static java.nio.charset.StandardCharsets.UTF_8; +import static org.eclipse.jgit.lib.Constants.CHARSET; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -95,15 +95,15 @@ public class SHA1Test { .fromString("a9993e364706816aba3e25717850c26c9cd0d89d"); MessageDigest m = MessageDigest.getInstance("SHA-1"); - m.update(TEST1.getBytes(UTF_8)); + m.update(TEST1.getBytes(CHARSET)); ObjectId m1 = ObjectId.fromRaw(m.digest()); SHA1 s = SHA1.newInstance(); - s.update(TEST1.getBytes(UTF_8)); + s.update(TEST1.getBytes(CHARSET)); ObjectId s1 = ObjectId.fromRaw(s.digest()); s.reset(); - s.update(TEST1.getBytes(UTF_8)); + s.update(TEST1.getBytes(CHARSET)); ObjectId s2 = s.toObjectId(); assertEquals(m1, s1); @@ -117,15 +117,15 @@ public class SHA1Test { .fromString("84983e441c3bd26ebaae4aa1f95129e5e54670f1"); MessageDigest m = MessageDigest.getInstance("SHA-1"); - m.update(TEST2.getBytes(UTF_8)); + m.update(TEST2.getBytes(CHARSET)); ObjectId m1 = ObjectId.fromRaw(m.digest()); SHA1 s = SHA1.newInstance(); - s.update(TEST2.getBytes(UTF_8)); + s.update(TEST2.getBytes(CHARSET)); ObjectId s1 = ObjectId.fromRaw(s.digest()); s.reset(); - s.update(TEST2.getBytes(UTF_8)); + s.update(TEST2.getBytes(CHARSET)); ObjectId s2 = s.toObjectId(); assertEquals(m1, s1); |