aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java7
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java15
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java17
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java2
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java37
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java7
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java7
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/storage/file/FileBasedConfigTest.java46
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java3
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java8
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java6
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java6
13 files changed, 88 insertions, 76 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java
index ca0630ea35..6f1e0cf220 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CommitAndLogCommandTest.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 static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -358,7 +359,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
messageHeader + messageFooter)
.setInsertChangeId(true).call();
// we should find a real change id (at the end of the file)
- byte[] chars = commit.getFullMessage().getBytes();
+ byte[] chars = commit.getFullMessage().getBytes(UTF_8);
int lastLineBegin = RawParseUtils.prevLF(chars, chars.length - 2);
String lastLine = RawParseUtils.decode(chars, lastLineBegin + 1,
chars.length);
@@ -371,7 +372,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
.setInsertChangeId(true).call();
// we should find a real change id (in the line as dictated by the
// template)
- chars = commit.getFullMessage().getBytes();
+ chars = commit.getFullMessage().getBytes(UTF_8);
int lineStart = 0;
int lineEnd = 0;
for (int i = 0; i < 4; i++) {
@@ -389,7 +390,7 @@ public class CommitAndLogCommandTest extends RepositoryTestCase {
messageHeader + changeIdTemplate + messageFooter)
.setInsertChangeId(false).call();
// we should find the untouched template
- chars = commit.getFullMessage().getBytes();
+ chars = commit.getFullMessage().getBytes(UTF_8);
lineStart = 0;
lineEnd = 0;
for (int i = 0; i < 4; i++) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java
index f0d3c3690f..f4ccf0506b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/attributes/AttributesNodeTest.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.attributes;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.attributes.Attribute.State.SET;
import static org.eclipse.jgit.attributes.Attribute.State.UNSET;
import static org.junit.Assert.assertEquals;
@@ -88,7 +89,7 @@ public class AttributesNodeTest {
String attributeFileContent = "*.type1 A -B C=value\n"
+ "*.type2 -A B C=value2";
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("file.type1", node,
@@ -102,7 +103,7 @@ public class AttributesNodeTest {
String attributeFileContent = "!*.type1 A -B C=value\n"
+ "!*.type2 -A B C=value2";
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("file.type1", node, new Attributes());
@@ -113,7 +114,7 @@ public class AttributesNodeTest {
public void testEmptyNegativeAttributeKey() throws IOException {
String attributeFileContent = "*.type1 - \n" //
+ "*.type2 - -A";
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("file.type1", node, new Attributes());
@@ -125,7 +126,7 @@ public class AttributesNodeTest {
String attributeFileContent = "*.type1 = \n" //
+ "*.type2 =value\n"//
+ "*.type3 attr=\n";
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("file.type1", node, new Attributes());
@@ -140,7 +141,7 @@ public class AttributesNodeTest {
+ " \n" //
+ "*.type2 -A B C=value2";
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("file.type1", node,
@@ -156,7 +157,7 @@ public class AttributesNodeTest {
+ "*.type3 \t\t B\n" //
+ "*.type3\t-A";//
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("file.type1", node,
@@ -170,7 +171,7 @@ public class AttributesNodeTest {
public void testDoubleAsteriskAtEnd() throws IOException {
String attributeFileContent = "dir/** \tA -B\tC=value";
- is = new ByteArrayInputStream(attributeFileContent.getBytes());
+ is = new ByteArrayInputStream(attributeFileContent.getBytes(UTF_8));
AttributesNode node = new AttributesNode();
node.parse(is);
assertAttribute("dir", node,
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java
index dc05eeabe1..acdaf3aa3c 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogReaderTest.java
@@ -44,6 +44,7 @@
package org.eclipse.jgit.internal.storage.file;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -67,31 +68,31 @@ import org.junit.Test;
public class ReflogReaderTest extends SampleDataRepositoryTestCase {
static byte[] oneLine = "da85355dfc525c9f6f3927b876f379f46ccf826e 3e7549db262d1e836d9bf0af7e22355468f1717c A O Thor Too <authortoo@wri.tr> 1243028200 +0200\tcommit: Add a toString for debugging to RemoteRefUpdate\n"
- .getBytes();
+ .getBytes(UTF_8);
static byte[] twoLine = ("0000000000000000000000000000000000000000 c6734895958052a9dbc396cff4459dc1a25029ab A U Thor <thor@committer.au> 1243028201 -0100\tbranch: Created from rr/renamebranchv4\n"
+ "c6734895958052a9dbc396cff4459dc1a25029ab 54794942a18a237c57a80719afed44bb78172b10 Same A U Thor <same.author@example.com> 1243028202 +0100\trebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d\n")
- .getBytes();
+ .getBytes(UTF_8);
static byte[] twoLineWithAppendInProgress = ("0000000000000000000000000000000000000000 c6734895958052a9dbc396cff4459dc1a25029ab A U Thor <thor@committer.au> 1243028201 -0100\tbranch: Created from rr/renamebranchv4\n"
+ "c6734895958052a9dbc396cff4459dc1a25029ab 54794942a18a237c57a80719afed44bb78172b10 Same A U Thor <same.author@example.com> 1243028202 +0100\trebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d\n"
+ "54794942a18a237c57a80719afed44bb78172b10 ")
- .getBytes();
+ .getBytes(UTF_8);
static byte[] aLine = "1111111111111111111111111111111111111111 3e7549db262d1e836d9bf0af7e22355468f1717c A U Thor <thor@committer.au> 1243028201 -0100\tbranch: change to a\n"
- .getBytes();
+ .getBytes(UTF_8);
static byte[] masterLine = "2222222222222222222222222222222222222222 3e7549db262d1e836d9bf0af7e22355468f1717c A U Thor <thor@committer.au> 1243028201 -0100\tbranch: change to master\n"
- .getBytes();
+ .getBytes(UTF_8);
static byte[] headLine = "3333333333333333333333333333333333333333 3e7549db262d1e836d9bf0af7e22355468f1717c A U Thor <thor@committer.au> 1243028201 -0100\tbranch: change to HEAD\n"
- .getBytes();
+ .getBytes(UTF_8);
static byte[] oneLineWithoutComment = "da85355dfc525c9f6f3927b876f379f46ccf826e 3e7549db262d1e836d9bf0af7e22355468f1717c A O Thor Too <authortoo@wri.tr> 1243028200 +0200\n"
- .getBytes();
+ .getBytes(UTF_8);
static byte[] switchBranch = "0d43a6890a19fd657faad1c4cfbe3cb1b47851c3 4809df9c0d8bce5b00955563f77c5a9f25aa0d12 A O Thor Too <authortoo@wri.tr> 1315088009 +0200\tcheckout: moving from new/work to master\n"
- .getBytes();
+ .getBytes(UTF_8);
@Test
public void testReadOneLine() throws Exception {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java
index d7e601e657..a84be7e9f0 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/ReflogWriterTest.java
@@ -74,7 +74,7 @@ public class ReflogWriterTest extends SampleDataRepositoryTestCase {
writer.log("refs/heads/master", oldId, newId, ident,
"stash: Add\nmessage\r\nwith line feeds");
- byte[] buffer = new byte[oneLine.getBytes().length];
+ byte[] buffer = new byte[oneLine.getBytes(UTF_8).length];
readReflog(buffer);
assertEquals(oneLine, new String(buffer, UTF_8));
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
index 6e2cddb4ce..30a07421ad 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/ConfigTest.java
@@ -48,6 +48,7 @@
package org.eclipse.jgit.lib;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -812,7 +813,7 @@ public class ConfigTest {
public void testIncludeTooManyRecursions() throws IOException {
File config = tmp.newFile("config");
String include = "[include]\npath=" + pathToString(config) + "\n";
- Files.write(config.toPath(), include.getBytes());
+ Files.write(config.toPath(), include.getBytes(UTF_8));
try {
loadConfig(config);
fail();
@@ -833,7 +834,7 @@ public class ConfigTest {
File config = tmp.newFile("config");
String fooBar = "[foo]\nbar=true\n";
- Files.write(config.toPath(), fooBar.getBytes());
+ Files.write(config.toPath(), fooBar.getBytes(UTF_8));
Config parsed = parse("[include]\npath=" + pathToString(config) + "\n");
assertFalse(parsed.getBoolean("foo", "bar", false));
@@ -844,11 +845,11 @@ public class ConfigTest {
throws IOException, ConfigInvalidException {
File included = tmp.newFile("included");
String content = "[foo]\nbar=true\n";
- Files.write(included.toPath(), content.getBytes());
+ Files.write(included.toPath(), content.getBytes(UTF_8));
File config = tmp.newFile("config");
content = "[Include]\npath=" + pathToString(included) + "\n";
- Files.write(config.toPath(), content.getBytes());
+ Files.write(config.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(config);
assertTrue(fbConfig.getBoolean("foo", "bar", false));
@@ -859,11 +860,11 @@ public class ConfigTest {
throws IOException, ConfigInvalidException {
File included = tmp.newFile("included");
String content = "[foo]\nbar=true\n";
- Files.write(included.toPath(), content.getBytes());
+ Files.write(included.toPath(), content.getBytes(UTF_8));
File config = tmp.newFile("config");
content = "[include]\nPath=" + pathToString(included) + "\n";
- Files.write(config.toPath(), content.getBytes());
+ Files.write(config.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(config);
assertTrue(fbConfig.getBoolean("foo", "bar", false));
@@ -886,11 +887,11 @@ public class ConfigTest {
File included = tmp.newFile("included");
String includedPath = pathToString(included);
String content = "[include]\npath=\n";
- Files.write(included.toPath(), content.getBytes());
+ Files.write(included.toPath(), content.getBytes(UTF_8));
File config = tmp.newFile("config");
String include = "[include]\npath=" + includedPath + "\n";
- Files.write(config.toPath(), include.getBytes());
+ Files.write(config.toPath(), include.getBytes(UTF_8));
try {
loadConfig(config);
fail("Expected ConfigInvalidException");
@@ -917,7 +918,7 @@ public class ConfigTest {
21, 31, CoreConfig.AutoCRLF.FALSE,
"+refs/heads/*:refs/remotes/origin/*") + "\n[include]\npath="
+ pathToString(includedFile);
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsIncluded(fbConfig, REFS_ORIGIN, REFS_UPSTREAM);
@@ -940,7 +941,7 @@ public class ConfigTest {
+ createAllTypesSampleContent("Alice Parker", false, 11, 21, 31,
CoreConfig.AutoCRLF.FALSE,
"+refs/heads/*:refs/remotes/origin/*");
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsConfig(fbConfig, REFS_UPSTREAM, REFS_ORIGIN);
@@ -960,7 +961,7 @@ public class ConfigTest {
File configFile = tmp.newFile("config");
String content = "[include]\npath=" + pathToString(includedFile);
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsIncluded(fbConfig, REFS_UPSTREAM);
@@ -981,7 +982,7 @@ public class ConfigTest {
File configFile = tmp.newFile("config");
String content = "[user]\n[include]\npath="
+ pathToString(includedFile);
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsIncluded(fbConfig, REFS_UPSTREAM);
@@ -1003,7 +1004,7 @@ public class ConfigTest {
File configFile = tmp.newFile("config");
String content = "[include]\npath=" + pathToString(includedFile)
+ "\n[user]";
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsIncluded(fbConfig, REFS_UPSTREAM);
@@ -1024,7 +1025,7 @@ public class ConfigTest {
File configFile = tmp.newFile("config");
String content = "[user]\nemail=alice@home\n[include]\npath="
+ pathToString(includedFile);
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsIncluded(fbConfig, REFS_UPSTREAM);
@@ -1046,7 +1047,7 @@ public class ConfigTest {
File configFile = tmp.newFile("config");
String content = "[include]\npath=" + pathToString(includedFile)
+ "\n[user]\nemail=alice@home\n";
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
assertValuesAsIncluded(fbConfig, REFS_UPSTREAM);
@@ -1066,13 +1067,13 @@ public class ConfigTest {
RefSpec includedRefSpec = new RefSpec(REFS_UPSTREAM);
String includedContent = "[remote \"origin\"]\n" + "fetch="
+ includedRefSpec;
- Files.write(includedFile.toPath(), includedContent.getBytes());
+ Files.write(includedFile.toPath(), includedContent.getBytes(UTF_8));
File configFile = tmp.newFile("config");
RefSpec refSpec = new RefSpec(REFS_ORIGIN);
String content = "[include]\npath=" + pathToString(includedFile) + "\n"
+ "[remote \"origin\"]\n" + "fetch=" + refSpec;
- Files.write(configFile.toPath(), content.getBytes());
+ Files.write(configFile.toPath(), content.getBytes(UTF_8));
FileBasedConfig fbConfig = loadConfig(configFile);
@@ -1094,7 +1095,7 @@ public class ConfigTest {
String includedContent = createAllTypesSampleContent("Alice Muller",
true, 10, 20, 30, CoreConfig.AutoCRLF.TRUE,
"+refs/heads/*:refs/remotes/upstream/*");
- Files.write(includedFile.toPath(), includedContent.getBytes());
+ Files.write(includedFile.toPath(), includedContent.getBytes(UTF_8));
return includedFile;
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java
index 32a1ec96a5..057e0c881b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutMaliciousPathTest.java
@@ -37,6 +37,7 @@
*/
package org.eclipse.jgit.lib;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -343,7 +344,7 @@ public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase {
ObjectInserter newObjectInserter;
newObjectInserter = git.getRepository().newObjectInserter();
ObjectId blobId = newObjectInserter.insert(Constants.OBJ_BLOB,
- "data".getBytes());
+ "data".getBytes(UTF_8));
newObjectInserter = git.getRepository().newObjectInserter();
FileMode mode = FileMode.REGULAR_FILE;
ObjectId insertId = blobId;
@@ -366,8 +367,8 @@ public class DirCacheCheckoutMaliciousPathTest extends RepositoryTestCase {
insertId = blobId;
for (int i = path.length - 1; i >= 0; --i) {
TreeFormatter treeFormatter = new TreeFormatter();
- treeFormatter.append(path[i].getBytes(), 0,
- path[i].getBytes().length,
+ treeFormatter.append(path[i].getBytes(UTF_8), 0,
+ path[i].getBytes(UTF_8).length,
mode, insertId, true);
insertId = newObjectInserter.insert(treeFormatter);
mode = FileMode.TREE;
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
index eb87827805..7cb91a2064 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java
@@ -40,6 +40,7 @@
*/
package org.eclipse.jgit.lib;
+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.assertFalse;
@@ -310,7 +311,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
assertTrue("unexpected content for path " + path
+ " in index. Expected: <" + expectedValue + ">",
Arrays.equals(db.open(read.getEntry(j).getObjectId())
- .getCachedBytes(), i.get(path).getBytes()));
+ .getCachedBytes(), i.get(path).getBytes(UTF_8)));
}
}
@@ -405,7 +406,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
ObjectId genSha1(String data) {
try (ObjectInserter w = db.newObjectInserter()) {
- ObjectId id = w.insert(Constants.OBJ_BLOB, data.getBytes());
+ ObjectId id = w.insert(Constants.OBJ_BLOB, data.getBytes(UTF_8));
w.flush();
return id;
} catch (IOException e) {
@@ -2048,7 +2049,7 @@ public class DirCacheCheckoutTest extends RepositoryTestCase {
assertArrayEquals(
"unexpected content for path " + path
+ " in workDir. ",
- buffer, i.get(path).getBytes());
+ buffer, i.get(path).getBytes(UTF_8));
}
nrFiles++;
} else if (file.isDirectory()) {
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
index ac142ed322..7d2c4a2784 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RefTest.java
@@ -45,6 +45,7 @@
package org.eclipse.jgit.lib;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.eclipse.jgit.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -261,7 +262,7 @@ public class RefTest extends SampleDataRepositoryTestCase {
assertEquals(Storage.PACKED, ref.getStorage());
try (FileOutputStream os = new FileOutputStream(
new File(db.getDirectory(), "refs/heads/master"))) {
- os.write(ref.getObjectId().name().getBytes());
+ os.write(ref.getObjectId().name().getBytes(UTF_8));
os.write('\n');
}
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 777a784c33..b401d2bea2 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
@@ -101,14 +101,14 @@ public class FileBasedConfigTest {
@Test
public void testSystemEncoding() throws IOException, ConfigInvalidException {
- final File file = createFile(CONTENT1.getBytes());
+ final File file = createFile(CONTENT1.getBytes(UTF_8));
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
config.load();
assertEquals(ALICE, config.getString(USER, null, NAME));
config.setString(USER, null, NAME, BOB);
config.save();
- assertArrayEquals(CONTENT2.getBytes(), IO.readFully(file));
+ assertArrayEquals(CONTENT2.getBytes(UTF_8), IO.readFully(file));
}
@Test
@@ -120,7 +120,7 @@ public class FileBasedConfigTest {
config.setString(USER, null, NAME, BOB);
config.save();
- assertArrayEquals(CONTENT2.getBytes(), IO.readFully(file));
+ assertArrayEquals(CONTENT2.getBytes(UTF_8), IO.readFully(file));
}
@Test
@@ -150,8 +150,8 @@ public class FileBasedConfigTest {
@Test
public void testLeadingWhitespaces() throws IOException, ConfigInvalidException {
final ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
- bos1.write(" \n\t".getBytes());
- bos1.write(CONTENT1.getBytes());
+ bos1.write(" \n\t".getBytes(UTF_8));
+ bos1.write(CONTENT1.getBytes(UTF_8));
final File file = createFile(bos1.toByteArray());
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@@ -162,18 +162,18 @@ public class FileBasedConfigTest {
config.save();
final ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
- bos2.write(" \n\t".getBytes());
- bos2.write(CONTENT2.getBytes());
+ bos2.write(" \n\t".getBytes(UTF_8));
+ bos2.write(CONTENT2.getBytes(UTF_8));
assertArrayEquals(bos2.toByteArray(), IO.readFully(file));
}
@Test
public void testIncludeAbsolute()
throws IOException, ConfigInvalidException {
- final File includedFile = createFile(CONTENT1.getBytes());
+ final File includedFile = createFile(CONTENT1.getBytes(UTF_8));
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write("[include]\npath=".getBytes());
- bos.write(pathToString(includedFile).getBytes());
+ bos.write("[include]\npath=".getBytes(UTF_8));
+ bos.write(pathToString(includedFile).getBytes(UTF_8));
final File file = createFile(bos.toByteArray());
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@@ -184,10 +184,10 @@ public class FileBasedConfigTest {
@Test
public void testIncludeRelativeDot()
throws IOException, ConfigInvalidException {
- final File includedFile = createFile(CONTENT1.getBytes(), "dir1");
+ final File includedFile = createFile(CONTENT1.getBytes(UTF_8), "dir1");
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write("[include]\npath=".getBytes());
- bos.write(("./" + includedFile.getName()).getBytes());
+ bos.write("[include]\npath=".getBytes(UTF_8));
+ bos.write(("./" + includedFile.getName()).getBytes(UTF_8));
final File file = createFile(bos.toByteArray(), "dir1");
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@@ -198,11 +198,11 @@ public class FileBasedConfigTest {
@Test
public void testIncludeRelativeDotDot()
throws IOException, ConfigInvalidException {
- final File includedFile = createFile(CONTENT1.getBytes(), "dir1");
+ final File includedFile = createFile(CONTENT1.getBytes(UTF_8), "dir1");
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write("[include]\npath=".getBytes());
+ bos.write("[include]\npath=".getBytes(UTF_8));
bos.write(("../" + includedFile.getParentFile().getName() + "/"
- + includedFile.getName()).getBytes());
+ + includedFile.getName()).getBytes(UTF_8));
final File file = createFile(bos.toByteArray(), "dir2");
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@@ -213,10 +213,10 @@ public class FileBasedConfigTest {
@Test
public void testIncludeRelativeDotDotNotFound()
throws IOException, ConfigInvalidException {
- final File includedFile = createFile(CONTENT1.getBytes());
+ final File includedFile = createFile(CONTENT1.getBytes(UTF_8));
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write("[include]\npath=".getBytes());
- bos.write(("../" + includedFile.getName()).getBytes());
+ bos.write("[include]\npath=".getBytes(UTF_8));
+ bos.write(("../" + includedFile.getName()).getBytes(UTF_8));
final File file = createFile(bos.toByteArray());
final FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
@@ -227,10 +227,10 @@ public class FileBasedConfigTest {
@Test
public void testIncludeWithTilde()
throws IOException, ConfigInvalidException {
- final File includedFile = createFile(CONTENT1.getBytes(), "home");
+ final File includedFile = createFile(CONTENT1.getBytes(UTF_8), "home");
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bos.write("[include]\npath=".getBytes());
- bos.write(("~/" + includedFile.getName()).getBytes());
+ bos.write("[include]\npath=".getBytes(UTF_8));
+ bos.write(("~/" + includedFile.getName()).getBytes(UTF_8));
final File file = createFile(bos.toByteArray(), "repo");
final FS fs = FS.DETECTED.newInstance();
@@ -246,7 +246,7 @@ public class FileBasedConfigTest {
throws IOException, ConfigInvalidException {
// use a content with multiple sections and multiple key/value pairs
// because code for first line works different than for subsequent lines
- final File includedFile = createFile(CONTENT3.getBytes(), "dir1");
+ final File includedFile = createFile(CONTENT3.getBytes(UTF_8), "dir1");
final File file = createFile(new byte[0], "dir2");
FileBasedConfig config = new FileBasedConfig(file, FS.DETECTED);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java
index cba35d8042..ea5db09349 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/treewalk/filter/InterIndexDiffFilterTest.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.treewalk.filter;
+import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -114,7 +115,7 @@ public class InterIndexDiffFilterTest extends LocalDiskRepositoryTestCase {
}
private ObjectId id(String data) {
- byte[] bytes = data.getBytes();
+ byte[] bytes = data.getBytes(UTF_8);
return db.newObjectInserter().idFor(Constants.OBJ_BLOB, bytes);
}
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java
index d92293bde4..19af83611b 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/RunExternalScriptTest.java
@@ -76,7 +76,7 @@ public class RunExternalScriptTest {
File script = writeTempFile("cat -");
int rc = FS.DETECTED.runProcess(
new ProcessBuilder("sh", script.getPath()), out, err,
- new ByteArrayInputStream(inputStr.getBytes()));
+ new ByteArrayInputStream(inputStr.getBytes(UTF_8)));
assertEquals(0, rc);
assertEquals(inputStr, new String(out.toByteArray(), UTF_8));
assertEquals("", new String(err.toByteArray(), UTF_8));
@@ -143,7 +143,7 @@ public class RunExternalScriptTest {
File script = writeTempFile("echo $#,$1,$2,$3,$4,$5,$6 >&2 ; cat -; exit 5");
int rc = FS.DETECTED.runProcess(
new ProcessBuilder("sh", script.getPath(), "a", "b", "c"),
- out, err, new ByteArrayInputStream(inputStr.getBytes()));
+ out, err, new ByteArrayInputStream(inputStr.getBytes(UTF_8)));
assertEquals(5, rc);
assertEquals(inputStr, new String(out.toByteArray(), UTF_8));
assertEquals("3,a,b,c,,," + LF, new String(err.toByteArray(), UTF_8));
@@ -173,7 +173,7 @@ public class RunExternalScriptTest {
File script = writeTempFile("cat -");
ProcessBuilder pb = new ProcessBuilder("sh", script.getPath());
ExecutionResult res = FS.DETECTED.execute(pb,
- new ByteArrayInputStream(inputStr.getBytes()));
+ new ByteArrayInputStream(inputStr.getBytes(UTF_8)));
assertEquals(0, res.getRc());
assertEquals(inputStr,
new String(res.getStdout().toByteArray(), UTF_8));
@@ -200,7 +200,7 @@ public class RunExternalScriptTest {
ProcessBuilder pb = new ProcessBuilder("sh", script.getPath(), "a",
"b", "c");
ExecutionResult res = FS.DETECTED.execute(pb,
- new ByteArrayInputStream(inputStr.getBytes()));
+ new ByteArrayInputStream(inputStr.getBytes(UTF_8)));
assertEquals(5, res.getRc());
assertEquals(inputStr,
new String(res.getStdout().toByteArray(), UTF_8));
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java
index 1272e16173..8f77c55af2 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFInputStreamTest.java
@@ -43,6 +43,8 @@
package org.eclipse.jgit.util.io;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -89,8 +91,8 @@ public class AutoCRLFInputStreamTest {
private void assertNoCrLfHelper(String expect, String input)
throws IOException {
- byte[] inbytes = input.getBytes();
- byte[] expectBytes = expect.getBytes();
+ byte[] inbytes = input.getBytes(UTF_8);
+ byte[] expectBytes = expect.getBytes(UTF_8);
for (int i = 0; i < 5; ++i) {
byte[] buf = new byte[i];
try (ByteArrayInputStream bis = new ByteArrayInputStream(inbytes);
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java
index 0655827310..3a3dc8117f 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/io/AutoCRLFOutputStreamTest.java
@@ -44,6 +44,8 @@
package org.eclipse.jgit.util.io;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -91,8 +93,8 @@ public class AutoCRLFOutputStreamTest {
private void assertNoCrLfHelper(String expect, String input)
throws IOException {
- byte[] inbytes = input.getBytes();
- byte[] expectBytes = expect.getBytes();
+ byte[] inbytes = input.getBytes(UTF_8);
+ byte[] expectBytes = expect.getBytes(UTF_8);
for (int i = -4; i < 5; ++i) {
int size = Math.abs(i);
byte[] buf = new byte[size];