aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/util
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2018-09-25 14:42:12 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2018-09-26 08:31:13 +0900
commit2f1350c9ac51f421e5642915716f43e732c4eb14 (patch)
tree0df09945624b113a36751490072e71815efe7494 /org.eclipse.jgit.test/tst/org/eclipse/jgit/util
parenta7d3fa3064a9c4a7d380415774b2c31ead5672f2 (diff)
downloadjgit-2f1350c9ac51f421e5642915716f43e732c4eb14.tar.gz
jgit-2f1350c9ac51f421e5642915716f43e732c4eb14.zip
Explicitly specify charset when calling getBytes
Change-Id: Ie492406005be56ccaf4dfb385ae376636404816d Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse/jgit/util')
-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
3 files changed, 12 insertions, 8 deletions
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];