summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/src
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2019-01-20 20:25:14 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2019-01-20 20:25:14 +0900
commit04c485b396231b9b64be47d106ebd91d0e7c7ed9 (patch)
treeb8341b993a96153ccd6188e7ad7d89345e91cad0 /org.eclipse.jgit.test/src
parent52923e9b077147d6734699f78247ac5b7666332f (diff)
downloadjgit-04c485b396231b9b64be47d106ebd91d0e7c7ed9.tar.gz
jgit-04c485b396231b9b64be47d106ebd91d0e7c7ed9.zip
Consistently import constants from StandardCharsets as static
Change-Id: I143c242c0e3299323ae166a59947b1195539e6bf Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/src')
-rw-r--r--org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java12
-rw-r--r--org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java8
2 files changed, 9 insertions, 11 deletions
diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java
index dde55b6d79..2f367ba51f 100644
--- a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java
+++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java
@@ -42,6 +42,7 @@
*/
package org.eclipse.jgit.transport.ssh;
+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;
@@ -51,7 +52,6 @@ import static org.junit.Assume.assumeTrue;
import java.io.File;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Locale;
@@ -409,8 +409,7 @@ public abstract class SshTestBase extends SshTestHarness {
private void checkKnownHostsModifiedHostKey(File backup, File newFile,
String wrongKey) throws IOException {
- List<String> oldLines = Files.readAllLines(backup.toPath(),
- StandardCharsets.UTF_8);
+ List<String> oldLines = Files.readAllLines(backup.toPath(), UTF_8);
// Find the original entry. We should have that again in known_hosts.
String oldKeyPart = null;
for (String oldLine : oldLines) {
@@ -424,8 +423,7 @@ public abstract class SshTestBase extends SshTestHarness {
}
}
assertNotNull("Old key not found", oldKeyPart);
- List<String> newLines = Files.readAllLines(newFile.toPath(),
- StandardCharsets.UTF_8);
+ List<String> newLines = Files.readAllLines(newFile.toPath(), UTF_8);
assertFalse("Old host key still found in known_hosts file" + newFile,
hasHostKey("localhost", testPort, wrongKey, newLines));
assertTrue("New host key not found in known_hosts file" + newFile,
@@ -448,10 +446,10 @@ public abstract class SshTestBase extends SshTestHarness {
"IdentityFile " + privateKey1.getAbsolutePath());
// File should not have been updated!
String[] oldLines = Files
- .readAllLines(backup.toPath(), StandardCharsets.UTF_8)
+ .readAllLines(backup.toPath(), UTF_8)
.toArray(new String[0]);
String[] newLines = Files
- .readAllLines(knownHosts.toPath(), StandardCharsets.UTF_8)
+ .readAllLines(knownHosts.toPath(), UTF_8)
.toArray(new String[0]);
assertArrayEquals("Known hosts file should not be modified", oldLines,
newLines);
diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java
index 59925a5a16..ada16b75eb 100644
--- a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java
+++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestHarness.java
@@ -42,6 +42,8 @@
*/
package org.eclipse.jgit.transport.ssh;
+import static java.nio.charset.StandardCharsets.US_ASCII;
+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.assertNotEquals;
@@ -54,7 +56,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
@@ -150,7 +151,7 @@ public abstract class SshTestHarness extends RepositoryTestCase {
knownHosts = new File(sshDir, "known_hosts");
Files.write(knownHosts.toPath(), Collections.singleton("[localhost]:"
+ testPort + ' '
- + publicHostKey.toString(StandardCharsets.US_ASCII.name())));
+ + publicHostKey.toString(US_ASCII.name())));
factory = createSessionFactory();
SshSessionFactory.setInstance(factory);
}
@@ -200,8 +201,7 @@ public abstract class SshTestHarness extends RepositoryTestCase {
*/
protected static String createKnownHostsFile(File file, String host,
int port, File publicKey) throws IOException {
- List<String> lines = Files.readAllLines(publicKey.toPath(),
- StandardCharsets.UTF_8);
+ List<String> lines = Files.readAllLines(publicKey.toPath(), UTF_8);
assertEquals("Public key has too many lines", 1, lines.size());
String pubKey = lines.get(0);
// Strip off the comment.