Browse Source

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>
stable-4.11
David Pursehouse 7 years ago
parent
commit
0b4e781f7c
  1. 6
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/JGitTestUtil.java
  2. 3
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java
  3. 3
      org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/RepositoryTestCase.java
  4. 5
      org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
  5. 3
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java
  6. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java
  7. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java
  8. 2
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java
  9. 5
      org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java

6
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);
}
/**

3
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:"

3
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));

5
org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java

@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.pgm;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@ -611,7 +612,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
private BufferedReader readFromProcess(Process proc) throws Exception {
return new BufferedReader(
new InputStreamReader(proc.getInputStream(), "UTF-8"));
new InputStreamReader(proc.getInputStream(), UTF_8));
}
private void grepForEntry(String name, String mode, String... cmdline)
@ -749,7 +750,7 @@ public class ArchiveTest extends CLIRepositoryTestCase {
// found!
List<String> l = new ArrayList<>();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in, "UTF-8"));
new InputStreamReader(in, UTF_8));
String line;
while ((line = reader.readLine()) != null)
l.add(line);

3
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/NotesCommandTest.java

@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.api;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import java.util.List;
@ -87,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");
UTF_8);
assertEquals(content, "data");
git.notesRemove().setObjectId(commit2).call();

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandTest.java

@ -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(), UTF_8);
assertEquals(string, content);
}
}

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PullCommandWithRebaseTest.java

@ -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(), UTF_8);
assertEquals(string, content);
}
}

2
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java

@ -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), UTF_8))) {
String line = br.readLine();
while (line != null) {
int firstBlank = line.indexOf(' ');

5
org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheCGitCompatabilityTest.java vendored

@ -43,6 +43,7 @@
package org.eclipse.jgit.dircache;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.junit.Assert.assertEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@ -235,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")), UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
final CGitIndexRecord cr = new CGitIndexRecord(line);
@ -248,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")), UTF_8))) {
String line;
while ((line = br.readLine()) != null) {
final CGitLsTreeRecord cr = new CGitLsTreeRecord(line);

Loading…
Cancel
Save