You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/02/26 06:07:57 UTC
[1/5] mina-sshd git commit: [SSHD-655] Apply checkstyle plugin to
test source code as well
Repository: mina-sshd
Updated Branches:
refs/heads/master a4307d1cc -> 39a71a151
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java
index c42e8f9..6eb12fd 100644
--- a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java
+++ b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/pubkey/LdapPublickeyAuthenticatorTest.java
@@ -46,8 +46,8 @@ import org.mockito.Mockito;
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LdapPublickeyAuthenticatorTest extends BaseAuthenticatorTest {
- private static final AtomicReference<Pair<LdapServer, DirectoryService>> ldapContextHolder = new AtomicReference<>();
- private static final Map<String, PublicKey> keysMap = new HashMap<>();
+ private static final AtomicReference<Pair<LdapServer, DirectoryService>> LDAP_CONTEX_HOLDER = new AtomicReference<>();
+ private static final Map<String, PublicKey> KEYS_MAP = new HashMap<>();
// we use this instead of the default since the default requires some extra LDIF manipulation which we don't need
private static final String TEST_ATTR_NAME = "description";
@@ -57,27 +57,27 @@ public class LdapPublickeyAuthenticatorTest extends BaseAuthenticatorTest {
@BeforeClass
public static void startApacheDs() throws Exception {
- ldapContextHolder.set(startApacheDs(LdapPublickeyAuthenticatorTest.class));
+ LDAP_CONTEX_HOLDER.set(startApacheDs(LdapPublickeyAuthenticatorTest.class));
Map<String, String> credentials =
- populateUsers(ldapContextHolder.get().getSecond(), LdapPublickeyAuthenticatorTest.class, TEST_ATTR_NAME);
+ populateUsers(LDAP_CONTEX_HOLDER.get().getSecond(), LdapPublickeyAuthenticatorTest.class, TEST_ATTR_NAME);
assertFalse("No keys retrieved", GenericUtils.isEmpty(credentials));
for (Map.Entry<String, String> ce : credentials.entrySet()) {
String username = ce.getKey();
AuthorizedKeyEntry entry = AuthorizedKeyEntry.parseAuthorizedKeyEntry(ce.getValue());
PublicKey key = ValidateUtils.checkNotNull(entry, "No key extracted").resolvePublicKey(PublicKeyEntryResolver.FAILING);
- keysMap.put(username, key);
+ KEYS_MAP.put(username, key);
}
}
@AfterClass
public static void stopApacheDs() throws Exception {
- stopApacheDs(ldapContextHolder.getAndSet(null));
+ stopApacheDs(LDAP_CONTEX_HOLDER.getAndSet(null));
}
@Test
public void testPublicKeyComparison() throws Exception {
- Pair<LdapServer, DirectoryService> ldapContext = ldapContextHolder.get();
+ Pair<LdapServer, DirectoryService> ldapContext = LDAP_CONTEX_HOLDER.get();
LdapPublickeyAuthenticator auth = new LdapPublickeyAuthenticator();
auth.setHost(getHost(ldapContext));
auth.setPort(getPort(ldapContext));
@@ -87,7 +87,7 @@ public class LdapPublickeyAuthenticatorTest extends BaseAuthenticatorTest {
ServerSession session = Mockito.mock(ServerSession.class);
outputDebugMessage("%s: %s", getCurrentTestName(), auth);
- for (Map.Entry<String, PublicKey> ke : keysMap.entrySet()) {
+ for (Map.Entry<String, PublicKey> ke : KEYS_MAP.entrySet()) {
String username = ke.getKey();
PublicKey key = ke.getValue();
outputDebugMessage("Authenticate: user=%s, key-type=%s, fingerprint=%s",
[2/5] mina-sshd git commit: [SSHD-655] Apply checkstyle plugin to
test source code as well
Posted by lg...@apache.org.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferTest.java
index d5b2d0f..82b16f2 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferTest.java
@@ -21,8 +21,6 @@ package org.apache.sshd.common.util.buffer;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.util.test.BaseTestSupport;
import org.junit.FixMethodOrder;
import org.junit.Test;
@@ -39,12 +37,12 @@ public class BufferTest extends BaseTestSupport {
long expected = 1234567890123456789L;
try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
- try (DataOutputStream ds = new DataOutputStream(stream)) {
- ds.writeLong(expected);
- }
+ try (DataOutputStream ds = new DataOutputStream(stream)) {
+ ds.writeLong(expected);
+ }
- Buffer buffer = new ByteArrayBuffer(stream.toByteArray());
- assertEquals("Mismatched recovered value", expected, buffer.getLong());
+ Buffer buffer = new ByteArrayBuffer(stream.toByteArray());
+ assertEquals("Mismatched recovered value", expected, buffer.getLong());
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferUtilsTest.java
index 6714202..388ad0f 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/buffer/BufferUtilsTest.java
@@ -53,13 +53,13 @@ public class BufferUtilsTest extends BaseTestSupport {
@Test
public void testGetCompactClone() {
byte[] expected = getCurrentTestName().getBytes(StandardCharsets.UTF_8);
- final int OFFSET = Byte.SIZE / 2;
- byte[] data = new byte[expected.length + 2 * OFFSET];
+ final int testOffset = Byte.SIZE / 2;
+ byte[] data = new byte[expected.length + 2 * testOffset];
Random rnd = new Random(System.nanoTime());
rnd.nextBytes(data);
- System.arraycopy(expected, 0, data, OFFSET, expected.length);
+ System.arraycopy(expected, 0, data, testOffset, expected.length);
- Buffer buf = ByteArrayBuffer.getCompactClone(data, OFFSET, expected.length);
+ Buffer buf = ByteArrayBuffer.getCompactClone(data, testOffset, expected.length);
assertEquals("Mismatched cloned buffer read position", 0, buf.rpos());
assertEquals("Mismatched cloned buffer available size", expected.length, buf.available());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/io/EmptyInputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/EmptyInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/EmptyInputStreamTest.java
index ada47a7..adf23b4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/io/EmptyInputStreamTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/EmptyInputStreamTest.java
@@ -77,7 +77,7 @@ public class EmptyInputStreamTest extends BaseTestSupport {
try {
int data = in.read();
assertFalse(message + ": Unexpected success in read(): " + data, errorExpected);
- assertEquals(message + ": Mismatched read() result", (-1), data);
+ assertEquals(message + ": Mismatched read() result", -1, data);
} catch (IOException e) {
assertTrue(message + ": Unexpected error on read(): " + e.getMessage(), errorExpected);
}
@@ -86,7 +86,7 @@ public class EmptyInputStreamTest extends BaseTestSupport {
try {
int len = in.read(bytes);
assertFalse(message + ": Unexpected success in read([]): " + BufferUtils.toHex(':', bytes), errorExpected);
- assertEquals(message + ": Mismatched read([]) result", (-1), len);
+ assertEquals(message + ": Mismatched read([]) result", -1, len);
} catch (IOException e) {
assertTrue(message + ": Unexpected error on read([]): " + e.getMessage(), errorExpected);
}
@@ -94,7 +94,7 @@ public class EmptyInputStreamTest extends BaseTestSupport {
try {
int len = in.read(bytes, 0, bytes.length);
assertFalse(message + ": Unexpected success in read([],int,int): " + BufferUtils.toHex(':', bytes), errorExpected);
- assertEquals(message + ": Mismatched read([],int,int) result", (-1), len);
+ assertEquals(message + ": Mismatched read([],int,int) result", -1, len);
} catch (IOException e) {
assertTrue(message + ": Unexpected error on read([],int,int): " + e.getMessage(), errorExpected);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
index f4acfc0..b8aa9b5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/ClientUserAuthServiceOld.java
@@ -38,6 +38,7 @@ import org.apache.sshd.deprecated.UserAuth.Result;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
+// CHECKSTYLE:OFF
public class ClientUserAuthServiceOld extends AbstractCloseable implements Service {
public static class Factory implements ServiceFactory {
@@ -205,3 +206,4 @@ public class ClientUserAuthServiceOld extends AbstractCloseable implements Servi
}
}
+// CHECKSTYLE:ON
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java
index 5d26ab0..bffbe62 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthAgent.java
@@ -35,6 +35,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
/**
* Authentication delegating to an SSH agent
*/
+// CHECKSTYLE:OFF
public class UserAuthAgent extends AbstractUserAuth {
private final SshAgent agent;
@@ -126,3 +127,4 @@ public class UserAuthAgent extends AbstractUserAuth {
}
}
}
+// CHECKSTYLE:ON
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
index 8b62602..bfa6a1d 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthKeyboardInteractive.java
@@ -32,6 +32,7 @@ import org.apache.sshd.common.util.buffer.Buffer;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
* @author <a href="mailto:j.kapitza@schwarze-allianz.de">Jens Kapitza</a>
*/
+// CHECKSTYLE:OFF
public class UserAuthKeyboardInteractive extends AbstractUserAuth {
private final String password;
@@ -117,5 +118,5 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
}
}
}
-
-}
\ No newline at end of file
+}
+// CHECKSTYLE:ON
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPassword.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPassword.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPassword.java
index accdb1a..df420b8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPassword.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPassword.java
@@ -30,6 +30,7 @@ import org.apache.sshd.common.util.buffer.Buffer;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
+// CHECKSTYLE:OFF
public class UserAuthPassword extends AbstractUserAuth {
private final String password;
@@ -76,3 +77,4 @@ public class UserAuthPassword extends AbstractUserAuth {
}
}
+// CHECKSTYLE:ON
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java
index 3c1ddca..1f9be26 100644
--- a/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java
+++ b/sshd-core/src/test/java/org/apache/sshd/deprecated/UserAuthPublicKey.java
@@ -36,6 +36,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
+// CHECKSTYLE:OFF
public class UserAuthPublicKey extends AbstractUserAuth {
private final KeyPair key;
@@ -111,3 +112,4 @@ public class UserAuthPublicKey extends AbstractUserAuth {
}
}
}
+// CHECKSTYLE:ON
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/PublickeyAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/PublickeyAuthenticatorTest.java b/sshd-core/src/test/java/org/apache/sshd/server/PublickeyAuthenticatorTest.java
index 88767ec..813f5a3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/PublickeyAuthenticatorTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/PublickeyAuthenticatorTest.java
@@ -67,9 +67,9 @@ public class PublickeyAuthenticatorTest extends BaseTestSupport {
Mockito.when(key.getPublicExponent()).thenReturn(BigInteger.ONE);
ServerSession session = Mockito.mock(ServerSession.class);
- Object[] invArgs = new Object[] { null /* username */, null /* key */, null /* server session */ };
+ Object[] invArgs = new Object[] {null /* username */, null /* key */, null /* server session */};
boolean expected = authenticator.isAccepted();
- boolean[] flags = new boolean[] { false, true };
+ boolean[] flags = new boolean[] {false, true};
for (boolean useUsername : flags) {
invArgs[0] = useUsername ? getCurrentTestName() : null;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/ServerMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerMain.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerMain.java
deleted file mode 100644
index d8af833..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerMain.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.server;
-
-/**
- * An activator for the {@link SshServer#main(String[])} - the reason it is
- * here is because the logging configuration is available only for test scope
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class ServerMain {
- public static void main(String[] args) throws Throwable {
- SshServer.main(args);
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/ServerSessionListenerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerSessionListenerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerSessionListenerTest.java
index 2187f92..8357be5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerSessionListenerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerSessionListenerTest.java
@@ -131,7 +131,8 @@ public class ServerSessionListenerTest extends BaseTestSupport {
int curCount = 0;
for (int retryCount = 0; retryCount < Byte.SIZE; retryCount++) {
synchronized (eventsMap) {
- if ((curCount = eventsMap.size()) >= 3) {
+ curCount = eventsMap.size();
+ if (curCount >= 3) {
return;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index b125de9..7b86595 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -57,6 +57,7 @@ import org.apache.sshd.common.auth.UserAuthMethodFactory;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.channel.ChannelListener;
import org.apache.sshd.common.channel.TestChannelListener;
+import org.apache.sshd.common.channel.Window;
import org.apache.sshd.common.channel.WindowClosedException;
import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.kex.KexProposalOption;
@@ -124,8 +125,8 @@ public class ServerTest extends BaseTestSupport {
*/
@Test
public void testFailAuthenticationWithWaitFor() throws Exception {
- final int MAX_AUTH_REQUESTS = 10;
- PropertyResolverUtils.updateProperty(sshd, ServerAuthenticationManager.MAX_AUTH_REQUESTS, MAX_AUTH_REQUESTS);
+ final int maxAllowedAuths = 10;
+ PropertyResolverUtils.updateProperty(sshd, ServerAuthenticationManager.MAX_AUTH_REQUESTS, maxAllowedAuths);
sshd.start();
client.setServiceFactories(Arrays.asList(
@@ -146,7 +147,7 @@ public class ServerTest extends BaseTestSupport {
res = s.waitFor(mask, TimeUnit.SECONDS.toMillis(5L));
assertFalse("Timeout signalled", res.contains(ClientSession.ClientSessionEvent.TIMEOUT));
}
- assertTrue("Number trials (" + nbTrials + ") below min.=" + MAX_AUTH_REQUESTS, nbTrials > MAX_AUTH_REQUESTS);
+ assertTrue("Number trials (" + nbTrials + ") below min.=" + maxAllowedAuths, nbTrials > maxAllowedAuths);
} finally {
client.stop();
}
@@ -154,8 +155,8 @@ public class ServerTest extends BaseTestSupport {
@Test
public void testFailAuthenticationWithFuture() throws Exception {
- final int MAX_AUTH_REQUESTS = 10;
- PropertyResolverUtils.updateProperty(sshd, ServerAuthenticationManager.MAX_AUTH_REQUESTS, MAX_AUTH_REQUESTS);
+ final int maxAllowedAuths = 10;
+ PropertyResolverUtils.updateProperty(sshd, ServerAuthenticationManager.MAX_AUTH_REQUESTS, maxAllowedAuths);
sshd.start();
@@ -179,7 +180,7 @@ public class ServerTest extends BaseTestSupport {
Throwable t = authFuture.getException();
assertNotNull("Missing auth future exception", t);
- assertTrue("Number trials (" + nbTrials + ") below min.=" + MAX_AUTH_REQUESTS, nbTrials > MAX_AUTH_REQUESTS);
+ assertTrue("Number trials (" + nbTrials + ") below min.=" + maxAllowedAuths, nbTrials > maxAllowedAuths);
} finally {
client.stop();
}
@@ -187,13 +188,13 @@ public class ServerTest extends BaseTestSupport {
@Test
public void testAuthenticationTimeout() throws Exception {
- final long AUTH_TIMEOUT = TimeUnit.SECONDS.toMillis(5L);
- PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, AUTH_TIMEOUT);
+ final long testAuthTimeout = TimeUnit.SECONDS.toMillis(5L);
+ PropertyResolverUtils.updateProperty(sshd, FactoryManager.AUTH_TIMEOUT, testAuthTimeout);
sshd.start();
client.start();
try (ClientSession s = client.connect(getCurrentTestName(), TEST_LOCALHOST, sshd.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) {
- Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * AUTH_TIMEOUT);
+ Collection<ClientSession.ClientSessionEvent> res = s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testAuthTimeout);
assertTrue("Session should be closed: " + res,
res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.WAIT_AUTH)));
} finally {
@@ -205,8 +206,8 @@ public class ServerTest extends BaseTestSupport {
public void testIdleTimeout() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
TestEchoShell.latch = new CountDownLatch(1);
- final long IDLE_TIMEOUT = 2500;
- PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, IDLE_TIMEOUT);
+ final long testIdleTimeout = 2500L;
+ PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, testIdleTimeout);
sshd.addSessionListener(new SessionListener() {
@Override
@@ -250,7 +251,7 @@ public class ServerTest extends BaseTestSupport {
assertTrue("No open server side channels", GenericUtils.size(channelListener.getOpenChannels()) > 0);
Collection<ClientSession.ClientSessionEvent> res =
- s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * IDLE_TIMEOUT);
+ s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testIdleTimeout);
assertTrue("Session should be closed and authenticated: " + res,
res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED)));
} finally {
@@ -274,11 +275,11 @@ public class ServerTest extends BaseTestSupport {
sshd.setCommandFactory(new StreamCommand.Factory());
- final long IDLE_TIMEOUT_VALUE = TimeUnit.SECONDS.toMillis(5L);
- PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, IDLE_TIMEOUT_VALUE);
+ final long idleTimeoutValue = TimeUnit.SECONDS.toMillis(5L);
+ PropertyResolverUtils.updateProperty(sshd, FactoryManager.IDLE_TIMEOUT, idleTimeoutValue);
- final long DISCONNECT_TIMEOUT_VALUE = TimeUnit.SECONDS.toMillis(2L);
- PropertyResolverUtils.updateProperty(sshd, FactoryManager.DISCONNECT_TIMEOUT, DISCONNECT_TIMEOUT_VALUE);
+ final long disconnectTimeoutValue = TimeUnit.SECONDS.toMillis(2L);
+ PropertyResolverUtils.updateProperty(sshd, FactoryManager.DISCONNECT_TIMEOUT, disconnectTimeoutValue);
sshd.addSessionListener(new SessionListener() {
@Override
@@ -327,24 +328,27 @@ public class ServerTest extends BaseTestSupport {
Collection<? extends Channel> channels = service.getChannels();
try (Channel channel = channels.iterator().next()) {
- final long MAX_TIMEOUT_VALUE = IDLE_TIMEOUT_VALUE + DISCONNECT_TIMEOUT_VALUE + TimeUnit.SECONDS.toMillis(3L);
- for (long totalNanoTime = 0L; channel.getRemoteWindow().getSize() > 0; ) {
+ final long maxTimeoutValue = idleTimeoutValue + disconnectTimeoutValue + TimeUnit.SECONDS.toMillis(3L);
+ final long maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxTimeoutValue);
+ Window wRemote = channel.getRemoteWindow();
+ for (long totalNanoTime = 0L; wRemote.getSize() > 0;) {
long nanoStart = System.nanoTime();
Thread.sleep(1L);
long nanoEnd = System.nanoTime();
long nanoDuration = nanoEnd - nanoStart;
totalNanoTime += nanoDuration;
- assertTrue("Waiting for too long on remote window size to reach zero", totalNanoTime < TimeUnit.MILLISECONDS.toNanos(MAX_TIMEOUT_VALUE));
+ assertTrue("Waiting for too long on remote window size to reach zero", totalNanoTime < maxWaitNanos);
}
LoggerFactory.getLogger(getClass()).info("Waiting for session idle timeouts");
long t0 = System.currentTimeMillis();
- latch.await(1, TimeUnit.MINUTES);
- long t1 = System.currentTimeMillis(), diff = t1 - t0;
- assertTrue("Wait time too low: " + diff, diff > IDLE_TIMEOUT_VALUE);
- assertTrue("Wait time too high: " + diff, diff < MAX_TIMEOUT_VALUE);
+ latch.await(1L, TimeUnit.MINUTES);
+ long t1 = System.currentTimeMillis();
+ long diff = t1 - t0;
+ assertTrue("Wait time too low: " + diff, diff > idleTimeoutValue);
+ assertTrue("Wait time too high: " + diff, diff < maxTimeoutValue);
}
}
} finally {
@@ -381,7 +385,9 @@ public class ServerTest extends BaseTestSupport {
@Override
public void sessionEvent(Session session, Event event) {
if (Event.KeyEstablished.equals(event)) {
- for (KexProposalOption option : new KexProposalOption[]{ KexProposalOption.S2CLANG, KexProposalOption.C2SLANG}) {
+ for (KexProposalOption option : new KexProposalOption[]{
+ KexProposalOption.S2CLANG, KexProposalOption.C2SLANG
+ }) {
assertNull("Unexpected negotiated language for " + option, session.getNegotiatedKexParameter(option));
}
@@ -734,7 +740,9 @@ public class ServerTest extends BaseTestSupport {
Map<String, String> vars = cmdEnv.getEnv();
assertTrue("Mismatched vars count", GenericUtils.size(vars) >= GenericUtils.size(expected));
for (Map.Entry<String, String> ee : expected.entrySet()) {
- String key = ee.getKey(), expValue = ee.getValue(), actValue = vars.get(key);
+ String key = ee.getKey();
+ String expValue = ee.getValue();
+ String actValue = vars.get(key);
assertEquals("Mismatched value for " + key, expValue, actValue);
}
}
@@ -759,7 +767,8 @@ public class ServerTest extends BaseTestSupport {
});
sshd.start();
- String authMethods = GenericUtils.join( // order is important
+ // order is important
+ String authMethods = GenericUtils.join(
Arrays.asList(UserAuthMethodFactory.KB_INTERACTIVE, UserAuthMethodFactory.PUBLIC_KEY, UserAuthMethodFactory.PUBLIC_KEY), ',');
PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PREFERRED_AUTHS, authMethods);
@@ -800,11 +809,12 @@ public class ServerTest extends BaseTestSupport {
});
sshd.start();
- String authMethods = GenericUtils.join( // order is important
+ // order is important
+ String authMethods = GenericUtils.join(
Arrays.asList(UserAuthMethodFactory.KB_INTERACTIVE, UserAuthMethodFactory.PUBLIC_KEY, UserAuthMethodFactory.PUBLIC_KEY), ',');
PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PREFERRED_AUTHS, authMethods);
final AtomicInteger clientCount = new AtomicInteger(0);
- final String[] replies = { getCurrentTestName() };
+ final String[] replies = {getCurrentTestName()};
client.setUserInteraction(new UserInteraction() {
@Override
public void welcome(ClientSession session, String banner, String lang) {
@@ -868,8 +878,9 @@ public class ServerTest extends BaseTestSupport {
}
public static class TestEchoShell extends EchoShell {
-
+ // CHECKSTYLE:OFF
public static CountDownLatch latch;
+ // CHECKSTYLE:ON
public TestEchoShell() {
super();
@@ -885,6 +896,9 @@ public class ServerTest extends BaseTestSupport {
}
public static class StreamCommand implements Command, Runnable {
+ // CHECKSTYLE:OFF
+ public static CountDownLatch latch;
+ // CHECKSTYLE:ON
public static class Factory implements CommandFactory {
@Override
@@ -893,8 +907,6 @@ public class ServerTest extends BaseTestSupport {
}
}
- public static CountDownLatch latch;
-
private final String name;
private OutputStream out;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/SshServerMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/SshServerMain.java b/sshd-core/src/test/java/org/apache/sshd/server/SshServerMain.java
index ef4e231..d4f3c60 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/SshServerMain.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/SshServerMain.java
@@ -25,7 +25,11 @@ package org.apache.sshd.server;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SshServerMain {
+public final class SshServerMain {
+ private SshServerMain() {
+ throw new UnsupportedOperationException("No instance");
+ }
+
public static void main(String[] args) throws Exception {
SshServer.main(args);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/channel/ChannelSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/channel/ChannelSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/server/channel/ChannelSessionTest.java
index a000104..13ce2a9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/channel/ChannelSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/channel/ChannelSessionTest.java
@@ -53,7 +53,7 @@ public class ChannelSessionTest extends BaseTestSupport {
try (ChannelSession channelSession = new ChannelSession() {
{
Window wRemote = getRemoteWindow();
- wRemote.init(PropertyResolverUtils.toPropertyResolver(Collections.<String,Object>emptyMap()));
+ wRemote.init(PropertyResolverUtils.toPropertyResolver(Collections.<String, Object>emptyMap()));
}
}) {
final AtomicBoolean expanded = new AtomicBoolean(false);
@@ -75,7 +75,7 @@ public class ChannelSessionTest extends BaseTestSupport {
try (ChannelSession session = new ChannelSession() {
{
Window wRemote = getRemoteWindow();
- wRemote.init(PropertyResolverUtils.toPropertyResolver(Collections.<String,Object>emptyMap()));
+ wRemote.init(PropertyResolverUtils.toPropertyResolver(Collections.<String, Object>emptyMap()));
}
}) {
session.addCloseFutureListener(new SshFutureListener<CloseFuture>() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/command/ScpCommandFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/command/ScpCommandFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/server/command/ScpCommandFactoryTest.java
index 5bcc437..0143790 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/command/ScpCommandFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/command/ScpCommandFactoryTest.java
@@ -60,7 +60,8 @@ public class ScpCommandFactoryTest extends BaseTestSupport {
public void testBuilderCorrectlyInitializesFactory() {
CommandFactory delegate = dummyFactory();
ExecutorService service = dummyExecutor();
- int receiveSize = Short.MAX_VALUE, sendSize = receiveSize + Long.SIZE;
+ int receiveSize = Short.MAX_VALUE;
+ int sendSize = receiveSize + Long.SIZE;
ScpCommandFactory factory = new ScpCommandFactory.Builder()
.withDelegate(delegate)
.withExecutorService(service)
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticatorTest.java b/sshd-core/src/test/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticatorTest.java
index 33d895e..5ba159c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticatorTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/config/keys/AuthorizedKeysAuthenticatorTest.java
@@ -71,13 +71,12 @@ public class AuthorizedKeysAuthenticatorTest extends AuthorizedKeysTestSupport {
List<String> keyLines = loadDefaultSupportedKeys();
assertHierarchyTargetFolderExists(file.getParent());
- while(keyLines.size() > 0) {
+ while (keyLines.size() > 0) {
try (Writer w = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) {
w.append(PublicKeyEntry.COMMENT_CHAR)
- .append(' ').append(getCurrentTestName())
- .append(' ').append(String.valueOf(keyLines.size())).append(" remaining keys")
- .append(IoUtils.EOL)
- ;
+ .append(' ').append(getCurrentTestName())
+ .append(' ').append(String.valueOf(keyLines.size())).append(" remaining keys")
+ .append(IoUtils.EOL);
for (String l : keyLines) {
w.append(l).append(IoUtils.EOL);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticatorTest.java b/sshd-core/src/test/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticatorTest.java
index 8e45310..3ac6e28 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticatorTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/jaas/JaasPasswordAuthenticatorTest.java
@@ -18,6 +18,10 @@
*/
package org.apache.sshd.server.jaas;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
@@ -28,9 +32,6 @@ import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import org.apache.sshd.util.test.BaseTestSupport;
import org.junit.After;
@@ -46,6 +47,9 @@ import org.junit.runners.MethodSorters;
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class JaasPasswordAuthenticatorTest extends BaseTestSupport {
+ public JaasPasswordAuthenticatorTest() {
+ super();
+ }
@Before
public void setUp() {
@@ -53,9 +57,9 @@ public class JaasPasswordAuthenticatorTest extends BaseTestSupport {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[]{
- new AppConfigurationEntry(DummyLoginModule.class.getName(),
- AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
- new HashMap<String, Object>())
+ new AppConfigurationEntry(DummyLoginModule.class.getName(),
+ AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+ new HashMap<String, Object>())
};
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProviderTest.java
index 873c17c..96ddfc6 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/AbstractGeneratorHostKeyProviderTest.java
@@ -54,7 +54,7 @@ public class AbstractGeneratorHostKeyProviderTest extends BaseTestSupport {
assertEquals("Mismatched load write count", 0, provider.getWriteCount());
}
- private static class TestProvider extends AbstractGeneratorHostKeyProvider {
+ private static final class TestProvider extends AbstractGeneratorHostKeyProvider {
private final AtomicInteger writes = new AtomicInteger(0);
private TestProvider(File file) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/PEMGeneratorHostKeyProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/PEMGeneratorHostKeyProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/PEMGeneratorHostKeyProviderTest.java
index 4a84c6b..815b545 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/PEMGeneratorHostKeyProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/PEMGeneratorHostKeyProviderTest.java
@@ -60,21 +60,21 @@ public class PEMGeneratorHostKeyProviderTest extends BaseTestSupport {
}
@Test
- public void testEC_NISTP256() throws IOException {
+ public void testECnistp256() throws IOException {
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
Assume.assumeTrue("ECC not supported", SecurityUtils.hasEcc());
testPEMGeneratorHostKeyProvider("EC", KeyPairProvider.ECDSA_SHA2_NISTP256, -1, new ECGenParameterSpec("prime256v1"));
}
@Test
- public void testEC_NISTP384() throws IOException {
+ public void testECnistp384() throws IOException {
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
Assume.assumeTrue("ECC not supported", SecurityUtils.hasEcc());
testPEMGeneratorHostKeyProvider("EC", KeyPairProvider.ECDSA_SHA2_NISTP384, -1, new ECGenParameterSpec("P-384"));
}
@Test
- public void testEC_NISTP521() throws IOException {
+ public void testECnistp521() throws IOException {
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
Assume.assumeTrue("ECC not supported", SecurityUtils.hasEcc());
testPEMGeneratorHostKeyProvider("EC", KeyPairProvider.ECDSA_SHA2_NISTP521, -1, new ECGenParameterSpec("P-521"));
@@ -86,7 +86,8 @@ public class PEMGeneratorHostKeyProviderTest extends BaseTestSupport {
assertTrue("Key file not generated: " + path, Files.exists(path, IoUtils.EMPTY_LINK_OPTIONS));
KeyPair kpRead = invokePEMGeneratorHostKeyProvider(path, algorithm, keyType, keySize, keySpec);
- PublicKey pubWrite = kpWrite.getPublic(), pubRead = kpRead.getPublic();
+ PublicKey pubWrite = kpWrite.getPublic();
+ PublicKey pubRead = kpRead.getPublic();
if (pubWrite instanceof ECPublicKey) {
// The algorithm is reported as ECDSA instead of EC
assertECPublicKeyEquals("Mismatched EC public key", ECPublicKey.class.cast(pubWrite), ECPublicKey.class.cast(pubRead));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/SimpleGeneratorHostKeyProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/SimpleGeneratorHostKeyProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/SimpleGeneratorHostKeyProviderTest.java
index a66959a..8897c97 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/SimpleGeneratorHostKeyProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/keyprovider/SimpleGeneratorHostKeyProviderTest.java
@@ -56,19 +56,19 @@ public class SimpleGeneratorHostKeyProviderTest extends BaseTestSupport {
}
@Test
- public void testEC_NISTP256() throws IOException {
+ public void testECnistp256() throws IOException {
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
testSimpleGeneratorHostKeyProvider("EC", KeyPairProvider.ECDSA_SHA2_NISTP256, -1, new ECGenParameterSpec("prime256v1"));
}
@Test
- public void testEC_NISTP384() throws IOException {
+ public void testECnistp384() throws IOException {
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
testSimpleGeneratorHostKeyProvider("EC", KeyPairProvider.ECDSA_SHA2_NISTP384, -1, new ECGenParameterSpec("P-384"));
}
@Test
- public void testEC_NISTP521() throws IOException {
+ public void testECnistp521() throws IOException {
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
testSimpleGeneratorHostKeyProvider("EC", KeyPairProvider.ECDSA_SHA2_NISTP521, -1, new ECGenParameterSpec("P-521"));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/shell/InvertedShellWrapperTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/InvertedShellWrapperTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/InvertedShellWrapperTest.java
index 1746d38..2a627fd 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/shell/InvertedShellWrapperTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/InvertedShellWrapperTest.java
@@ -76,7 +76,7 @@ public class InvertedShellWrapperTest extends BaseTestSupport {
final BogusInvertedShell bogusShell = newShell("out", "err");
bogusShell.setAlive(false);
- final int DESTROYED_EXIT_VALUE = 7365;
+ final int destroyedExitValue = 7365;
InvertedShell shell = new InvertedShell() {
private boolean destroyed;
@@ -112,7 +112,7 @@ public class InvertedShellWrapperTest extends BaseTestSupport {
@Override
public int exitValue() {
- return destroyed ? DESTROYED_EXIT_VALUE : bogusShell.exitValue();
+ return destroyed ? destroyedExitValue : bogusShell.exitValue();
}
@Override
@@ -126,22 +126,22 @@ public class InvertedShellWrapperTest extends BaseTestSupport {
try (ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
InputStream stdin = new InputStream() {
- private final byte[] data = getCurrentTestName().getBytes(StandardCharsets.UTF_8);
- private int readPos;
-
- @Override
- public int read() throws IOException {
- if (readPos >= data.length) {
- throw new EOFException("Data exhausted");
- }
-
- return data[readPos++];
- }
-
- @Override
- public int available() throws IOException {
- return data.length;
- }
+ private final byte[] data = getCurrentTestName().getBytes(StandardCharsets.UTF_8);
+ private int readPos;
+
+ @Override
+ public int read() throws IOException {
+ if (readPos >= data.length) {
+ throw new EOFException("Data exhausted");
+ }
+
+ return data[readPos++];
+ }
+
+ @Override
+ public int available() throws IOException {
+ return data.length;
+ }
}) {
BogusExitCallback exitCallback = new BogusExitCallback();
@@ -159,22 +159,22 @@ public class InvertedShellWrapperTest extends BaseTestSupport {
wrapper.destroy();
}
- assertEquals("Mismatched exit value", DESTROYED_EXIT_VALUE, exitCallback.getExitValue());
+ assertEquals("Mismatched exit value", destroyedExitValue, exitCallback.getExitValue());
assertEquals("Mismatched exit message", EOFException.class.getSimpleName(), exitCallback.getExitMessage());
}
}
@Test // see SSHD-576
public void testShellDiesBeforeAllDataExhausted() throws Exception {
- final String IN_CONTENT = "shellInput";
- final String OUT_CONTENT = "shellOutput";
- final String ERR_CONTENT = "shellError";
- try (final InputStream stdin = newDelayedInputStream(Long.SIZE, IN_CONTENT);
+ final String inputContent = "shellInput";
+ final String outputContent = "shellOutput";
+ final String errorContent = "shellError";
+ try (final InputStream stdin = newDelayedInputStream(Long.SIZE, inputContent);
final ByteArrayOutputStream shellIn = new ByteArrayOutputStream(Byte.MAX_VALUE);
- final InputStream shellOut = newDelayedInputStream(Byte.SIZE, OUT_CONTENT);
- ByteArrayOutputStream stdout = new ByteArrayOutputStream(OUT_CONTENT.length() + Byte.SIZE);
- final InputStream shellErr = newDelayedInputStream(Short.SIZE, ERR_CONTENT);
- ByteArrayOutputStream stderr = new ByteArrayOutputStream(ERR_CONTENT.length() + Byte.SIZE)) {
+ final InputStream shellOut = newDelayedInputStream(Byte.SIZE, outputContent);
+ ByteArrayOutputStream stdout = new ByteArrayOutputStream(outputContent.length() + Byte.SIZE);
+ final InputStream shellErr = newDelayedInputStream(Short.SIZE, errorContent);
+ ByteArrayOutputStream stderr = new ByteArrayOutputStream(errorContent.length() + Byte.SIZE)) {
InvertedShell shell = new InvertedShell() {
@Override
@@ -233,9 +233,9 @@ public class InvertedShellWrapperTest extends BaseTestSupport {
wrapper.destroy();
}
- assertEquals("Mismatched STDIN value", IN_CONTENT, shellIn.toString(StandardCharsets.UTF_8.name()));
- assertEquals("Mismatched STDOUT value", OUT_CONTENT, stdout.toString(StandardCharsets.UTF_8.name()));
- assertEquals("Mismatched STDERR value", ERR_CONTENT, stderr.toString(StandardCharsets.UTF_8.name()));
+ assertEquals("Mismatched STDIN value", inputContent, shellIn.toString(StandardCharsets.UTF_8.name()));
+ assertEquals("Mismatched STDOUT value", outputContent, stdout.toString(StandardCharsets.UTF_8.name()));
+ assertEquals("Mismatched STDERR value", errorContent, stderr.toString(StandardCharsets.UTF_8.name()));
}
}
@@ -245,7 +245,7 @@ public class InvertedShellWrapperTest extends BaseTestSupport {
private static InputStream newDelayedInputStream(final int callsCount, byte ... data) {
return new ByteArrayInputStream(data) {
- private int delayCount = 0;
+ private int delayCount;
@Override
public synchronized int read() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
index b234f72..e15aa44 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterOutputStreamTest.java
@@ -68,18 +68,19 @@ public class TtyFilterOutputStreamTest extends BaseTestSupport {
final AtomicInteger crCount = new AtomicInteger(0);
final AtomicInteger lfCount = new AtomicInteger(0);
try (OutputStream output = new OutputStream() {
- @Override
- public void write(int b) throws IOException {
- if (b == '\r') {
- crCount.incrementAndGet();
- } else if (b == '\n') {
- lfCount.incrementAndGet();
- }
+ @Override
+ public void write(int b) throws IOException {
+ if (b == '\r') {
+ crCount.incrementAndGet();
+ } else if (b == '\n') {
+ lfCount.incrementAndGet();
}
- };
- TtyFilterOutputStream ttyOut = new TtyFilterOutputStream(
- output, null, PtyMode.ECHO.equals(mode) ? Collections.<PtyMode>emptySet(): EnumSet.of(mode));
- Writer writer = new OutputStreamWriter(ttyOut, StandardCharsets.UTF_8)) {
+ }
+ };
+ TtyFilterOutputStream ttyOut = new TtyFilterOutputStream(
+ output, null, PtyMode.ECHO.equals(mode) ? Collections.<PtyMode>emptySet() : EnumSet.of(mode));
+ Writer writer = new OutputStreamWriter(ttyOut, StandardCharsets.UTF_8)) {
+
for (String l : lines) {
writer.append(l).append("\r\n");
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java b/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java
index 1b4127f..35cfece 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/subsystem/sftp/SshFsMounter.java
@@ -62,13 +62,15 @@ import org.apache.sshd.util.test.Utils;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SshFsMounter {
+public final class SshFsMounter {
public static class MounterCommand extends AbstractLoggingBean implements Command, SessionAware, Runnable {
- private final String command, cmdName;
+ private final String command;
+ private final String cmdName;
private final List<String> args;
private String username;
private InputStream stdin;
- private PrintStream stdout, stderr;
+ private PrintStream stdout;
+ private PrintStream stderr;
private ExitCallback callback;
private ExecutorService executor;
private Future<?> future;
@@ -123,7 +125,7 @@ public class SshFsMounter {
} catch (Exception e) {
log.error("run(" + username + ")[" + command + "] " + e.getClass().getSimpleName() + ": " + e.getMessage(), e);
stderr.append(e.getClass().getSimpleName()).append(": ").println(e.getMessage());
- callback.onExit((-1), e.toString());
+ callback.onExit(-1, e.toString());
}
}
@@ -234,6 +236,12 @@ public class SshFsMounter {
}
}
+ private SshFsMounter() {
+ throw new UnsupportedOperationException("No instance");
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+
public static void main(String[] args) throws Exception {
int port = SshConfigFileReader.DEFAULT_PORT;
boolean error = false;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
index d1478e8..9c04133 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
@@ -59,7 +59,7 @@ import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
/**
- * TODO Add javadoc
+ * Helper used as base class for all test classes
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@@ -68,6 +68,9 @@ public abstract class BaseTestSupport extends Assert {
// can be used to override the 'localhost' with an address other than 127.0.0.1 in case it is required
public static final String TEST_LOCALHOST = System.getProperty("org.apache.sshd.test.localhost", SshdSocketAddress.LOCALHOST_IP);
public static final boolean OUTPUT_DEBUG_MESSAGES = Boolean.parseBoolean(System.getProperty("org.apache.sshd.test.outputDebugMessages", "false"));
+ public static final String MAIN_SUBFOLDER = "main";
+ public static final String TEST_SUBFOLDER = "test";
+ public static final String RESOURCES_SUBFOLDER = "resources";
// useful test sizes for keys
@SuppressWarnings("boxing")
@@ -97,7 +100,7 @@ public abstract class BaseTestSupport extends Assert {
};
@Rule
- public final TestName TEST_NAME_HOLDER = new TestName();
+ public final TestName testNameHilder = new TestName();
private Path targetFolder;
private Path tempFolder;
@@ -106,7 +109,7 @@ public abstract class BaseTestSupport extends Assert {
}
public final String getCurrentTestName() {
- return TEST_NAME_HOLDER.getMethodName();
+ return testNameHilder.getMethodName();
}
protected SshServer setupTestServer() {
@@ -154,7 +157,7 @@ public abstract class BaseTestSupport extends Assert {
* associated with the project - never {@code null}
*/
protected Path getTempTargetFolder() {
- synchronized(TEMP_SUBFOLDER_NAME) {
+ synchronized (TEMP_SUBFOLDER_NAME) {
if (tempFolder == null) {
tempFolder = ValidateUtils.checkNotNull(detectTargetFolder(), "No target folder detected").resolve(TEMP_SUBFOLDER_NAME);
}
@@ -210,9 +213,6 @@ public abstract class BaseTestSupport extends Assert {
return parent.resolve("src");
}
- public static final String MAIN_SUBFOLDER = "main", TEST_SUBFOLDER = "test";
- public static final String RESOURCES_SUBFOLDER = "resources";
-
protected Path getClassResourcesFolder(String resType /* test or main */) {
return getClassResourcesFolder(resType, getClass());
}
@@ -300,7 +300,8 @@ public abstract class BaseTestSupport extends Assert {
for (int index = 0; expected.hasNext(); index++) {
assertTrue(message + "[next actual index=" + index + "]", actual.hasNext());
- T expValue = expected.next(), actValue = actual.next();
+ T expValue = expected.next();
+ T actValue = actual.next();
assertEquals(message + "[iterator index=" + index + "]", expValue, actValue);
}
@@ -338,11 +339,13 @@ public abstract class BaseTestSupport extends Assert {
}
public static <E> void assertListEquals(String message, List<? extends E> expected, List<? extends E> actual) {
- int expSize = GenericUtils.size(expected), actSize = GenericUtils.size(actual);
+ int expSize = GenericUtils.size(expected);
+ int actSize = GenericUtils.size(actual);
assertEquals(message + "[size]", expSize, actSize);
for (int index = 0; index < expSize; index++) {
- E expValue = expected.get(index), actValue = actual.get(index);
+ E expValue = expected.get(index);
+ E actValue = actual.get(index);
assertEquals(message + "[" + index + "]", expValue, actValue);
}
}
@@ -366,7 +369,7 @@ public abstract class BaseTestSupport extends Assert {
assertKeyEquals(message + "[private]", expected.getPrivate(), actual.getPrivate());
}
- public static final <T extends Key> void assertKeyEquals(String message, T expected, T actual) {
+ public static <T extends Key> void assertKeyEquals(String message, T expected, T actual) {
if (expected == actual) {
return;
}
@@ -387,7 +390,7 @@ public abstract class BaseTestSupport extends Assert {
assertArrayEquals(message + "[encdoded-data]", expected.getEncoded(), actual.getEncoded());
}
- public static final void assertRSAPublicKeyEquals(String message, RSAPublicKey expected, RSAPublicKey actual) {
+ public static void assertRSAPublicKeyEquals(String message, RSAPublicKey expected, RSAPublicKey actual) {
if (expected == actual) {
return;
}
@@ -396,7 +399,7 @@ public abstract class BaseTestSupport extends Assert {
assertEquals(message + "[n]", expected.getModulus(), actual.getModulus());
}
- public static final void assertDSAPublicKeyEquals(String message, DSAPublicKey expected, DSAPublicKey actual) {
+ public static void assertDSAPublicKeyEquals(String message, DSAPublicKey expected, DSAPublicKey actual) {
if (expected == actual) {
return;
}
@@ -405,7 +408,7 @@ public abstract class BaseTestSupport extends Assert {
assertDSAParamsEquals(message + "[params]", expected.getParams(), actual.getParams());
}
- public static final void assertECPublicKeyEquals(String message, ECPublicKey expected, ECPublicKey actual) {
+ public static void assertECPublicKeyEquals(String message, ECPublicKey expected, ECPublicKey actual) {
if (expected == actual) {
return;
}
@@ -414,7 +417,7 @@ public abstract class BaseTestSupport extends Assert {
assertECParameterSpecEquals(message, expected, actual);
}
- public static final void assertRSAPrivateKeyEquals(String message, RSAPrivateKey expected, RSAPrivateKey actual) {
+ public static void assertRSAPrivateKeyEquals(String message, RSAPrivateKey expected, RSAPrivateKey actual) {
if (expected == actual) {
return;
}
@@ -423,7 +426,7 @@ public abstract class BaseTestSupport extends Assert {
assertEquals(message + "[n]", expected.getModulus(), actual.getModulus());
}
- public static final void assertDSAPrivateKeyEquals(String message, DSAPrivateKey expected, DSAPrivateKey actual) {
+ public static void assertDSAPrivateKeyEquals(String message, DSAPrivateKey expected, DSAPrivateKey actual) {
if (expected == actual) {
return;
}
@@ -432,7 +435,7 @@ public abstract class BaseTestSupport extends Assert {
assertDSAParamsEquals(message + "[params]", expected.getParams(), actual.getParams());
}
- public static final void assertDSAParamsEquals(String message, DSAParams expected, DSAParams actual) {
+ public static void assertDSAParamsEquals(String message, DSAParams expected, DSAParams actual) {
if (expected == actual) {
return;
}
@@ -442,7 +445,7 @@ public abstract class BaseTestSupport extends Assert {
assertEquals(message + "[q]", expected.getQ(), actual.getQ());
}
- public static final void assertECPrivateKeyEquals(String message, ECPrivateKey expected, ECPrivateKey actual) {
+ public static void assertECPrivateKeyEquals(String message, ECPrivateKey expected, ECPrivateKey actual) {
if (expected == actual) {
return;
}
@@ -451,14 +454,14 @@ public abstract class BaseTestSupport extends Assert {
assertECParameterSpecEquals(message, expected, actual);
}
- public static final void assertECParameterSpecEquals(String message, ECKey expected, ECKey actual) {
+ public static void assertECParameterSpecEquals(String message, ECKey expected, ECKey actual) {
if (expected == actual) {
return;
}
assertECParameterSpecEquals(message, expected.getParams(), actual.getParams());
}
- public static final void assertECParameterSpecEquals(String message, ECParameterSpec expected, ECParameterSpec actual) {
+ public static void assertECParameterSpecEquals(String message, ECParameterSpec expected, ECParameterSpec actual) {
if (expected == actual) {
return;
}
@@ -469,7 +472,7 @@ public abstract class BaseTestSupport extends Assert {
assertCurveEquals(message + "[curve]", expected.getCurve(), actual.getCurve());
}
- public static final void assertCurveEquals(String message, EllipticCurve expected, EllipticCurve actual) {
+ public static void assertCurveEquals(String message, EllipticCurve expected, EllipticCurve actual) {
if (expected == actual) {
return;
}
@@ -480,7 +483,7 @@ public abstract class BaseTestSupport extends Assert {
assertECFieldEquals(message + "[field]", expected.getField(), actual.getField());
}
- public static final void assertECFieldEquals(String message, ECField expected, ECField actual) {
+ public static void assertECFieldEquals(String message, ECField expected, ECField actual) {
if (expected == actual) {
return;
}
@@ -488,7 +491,7 @@ public abstract class BaseTestSupport extends Assert {
assertEquals(message + "[size]", expected.getFieldSize(), actual.getFieldSize());
}
- public static final void assertECPointEquals(String message, ECPoint expected, ECPoint actual) {
+ public static void assertECPointEquals(String message, ECPoint expected, ECPoint actual) {
if (expected == actual) {
return;
}
@@ -526,7 +529,8 @@ public abstract class BaseTestSupport extends Assert {
long sleepStart = System.nanoTime();
Thread.sleep(sleepTime);
- long sleepEnd = System.nanoTime(), nanoSleep = sleepEnd - sleepStart;
+ long sleepEnd = System.nanoTime();
+ long nanoSleep = sleepEnd - sleepStart;
sleepTime = TimeUnit.NANOSECONDS.toMillis(nanoSleep);
timeout -= sleepTime;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/util/test/BogusInvertedShell.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/BogusInvertedShell.java b/sshd-core/src/test/java/org/apache/sshd/util/test/BogusInvertedShell.java
index c99f4ce..ca7ae2c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/BogusInvertedShell.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/BogusInvertedShell.java
@@ -38,9 +38,9 @@ public class BogusInvertedShell implements InvertedShell, ServerSessionHolder {
// for test assertions
private ServerSession session;
- private boolean started = false;
+ private boolean started;
private boolean alive = true;
- private Map<String, String> env = null;
+ private Map<String, String> env;
public BogusInvertedShell(OutputStream in, InputStream out, InputStream err) {
this.in = in;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/util/test/EchoShell.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/EchoShell.java b/sshd-core/src/test/java/org/apache/sshd/util/test/EchoShell.java
index 89fa159..4d12093 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/EchoShell.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/EchoShell.java
@@ -99,7 +99,7 @@ public class EchoShell implements Command, Runnable {
public void run() {
BufferedReader r = new BufferedReader(new InputStreamReader(in));
try {
- for (; ; ) {
+ for (;;) {
String s = r.readLine();
if (s == null) {
return;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/util/test/JSchLogger.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/JSchLogger.java b/sshd-core/src/test/java/org/apache/sshd/util/test/JSchLogger.java
index c8ec459..09124c1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/JSchLogger.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/JSchLogger.java
@@ -20,17 +20,13 @@ package org.apache.sshd.util.test;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Logger;
+
import org.slf4j.LoggerFactory;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class JSchLogger implements Logger {
-
- public static void init() {
- JSch.setLogger(new JSchLogger());
- }
-
private final org.slf4j.Logger log = LoggerFactory.getLogger(JSch.class);
public JSchLogger() {
@@ -72,4 +68,8 @@ public class JSchLogger implements Logger {
log.error("[LEVEL=" + level + "]: " + message);
}
}
+
+ public static void init() {
+ JSch.setLogger(new JSchLogger());
+ }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
index 1dcfd12..be121dd 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/Utils.java
@@ -66,13 +66,58 @@ import org.apache.sshd.server.SshServer;
import org.apache.sshd.server.auth.pubkey.AcceptAllPublickeyAuthenticator;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
-public class Utils {
- // uses a cached instance to avoid re-creating the keys as it is a time-consuming effort
- private static final AtomicReference<KeyPairProvider> keyPairProviderHolder = new AtomicReference<KeyPairProvider>();
+public final class Utils {
+ /**
+ * URL/URI scheme that refers to a file
+ */
+ public static final String FILE_URL_SCHEME = "file";
+ /**
+ * Prefix used in URL(s) that reference a file resource
+ */
+ public static final String FILE_URL_PREFIX = FILE_URL_SCHEME + ":";
+
+ /**
+ * Separator used in URL(s) that reference a resource inside a JAR
+ * to denote the sub-path inside the JAR
+ */
+ public static final char RESOURCE_SUBPATH_SEPARATOR = '!';
+
+ /**
+ * Suffix of JAR files
+ */
+ public static final String JAR_FILE_SUFFIX = ".jar";
+
+ /**
+ * URL/URI scheme that refers to a JAR
+ */
+ public static final String JAR_URL_SCHEME = "jar";
+
+ /**
+ * Prefix used in URL(s) that reference a resource inside a JAR
+ */
+ public static final String JAR_URL_PREFIX = JAR_URL_SCHEME + ":";
+
+ /**
+ * Suffix of compile Java class files
+ */
+ public static final String CLASS_FILE_SUFFIX = ".class";
+
+ public static final List<String> TARGET_FOLDER_NAMES = // NOTE: order is important
+ Collections.unmodifiableList(
+ Arrays.asList("target" /* Maven */, "build" /* Gradle */));
+
public static final String DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM = "RSA";
+ // uses a cached instance to avoid re-creating the keys as it is a time-consuming effort
+ private static final AtomicReference<KeyPairProvider> KEYPAIR_PROVIDER_HOLDER = new AtomicReference<KeyPairProvider>();
+ // uses a cached instance to avoid re-creating the keys as it is a time-consuming effort
+ private static final Map<String, AbstractFileKeyPairProvider> PROVIDERS_MAP = new ConcurrentHashMap<String, AbstractFileKeyPairProvider>();
+
+ private Utils() {
+ throw new UnsupportedOperationException("No instance");
+ }
public static KeyPairProvider createTestHostKeyProvider(Class<?> anchor) {
- KeyPairProvider provider = keyPairProviderHolder.get();
+ KeyPairProvider provider = KEYPAIR_PROVIDER_HOLDER.get();
if (provider != null) {
return provider;
}
@@ -81,7 +126,7 @@ public class Utils {
File file = new File(targetFolder, "hostkey." + DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM.toLowerCase());
provider = createTestHostKeyProvider(file);
- KeyPairProvider prev = keyPairProviderHolder.getAndSet(provider);
+ KeyPairProvider prev = KEYPAIR_PROVIDER_HOLDER.getAndSet(provider);
if (prev != null) { // check if somebody else beat us to it
return prev;
} else {
@@ -127,13 +172,10 @@ public class Utils {
return gen.generateKeyPair();
}
- // uses a cached instance to avoid re-creating the keys as it is a time-consuming effort
- private static final Map<String, AbstractFileKeyPairProvider> providersMap = new ConcurrentHashMap<String, AbstractFileKeyPairProvider>();
-
public static AbstractFileKeyPairProvider createTestKeyPairProvider(String resource) {
File file = getFile(resource);
String filePath = file.getAbsolutePath();
- AbstractFileKeyPairProvider provider = providersMap.get(filePath);
+ AbstractFileKeyPairProvider provider = PROVIDERS_MAP.get(filePath);
if (provider != null) {
return provider;
}
@@ -142,7 +184,7 @@ public class Utils {
provider.setFiles(Collections.singletonList(file));
provider = validateKeyPairProvider(provider);
- AbstractFileKeyPairProvider prev = providersMap.put(filePath, provider);
+ AbstractFileKeyPairProvider prev = PROVIDERS_MAP.put(filePath, provider);
if (prev != null) { // check if somebody else beat us to it
return prev;
} else {
@@ -303,7 +345,7 @@ public class Utils {
* @return The "target" <U>folder</U> - {@code null} if not found
* @see #detectTargetFolder(File)
*/
- public static final File detectTargetFolder(Class<?> anchor) {
+ public static File detectTargetFolder(Class<?> anchor) {
return detectTargetFolder(getClassContainerLocationFile(anchor));
}
@@ -317,7 +359,7 @@ public class Utils {
* @see #getClassContainerLocationURI(Class)
* @see #toFileSource(URI)
*/
- public static final File getClassContainerLocationFile(Class<?> clazz)
+ public static File getClassContainerLocationFile(Class<?> clazz)
throws IllegalArgumentException {
try {
URI uri = getClassContainerLocationURI(clazz);
@@ -335,7 +377,7 @@ public class Utils {
* @throws URISyntaxException if location is not a valid URI
* @see #getClassContainerLocationURL(Class)
*/
- public static final URI getClassContainerLocationURI(Class<?> clazz) throws URISyntaxException {
+ public static URI getClassContainerLocationURI(Class<?> clazz) throws URISyntaxException {
URL url = getClassContainerLocationURL(clazz);
return (url == null) ? null : url.toURI();
}
@@ -346,12 +388,13 @@ public class Utils {
* - e.g., the root folder, the containing JAR, etc.. Returns
* {@code null} if location could not be resolved
*/
- public static final URL getClassContainerLocationURL(Class<?> clazz) {
+ public static URL getClassContainerLocationURL(Class<?> clazz) {
ProtectionDomain pd = clazz.getProtectionDomain();
CodeSource cs = (pd == null) ? null : pd.getCodeSource();
URL url = (cs == null) ? null : cs.getLocation();
if (url == null) {
- if ((url = getClassBytesURL(clazz)) == null) {
+ url = getClassBytesURL(clazz);
+ if (url == null) {
return null;
}
@@ -398,15 +441,6 @@ public class Utils {
}
/**
- * URL/URI scheme that refers to a file
- */
- public static final String FILE_URL_SCHEME = "file";
- /**
- * Prefix used in URL(s) that reference a file resource
- */
- public static final String FILE_URL_PREFIX = FILE_URL_SCHEME + ":";
-
- /**
* Converts a {@link URI} that may refer to an internal resource to
* a {@link File} representing is "source" container (e.g.,
* if it is a resource in a JAR, then the result is the JAR's path)
@@ -442,7 +476,7 @@ public class Utils {
* any sub-resource are stripped
* @see #getURLSource(String)
*/
- public static final String getURLSource(URI uri) {
+ public static String getURLSource(URI uri) {
return getURLSource((uri == null) ? null : uri.toString());
}
@@ -452,23 +486,17 @@ public class Utils {
* any sub-resource are stripped
* @see #getURLSource(String)
*/
- public static final String getURLSource(URL url) {
+ public static String getURLSource(URL url) {
return getURLSource((url == null) ? null : url.toExternalForm());
}
/**
- * Separator used in URL(s) that reference a resource inside a JAR
- * to denote the sub-path inside the JAR
- */
- public static final char RESOURCE_SUBPATH_SEPARATOR = '!';
-
- /**
* @param externalForm The {@link URL#toExternalForm()} string - ignored if
* {@code null}/empty
* @return The URL(s) source path where {@link #JAR_URL_PREFIX} and
* any sub-resource are stripped
*/
- public static final String getURLSource(String externalForm) {
+ public static String getURLSource(String externalForm) {
String url = externalForm;
if (GenericUtils.isEmpty(url)) {
return url;
@@ -493,7 +521,7 @@ public class Utils {
* is not '/' itself
* @see #adjustURLPathValue(String)
*/
- public static final String adjustURLPathValue(URL url) {
+ public static String adjustURLPathValue(URL url) {
return adjustURLPathValue((url == null) ? null : url.getPath());
}
@@ -502,7 +530,7 @@ public class Utils {
* @return The path after stripping any trailing '/' provided the path
* is not '/' itself
*/
- public static final String adjustURLPathValue(final String path) {
+ public static String adjustURLPathValue(final String path) {
final int pathLen = (path == null) ? 0 : path.length();
if ((pathLen <= 1) || (path.charAt(pathLen - 1) != '/')) {
return path;
@@ -511,20 +539,7 @@ public class Utils {
return path.substring(0, pathLen - 1);
}
- /**
- * Suffix of JAR files
- */
- public static final String JAR_FILE_SUFFIX = ".jar";
- /**
- * URL/URI scheme that refers to a JAR
- */
- public static final String JAR_URL_SCHEME = "jar";
- /**
- * Prefix used in URL(s) that reference a resource inside a JAR
- */
- public static final String JAR_URL_PREFIX = JAR_URL_SCHEME + ":";
-
- public static final String stripJarURLPrefix(String externalForm) {
+ public static String stripJarURLPrefix(String externalForm) {
String url = externalForm;
if (GenericUtils.isEmpty(url)) {
return url;
@@ -538,21 +553,17 @@ public class Utils {
}
/**
- * Suffix of compile Java class files
- */
- public static final String CLASS_FILE_SUFFIX = ".class";
-
- /**
* @param clazz The request {@link Class}
* @return A {@link URL} to the location of the <code>.class</code> file
* - {@code null} if location could not be resolved
*/
- public static final URL getClassBytesURL(Class<?> clazz) {
+ public static URL getClassBytesURL(Class<?> clazz) {
String className = clazz.getName();
int sepPos = className.indexOf('$');
// if this is an internal class, then need to use its parent as well
if (sepPos > 0) {
- if ((sepPos = className.lastIndexOf('.')) > 0) {
+ sepPos = className.lastIndexOf('.');
+ if (sepPos > 0) {
className = className.substring(sepPos + 1);
}
} else {
@@ -562,7 +573,7 @@ public class Utils {
return clazz.getResource(className + CLASS_FILE_SUFFIX);
}
- public static final String getClassBytesResourceName(Class<?> clazz) {
+ public static String getClassBytesResourceName(Class<?> clazz) {
return getClassBytesResourceName((clazz == null) ? null : clazz.getName());
}
@@ -570,29 +581,24 @@ public class Utils {
* @param name The fully qualified class name - ignored if {@code null}/empty
* @return The relative path of the class file byte-code resource
*/
- public static final String getClassBytesResourceName(String name) {
+ public static String getClassBytesResourceName(String name) {
if (GenericUtils.isEmpty(name)) {
return name;
} else {
return new StringBuilder(name.length() + CLASS_FILE_SUFFIX.length())
.append(name.replace('.', '/'))
.append(CLASS_FILE_SUFFIX)
- .toString()
- ;
+ .toString();
}
}
- public static final List<String> TARGET_FOLDER_NAMES = // NOTE: order is important
- Collections.unmodifiableList(
- Arrays.asList("target" /* Maven */, "build" /* Gradle */));
-
/**
* @param anchorFile An anchor {@link File} we want to use
* as the starting point for the "target" or "build" folder
* lookup up the hierarchy
* @return The "target" <U>folder</U> - {@code null} if not found
*/
- public static final File detectTargetFolder(File anchorFile) {
+ public static File detectTargetFolder(File anchorFile) {
for (File file = anchorFile; file != null; file = file.getParentFile()) {
if (!file.isDirectory()) {
continue;
@@ -607,12 +613,12 @@ public class Utils {
return null;
}
- public static final String resolveRelativeRemotePath(Path root, Path file) {
+ public static String resolveRelativeRemotePath(Path root, Path file) {
Path relPath = root.relativize(file);
return relPath.toString().replace(File.separatorChar, '/');
}
- public static final SshClient setupTestClient(Class<?> anchor) {
+ public static SshClient setupTestClient(Class<?> anchor) {
SshClient client = SshClient.setUpDefaultClient();
client.setServerKeyVerifier(AcceptAllServerKeyVerifier.INSTANCE);
client.setHostConfigEntryResolver(HostConfigEntryResolver.EMPTY);
@@ -620,7 +626,7 @@ public class Utils {
return client;
}
- public static final SshServer setupTestServer(Class<?> anchor) {
+ public static SshServer setupTestServer(Class<?> anchor) {
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setKeyPairProvider(createTestHostKeyProvider(anchor));
sshd.setPasswordAuthenticator(BogusPasswordAuthenticator.INSTANCE);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-git/src/test/java/org/apache/sshd/git/pack/GitPackCommandTest.java
----------------------------------------------------------------------
diff --git a/sshd-git/src/test/java/org/apache/sshd/git/pack/GitPackCommandTest.java b/sshd-git/src/test/java/org/apache/sshd/git/pack/GitPackCommandTest.java
index 07ee4b2..37b79fe 100644
--- a/sshd-git/src/test/java/org/apache/sshd/git/pack/GitPackCommandTest.java
+++ b/sshd-git/src/test/java/org/apache/sshd/git/pack/GitPackCommandTest.java
@@ -22,6 +22,8 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
+import com.jcraft.jsch.JSch;
+
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.git.transport.GitSshdSessionFactory;
import org.apache.sshd.server.Command;
@@ -39,8 +41,6 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import com.jcraft.jsch.JSch;
-
/**
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@@ -59,7 +59,7 @@ public class GitPackCommandTest extends BaseTestSupport {
Path targetParent = detectTargetFolder().getParent();
Path gitRootDir = getTempTargetRelativeFile(getClass().getSimpleName());
- try(SshServer sshd = setupTestServer()) {
+ try (SshServer sshd = setupTestServer()) {
Path serverRootDir = gitRootDir.resolve("server");
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));
sshd.setCommandFactory(new GitPackCommandFactory(Utils.resolveRelativeRemotePath(targetParent, serverRootDir)));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
----------------------------------------------------------------------
diff --git a/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java b/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
index a6be166..77c14db 100644
--- a/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
+++ b/sshd-git/src/test/java/org/apache/sshd/git/pgm/GitPgmCommandTest.java
@@ -59,7 +59,7 @@ public class GitPgmCommandTest extends BaseTestSupport {
// TODO: because it's quite limited for now
//
- try(SshServer sshd = setupTestServer()) {
+ try (SshServer sshd = setupTestServer()) {
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));
sshd.setCommandFactory(new GitPgmCommandFactory(Utils.resolveRelativeRemotePath(targetParent, serverDir)));
sshd.start();
@@ -68,10 +68,10 @@ public class GitPgmCommandTest extends BaseTestSupport {
try {
Utils.deleteRecursive(serverDir);
- try(SshClient client = setupTestClient()) {
+ try (SshClient client = setupTestClient()) {
client.start();
- try(ClientSession session = client.connect(getCurrentTestName(), SshdSocketAddress.LOCALHOST_IP, port).verify(7L, TimeUnit.SECONDS).getSession()) {
+ try (ClientSession session = client.connect(getCurrentTestName(), SshdSocketAddress.LOCALHOST_IP, port).verify(7L, TimeUnit.SECONDS).getSession()) {
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
@@ -95,7 +95,7 @@ public class GitPgmCommandTest extends BaseTestSupport {
}
private void execute(ClientSession session, String command) throws Exception {
- try(ChannelExec channel = session.createExecChannel(command)) {
+ try (ChannelExec channel = session.createExecChannel(command)) {
channel.setOut(System.out);
channel.setErr(System.err);
channel.open().verify(11L, TimeUnit.SECONDS);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java
index f60ca32..0d48b61 100644
--- a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java
+++ b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/BaseAuthenticatorTest.java
@@ -61,7 +61,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class BaseAuthenticatorTest extends BaseTestSupport {
public static final int PORT = Integer.parseInt(System.getProperty("org.apache.sshd.test.ldap.port", "11389"));
- public static String BASE_DN_TEST = "ou=People,dc=sshd,dc=apache,dc=org";
+ public static final String BASE_DN_TEST = "ou=People,dc=sshd,dc=apache,dc=org";
protected BaseAuthenticatorTest() {
super();
@@ -94,6 +94,7 @@ public abstract class BaseAuthenticatorTest extends BaseTestSupport {
// see http://javlog.cacek.cz/2014/09/speed-up-apacheds-ldap-server.html
// see https://cwiki.apache.org/confluence/display/DIRxSRVx11/4.1.+Embedding+ApacheDS+into+an+application
// see http://stackoverflow.com/questions/1560230/running-apache-ds-embedded-in-my-application
+ @SuppressWarnings("checkstyle:avoidnestedblocks")
public static Pair<LdapServer, DirectoryService> startApacheDs(Class<?> anchor) throws Exception {
Logger log = LoggerFactory.getLogger(anchor);
File targetFolder = ValidateUtils.checkNotNull(Utils.detectTargetFolder(anchor), "Failed to detect target folder");
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-ldap/src/test/java/org/apache/sshd/server/auth/password/LdapPasswordAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/password/LdapPasswordAuthenticatorTest.java b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/password/LdapPasswordAuthenticatorTest.java
index b7c2f2b..a942b79 100644
--- a/sshd-ldap/src/test/java/org/apache/sshd/server/auth/password/LdapPasswordAuthenticatorTest.java
+++ b/sshd-ldap/src/test/java/org/apache/sshd/server/auth/password/LdapPasswordAuthenticatorTest.java
@@ -40,7 +40,7 @@ import org.mockito.Mockito;
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class LdapPasswordAuthenticatorTest extends BaseAuthenticatorTest {
- private static final AtomicReference<Pair<LdapServer, DirectoryService>> ldapContextHolder = new AtomicReference<>();
+ private static final AtomicReference<Pair<LdapServer, DirectoryService>> LDAP_CONTEX_HOLDER = new AtomicReference<>();
private static Map<String, String> usersMap;
public LdapPasswordAuthenticatorTest() {
@@ -49,19 +49,19 @@ public class LdapPasswordAuthenticatorTest extends BaseAuthenticatorTest {
@BeforeClass
public static void startApacheDs() throws Exception {
- ldapContextHolder.set(startApacheDs(LdapPasswordAuthenticatorTest.class));
- usersMap = populateUsers(ldapContextHolder.get().getSecond(), LdapPasswordAuthenticatorTest.class, LdapPasswordAuthenticator.DEFAULT_PASSWORD_ATTR_NAME);
+ LDAP_CONTEX_HOLDER.set(startApacheDs(LdapPasswordAuthenticatorTest.class));
+ usersMap = populateUsers(LDAP_CONTEX_HOLDER.get().getSecond(), LdapPasswordAuthenticatorTest.class, LdapPasswordAuthenticator.DEFAULT_PASSWORD_ATTR_NAME);
assertFalse("No users retrieved", GenericUtils.isEmpty(usersMap));
}
@AfterClass
public static void stopApacheDs() throws Exception {
- stopApacheDs(ldapContextHolder.getAndSet(null));
+ stopApacheDs(LDAP_CONTEX_HOLDER.getAndSet(null));
}
@Test // the user's password is compared with the LDAP stored one
public void testPasswordComparison() throws Exception {
- Pair<LdapServer, DirectoryService> ldapContext = ldapContextHolder.get();
+ Pair<LdapServer, DirectoryService> ldapContext = LDAP_CONTEX_HOLDER.get();
LdapPasswordAuthenticator auth = new LdapPasswordAuthenticator();
auth.setHost(getHost(ldapContext));
auth.setPort(getPort(ldapContext));
[5/5] mina-sshd git commit: [SSHD-655] Apply checkstyle plugin to
test source code as well
Posted by lg...@apache.org.
[SSHD-655] Apply checkstyle plugin to test source code as well
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/39a71a15
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/39a71a15
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/39a71a15
Branch: refs/heads/master
Commit: 39a71a151d9169aedf8863c6f79e82bf3e195d14
Parents: a4307d1
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Fri Feb 26 07:08:40 2016 +0200
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Fri Feb 26 07:08:40 2016 +0200
----------------------------------------------------------------------
pom.xml | 506 ++++++++++---------
.../java/org/apache/sshd/client/SshClient.java | 6 +-
.../channel/PtyCapableChannelSession.java | 6 +-
.../apache/sshd/common/channel/SttySupport.java | 2 +-
.../sshd/common/kex/KexProposalOption.java | 4 +-
.../org/apache/sshd/common/util/io/IoUtils.java | 2 +-
.../java/org/apache/sshd/KeepAliveTest.java | 13 +-
.../java/org/apache/sshd/KeyReExchangeTest.java | 56 +-
.../src/test/java/org/apache/sshd/LoadTest.java | 3 +-
.../java/org/apache/sshd/WindowAdjustTest.java | 8 +-
.../java/org/apache/sshd/agent/AgentTest.java | 13 +
.../client/ClientAuthenticationManagerTest.java | 6 +-
.../java/org/apache/sshd/client/ClientTest.java | 185 ++++---
.../org/apache/sshd/client/SshClientMain.java | 6 +-
.../auth/PasswordIdentityProviderTest.java | 6 +-
.../hosts/ConfigFileHostEntryResolverTest.java | 42 +-
.../hosts/HostConfigEntryResolverTest.java | 57 ++-
.../config/hosts/HostConfigEntryTest.java | 65 +--
.../config/hosts/KnownHostHashValueTest.java | 2 +-
.../BuiltinClientIdentitiesWatcherTest.java | 2 +-
.../keys/ClientIdentityFileWatcherTest.java | 2 +-
.../KnownHostsServerKeyVerifierTest.java | 12 +-
.../apache/sshd/client/scp/ScpCommandMain.java | 10 +-
.../org/apache/sshd/client/scp/ScpTest.java | 39 +-
.../sshd/client/simple/SimpleScpClientTest.java | 6 +-
.../client/simple/SimpleSessionClientTest.java | 8 +-
.../client/simple/SimpleSftpClientTest.java | 6 +-
.../client/subsystem/sftp/SftpCommandMain.java | 6 +-
.../subsystem/sftp/SftpFileSystemTest.java | 10 +-
.../sshd/client/subsystem/sftp/SftpTest.java | 68 +--
.../subsystem/sftp/SftpVersionSelectorTest.java | 11 +-
.../helpers/AbstractCheckFileExtensionTest.java | 18 +-
.../helpers/AbstractMD5HashExtensionTest.java | 13 +-
.../helpers/CopyDataExtensionImplTest.java | 17 +-
.../openssh/helpers/OpenSSHExtensionsTest.java | 45 +-
.../sshd/common/PropertyResolverUtilsTest.java | 43 +-
.../apache/sshd/common/SshConstantsTest.java | 2 +-
.../sshd/common/auth/AuthenticationTest.java | 24 +-
.../apache/sshd/common/channel/WindowTest.java | 12 +-
.../sshd/common/channel/WindowTimeoutTest.java | 7 +-
.../sshd/common/cipher/BaseCipherTest.java | 11 +-
.../sshd/common/cipher/BuiltinCiphersTest.java | 2 +-
.../apache/sshd/common/cipher/CipherTest.java | 32 +-
.../compression/BuiltinCompressionsTest.java | 2 +-
.../common/compression/CompressionTest.java | 20 +-
.../common/config/SshConfigFileReaderTest.java | 6 +-
.../sshd/common/config/TimeValueConfigTest.java | 10 +-
.../config/keys/AuthorizedKeyEntryTest.java | 3 -
.../config/keys/AuthorizedKeysTestSupport.java | 8 +-
.../config/keys/BuiltinIdentitiesTest.java | 3 +-
.../keys/KeyUtilsFingerprintGenerationTest.java | 4 +-
.../sshd/common/config/keys/KeyUtilsTest.java | 10 +-
.../common/config/keys/PublicKeyEntryTest.java | 2 +-
.../sshd/common/file/util/BasePathTest.java | 17 +-
.../common/forward/PortForwardingLoadTest.java | 102 ++--
.../sshd/common/forward/PortForwardingTest.java | 86 ++--
.../common/future/DefaultSshFutureTest.java | 6 +-
.../io/DefaultIoServiceFactoryFactoryTest.java | 3 +-
.../sshd/common/io/nio2/Nio2ServiceTest.java | 4 +-
.../apache/sshd/common/kex/AbstractDHTest.java | 3 +-
.../sshd/common/kex/BuiltinDHFactoriesTest.java | 2 +-
.../sshd/common/kex/KexProposalOptionTest.java | 5 +-
.../common/keyprovider/KeyPairProviderTest.java | 3 +-
.../apache/sshd/common/mac/BuiltinMacsTest.java | 2 +-
.../org/apache/sshd/common/mac/MacTest.java | 28 +-
.../apache/sshd/common/mac/MacVectorsTest.java | 14 +-
.../sshd/common/random/RandomFactoryTest.java | 12 +-
.../session/helpers/AbstractSessionTest.java | 5 +-
.../common/signature/BuiltinSignaturesTest.java | 2 +-
.../signature/SignatureDSSFactoryTest.java | 8 +-
.../signature/SignatureECDSAFactoryTest.java | 8 +-
.../signature/SignatureRSAFactoryTest.java | 8 +-
.../sshd/common/signature/SignatureRSATest.java | 3 +
.../subsystem/sftp/SftpConstantsTest.java | 7 +-
.../sftp/SftpUniversalOwnerAndGroupTest.java | 2 +-
.../common/util/EventListenerUtilsTest.java | 4 +-
.../sshd/common/util/GenericUtilsTest.java | 12 +-
.../sshd/common/util/SecurityUtilsTest.java | 10 +-
.../sshd/common/util/SelectorUtilsTest.java | 23 +-
.../sshd/common/util/TransformerTest.java | 10 +-
.../sshd/common/util/buffer/BufferTest.java | 12 +-
.../common/util/buffer/BufferUtilsTest.java | 8 +-
.../common/util/io/EmptyInputStreamTest.java | 6 +-
.../deprecated/ClientUserAuthServiceOld.java | 2 +
.../apache/sshd/deprecated/UserAuthAgent.java | 2 +
.../deprecated/UserAuthKeyboardInteractive.java | 5 +-
.../sshd/deprecated/UserAuthPassword.java | 2 +
.../sshd/deprecated/UserAuthPublicKey.java | 2 +
.../sshd/server/PublickeyAuthenticatorTest.java | 4 +-
.../java/org/apache/sshd/server/ServerMain.java | 32 --
.../sshd/server/ServerSessionListenerTest.java | 3 +-
.../java/org/apache/sshd/server/ServerTest.java | 74 +--
.../org/apache/sshd/server/SshServerMain.java | 6 +-
.../sshd/server/channel/ChannelSessionTest.java | 4 +-
.../server/command/ScpCommandFactoryTest.java | 3 +-
.../keys/AuthorizedKeysAuthenticatorTest.java | 9 +-
.../jaas/JaasPasswordAuthenticatorTest.java | 16 +-
.../AbstractGeneratorHostKeyProviderTest.java | 2 +-
.../PEMGeneratorHostKeyProviderTest.java | 9 +-
.../SimpleGeneratorHostKeyProviderTest.java | 6 +-
.../server/shell/InvertedShellWrapperTest.java | 62 +--
.../server/shell/TtyFilterOutputStreamTest.java | 23 +-
.../server/subsystem/sftp/SshFsMounter.java | 16 +-
.../apache/sshd/util/test/BaseTestSupport.java | 52 +-
.../sshd/util/test/BogusInvertedShell.java | 4 +-
.../org/apache/sshd/util/test/EchoShell.java | 2 +-
.../org/apache/sshd/util/test/JSchLogger.java | 10 +-
.../java/org/apache/sshd/util/test/Utils.java | 142 +++---
.../sshd/git/pack/GitPackCommandTest.java | 6 +-
.../apache/sshd/git/pgm/GitPgmCommandTest.java | 8 +-
.../sshd/server/auth/BaseAuthenticatorTest.java | 3 +-
.../password/LdapPasswordAuthenticatorTest.java | 10 +-
.../pubkey/LdapPublickeyAuthenticatorTest.java | 16 +-
113 files changed, 1267 insertions(+), 1145 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 84cf0e2..c80533c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -454,6 +454,7 @@
<version>2.17</version>
<configuration>
<logViolationsToConsole>true</logViolationsToConsole>
+ <includeTestSourceDirectory>true</includeTestSourceDirectory>
<resourceExcludes>**/*.properties</resourceExcludes>
<checkstyleRules>
<module name="Checker">
@@ -470,260 +471,261 @@
<!--<module name="StrictDuplicateCode" />-->
<module name="TreeWalker">
- <!-- Enable FileContentsHolder to allow us to in turn turn on suppression comments -->
- <module name="FileContentsHolder" />
- <!-- Checks for Javadoc comments. -->
- <!-- See http://checkstyle.sf.net/config_javadoc.html -->
- <!--
- <module name="PackageHtml" />
- <module name="JavadocMethod" />
- <module name="JavadocType" />
- <module name="JavadocVariable" />
- <module name="JavadocStyle" />
- -->
-
- <!-- Check annotations conventions -->
- <!-- See http://checkstyle.sourceforge.net/config_annotation.html -->
- <module name="MissingOverride" />
- <module name="MissingDeprecated" />
- <module name="AnnotationLocation">
- <property name="allowSamelineMultipleAnnotations" value="false" />
- <property name="allowSamelineSingleParameterlessAnnotation" value="false" />
- <property name="allowSamelineParameterizedAnnotation" value="false" />
- </module>
-
- <!-- Checks for Naming Conventions. -->
- <!-- See http://checkstyle.sf.net/config_naming.html -->
- <module name="ConstantName" />
- <module name="LocalFinalVariableName" />
- <module name="LocalVariableName">
- <property name="format" value="^[a-z][a-zA-Z0-9_]*$" />
- </module>
- <module name="MemberName">
- <property name="format" value="^[a-z][a-zA-Z0-9_]*$" />
- </module>
- <module name="MethodName" />
- <module name="PackageName" />
- <module name="ParameterName">
- <property name="format" value="^[a-z][a-zA-Z0-9_]*$" />
- </module>
- <module name="StaticVariableName" />
- <module name="TypeName" />
-
- <!-- Checks for imports -->
- <!-- See http://checkstyle.sf.net/config_import.html -->
- <module name="AvoidStarImport" />
- <module name="IllegalImport" /><!-- defaults to sun.* packages -->
- <module name="RedundantImport" />
- <module name="UnusedImports" />
- <module name="ImportOrder">
- <property name="groups" value="java,javax,org.w3c,org.xml,junit,antlr,com.,net,org,*" />
- <property name="ordered" value="true" />
- </module>
+ <!-- Enable FileContentsHolder to allow us to in turn turn on suppression comments -->
+ <module name="FileContentsHolder" />
+ <!-- Checks for Javadoc comments. -->
+ <!-- See http://checkstyle.sf.net/config_javadoc.html -->
+ <!--
+ <module name="PackageHtml" />
+ <module name="JavadocMethod" />
+ <module name="JavadocType" />
+ <module name="JavadocVariable" />
+ <module name="JavadocStyle" />
+ -->
+
+ <!-- Check annotations conventions -->
+ <!-- See http://checkstyle.sourceforge.net/config_annotation.html -->
+ <module name="MissingOverride" />
+ <module name="MissingDeprecated" />
+ <module name="AnnotationLocation">
+ <property name="allowSamelineMultipleAnnotations" value="false" />
+ <property name="allowSamelineSingleParameterlessAnnotation" value="false" />
+ <property name="allowSamelineParameterizedAnnotation" value="false" />
+ </module>
+
+ <!-- Checks for Naming Conventions. -->
+ <!-- See http://checkstyle.sf.net/config_naming.html -->
+ <module name="ConstantName" />
+ <module name="LocalFinalVariableName" />
+ <module name="LocalVariableName">
+ <property name="format" value="^[a-z][a-zA-Z0-9_]*$" />
+ </module>
+ <module name="MemberName">
+ <property name="format" value="^[a-z][a-zA-Z0-9_]*$" />
+ </module>
+ <module name="MethodName" />
+ <module name="PackageName" />
+ <module name="ParameterName">
+ <property name="format" value="^[a-z][a-zA-Z0-9_]*$" />
+ </module>
+ <module name="StaticVariableName" />
+ <module name="TypeName" />
+
+ <!-- Checks for imports -->
+ <!-- See http://checkstyle.sf.net/config_import.html -->
+ <module name="AvoidStarImport" />
+ <module name="IllegalImport" /><!-- defaults to sun.* packages -->
+ <module name="RedundantImport" />
+ <module name="UnusedImports" />
+ <module name="ImportOrder">
+ <property name="groups" value="java,javax,org.w3c,org.xml,junit,antlr,com.,net,org,*" />
+ <property name="ordered" value="true" />
+ </module>
- <!--
- <module name="ImportControl">
- <property name="file" value="etc/import-control.xml" />
- </module>
- -->
-
- <!-- Checks for Size Violations. -->
- <!-- See http://checkstyle.sf.net/config_sizes.html -->
- <module name="AnonInnerLength">
- <property name="max" value="50" />
- </module>
- <module name="ExecutableStatementCount">
- <property name="max" value="100" />
- </module>
- <module name="LineLength">
- <property name="max" value="180" />
- </module>
- <module name="MethodLength">
- <property name="max" value="150" />
- <property name="countEmpty" value="false" />
- </module>
+ <!--
+ <module name="ImportControl">
+ <property name="file" value="etc/import-control.xml" />
+ </module>
+ -->
+
+ <!-- Checks for Size Violations. -->
+ <!-- See http://checkstyle.sf.net/config_sizes.html -->
+ <module name="AnonInnerLength">
+ <property name="max" value="50" />
+ </module>
+ <module name="ExecutableStatementCount">
+ <property name="max" value="100" />
+ </module>
+ <module name="LineLength">
+ <property name="max" value="180" />
+ </module>
+ <module name="MethodLength">
+ <property name="max" value="150" />
+ <property name="countEmpty" value="false" />
+ </module>
- <!-- DISABLED
- <module name="ParameterNumber">
- <property name="max" value="7" />
- </module>
- -->
-
- <!-- Checks for whitespace -->
- <!-- See http://checkstyle.sf.net/config_whitespace.html -->
- <module name="EmptyForIteratorPad" />
- <module name="EmptyForInitializerPad" />
- <module name="MethodParamPad" />
- <module name="NoWhitespaceAfter">
- <property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS" />
- </module>
- <module name="NoWhitespaceBefore" />
- <module name="OperatorWrap" />
- <module name="ParenPad" />
- <module name="TypecastParenPad" />
- <module name="WhitespaceAfter">
- <property name="tokens" value="COMMA, SEMI" />
- </module>
- <module name="WhitespaceAround">
- <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND" />
- </module>
-
- <!-- Modifier Checks -->
- <!-- See http://checkstyle.sf.net/config_modifiers.html -->
- <module name="ModifierOrder" />
- <module name="RedundantModifier" />
-
- <!-- Checks for blocks. You know, those {}'s -->
- <!-- See http://checkstyle.sf.net/config_blocks.html -->
- <module name="AvoidNestedBlocks">
- <property name="allowInSwitchCase" value="true" />
- </module>
- <module name="EmptyBlock">
- <property name="option" value="text" />
- </module>
- <module name="LeftCurly" />
- <module name="NeedBraces" />
- <module name="RightCurly" />
- <module name="EmptyCatchBlock">
- <property name="exceptionVariableName" value="expected|ignore" />
- </module>
-
- <!-- Checks for common coding problems -->
- <!-- See http://checkstyle.sf.net/config_coding.html -->
- <!--<module name="ArrayTrailingComma" />-->
- <!--<module name="AvoidInlineConditionals" />-->
- <module name="CovariantEquals" />
- <module name="EmptyStatement" />
- <module name="EqualsHashCode" />
- <!--<module name="FinalLocalVariable" />-->
- <!-- DISABLED
- <module name="HiddenField">
- <property name="ignoreConstructorParameter" value="true" />
- <property name="ignoreSetter" value="true" />
- </module>
- -->
- <module name="IllegalInstantiation" />
- <!--<module name="IllegalToken" />-->
- <!--<module name="IllegalTokenText" />-->
- <module name="InnerAssignment" />
- <!--<module name="MagicNumber" />-->
- <module name="MissingSwitchDefault" />
- <!--module name="ModifiedControlVariable"/-->
- <module name="SimplifyBooleanExpression" />
- <module name="SimplifyBooleanReturn" />
- <module name="StringLiteralEquality" />
- <module name="NestedIfDepth">
- <property name="max" value="3" />
- </module>
- <module name="NestedTryDepth">
- <property name="max" value="3" />
- </module>
- <module name="SuperClone" />
- <module name="SuperFinalize" />
- <!--<module name="IllegalCatch" />-->
- <module name="IllegalThrows">
- <property name="illegalClassNames" value="java.lang.Error,java.lang.RuntimeException" />
- </module>
- <!--<module name="RedundantThrows" />-->
- <module name="PackageDeclaration" />
- <module name="ReturnCount">
- <property name="max" value="15" />
- </module>
-
- <module name="IllegalType">
- <property name="format" value="^xxx$" />
- <property name="illegalClassNames" value="java.util.GregorianCalendar, java.util.Hashtable, java.util.HashSet, java.util.HashMap, java.util.ArrayList, java.util.LinkedList, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeSet, java.util.TreeMap" />
- </module>
- <module name="DeclarationOrder" />
- <!--<module name="ParameterAssignment" />-->
- <module name="ExplicitInitialization" />
- <module name="DefaultComesLast" />
- <!--<module name="MissingCtor" />-->
- <module name="FallThrough" />
- <!--<module name="MultipleStringLiterals" />-->
- <module name="MultipleVariableDeclarations" />
- <!--<module name="RequireThis" />-->
- <module name="UnnecessaryParentheses" />
-
- <!-- Checks for class design -->
- <!-- See http://checkstyle.sf.net/config_design.html -->
- <!--<module name="DesignForExtension" />-->
- <module name="FinalClass" />
- <module name="HideUtilityClassConstructor" />
- <module name="InterfaceIsType" />
- <!--<module name="MutableException" />-->
- <module name="ThrowsCount">
- <property name="max" value="5" />
- </module>
- <module name="VisibilityModifier">
- <property name="protectedAllowed" value="true" />
- <property name="packageAllowed" value="true" />
- <!-- this is needed for the resource injection unit tests. It will removed
- when private member inject is supported.
- -->
- <property name="publicMemberPattern" value="resource[12].*" />
- </module>
-
- <!-- Metrics checks. -->
- <!-- See http://checkstyle.sf.net/config_metrics.html -->
- <module name="BooleanExpressionComplexity">
- <property name="max" value="10" />
- </module>
- <!--<module name="ClassDataAbstractionCoupling" />-->
- <!--<module name="ClassFanOutComplexity" />-->
- <!--<module name="CyclomaticComplexity" />-->
- <!--<module name="NPathComplexity" />-->
- <module name="JavaNCSS">
- <property name="methodMaximum" value="150" />
- <property name="classMaximum" value="2000" />
- </module>
-
- <!-- Miscellaneous other checks. -->
- <!-- See http://checkstyle.sf.net/config_misc.html -->
- <!--
- <module name="ArrayTypeStyle" />
- <module name="FinalParameters" />
- -->
- <!--
- <module name="GenericIllegalRegexp">
- <property name="format" value="\s+$" />
- <property name="message" value="Line has trailing spaces." />
- </module>
- -->
- <!-- DISABLED
- <module name="TodoComment">
- <property name="format" value="TODO" />
- </module>
- -->
-
- <module name="UpperEll" />
-
- <!--Assert statement may have side effects:-->
- <module name="DescendantToken">
- <property name="tokens" value="LITERAL_ASSERT" />
- <property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN" />
- <property name="maximumNumber" value="0" />
- </module>
-
- <!--<module name="UncommentedMain" />-->
- <!--module name="TrailingComment"/-->
- <module name="Indentation">
- <property name="caseIndent" value="4" />
- <property name="lineWrappingIndentation" value="0" />
- </module>
- <!--<module name="RequiredRegexp">-->
- <module name="SuppressWarningsHolder" />
- </module>
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="CHECKSTYLE\:OFF" />
- <property name="onCommentFormat" value="CHECKSTYLE\:ON" />
- </module>
- <module name="SuppressionCommentFilter">
- <property name="offCommentFormat" value="CHECKSTYLE.OFF\:([\w\|]+)" />
- <property name="onCommentFormat" value="CHECKSTYLE.ON\:([\w\|]+)" />
- <property name="checkFormat" value="$1" />
- </module>
- <module name="SuppressWarningsFilter" />
+ <!-- DISABLED
+ <module name="ParameterNumber">
+ <property name="max" value="7" />
+ </module>
+ -->
+
+ <!-- Checks for whitespace -->
+ <!-- See http://checkstyle.sf.net/config_whitespace.html -->
+ <module name="EmptyForIteratorPad" />
+ <module name="EmptyForInitializerPad" />
+ <module name="MethodParamPad" />
+ <module name="NoWhitespaceAfter">
+ <property name="tokens" value="ARRAY_INIT,BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS" />
+ </module>
+ <module name="NoWhitespaceBefore" />
+ <module name="OperatorWrap" />
+ <module name="ParenPad" />
+ <module name="TypecastParenPad" />
+ <module name="WhitespaceAfter">
+ <property name="tokens" value="COMMA, SEMI" />
+ </module>
+ <module name="WhitespaceAround">
+ <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, RCURLY, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN,TYPE_EXTENSION_AND" />
+ </module>
+
+ <!-- Modifier Checks -->
+ <!-- See http://checkstyle.sf.net/config_modifiers.html -->
+ <module name="ModifierOrder" />
+ <module name="RedundantModifier" />
+
+ <!-- Checks for blocks. You know, those {}'s -->
+ <!-- See http://checkstyle.sf.net/config_blocks.html -->
+ <module name="AvoidNestedBlocks">
+ <property name="allowInSwitchCase" value="true" />
+ </module>
+ <module name="EmptyBlock">
+ <property name="option" value="text" />
+ </module>
+ <module name="LeftCurly" />
+ <module name="NeedBraces" />
+ <module name="RightCurly" />
+ <module name="EmptyCatchBlock">
+ <property name="exceptionVariableName" value="expected|ignore" />
+ </module>
+
+ <!-- Checks for common coding problems -->
+ <!-- See http://checkstyle.sf.net/config_coding.html -->
+ <!--<module name="ArrayTrailingComma" />-->
+ <!--<module name="AvoidInlineConditionals" />-->
+ <module name="CovariantEquals" />
+ <module name="EmptyStatement" />
+ <module name="EqualsHashCode" />
+ <!--<module name="FinalLocalVariable" />-->
+ <!-- DISABLED
+ <module name="HiddenField">
+ <property name="ignoreConstructorParameter" value="true" />
+ <property name="ignoreSetter" value="true" />
+ </module>
+ -->
+ <module name="IllegalInstantiation" />
+ <!--<module name="IllegalToken" />-->
+ <!--<module name="IllegalTokenText" />-->
+ <module name="InnerAssignment" />
+ <!--<module name="MagicNumber" />-->
+ <module name="MissingSwitchDefault" />
+ <!--module name="ModifiedControlVariable"/-->
+ <module name="SimplifyBooleanExpression" />
+ <module name="SimplifyBooleanReturn" />
+ <module name="StringLiteralEquality" />
+ <module name="NestedIfDepth">
+ <property name="max" value="3" />
+ </module>
+ <module name="NestedTryDepth">
+ <property name="max" value="3" />
+ </module>
+ <module name="SuperClone" />
+ <module name="SuperFinalize" />
+ <!--<module name="IllegalCatch" />-->
+ <module name="IllegalThrows">
+ <property name="illegalClassNames" value="java.lang.Error,java.lang.RuntimeException" />
+ </module>
+ <!--<module name="RedundantThrows" />-->
+ <module name="PackageDeclaration" />
+ <module name="ReturnCount">
+ <property name="max" value="15" />
+ </module>
+
+ <module name="IllegalType">
+ <property name="format" value="^xxx$" />
+ <property name="illegalClassNames" value="java.util.GregorianCalendar, java.util.Hashtable, java.util.HashSet, java.util.HashMap, java.util.ArrayList, java.util.LinkedList, java.util.LinkedHashMap, java.util.LinkedHashSet, java.util.TreeSet, java.util.TreeMap" />
+ </module>
+ <module name="DeclarationOrder" />
+ <!--<module name="ParameterAssignment" />-->
+ <module name="ExplicitInitialization" />
+ <module name="DefaultComesLast" />
+ <!--<module name="MissingCtor" />-->
+ <module name="FallThrough" />
+ <!--<module name="MultipleStringLiterals" />-->
+ <module name="MultipleVariableDeclarations" />
+ <!--<module name="RequireThis" />-->
+ <module name="UnnecessaryParentheses" />
+
+ <!-- Checks for class design -->
+ <!-- See http://checkstyle.sf.net/config_design.html -->
+ <!--<module name="DesignForExtension" />-->
+ <module name="FinalClass" />
+ <module name="HideUtilityClassConstructor" />
+ <module name="InterfaceIsType" />
+ <!--<module name="MutableException" />-->
+ <module name="ThrowsCount">
+ <property name="max" value="5" />
+ </module>
+ <module name="VisibilityModifier">
+ <property name="protectedAllowed" value="true" />
+ <property name="packageAllowed" value="true" />
+ <!-- this is needed for the resource injection unit tests. It will removed
+ when private member inject is supported.
+ -->
+ <property name="publicMemberPattern" value="resource[12].*" />
+ </module>
+
+ <!-- Metrics checks. -->
+ <!-- See http://checkstyle.sf.net/config_metrics.html -->
+ <module name="BooleanExpressionComplexity">
+ <property name="max" value="10" />
+ </module>
+ <!--<module name="ClassDataAbstractionCoupling" />-->
+ <!--<module name="ClassFanOutComplexity" />-->
+ <!--<module name="CyclomaticComplexity" />-->
+ <!--<module name="NPathComplexity" />-->
+ <module name="JavaNCSS">
+ <property name="methodMaximum" value="150" />
+ <property name="classMaximum" value="2000" />
+ </module>
+
+ <!-- Miscellaneous other checks. -->
+ <!-- See http://checkstyle.sf.net/config_misc.html -->
+ <!--
+ <module name="ArrayTypeStyle" />
+ <module name="FinalParameters" />
+ -->
+ <!--
+ <module name="GenericIllegalRegexp">
+ <property name="format" value="\s+$" />
+ <property name="message" value="Line has trailing spaces." />
+ </module>
+ -->
+ <!-- DISABLED
+ <module name="TodoComment">
+ <property name="format" value="TODO" />
+ </module>
+ -->
+
+ <module name="UpperEll" />
+
+ <!--Assert statement may have side effects:-->
+ <module name="DescendantToken">
+ <property name="tokens" value="LITERAL_ASSERT" />
+ <property name="limitedTokens" value="ASSIGN,DEC,INC,POST_DEC,POST_INC,PLUS_ASSIGN,MINUS_ASSIGN,STAR_ASSIGN,DIV_ASSIGN,MOD_ASSIGN,BSR_ASSIGN,SR_ASSIGN,SL_ASSIGN,BAND_ASSIGN,BXOR_ASSIGN,BOR_ASSIGN" />
+ <property name="maximumNumber" value="0" />
+ </module>
+
+ <!--<module name="UncommentedMain" />-->
+ <!--module name="TrailingComment"/-->
+ <module name="Indentation">
+ <property name="caseIndent" value="4" />
+ <property name="lineWrappingIndentation" value="0" />
+ </module>
+ <!--<module name="RequiredRegexp">-->
+ <!-- Make the @SuppressWarnings annotations available to Checkstyle -->
+ <module name="SuppressWarningsHolder" />
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE\:OFF" />
+ <property name="onCommentFormat" value="CHECKSTYLE\:ON" />
+ </module>
+ <module name="SuppressionCommentFilter">
+ <property name="offCommentFormat" value="CHECKSTYLE.OFF\:([\w\|]+)" />
+ <property name="onCommentFormat" value="CHECKSTYLE.ON\:([\w\|]+)" />
+ <property name="checkFormat" value="$1" />
+ </module>
+ <module name="SuppressWarningsFilter" />
<!-- Header checks -->
<module name="Header">
<property name="header" value="/*\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * &quot;License&quot;); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n" />
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index 6ae44d6..a266f6b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -149,14 +149,14 @@ import org.apache.sshd.common.util.net.SshdSocketAddress;
* </P>
*
* <pre>
- * try(SshClient client = SshClient.setUpDefaultClient()) {
+ * try (SshClient client = SshClient.setUpDefaultClient()) {
* client.start();
*
- * try(ClientSession session = client.connect(login, host, port).await().getSession()) {
+ * try (ClientSession session = client.connect(login, host, port).await().getSession()) {
* session.addPasswordIdentity(password);
* session.auth().verify(...timeout...);
*
- * try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
+ * try (ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
* channel.setIn(new NoCloseInputStream(System.in));
* channel.setOut(new NoCloseOutputStream(System.out));
* channel.setErr(new NoCloseOutputStream(System.err));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java
index 7e77c95..61d0e91 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/PtyCapableChannelSession.java
@@ -41,14 +41,14 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
* ignored).</P>
* <P>A typical code snippet would be:</P>
* <PRE>
- * try(client = SshClient.setUpDefaultClient()) {
+ * try (client = SshClient.setUpDefaultClient()) {
* client.start();
*
- * try(ClientSession s = client.connect(getCurrentTestName(), "localhost", port).verify(7L, TimeUnit.SECONDS).getSession()) {
+ * try (ClientSession s = client.connect(getCurrentTestName(), "localhost", port).verify(7L, TimeUnit.SECONDS).getSession()) {
* s.addPasswordIdentity(getCurrentTestName());
* s.auth().verify(5L, TimeUnit.SECONDS);
*
- * try(ChannelExec shell = s.createExecChannel("my super duper command")) {
+ * try (ChannelExec shell = s.createExecChannel("my super duper command")) {
* shell.setEnv("var1", "val1");
* shell.setEnv("var2", "val2");
* ...etc...
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
index f3daa1d..fa92fe1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/SttySupport.java
@@ -278,7 +278,7 @@ public final class SttySupport {
int count = 0;
while (true) {
int c = in.read();
- if (c == (-1)) {
+ if (c == -1) {
return count;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
index b9ff8cd..3216a71 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
@@ -65,8 +65,8 @@ public enum KexProposalOption {
new Comparator<KexProposalOption>() {
@Override
public int compare(KexProposalOption o1, KexProposalOption o2) {
- int i1 = (o1 == null) ? (-1) : o1.getProposalIndex();
- int i2 = (o2 == null) ? (-1) : o2.getProposalIndex();
+ int i1 = (o1 == null) ? -1 : o1.getProposalIndex();
+ int i2 = (o2 == null) ? -1 : o2.getProposalIndex();
return Integer.compare(i1, i2);
}
};
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/io/IoUtils.java b/sshd-core/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
index 11948ec..ff0e1b3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
@@ -368,7 +368,7 @@ public final class IoUtils {
public static int read(InputStream input, byte[] buffer, int offset, int length) throws IOException {
for (int remaining = length, curOffset = offset; remaining > 0;) {
int count = input.read(buffer, curOffset, remaining);
- if (count == (-1)) { // EOF before achieved required length
+ if (count == -1) { // EOF before achieved required length
return curOffset - offset;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java b/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
index 149fecc..03c5375 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
@@ -51,13 +51,17 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KeepAliveTest extends BaseTestSupport {
- private SshServer sshd;
- private int port;
-
private static final long HEARTBEAT = TimeUnit.SECONDS.toMillis(2L);
private static final long TIMEOUT = 2L * HEARTBEAT;
private static final long WAIT = 2L * TIMEOUT;
+ private SshServer sshd;
+ private int port;
+
+ public KeepAliveTest() {
+ super();
+ }
+
@Before
public void setUp() throws Exception {
sshd = setupTestServer();
@@ -153,8 +157,9 @@ public class KeepAliveTest extends BaseTestSupport {
}
public static class TestEchoShell extends EchoShell {
-
+ // CHECKSTYLE:OFF
public static CountDownLatch latch;
+ // CHECKSTYLE:ON
@Override
public void destroy() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
index 5670612..c86883a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
@@ -36,6 +36,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import com.jcraft.jsch.JSch;
+
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.client.channel.ClientChannel;
@@ -67,8 +69,6 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import com.jcraft.jsch.JSch;
-
/**
* Test key exchange algorithms.
*
@@ -149,7 +149,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
final AtomicBoolean successfulInit = new AtomicBoolean(true);
final AtomicBoolean successfulNext = new AtomicBoolean(true);
final ClassLoader loader = getClass().getClassLoader();
- final Class<?>[] interfaces = { KeyExchange.class };
+ final Class<?>[] interfaces = {KeyExchange.class};
for (final NamedFactory<KeyExchange> factory : client.getKeyExchangeFactories()) {
kexFactories.add(new NamedFactory<KeyExchange>() {
@Override
@@ -266,7 +266,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
InputStream inPipe = new PipedInputStream(pipedIn);
OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
ByteArrayOutputStream out = new ByteArrayOutputStream() {
- private long writeCount = 0L;
+ private long writeCount;
@Override
public void write(int b) {
@@ -334,8 +334,8 @@ public class KeyReExchangeTest extends BaseTestSupport {
@Test
public void testReExchangeFromServerBySize() throws Exception {
- final long LIMIT = 10 * 1024L;
- setUp(LIMIT, 0L, 0L);
+ final long bytesLImit = 10 * 1024L;
+ setUp(bytesLImit, 0L, 0L);
try (SshClient client = setupTestClient()) {
client.start();
@@ -344,7 +344,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession();
ByteArrayOutputStream sent = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream() {
- private long writeCount = 0L;
+ private long writeCount;
@Override
public void write(int b) {
@@ -416,7 +416,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
});
byte[] data = sb.toString().getBytes(StandardCharsets.UTF_8);
- for (long sentSize = 0L; sentSize < (LIMIT + Byte.MAX_VALUE + data.length); sentSize += data.length) {
+ for (long sentSize = 0L; sentSize < (bytesLImit + Byte.MAX_VALUE + data.length); sentSize += data.length) {
teeOut.write(data);
teeOut.flush();
// no need to wait until the limit is reached if a re-key occurred
@@ -451,8 +451,8 @@ public class KeyReExchangeTest extends BaseTestSupport {
@Test
public void testReExchangeFromServerByTime() throws Exception {
- final long TIME = TimeUnit.SECONDS.toMillis(2L);
- setUp(0L, TIME, 0L);
+ final long timeLimit = TimeUnit.SECONDS.toMillis(2L);
+ setUp(0L, timeLimit, 0L);
try (SshClient client = setupTestClient()) {
client.start();
@@ -461,7 +461,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession();
ByteArrayOutputStream sent = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream() {
- private long writeCount = 0L;
+ private long writeCount;
@Override
public void write(int b) {
@@ -533,10 +533,10 @@ public class KeyReExchangeTest extends BaseTestSupport {
});
byte[] data = getCurrentTestName().getBytes(StandardCharsets.UTF_8);
- final long MAX_WAIT_NANOS = TimeUnit.MILLISECONDS.toNanos(3L * TIME);
- final long MIN_WAIT = 10L;
- final long MIN_WAIT_NANOS = TimeUnit.MILLISECONDS.toNanos(MIN_WAIT);
- for (long timePassed = 0L, sentSize = 0L; timePassed < MAX_WAIT_NANOS; timePassed++) {
+ final long maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(3L * timeLimit);
+ final long minWaitValue = 10L;
+ final long minWaitNanos = TimeUnit.MILLISECONDS.toNanos(minWaitValue);
+ for (long timePassed = 0L, sentSize = 0L; timePassed < maxWaitNanos; timePassed++) {
long nanoStart = System.nanoTime();
teeOut.write(data);
teeOut.write('\n');
@@ -555,8 +555,8 @@ public class KeyReExchangeTest extends BaseTestSupport {
break;
}
- if ((timePassed < MAX_WAIT_NANOS) && (nanoDuration < MIN_WAIT_NANOS)) {
- Thread.sleep(MIN_WAIT);
+ if ((timePassed < maxWaitNanos) && (nanoDuration < minWaitNanos)) {
+ Thread.sleep(minWaitValue);
}
}
@@ -586,8 +586,8 @@ public class KeyReExchangeTest extends BaseTestSupport {
@Test // see SSHD-601
public void testReExchangeFromServerByPackets() throws Exception {
- final int PACKETS = 135;
- setUp(0L, 0L, PACKETS);
+ final int packetsLimit = 135;
+ setUp(0L, 0L, packetsLimit);
try (SshClient client = setupTestClient()) {
client.start();
@@ -596,7 +596,7 @@ public class KeyReExchangeTest extends BaseTestSupport {
try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession();
ByteArrayOutputStream sent = new ByteArrayOutputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream() {
- private long writeCount = 0L;
+ private long writeCount;
@Override
public void write(int b) {
@@ -634,12 +634,12 @@ public class KeyReExchangeTest extends BaseTestSupport {
OutputStream teeOut = new TeeOutputStream(sentTracker, pipedIn);
OutputStream stderr = new NullOutputStream();
OutputStream stdout = new OutputCountTrackingOutputStream(out) {
- @Override
- protected long updateWriteCount(long delta) {
- long result = super.updateWriteCount(delta);
- outputDebugMessage("OUT write count=%d", result);
- return result;
- }
+ @Override
+ protected long updateWriteCount(long delta) {
+ long result = super.updateWriteCount(delta);
+ outputDebugMessage("OUT write count=%d", result);
+ return result;
+ }
};
InputStream inPipe = new PipedInputStream(pipedIn)) {
@@ -678,14 +678,14 @@ public class KeyReExchangeTest extends BaseTestSupport {
});
byte[] data = (getClass().getName() + "#" + getCurrentTestName() + "\n").getBytes(StandardCharsets.UTF_8);
- for (int index = 0; index < (PACKETS * 2); index++) {
+ for (int index = 0; index < (packetsLimit * 2); index++) {
teeOut.write(data);
teeOut.flush();
// no need to wait until the packets limit is reached if a re-key occurred
if (exchanges.get() > 0) {
outputDebugMessage("Stop sending after %d packets and %d bytes - exchanges=%s",
- (index + 1), (index + 1L) * data.length, exchanges);
+ index + 11L, (index + 1L) * data.length, exchanges);
break;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/LoadTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/LoadTest.java b/sshd-core/src/test/java/org/apache/sshd/LoadTest.java
index 9916d14..d27e6c9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/LoadTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/LoadTest.java
@@ -35,9 +35,9 @@ import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.channel.ClientChannelEvent;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.channel.Channel;
-import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.cipher.Cipher;
import org.apache.sshd.common.kex.BuiltinDHFactories;
@@ -120,6 +120,7 @@ public class LoadTest extends BaseTestSupport {
}
}
+ @SuppressWarnings("checkstyle:nestedtrydepth")
protected void runClient(String msg) throws Exception {
try (SshClient client = setupTestClient()) {
PropertyResolverUtils.updateProperty(client, FactoryManager.MAX_PACKET_SIZE, 1024 * 16);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java b/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
index b20cfb7..61d0345 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
@@ -142,7 +142,7 @@ public class WindowAdjustTest extends BaseTestSupport {
private final ClientChannel channel;
private final byte eofSignal;
- public VerifyingOutputStream(ClientChannel channel, final byte eofSignal) {
+ VerifyingOutputStream(ClientChannel channel, final byte eofSignal) {
this.log = LoggerFactory.getLogger(getClass());
this.channel = channel;
this.eofSignal = eofSignal;
@@ -179,7 +179,7 @@ public class WindowAdjustTest extends BaseTestSupport {
}
public static final class FloodingAsyncCommand extends AbstractLoggingBean implements AsyncCommand {
- private static final AtomicInteger poolCount = new AtomicInteger(0);
+ private static final AtomicInteger POOL_COUNT = new AtomicInteger(0);
private final AtomicReference<ExecutorService> executorHolder = new AtomicReference<>();
private final AtomicReference<Future<?>> futureHolder = new AtomicReference<Future<?>>();
@@ -234,7 +234,7 @@ public class WindowAdjustTest extends BaseTestSupport {
public void start(Environment env) throws IOException {
log.info("Starting");
- ExecutorService service = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName() + "-" + poolCount.incrementAndGet());
+ ExecutorService service = ThreadUtils.newSingleThreadExecutor(getClass().getSimpleName() + "-" + POOL_COUNT.incrementAndGet());
executorHolder.set(service);
futureHolder.set(service.submit(new Runnable() {
@@ -287,7 +287,7 @@ public class WindowAdjustTest extends BaseTestSupport {
}
};
- public AsyncInPendingWrapper(IoOutputStream out) {
+ AsyncInPendingWrapper(IoOutputStream out) {
this.asyncIn = out;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java b/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
index a906c55..e27b505 100644
--- a/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/agent/AgentTest.java
@@ -98,6 +98,7 @@ public class AgentTest extends BaseTestSupport {
}
@Test
+ @SuppressWarnings("checkstyle:nestedtrydepth")
public void testAgentForwarding() throws Exception {
// TODO: revisit this test to work without BC
Assume.assumeTrue("BouncyCastle not registered", SecurityUtils.isBouncyCastleRegistered());
@@ -186,7 +187,13 @@ public class AgentTest extends BaseTestSupport {
}
public static class TestEchoShellFactory extends EchoShellFactory {
+ // CHECKSTYLE:OFF
public final TestEchoShell shell = new TestEchoShell();
+ // CHECKSTYLE:ON
+
+ public TestEchoShellFactory() {
+ super();
+ }
@Override
public Command create() {
@@ -195,7 +202,13 @@ public class AgentTest extends BaseTestSupport {
}
public static class TestEchoShell extends EchoShell {
+ // CHECKSTYLE:OFF
public boolean started;
+ // CHECKSTYLE:ON
+
+ public TestEchoShell() {
+ super();
+ }
@Override
public synchronized void start(Environment env) throws IOException {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/ClientAuthenticationManagerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/ClientAuthenticationManagerTest.java b/sshd-core/src/test/java/org/apache/sshd/client/ClientAuthenticationManagerTest.java
index 6aeae0e..2b9bf18 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/ClientAuthenticationManagerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/ClientAuthenticationManagerTest.java
@@ -105,12 +105,12 @@ public class ClientAuthenticationManagerTest extends BaseTestSupport {
setter.invoke(session, sessionProvider);
assertSame(baseName + ": mismatched session override provider", sessionProvider, getter.invoke(session));
- setter.invoke(session, new Object[] { null });
+ setter.invoke(session, new Object[]{null});
assertSame(baseName + ": mismatched nullified session provider", clientProvider, getter.invoke(session));
}
private <M extends ClientAuthenticationManager> M testClientAuthenticationManager(M manager) {
- {
+ if (manager != null) {
String expected = getCurrentTestName();
assertNull("Unexpected initial password identity", manager.removePasswordIdentity(expected));
manager.addPasswordIdentity(expected);
@@ -120,7 +120,7 @@ public class ClientAuthenticationManagerTest extends BaseTestSupport {
assertNull("Password identity not removed", manager.removePasswordIdentity(expected));
}
- {
+ if (manager != null) {
KeyPair expected = new KeyPair(Mockito.mock(PublicKey.class), Mockito.mock(PrivateKey.class));
assertNull("Unexpected initial pubket identity", manager.removePublicKeyIdentity(expected));
manager.addPublicKeyIdentity(expected);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
index 07070d5..e2aa279 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
@@ -241,7 +241,7 @@ public class ClientTest extends BaseTestSupport {
@Test
public void testPropertyResolutionHierarchy() throws Exception {
- final String SESSION_PROP_NAME = getCurrentTestName() + "-session";
+ final String sessionPropName = getCurrentTestName() + "-session";
final AtomicReference<Object> sessionConfigValueHolder = new AtomicReference<>(null);
client.addSessionListener(new SessionListener() {
@Override
@@ -265,12 +265,12 @@ public class ClientTest extends BaseTestSupport {
}
private void updateSessionConfigProperty(Session session, Object value) {
- PropertyResolverUtils.updateProperty(session, SESSION_PROP_NAME, value);
+ PropertyResolverUtils.updateProperty(session, sessionPropName, value);
sessionConfigValueHolder.set(value);
}
});
- final String CHANNEL_PROP_NAME = getCurrentTestName() + "-channel";
+ final String channelPropName = getCurrentTestName() + "-channel";
final AtomicReference<Object> channelConfigValueHolder = new AtomicReference<>(null);
client.addChannelListener(new ChannelListener() {
@Override
@@ -299,24 +299,24 @@ public class ClientTest extends BaseTestSupport {
}
private void updateChannelConfigProperty(Channel channel, Object value) {
- PropertyResolverUtils.updateProperty(channel, CHANNEL_PROP_NAME, value);
+ PropertyResolverUtils.updateProperty(channel, channelPropName, value);
channelConfigValueHolder.set(value);
}
});
client.start();
try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port).verify(7L, TimeUnit.SECONDS).getSession()) {
- assertSame("Session established", sessionConfigValueHolder.get(), PropertyResolverUtils.getObject(session, SESSION_PROP_NAME));
+ assertSame("Session established", sessionConfigValueHolder.get(), PropertyResolverUtils.getObject(session, sessionPropName));
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
- assertSame("Session authenticated", sessionConfigValueHolder.get(), PropertyResolverUtils.getObject(session, SESSION_PROP_NAME));
+ assertSame("Session authenticated", sessionConfigValueHolder.get(), PropertyResolverUtils.getObject(session, sessionPropName));
try (ChannelExec channel = session.createExecChannel(getCurrentTestName());
OutputStream stdout = new NoCloseOutputStream(System.out);
OutputStream stderr = new NoCloseOutputStream(System.err)) {
- assertSame("Channel created", channelConfigValueHolder.get(), PropertyResolverUtils.getObject(channel, CHANNEL_PROP_NAME));
- assertNull("Direct channel created session prop", PropertyResolverUtils.getObject(channel.getProperties(), SESSION_PROP_NAME));
- assertSame("Indirect channel created session prop", sessionConfigValueHolder.get(), PropertyResolverUtils.getObject(channel, SESSION_PROP_NAME));
+ assertSame("Channel created", channelConfigValueHolder.get(), PropertyResolverUtils.getObject(channel, channelPropName));
+ assertNull("Direct channel created session prop", PropertyResolverUtils.getObject(channel.getProperties(), sessionPropName));
+ assertSame("Indirect channel created session prop", sessionConfigValueHolder.get(), PropertyResolverUtils.getObject(channel, sessionPropName));
channel.setOut(stdout);
channel.setErr(stderr);
@@ -389,7 +389,7 @@ public class ClientTest extends BaseTestSupport {
out.reset();
err.reset();
- try(ChannelShell channel = session.createShellChannel()) {
+ try (ChannelShell channel = session.createShellChannel()) {
channel.setIn(inPipe);
channel.setOut(out);
channel.setErr(err);
@@ -497,7 +497,7 @@ public class ClientTest extends BaseTestSupport {
private <C extends Closeable> void testClientListener(AtomicReference<Channel> channelHolder, Class<C> channelType, Factory<? extends C> factory) throws Exception {
assertNull(channelType.getSimpleName() + ": Unexpected currently active channel", channelHolder.get());
- try(C instance = factory.create()) {
+ try (C instance = factory.create()) {
Channel expectedChannel;
if (instance instanceof Channel) {
expectedChannel = (Channel) instance;
@@ -532,71 +532,68 @@ public class ClientTest extends BaseTestSupport {
final int nbMessages = 1000;
try (final ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
- final ByteArrayOutputStream baosErr = new ByteArrayOutputStream()) {
- final AtomicInteger writes = new AtomicInteger(nbMessages);
-
- channel.getAsyncIn().write(new ByteArrayBuffer(message))
- .addListener(new SshFutureListener<IoWriteFuture>() {
- @Override
- public void operationComplete(IoWriteFuture future) {
- try {
- if (future.isWritten()) {
- if (writes.decrementAndGet() > 0) {
- channel.getAsyncIn().write(new ByteArrayBuffer(message)).addListener(this);
- } else {
- channel.getAsyncIn().close(false);
- }
- } else {
- throw new SshException("Error writing", future.getException());
- }
- } catch (IOException e) {
- if (!channel.isClosing()) {
- e.printStackTrace();
- channel.close(true);
- }
- }
- }
- });
- channel.getAsyncOut().read(new ByteArrayBuffer())
- .addListener(new SshFutureListener<IoReadFuture>() {
- @Override
- public void operationComplete(IoReadFuture future) {
- try {
- future.verify(5L, TimeUnit.SECONDS);
-
- Buffer buffer = future.getBuffer();
- baosOut.write(buffer.array(), buffer.rpos(), buffer.available());
- buffer.rpos(buffer.rpos() + buffer.available());
- buffer.compact();
- channel.getAsyncOut().read(buffer).addListener(this);
- } catch (IOException e) {
- if (!channel.isClosing()) {
- e.printStackTrace();
- channel.close(true);
- }
- }
- }
- });
- channel.getAsyncErr().read(new ByteArrayBuffer())
- .addListener(new SshFutureListener<IoReadFuture>() {
- @Override
- public void operationComplete(IoReadFuture future) {
- try {
- future.verify(5L, TimeUnit.SECONDS);
-
- Buffer buffer = future.getBuffer();
- baosErr.write(buffer.array(), buffer.rpos(), buffer.available());
- buffer.rpos(buffer.rpos() + buffer.available());
- buffer.compact();
- channel.getAsyncErr().read(buffer).addListener(this);
- } catch (IOException e) {
- if (!channel.isClosing()) {
- e.printStackTrace();
- channel.close(true);
- }
- }
+ final ByteArrayOutputStream baosErr = new ByteArrayOutputStream()) {
+ final AtomicInteger writes = new AtomicInteger(nbMessages);
+
+ channel.getAsyncIn().write(new ByteArrayBuffer(message)).addListener(new SshFutureListener<IoWriteFuture>() {
+ @Override
+ public void operationComplete(IoWriteFuture future) {
+ try {
+ if (future.isWritten()) {
+ if (writes.decrementAndGet() > 0) {
+ channel.getAsyncIn().write(new ByteArrayBuffer(message)).addListener(this);
+ } else {
+ channel.getAsyncIn().close(false);
}
- });
+ } else {
+ throw new SshException("Error writing", future.getException());
+ }
+ } catch (IOException e) {
+ if (!channel.isClosing()) {
+ e.printStackTrace();
+ channel.close(true);
+ }
+ }
+ }
+ });
+ channel.getAsyncOut().read(new ByteArrayBuffer()).addListener(new SshFutureListener<IoReadFuture>() {
+ @Override
+ public void operationComplete(IoReadFuture future) {
+ try {
+ future.verify(5L, TimeUnit.SECONDS);
+
+ Buffer buffer = future.getBuffer();
+ baosOut.write(buffer.array(), buffer.rpos(), buffer.available());
+ buffer.rpos(buffer.rpos() + buffer.available());
+ buffer.compact();
+ channel.getAsyncOut().read(buffer).addListener(this);
+ } catch (IOException e) {
+ if (!channel.isClosing()) {
+ e.printStackTrace();
+ channel.close(true);
+ }
+ }
+ }
+ });
+ channel.getAsyncErr().read(new ByteArrayBuffer()).addListener(new SshFutureListener<IoReadFuture>() {
+ @Override
+ public void operationComplete(IoReadFuture future) {
+ try {
+ future.verify(5L, TimeUnit.SECONDS);
+
+ Buffer buffer = future.getBuffer();
+ baosErr.write(buffer.array(), buffer.rpos(), buffer.available());
+ buffer.rpos(buffer.rpos() + buffer.available());
+ buffer.compact();
+ channel.getAsyncErr().read(buffer).addListener(this);
+ } catch (IOException e) {
+ if (!channel.isClosing()) {
+ e.printStackTrace();
+ channel.close(true);
+ }
+ }
+ }
+ });
Collection<ClientChannelEvent> result =
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), TimeUnit.SECONDS.toMillis(15L));
@@ -1093,7 +1090,7 @@ public class ClientTest extends BaseTestSupport {
final Transformer<String, String> stripper = new Transformer<String, String>() {
@Override
public String transform(String input) {
- int pos = GenericUtils.isEmpty(input) ? (-1) : input.lastIndexOf(':');
+ int pos = GenericUtils.isEmpty(input) ? -1 : input.lastIndexOf(':');
if (pos < 0) {
return input;
} else {
@@ -1171,7 +1168,7 @@ public class ClientTest extends BaseTestSupport {
final AtomicInteger count = new AtomicInteger();
final AtomicReference<ClientSession> interactionSessionHolder = new AtomicReference<>(null);
client.setUserInteraction(new UserInteraction() {
- private final String[] BAD_RESPONSE = { "bad" };
+ private final String[] badResponse = {"bad"};
@Override
public boolean isInteractionAllowed(ClientSession session) {
@@ -1187,7 +1184,7 @@ public class ClientTest extends BaseTestSupport {
public String[] interactive(ClientSession session, String name, String instruction, String lang, String[] prompt, boolean[] echo) {
validateSession("interactive", session);
count.incrementAndGet();
- return BAD_RESPONSE;
+ return badResponse;
}
@Override
@@ -1203,8 +1200,8 @@ public class ClientTest extends BaseTestSupport {
}
});
- final int MAX_PROMPTS = 3;
- PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PASSWORD_PROMPTS, MAX_PROMPTS);
+ final int maxPrompts = 3;
+ PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PASSWORD_PROMPTS, maxPrompts);
client.start();
@@ -1214,7 +1211,7 @@ public class ClientTest extends BaseTestSupport {
AuthFuture future = session.auth();
assertTrue("Failed to complete authentication on time", future.await(15L, TimeUnit.SECONDS));
assertTrue("Unexpected authentication success", future.isFailure());
- assertEquals("Mismatched authentication retry count", MAX_PROMPTS, count.get());
+ assertEquals("Mismatched authentication retry count", maxPrompts, count.get());
} finally {
client.stop();
}
@@ -1225,8 +1222,8 @@ public class ClientTest extends BaseTestSupport {
@Test
public void testDefaultKeyboardInteractiveInSessionUserInteractive() throws Exception {
final AtomicInteger count = new AtomicInteger();
- final int MAX_PROMPTS = 3;
- PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PASSWORD_PROMPTS, MAX_PROMPTS);
+ final int maxPrompts = 3;
+ PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PASSWORD_PROMPTS, maxPrompts);
client.setUserAuthFactories(Collections.<NamedFactory<UserAuth>>singletonList(UserAuthKeyboardInteractiveFactory.INSTANCE));
client.start();
@@ -1272,8 +1269,8 @@ public class ClientTest extends BaseTestSupport {
@Test
public void testKeyboardInteractiveInSessionUserInteractiveFailure() throws Exception {
final AtomicInteger count = new AtomicInteger();
- final int MAX_PROMPTS = 3;
- PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PASSWORD_PROMPTS, MAX_PROMPTS);
+ final int maxPrompts = 3;
+ PropertyResolverUtils.updateProperty(client, ClientAuthenticationManager.PASSWORD_PROMPTS, maxPrompts);
client.setUserAuthFactories(Collections.<NamedFactory<UserAuth>>singletonList(UserAuthKeyboardInteractiveFactory.INSTANCE));
client.start();
@@ -1306,7 +1303,7 @@ public class ClientTest extends BaseTestSupport {
AuthFuture future = session.auth();
assertTrue("Authentication not completed in time", future.await(11L, TimeUnit.SECONDS));
assertTrue("Authentication not, marked as failure", future.isFailure());
- assertEquals("Mismatched authentication retry count", MAX_PROMPTS, count.get());
+ assertEquals("Mismatched authentication retry count", maxPrompts, count.get());
} finally {
client.stop();
}
@@ -1418,7 +1415,7 @@ public class ClientTest extends BaseTestSupport {
*/
@Test
public void testChannelListenersPropagation() throws Exception {
- Map<String,TestChannelListener> clientListeners = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ Map<String, TestChannelListener> clientListeners = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
addChannelListener(clientListeners, client, new TestChannelListener(client.getClass().getSimpleName()));
// required since we do not use an SFTP subsystem
@@ -1447,7 +1444,7 @@ public class ClientTest extends BaseTestSupport {
assertListenerSizes("ClientStop", clientListeners, 0, 1);
}
- private static void assertListenerSizes(String phase, Map<String,? extends TestChannelListener> listeners, int activeSize, int openSize) {
+ private static void assertListenerSizes(String phase, Map<String, ? extends TestChannelListener> listeners, int activeSize, int openSize) {
assertListenerSizes(phase, listeners.values(), activeSize, openSize);
}
@@ -1469,7 +1466,7 @@ public class ClientTest extends BaseTestSupport {
}
}
- private static <L extends ChannelListener & NamedResource> void addChannelListener(Map<String,L> listeners, ChannelListenerManager manager, L listener) {
+ private static <L extends ChannelListener & NamedResource> void addChannelListener(Map<String, L> listeners, ChannelListenerManager manager, L listener) {
String name = listener.getName();
assertNull("Duplicate listener named " + name, listeners.put(name, listener));
manager.addChannelListener(listener);
@@ -1513,7 +1510,13 @@ public class ClientTest extends BaseTestSupport {
}
public static class TestEchoShell extends EchoShell {
+ // CHECKSTYLE:OFF
public static CountDownLatch latch;
+ // CHECKSTYLE:ON
+
+ public TestEchoShell() {
+ super();
+ }
@Override
public void destroy() {
@@ -1543,8 +1546,4 @@ public class ClientTest extends BaseTestSupport {
return getName();
}
}
-
- public static void main(String[] args) throws Exception {
- SshClient.main(args);
- }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/SshClientMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/SshClientMain.java b/sshd-core/src/test/java/org/apache/sshd/client/SshClientMain.java
index 8d770c4..66f66dd 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/SshClientMain.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/SshClientMain.java
@@ -25,7 +25,11 @@ package org.apache.sshd.client;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SshClientMain {
+public final class SshClientMain {
+ private SshClientMain() {
+ throw new UnsupportedOperationException("No instance");
+ }
+
public static void main(String[] args) throws Exception {
SshClient.main(args);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/auth/PasswordIdentityProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/auth/PasswordIdentityProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/client/auth/PasswordIdentityProviderTest.java
index 9ed8497..bdda762 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/auth/PasswordIdentityProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/auth/PasswordIdentityProviderTest.java
@@ -44,9 +44,9 @@ public class PasswordIdentityProviderTest extends BaseTestSupport {
@Test
public void testMultiProvider() {
String[][] values = {
- { getClass().getSimpleName(), getCurrentTestName() },
- { new Date(System.currentTimeMillis()).toString() },
- { getClass().getPackage().getName() }
+ {getClass().getSimpleName(), getCurrentTestName()},
+ {new Date(System.currentTimeMillis()).toString()},
+ {getClass().getPackage().getName()}
};
List<String> expected = new ArrayList<>();
Collection<PasswordIdentityProvider> providers = new LinkedList<>();
[4/5] mina-sshd git commit: [SSHD-655] Apply checkstyle plugin to
test source code as well
Posted by lg...@apache.org.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolverTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolverTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolverTest.java
index a75e18f..1a7e319 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolverTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/ConfigFileHostEntryResolverTest.java
@@ -65,19 +65,39 @@ public class ConfigFileHostEntryResolverTest extends BaseTestSupport {
resolver, expected, expected);
testConfigFileReload("Wildcard", path, reloadCount,
Arrays.asList(
- new HostConfigEntry(HostPatternsHolder.ALL_HOSTS_PATTERN, getClass().getSimpleName(), 1234, getClass().getSimpleName()),
- new HostConfigEntry(expected.getHost() + String.valueOf(HostPatternsHolder.WILDCARD_PATTERN), expected.getHost(), expected.getPort(), expected.getUsername())),
+ new HostConfigEntry(
+ HostPatternsHolder.ALL_HOSTS_PATTERN,
+ getClass().getSimpleName(),
+ 1234,
+ getClass().getSimpleName()),
+ new HostConfigEntry(
+ expected.getHost() + String.valueOf(HostPatternsHolder.WILDCARD_PATTERN),
+ expected.getHost(),
+ expected.getPort(),
+ expected.getUsername())),
resolver, expected, expected);
testConfigFileReload("Specific", path, reloadCount,
Arrays.asList(
- new HostConfigEntry(HostPatternsHolder.ALL_HOSTS_PATTERN, getClass().getSimpleName(), 1234, getClass().getSimpleName()),
- new HostConfigEntry(getClass().getSimpleName() + String.valueOf(HostPatternsHolder.WILDCARD_PATTERN), getClass().getSimpleName(), 1234, getClass().getSimpleName()),
+ new HostConfigEntry(
+ HostPatternsHolder.ALL_HOSTS_PATTERN,
+ getClass().getSimpleName(),
+ 1234,
+ getClass().getSimpleName()),
+ new HostConfigEntry(
+ getClass().getSimpleName() + String.valueOf(HostPatternsHolder.WILDCARD_PATTERN),
+ getClass().getSimpleName(),
+ 1234,
+ getClass().getSimpleName()),
expected),
resolver, expected, expected);
}
private static void testConfigFileReload(
- String phase, Path path, AtomicInteger reloadCount, Collection<? extends HostConfigEntry> entries, HostConfigEntryResolver resolver, HostConfigEntry query, HostConfigEntry expected)
+ String phase, Path path, AtomicInteger reloadCount,
+ Collection<? extends HostConfigEntry> entries,
+ HostConfigEntryResolver resolver,
+ HostConfigEntry query,
+ HostConfigEntry expected)
throws IOException {
if (entries == null) {
if (Files.exists(path)) {
@@ -90,7 +110,8 @@ public class ConfigFileHostEntryResolverTest extends BaseTestSupport {
reloadCount.set(0);
for (int index = 1; index < Byte.SIZE; index++) {
- HostConfigEntry actual = resolver.resolveEffectiveHost(query.getHostName(), query.getPort(), query.getUsername());
+ HostConfigEntry actual =
+ resolver.resolveEffectiveHost(query.getHostName(), query.getPort(), query.getUsername());
if (entries == null) {
assertEquals(phase + "[" + index + "]: mismatched reload count", 0, reloadCount.get());
@@ -103,9 +124,12 @@ public class ConfigFileHostEntryResolverTest extends BaseTestSupport {
} else {
assertNotNull(phase + "[" + index + "]: No result for " + query, actual);
assertNotSame(phase + "[" + index + "]: No cloned result for " + query, expected, actual);
- assertEquals(phase + "[" + index + "]: Mismatched host for " + query, expected.getHostName(), actual.getHostName());
- assertEquals(phase + "[" + index + "]: Mismatched port for " + query, expected.getPort(), actual.getPort());
- assertEquals(phase + "[" + index + "]: Mismatched user for " + query, expected.getUsername(), actual.getUsername());
+ assertEquals(phase + "[" + index + "]: Mismatched host for " + query,
+ expected.getHostName(), actual.getHostName());
+ assertEquals(phase + "[" + index + "]: Mismatched port for " + query,
+ expected.getPort(), actual.getPort());
+ assertEquals(phase + "[" + index + "]: Mismatched user for " + query,
+ expected.getUsername(), actual.getUsername());
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
index 4296b72..ccb874f 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryResolverTest.java
@@ -101,7 +101,10 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
});
client.start();
- try(ClientSession session = client.connect(getClass().getSimpleName(), getClass().getPackage().getName(), getMovedPortNumber(port)).verify(7L, TimeUnit.SECONDS).getSession()) {
+ try (ClientSession session = client.connect(
+ getClass().getSimpleName(),
+ getClass().getPackage().getName(),
+ getMovedPortNumber(port)).verify(7L, TimeUnit.SECONDS).getSession()) {
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
assertEffectiveRemoteAddress(session, entry);
@@ -118,10 +121,15 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
positiveEntry.getHostName(),
getMovedPortNumber(positiveEntry.getPort()),
getClass().getPackage().getName());
- client.setHostConfigEntryResolver(HostConfigEntry.toHostConfigEntryResolver(Arrays.asList(negativeEntry, positiveEntry)));
+ client.setHostConfigEntryResolver(
+ HostConfigEntry.toHostConfigEntryResolver(
+ Arrays.asList(negativeEntry, positiveEntry)));
client.start();
- try(ClientSession session = client.connect(negativeEntry.getUsername(), negativeEntry.getHostName(), negativeEntry.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) {
+ try (ClientSession session = client.connect(
+ negativeEntry.getUsername(),
+ negativeEntry.getHostName(),
+ negativeEntry.getPort()).verify(7L, TimeUnit.SECONDS).getSession()) {
session.addPasswordIdentity(getCurrentTestName());
session.auth().verify(5L, TimeUnit.SECONDS);
assertEffectiveRemoteAddress(session, positiveEntry);
@@ -133,12 +141,12 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
@Test
public void testPreloadedIdentities() throws Exception {
final KeyPair identity = Utils.getFirstKeyPair(sshd);
- final String USER = getCurrentTestName();
+ final String user = getCurrentTestName();
// make sure authentication is achieved only via the identity public key
sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
@Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
- if (USER.equals(username)) {
+ if (user.equals(username)) {
return KeyUtils.compareKeys(identity.getPublic(), key);
}
@@ -147,15 +155,16 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
});
sshd.setPasswordAuthenticator(RejectAllPasswordAuthenticator.INSTANCE);
- final String IDENTITY = getCurrentTestName();
+ final String clientIdentity = getCurrentTestName();
client.setClientIdentityLoader(new ClientIdentityLoader() {
@Override
public boolean isValidLocation(String location) throws IOException {
- return IDENTITY.equals(location);
+ return clientIdentity.equals(location);
}
@Override
- public KeyPair loadClientIdentity(String location, FilePasswordProvider provider) throws IOException, GeneralSecurityException {
+ public KeyPair loadClientIdentity(String location, FilePasswordProvider provider)
+ throws IOException, GeneralSecurityException {
if (isValidLocation(location)) {
return identity;
}
@@ -165,9 +174,9 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
});
PropertyResolverUtils.updateProperty(client, ClientFactoryManager.IGNORE_INVALID_IDENTITIES, false);
- final String HOST = getClass().getSimpleName();
- final HostConfigEntry entry = new HostConfigEntry(HOST, TEST_LOCALHOST, port, USER);
- entry.addIdentity(IDENTITY);
+ final String host = getClass().getSimpleName();
+ final HostConfigEntry entry = new HostConfigEntry(host, TEST_LOCALHOST, port, user);
+ entry.addIdentity(clientIdentity);
client.setHostConfigEntryResolver(new HostConfigEntryResolver() {
@Override
public HostConfigEntry resolveEffectiveHost(String host, int portValue, String username) throws IOException {
@@ -176,7 +185,8 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
});
client.start();
- try(ClientSession session = client.connect(USER, HOST, getMovedPortNumber(port)).verify(7L, TimeUnit.SECONDS).getSession()) {
+ try (ClientSession session = client.connect(
+ user, host, getMovedPortNumber(port)).verify(7L, TimeUnit.SECONDS).getSession()) {
session.auth().verify(5L, TimeUnit.SECONDS);
assertEffectiveRemoteAddress(session, entry);
} finally {
@@ -187,14 +197,16 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
@Test
public void testUseIdentitiesOnly() throws Exception {
Path clientIdFile = assertHierarchyTargetFolderExists(getTempTargetRelativeFile(getClass().getSimpleName()));
- KeyPairProvider clientIdProvider = Utils.createTestHostKeyProvider(clientIdFile.resolve(getCurrentTestName() + ".pem"));
+ KeyPairProvider clientIdProvider =
+ Utils.createTestHostKeyProvider(clientIdFile.resolve(getCurrentTestName() + ".pem"));
final KeyPair specificIdentity = Utils.getFirstKeyPair(sshd);
final KeyPair defaultIdentity = Utils.getFirstKeyPair(clientIdProvider);
- ValidateUtils.checkTrue(!KeyUtils.compareKeyPairs(specificIdentity, defaultIdentity), "client identity not different then entry one");
+ ValidateUtils.checkTrue(!KeyUtils.compareKeyPairs(specificIdentity, defaultIdentity),
+ "client identity not different then entry one");
client.setKeyPairProvider(clientIdProvider);
- final String USER = getCurrentTestName();
+ final String user = getCurrentTestName();
final AtomicBoolean defaultClientIdentityAttempted = new AtomicBoolean(false);
// make sure authentication is achieved only via the identity public key
sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
@@ -204,7 +216,7 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
defaultClientIdentityAttempted.set(true);
}
- if (USER.equals(username)) {
+ if (user.equals(username)) {
return KeyUtils.compareKeys(specificIdentity.getPublic(), key);
}
@@ -213,19 +225,20 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
});
sshd.setPasswordAuthenticator(RejectAllPasswordAuthenticator.INSTANCE);
- final String IDENTITY = getCurrentTestName();
- HostConfigEntry entry = new HostConfigEntry(TEST_LOCALHOST, TEST_LOCALHOST, port, USER);
- entry.addIdentity(IDENTITY);
+ final String clientIdentity = getCurrentTestName();
+ HostConfigEntry entry = new HostConfigEntry(TEST_LOCALHOST, TEST_LOCALHOST, port, user);
+ entry.addIdentity(clientIdentity);
entry.setIdentitiesOnly(true);
client.setClientIdentityLoader(new ClientIdentityLoader() {
@Override
public boolean isValidLocation(String location) throws IOException {
- return IDENTITY.equals(location);
+ return clientIdentity.equals(location);
}
@Override
- public KeyPair loadClientIdentity(String location, FilePasswordProvider provider) throws IOException, GeneralSecurityException {
+ public KeyPair loadClientIdentity(String location, FilePasswordProvider provider)
+ throws IOException, GeneralSecurityException {
if (isValidLocation(location)) {
return specificIdentity;
}
@@ -245,7 +258,7 @@ public class HostConfigEntryResolverTest extends BaseTestSupport {
client.setKeyPairProvider(provider);
client.start();
- try(ClientSession session = client.connect(entry).verify(7L, TimeUnit.SECONDS).getSession()) {
+ try (ClientSession session = client.connect(entry).verify(7L, TimeUnit.SECONDS).getSession()) {
assertSame("Unexpected session key pairs provider", provider, session.getKeyPairProvider());
session.auth().verify(5L, TimeUnit.SECONDS);
assertFalse("Unexpected default client identity attempted", defaultClientIdentityAttempted.get());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
index 635c6cc..814deb6 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/HostConfigEntryTest.java
@@ -93,7 +93,7 @@ public class HostConfigEntryTest extends BaseTestSupport {
getCurrentTestName(),
getClass().getSimpleName() + "-" + getCurrentTestName(),
getClass().getSimpleName() + "." + getCurrentTestName(),
- }) {
+ }) {
sb.setLength(0); // start from scratch
sb.append(host).append(domain);
@@ -120,7 +120,7 @@ public class HostConfigEntryTest extends BaseTestSupport {
public void testHostSingleCharPatternMatching() {
String value = getCurrentTestName();
StringBuilder sb = new StringBuilder(value);
- for (boolean restoreOriginal : new boolean[] { true, false }) {
+ for (boolean restoreOriginal : new boolean[] {true, false}) {
for (int index = 0; index < value.length(); index++) {
sb.setCharAt(index, HostPatternsHolder.SINGLE_CHAR_PATTERN);
testCaseInsensitivePatternMatching(value, HostPatternsHolder.toPattern(sb.toString()).getFirst(), true);
@@ -170,14 +170,15 @@ public class HostConfigEntryTest extends BaseTestSupport {
assertTrue("Valid character not recognized: " + String.valueOf(ch), HostPatternsHolder.isValidPatternChar(ch));
}
- for (char ch : new char[] { '-', '_', '.', HostPatternsHolder.SINGLE_CHAR_PATTERN, HostPatternsHolder.WILDCARD_PATTERN }) {
+ for (char ch : new char[] {'-', '_', '.', HostPatternsHolder.SINGLE_CHAR_PATTERN, HostPatternsHolder.WILDCARD_PATTERN}) {
assertTrue("Valid character not recognized: " + String.valueOf(ch), HostPatternsHolder.isValidPatternChar(ch));
}
for (char ch : new char[] {
- '(', ')', '{', '}', '[', ']', '@',
- '#', '$', '^', '&', '%', '~', '<', '>',
- ',', '/', '\\', '\'', '"', ':', ';' }) {
+ '(', ')', '{', '}', '[', ']', '@',
+ '#', '$', '^', '&', '%', '~', '<', '>',
+ ',', '/', '\\', '\'', '"', ':', ';'
+ }) {
assertFalse("Unexpected valid character: " + String.valueOf(ch), HostPatternsHolder.isValidPatternChar(ch));
}
@@ -188,23 +189,27 @@ public class HostConfigEntryTest extends BaseTestSupport {
@Test
public void testResolvePort() {
- final int ORIGINAL_PORT = Short.MAX_VALUE;
- final int ENTRY_PORT = 7365;
- assertEquals("Mismatched entry port preference", ENTRY_PORT, HostConfigEntry.resolvePort(ORIGINAL_PORT, ENTRY_PORT));
-
- for (int entryPort : new int[] { -1, 0 }) {
- assertEquals("Non-preferred original port for entry port=" + entryPort, ORIGINAL_PORT, HostConfigEntry.resolvePort(ORIGINAL_PORT, entryPort));
+ final int originalPort = Short.MAX_VALUE;
+ final int preferredPort = 7365;
+ assertEquals("Mismatched entry port preference",
+ preferredPort, HostConfigEntry.resolvePort(originalPort, preferredPort));
+
+ for (int entryPort : new int[] {-1, 0}) {
+ assertEquals("Non-preferred original port for entry port=" + entryPort,
+ originalPort, HostConfigEntry.resolvePort(originalPort, entryPort));
}
}
@Test
public void testResolveUsername() {
- final String ORIGINAL_USER = getCurrentTestName();
- final String ENTRY_USER = getClass().getSimpleName();
- assertSame("Mismatched entry user preference", ENTRY_USER, HostConfigEntry.resolveUsername(ORIGINAL_USER, ENTRY_USER));
-
- for (String entryUser : new String[] { null, "" }) {
- assertSame("Non-preferred original user for entry user='" + entryUser + "'", ORIGINAL_USER, HostConfigEntry.resolveUsername(ORIGINAL_USER, entryUser));
+ final String originalUser = getCurrentTestName();
+ final String preferredUser = getClass().getSimpleName();
+ assertSame("Mismatched entry user preference",
+ preferredUser, HostConfigEntry.resolveUsername(originalUser, preferredUser));
+
+ for (String entryUser : new String[] {null, ""}) {
+ assertSame("Non-preferred original user for entry user='" + entryUser + "'",
+ originalUser, HostConfigEntry.resolveUsername(originalUser, entryUser));
}
}
@@ -241,20 +246,20 @@ public class HostConfigEntryTest extends BaseTestSupport {
@Test
public void testResolveIdentityFilePath() throws Exception {
- final String HOST = getClass().getSimpleName();
- final int PORT = 7365;
- final String USER = getCurrentTestName();
+ final String hostValue = getClass().getSimpleName();
+ final int portValue = 7365;
+ final String userValue = getCurrentTestName();
Exception err = null;
for (String pattern : new String[] {
- "~/.ssh/%h.key",
- "%d/.ssh/%h.key",
- "/home/%u/.ssh/id_rsa_%p",
- "/home/%u/.ssh/id_%r_rsa",
- "/home/%u/.ssh/%h/%l.key"
+ "~/.ssh/%h.key",
+ "%d/.ssh/%h.key",
+ "/home/%u/.ssh/id_rsa_%p",
+ "/home/%u/.ssh/id_%r_rsa",
+ "/home/%u/.ssh/%h/%l.key"
}) {
try {
- String result = HostConfigEntry.resolveIdentityFilePath(pattern, HOST, PORT, USER);
+ String result = HostConfigEntry.resolveIdentityFilePath(pattern, hostValue, portValue, userValue);
System.out.append('\t').append(pattern).append(" => ").println(result);
} catch (Exception e) {
System.err.append("Failed (").append(e.getClass().getSimpleName())
@@ -271,11 +276,11 @@ public class HostConfigEntryTest extends BaseTestSupport {
@Test
public void testFindBestMatch() {
- final String HOST = getCurrentTestName();
- HostConfigEntry expected = new HostConfigEntry(HOST, HOST, 7365, HOST);
+ final String hostValue = getCurrentTestName();
+ HostConfigEntry expected = new HostConfigEntry(hostValue, hostValue, 7365, hostValue);
List<HostConfigEntry> matches = new ArrayList<>();
matches.add(new HostConfigEntry(HostPatternsHolder.ALL_HOSTS_PATTERN, getClass().getSimpleName(), Short.MAX_VALUE, getClass().getSimpleName()));
- matches.add(new HostConfigEntry(HOST + String.valueOf(HostPatternsHolder.WILDCARD_PATTERN), getClass().getSimpleName(), Byte.MAX_VALUE, getClass().getSimpleName()));
+ matches.add(new HostConfigEntry(hostValue + String.valueOf(HostPatternsHolder.WILDCARD_PATTERN), getClass().getSimpleName(), Byte.MAX_VALUE, getClass().getSimpleName()));
matches.add(expected);
for (int index = 0; index < matches.size(); index++) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/KnownHostHashValueTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/KnownHostHashValueTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/KnownHostHashValueTest.java
index 2dcdbff..4fa4943 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/KnownHostHashValueTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/hosts/KnownHostHashValueTest.java
@@ -49,7 +49,7 @@ public class KnownHostHashValueTest extends BaseTestSupport {
@Parameters(name = "host={0}, hash={1}")
public static Collection<Object[]> parameters() {
return Arrays.<Object[]>asList(
- (Object[]) new String[]{ "192.168.1.61", "|1|F1E1KeoE/eEWhi10WpGv4OdiO6Y=|3988QV0VE8wmZL7suNrYQLITLCg=" });
+ (Object[]) new String[]{"192.168.1.61", "|1|F1E1KeoE/eEWhi10WpGv4OdiO6Y=|3988QV0VE8wmZL7suNrYQLITLCg="});
}
@Test
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
index 1a55b6e..9599684 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/keys/BuiltinClientIdentitiesWatcherTest.java
@@ -134,7 +134,7 @@ public class BuiltinClientIdentitiesWatcherTest extends BaseTestSupport {
options = new OpenOption[]{StandardOpenOption.WRITE, StandardOpenOption.APPEND};
}
- try(OutputStream out = Files.newOutputStream(idFile, options)) {
+ try (OutputStream out = Files.newOutputStream(idFile, options)) {
out.write(new Date(System.currentTimeMillis()).toString().getBytes(StandardCharsets.UTF_8));
out.write('\n');
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcherTest.java b/sshd-core/src/test/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcherTest.java
index 6a6ee3c..a44fad6 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/config/keys/ClientIdentityFileWatcherTest.java
@@ -102,7 +102,7 @@ public class ClientIdentityFileWatcherTest extends BaseTestSupport {
options = new OpenOption[]{StandardOpenOption.WRITE, StandardOpenOption.APPEND};
}
- try(OutputStream out = Files.newOutputStream(idFile, options)) {
+ try (OutputStream out = Files.newOutputStream(idFile, options)) {
out.write(new Date(System.currentTimeMillis()).toString().getBytes(StandardCharsets.UTF_8));
out.write('\n');
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java b/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
index 97ee2de..28abac5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/keyverifier/KnownHostsServerKeyVerifierTest.java
@@ -62,7 +62,7 @@ import org.mockito.Mockito;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class KnownHostsServerKeyVerifierTest extends BaseTestSupport {
private static final String HASHED_HOST = "192.168.1.61";
- private static final Map<String, PublicKey> hostsKeys = new TreeMap<String, PublicKey>(String.CASE_INSENSITIVE_ORDER);
+ private static final Map<String, PublicKey> HOST_KEYS = new TreeMap<String, PublicKey>(String.CASE_INSENSITIVE_ORDER);
private static Map<String, KnownHostEntry> hostsEntries;
private static Path entriesFile;
@@ -83,7 +83,7 @@ public class KnownHostsServerKeyVerifierTest extends BaseTestSupport {
KnownHostEntry entry = ke.getValue();
AuthorizedKeyEntry authEntry = ValidateUtils.checkNotNull(entry.getKeyEntry(), "No key extracted from %s", entry);
PublicKey key = authEntry.resolvePublicKey(PublicKeyEntryResolver.FAILING);
- assertNull("Multiple keys for host=" + host, hostsKeys.put(host, key));
+ assertNull("Multiple keys for host=" + host, HOST_KEYS.put(host, key));
}
}
@@ -113,7 +113,7 @@ public class KnownHostsServerKeyVerifierTest extends BaseTestSupport {
};
- for (Map.Entry<String, PublicKey> ke : hostsKeys.entrySet()) {
+ for (Map.Entry<String, PublicKey> ke : HOST_KEYS.entrySet()) {
String host = ke.getKey();
PublicKey serverKey = ke.getValue();
KnownHostEntry entry = hostsEntries.get(host);
@@ -151,7 +151,7 @@ public class KnownHostsServerKeyVerifierTest extends BaseTestSupport {
};
int verificationCount = 0;
- for (Map.Entry<String, PublicKey> ke : hostsKeys.entrySet()) {
+ for (Map.Entry<String, PublicKey> ke : HOST_KEYS.entrySet()) {
String host = ke.getKey();
PublicKey serverKey = ke.getValue();
KnownHostEntry entry = hostsEntries.get(host);
@@ -205,7 +205,7 @@ public class KnownHostsServerKeyVerifierTest extends BaseTestSupport {
ClientSession session = Mockito.mock(ClientSession.class);
Mockito.when(session.getFactoryManager()).thenReturn(manager);
- for (Map.Entry<String, PublicKey> ke : hostsKeys.entrySet()) {
+ for (Map.Entry<String, PublicKey> ke : HOST_KEYS.entrySet()) {
String host = ke.getKey();
PublicKey serverKey = ke.getValue();
KnownHostEntry entry = hostsEntries.get(host);
@@ -225,7 +225,7 @@ public class KnownHostsServerKeyVerifierTest extends BaseTestSupport {
verifier.setLoadedHostsEntries(keys);
// make sure can still validate the original hosts
- for (Map.Entry<String, PublicKey> ke : hostsKeys.entrySet()) {
+ for (Map.Entry<String, PublicKey> ke : HOST_KEYS.entrySet()) {
String host = ke.getKey();
PublicKey serverKey = ke.getValue();
KnownHostEntry entry = hostsEntries.get(host);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpCommandMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpCommandMain.java b/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpCommandMain.java
index cd3d75e..75b0454 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpCommandMain.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpCommandMain.java
@@ -19,15 +19,17 @@
package org.apache.sshd.client.scp;
-import org.apache.sshd.client.scp.DefaultScpClient;
-
/**
- * Just a test class used to invoke {@link DefaultScpClient#main(String[])} in
+ * Just a test class used to invoke {@link org.apache.sshd.client.scp.DefaultScpClient#main(String[])} in
* order to have logging - which is in {@code test} scope
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ScpCommandMain {
+public final class ScpCommandMain {
+ private ScpCommandMain() {
+ throw new UnsupportedOperationException("No instance");
+ }
+
public static void main(String[] args) throws Exception {
DefaultScpClient.main(args);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java b/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
index 928ee4c..b797680 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/scp/ScpTest.java
@@ -39,6 +39,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.Factory;
@@ -72,10 +76,6 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.ConnectionInfo;
import ch.ethz.ssh2.SCPClient;
@@ -118,8 +118,7 @@ public class ScpTest extends BaseTestSupport {
.append('[').append(op).append(']')
.append(' ').append(isFile ? "File" : "Directory").append('=').append(path)
.append(' ').append("length=").append(length)
- .append(' ').append("perms=").append(perms)
- ;
+ .append(' ').append("perms=").append(perms);
if (t != null) {
sb.append(' ').append("ERROR=").append(t.getClass().getSimpleName()).append(": ").append(t.getMessage());
}
@@ -824,11 +823,11 @@ public class ScpTest extends BaseTestSupport {
@Test // see SSHD-628
public void testScpExitStatusPropagation() throws Exception {
- final int TEST_EXIT_VALUE = 7365;
+ final int testExitValue = 7365;
class InternalScpCommand extends ScpCommand implements ExitCallback {
private ExitCallback delegate;
- public InternalScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit,
+ InternalScpCommand(String command, ExecutorService executorService, boolean shutdownOnExit,
int sendSize, int receiveSize, ScpFileOpener opener, ScpTransferEventListener eventListener) {
super(command, executorService, shutdownOnExit, sendSize, receiveSize, opener, eventListener);
}
@@ -836,7 +835,7 @@ public class ScpTest extends BaseTestSupport {
@Override
protected void writeCommandResponseMessage(String command, int exitValue, String exitMessage) throws IOException {
outputDebugMessage("writeCommandResponseMessage(%s) status=%d", command, exitValue);
- super.writeCommandResponseMessage(command, TEST_EXIT_VALUE, exitMessage);
+ super.writeCommandResponseMessage(command, testExitValue, exitMessage);
}
@Override
@@ -854,7 +853,7 @@ public class ScpTest extends BaseTestSupport {
public void onExit(int exitValue, String exitMessage) {
outputDebugMessage("onExit(%s) status=%d", this, exitValue);
if (exitValue == ScpHelper.OK) {
- delegate.onExit(TEST_EXIT_VALUE, exitMessage);
+ delegate.onExit(testExitValue, exitMessage);
} else {
delegate.onExit(exitValue, exitMessage);
}
@@ -895,7 +894,7 @@ public class ScpTest extends BaseTestSupport {
} catch (ScpException e) {
Integer exitCode = e.getExitStatus();
assertNotNull("No upload exit status", exitCode);
- assertEquals("Mismatched upload exit status", TEST_EXIT_VALUE, exitCode.intValue());
+ assertEquals("Mismatched upload exit status", testExitValue, exitCode.intValue());
}
if (Files.deleteIfExists(remoteFile)) {
@@ -912,7 +911,7 @@ public class ScpTest extends BaseTestSupport {
} catch (ScpException e) {
Integer exitCode = e.getExitStatus();
assertNotNull("No download exit status", exitCode);
- assertEquals("Mismatched download exit status", TEST_EXIT_VALUE, exitCode.intValue());
+ assertEquals("Mismatched download exit status", testExitValue, exitCode.intValue());
}
} finally {
client.stop();
@@ -930,11 +929,9 @@ public class ScpTest extends BaseTestSupport {
if (!modSuccess) {
System.err.append("Failed to set last modified time of ").append(file.getAbsolutePath())
.append(" to ").append(String.valueOf(expectedMillis))
- .append(" - ").println(new Date(expectedMillis))
- ;
+ .append(" - ").println(new Date(expectedMillis));
System.err.append("\t\t").append("Current value: ").append(String.valueOf(actualMillis))
- .append(" - ").println(new Date(actualMillis))
- ;
+ .append(" - ").println(new Date(actualMillis));
return;
}
@@ -1031,8 +1028,8 @@ public class ScpTest extends BaseTestSupport {
info.clientToServerMACAlgorithm, info.serverToClientMACAlgorithm);
assertTrue("Failed to authenticate", conn.authenticateWithPassword(getCurrentTestName(), getCurrentTestName()));
- final SCPClient scp_client = new SCPClient(conn);
- try (OutputStream output = scp_client.put(fileName, expected.length, remotePath, mode)) {
+ SCPClient scpClient = new SCPClient(conn);
+ try (OutputStream output = scpClient.put(fileName, expected.length, remotePath, mode)) {
output.write(expected);
}
@@ -1041,11 +1038,11 @@ public class ScpTest extends BaseTestSupport {
assertArrayEquals("Mismatched remote put data", expected, remoteData);
Arrays.fill(remoteData, (byte) 0); // make sure we start with a clean slate
- try (InputStream input = scp_client.get(remotePath + "/" + fileName)) {
+ try (InputStream input = scpClient.get(remotePath + "/" + fileName)) {
int readLen = input.read(remoteData);
assertEquals("Mismatched remote get data size", expected.length, readLen);
// make sure we reached EOF
- assertEquals("Unexpected extra data after read expected size", (-1), input.read());
+ assertEquals("Unexpected extra data after read expected size", -1, input.read());
}
assertArrayEquals("Mismatched remote get data", expected, remoteData);
@@ -1230,7 +1227,7 @@ public class ScpTest extends BaseTestSupport {
private static String readLine(InputStream in) throws IOException {
OutputStream baos = new ByteArrayOutputStream();
try {
- for (; ; ) {
+ for (;;) {
int c = in.read();
if (c == '\n') {
return baos.toString();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleScpClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleScpClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleScpClientTest.java
index f099fb2..ab96bc1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleScpClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleScpClientTest.java
@@ -60,7 +60,7 @@ public class SimpleScpClientTest extends BaseSimpleClientTestSupport {
@Test
public void testSessionClosedWhenClientClosed() throws Exception {
- try(CloseableScpClient scp = login()) {
+ try (CloseableScpClient scp = login()) {
assertTrue("SCP not open", scp.isOpen());
Session session = scp.getClientSession();
@@ -74,7 +74,7 @@ public class SimpleScpClientTest extends BaseSimpleClientTestSupport {
@Test
public void testScpUploadProxy() throws Exception {
- try(CloseableScpClient scp = login()) {
+ try (CloseableScpClient scp = login()) {
Path scpRoot = Utils.resolve(targetPath, ScpHelper.SCP_COMMAND_PREFIX, getClass().getSimpleName(), getCurrentTestName());
Utils.deleteRecursive(scpRoot);
@@ -95,7 +95,7 @@ public class SimpleScpClientTest extends BaseSimpleClientTestSupport {
@Test
public void testScpDownloadProxy() throws Exception {
- try(CloseableScpClient scp = login()) {
+ try (CloseableScpClient scp = login()) {
Path scpRoot = Utils.resolve(targetPath, ScpHelper.SCP_COMMAND_PREFIX, getClass().getSimpleName(), getCurrentTestName());
Utils.deleteRecursive(scpRoot);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java
index 450da6f..bafd8aa 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSessionClientTest.java
@@ -55,7 +55,7 @@ public class SimpleSessionClientTest extends BaseSimpleClientTestSupport {
sshd.setPublickeyAuthenticator(RejectAllPublickeyAuthenticator.INSTANCE);
client.start();
- try(ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), getCurrentTestName())) {
+ try (ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), getCurrentTestName())) {
assertEquals("Mismatched session username", getCurrentTestName(), session.getUsername());
}
}
@@ -79,7 +79,7 @@ public class SimpleSessionClientTest extends BaseSimpleClientTestSupport {
sshd.setPasswordAuthenticator(RejectAllPasswordAuthenticator.INSTANCE);
client.start();
- try(ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), identity)) {
+ try (ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), identity)) {
assertEquals("Mismatched session username", getCurrentTestName(), session.getUsername());
assertTrue("User identity not queried", identityQueried.get());
}
@@ -115,7 +115,7 @@ public class SimpleSessionClientTest extends BaseSimpleClientTestSupport {
client.start();
long nanoStart = System.nanoTime();
- try(ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), getCurrentTestName())) {
+ try (ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), getCurrentTestName())) {
fail("Unexpected connection success");
} catch (IOException e) {
long nanoEnd = System.nanoTime();
@@ -145,7 +145,7 @@ public class SimpleSessionClientTest extends BaseSimpleClientTestSupport {
client.start();
long nanoStart = System.nanoTime();
- try(ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), getCurrentTestName())) {
+ try (ClientSession session = simple.sessionLogin(TEST_LOCALHOST, port, getCurrentTestName(), getCurrentTestName())) {
fail("Unexpected connection success");
} catch (IOException e) {
long nanoEnd = System.nanoTime();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSftpClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSftpClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSftpClientTest.java
index d3748b9..b691a02 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSftpClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/simple/SimpleSftpClientTest.java
@@ -69,7 +69,7 @@ public class SimpleSftpClientTest extends BaseSimpleClientTestSupport {
@Test
public void testSessionClosedWhenClientClosed() throws Exception {
- try(SftpClient sftp = login()) {
+ try (SftpClient sftp = login()) {
assertTrue("SFTP not open", sftp.isOpen());
Session session = sftp.getClientSession();
@@ -91,7 +91,7 @@ public class SimpleSftpClientTest extends BaseSimpleClientTestSupport {
String clientFileName = clientFile.getFileName().toString();
String remoteFilePath = remoteFileDir + "/" + clientFileName;
- try(SftpClient sftp = login()) {
+ try (SftpClient sftp = login()) {
sftp.mkdir(remoteFileDir);
byte[] written = (getClass().getSimpleName() + "#" + getCurrentTestName() + IoUtils.EOL).getBytes(StandardCharsets.UTF_8);
@@ -112,7 +112,7 @@ public class SimpleSftpClientTest extends BaseSimpleClientTestSupport {
assertNotNull("No dir entries", dirEntries);
boolean matchFound = false;
- for (Iterator<SftpClient.DirEntry> it = dirEntries.iterator(); it.hasNext(); ) {
+ for (Iterator<SftpClient.DirEntry> it = dirEntries.iterator(); it.hasNext();) {
SftpClient.DirEntry entry = it.next();
String name = entry.getFilename();
if (clientFileName.equals(name)) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpCommandMain.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpCommandMain.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpCommandMain.java
index 4b6a8c8..4b34f92 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpCommandMain.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpCommandMain.java
@@ -25,7 +25,11 @@ package org.apache.sshd.client.subsystem.sftp;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SftpCommandMain {
+public final class SftpCommandMain {
+ private SftpCommandMain() {
+ throw new UnsupportedOperationException("No instance");
+ }
+
public static void main(String[] args) throws Exception {
SftpCommand.main(args);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java
index f21a636..3a9ae43 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemTest.java
@@ -369,12 +369,10 @@ public class SftpFileSystemTest extends BaseTestSupport {
assertHierarchyTargetFolderExists(file1.getParent());
String expected = "Hello world: " + getCurrentTestName();
- {
- outputDebugMessage("Write initial data to %s", file1);
- Files.write(file1, expected.getBytes(StandardCharsets.UTF_8));
- String buf = new String(Files.readAllBytes(file1), StandardCharsets.UTF_8);
- assertEquals("Mismatched read test data", expected, buf);
- }
+ outputDebugMessage("Write initial data to %s", file1);
+ Files.write(file1, expected.getBytes(StandardCharsets.UTF_8));
+ String buf = new String(Files.readAllBytes(file1), StandardCharsets.UTF_8);
+ assertEquals("Mismatched read test data", expected, buf);
if (version >= SftpConstants.SFTP_V4) {
outputDebugMessage("getFileAttributeView(%s)", file1);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
index b9a2f78..bf4a458 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpTest.java
@@ -49,6 +49,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
+import com.jcraft.jsch.ChannelSftp;
+import com.jcraft.jsch.JSch;
+
import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.client.subsystem.sftp.SftpClient.CloseableHandle;
@@ -102,14 +105,12 @@ import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.jcraft.jsch.ChannelSftp;
-import com.jcraft.jsch.JSch;
-
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SftpTest extends AbstractSftpClientTestSupport {
+ private static final Map<String, OptionalFeature> EXPECTED_EXTENSIONS = SftpSubsystem.DEFAULT_SUPPORTED_CLIENT_EXTENSIONS;
private com.jcraft.jsch.Session session;
@@ -219,16 +220,17 @@ public class SftpTest extends AbstractSftpClientTestSupport {
int maxAllowed = actual.length / 4;
// allow less than actual
PropertyResolverUtils.updateProperty(sshd, SftpSubsystem.MAX_PACKET_LENGTH_PROP, maxAllowed);
- try(CloseableHandle handle = sftp.open(file, OpenMode.Read)) {
+ try (CloseableHandle handle = sftp.open(file, OpenMode.Read)) {
int readLen = sftp.read(handle, 0L, actual);
assertEquals("Mismatched read len", maxAllowed, readLen);
for (int index = 0; index < readLen; index++) {
- byte expByte = expected[index], actByte = actual[index];
+ byte expByte = expected[index];
+ byte actByte = actual[index];
if (expByte != actByte) {
fail("Mismatched values at index=" + index
- + ": expected=0x" + Integer.toHexString(expByte & 0xFF)
- + ", actual=0x" + Integer.toHexString(actByte & 0xFF));
+ + ": expected=0x" + Integer.toHexString(expByte & 0xFF)
+ + ", actual=0x" + Integer.toHexString(actByte & 0xFF));
}
}
}
@@ -425,7 +427,8 @@ public class SftpTest extends AbstractSftpClientTestSupport {
try (SftpClient.CloseableHandle h = sftp.open(file /* no mode == read */)) {
// NOTE: on Windows files are always readable
- // see https://svn.apache.org/repos/asf/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java
+ // see https://svn.apache.org/repos/asf/harmony/enhanced/java/branches/java6/classlib/modules/
+ // luni/src/test/api/windows/org/apache/harmony/luni/tests/java/io/WinFileTest.java
assertTrue("Empty read should have failed on " + file, isWindows);
} catch (IOException e) {
if (isWindows) {
@@ -448,8 +451,9 @@ public class SftpTest extends AbstractSftpClientTestSupport {
// NOTE: on Windows files are always readable
int perms = sftp.stat(file).getPermissions();
- int permsMask = SftpConstants.S_IWUSR | (isWindows ? 0 : SftpConstants.S_IRUSR);
- assertEquals("Mismatched permissions for " + file + ": 0x" + Integer.toHexString(perms), 0, (perms & permsMask));
+ int readMask = isWindows ? 0 : SftpConstants.S_IRUSR;
+ int permsMask = SftpConstants.S_IWUSR | readMask;
+ assertEquals("Mismatched permissions for " + file + ": 0x" + Integer.toHexString(perms), 0, perms & permsMask);
javaFile.setWritable(true, false);
@@ -500,6 +504,7 @@ public class SftpTest extends AbstractSftpClientTestSupport {
}
@Test
+ @SuppressWarnings({"checkstyle:anoninnerlength", "checkstyle:methodlength"})
public void testClient() throws Exception {
List<NamedFactory<Command>> factories = sshd.getSubsystemFactories();
assertEquals("Mismatched subsystem factories count", 1, GenericUtils.size(factories));
@@ -520,6 +525,7 @@ public class SftpTest extends AbstractSftpClientTestSupport {
final AtomicInteger removedCount = new AtomicInteger(0);
final AtomicInteger modifyingCount = new AtomicInteger(0);
final AtomicInteger modifiedCount = new AtomicInteger(0);
+
factory.addSftpEventListener(new SftpEventListener() {
private final Logger log = LoggerFactory.getLogger(SftpEventListener.class);
@@ -822,9 +828,9 @@ public class SftpTest extends AbstractSftpClientTestSupport {
Path target = assertHierarchyTargetFolderExists(lclSftp).resolve("file.txt");
String remotePath = Utils.resolveRelativeRemotePath(targetPath.getParent(), target);
- final int NUM_ITERATIONS = 10;
- StringBuilder sb = new StringBuilder(d.length() * NUM_ITERATIONS * NUM_ITERATIONS);
- for (int j = 1; j <= NUM_ITERATIONS; j++) {
+ final int numIterations = 10;
+ StringBuilder sb = new StringBuilder(d.length() * numIterations * numIterations);
+ for (int j = 1; j <= numIterations; j++) {
if (sb.length() > 0) {
sb.setLength(0);
}
@@ -888,8 +894,7 @@ public class SftpTest extends AbstractSftpClientTestSupport {
File dir = baseDir.getParentFile();
Collection<String> expNames = OsUtils.isUNIX()
? new LinkedList<String>()
- : new TreeSet<String>(String.CASE_INSENSITIVE_ORDER)
- ;
+ : new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
String[] names = dir.list();
if (GenericUtils.length(names) > 0) {
for (String n : names) {
@@ -984,9 +989,9 @@ public class SftpTest extends AbstractSftpClientTestSupport {
try (SftpClient sftp = session.createSftpClient()) {
Map<String, byte[]> extensions = sftp.getServerExtensions();
for (String name : new String[]{
- SftpConstants.EXT_NEWLINE, SftpConstants.EXT_VERSIONS,
- SftpConstants.EXT_VENDOR_ID, SftpConstants.EXT_ACL_SUPPORTED,
- SftpConstants.EXT_SUPPORTED, SftpConstants.EXT_SUPPORTED2
+ SftpConstants.EXT_NEWLINE, SftpConstants.EXT_VERSIONS,
+ SftpConstants.EXT_VENDOR_ID, SftpConstants.EXT_ACL_SUPPORTED,
+ SftpConstants.EXT_SUPPORTED, SftpConstants.EXT_SUPPORTED2
}) {
assertTrue("Missing extension=" + name, extensions.containsKey(name));
}
@@ -1048,7 +1053,6 @@ public class SftpTest extends AbstractSftpClientTestSupport {
}
}
- private static Map<String, OptionalFeature> EXPECTED_EXTENSIONS = SftpSubsystem.DEFAULT_SUPPORTED_CLIENT_EXTENSIONS;
private static void assertSupportedExtensions(String extName, Collection<String> extensionNames) {
assertEquals(extName + "[count]", EXPECTED_EXTENSIONS.size(), GenericUtils.size(extensionNames));
@@ -1180,8 +1184,9 @@ public class SftpTest extends AbstractSftpClientTestSupport {
List<SftpClient.DirEntry> dirEntries = sftp.readDir(h);
assertNotNull("No dir entries", dirEntries);
- boolean dotFiltered = false, dotdotFiltered = false;
- for (Iterator<SftpClient.DirEntry> it = dirEntries.iterator(); it.hasNext(); ) {
+ boolean dotFiltered = false;
+ boolean dotdotFiltered = false;
+ for (Iterator<SftpClient.DirEntry> it = dirEntries.iterator(); it.hasNext();) {
SftpClient.DirEntry entry = it.next();
String name = entry.getFilename();
if (".".equals(name) && (!dotFiltered)) {
@@ -1201,7 +1206,7 @@ public class SftpTest extends AbstractSftpClientTestSupport {
sftp.remove(file);
- final int SIZE_FACTOR = Short.SIZE;
+ final int sizeFactor = Short.SIZE;
byte[] workBuf = new byte[IoUtils.DEFAULT_COPY_SIZE * Short.SIZE];
Factory<? extends Random> factory = manager.getRandomFactory();
Random random = factory.create();
@@ -1212,7 +1217,7 @@ public class SftpTest extends AbstractSftpClientTestSupport {
}
// force several internal read cycles to satisfy the full read
- try (InputStream is = sftp.read(file, workBuf.length / SIZE_FACTOR)) {
+ try (InputStream is = sftp.read(file, workBuf.length / sizeFactor)) {
int readLen = is.read(workBuf);
assertEquals("Mismatched read data length", workBuf.length, readLen);
@@ -1227,7 +1232,8 @@ public class SftpTest extends AbstractSftpClientTestSupport {
assertTrue("Test directory not reported as such", attributes.isDirectory());
int nb = 0;
- boolean dotFiltered = false, dotdotFiltered = false;
+ boolean dotFiltered = false;
+ boolean dotdotFiltered = false;
for (SftpClient.DirEntry entry : sftp.readDir(dir)) {
assertNotNull("Unexpected null entry", entry);
String name = entry.getFilename();
@@ -1286,10 +1292,10 @@ public class SftpTest extends AbstractSftpClientTestSupport {
* (see http://epaul.github.io/jsch-documentation/simple.javadoc/com/jcraft/jsch/ChannelSftp.html#current-directory)
*
*
- * This sftp client has the concept of a current local directory and
- * a current remote directory. These are not inherent to the protocol,
- * but are used implicitly for all path-based commands sent to the server
- * for the remote directory) or accessing the local file system (for the local directory).
+ * This sftp client has the concept of a current local directory and
+ * a current remote directory. These are not inherent to the protocol,
+ * but are used implicitly for all path-based commands sent to the server
+ * for the remote directory) or accessing the local file system (for the local directory).
*
* Therefore we are using "absolute" remote files for this test
*/
@@ -1301,9 +1307,9 @@ public class SftpTest extends AbstractSftpClientTestSupport {
ChannelSftp c = (ChannelSftp) session.openChannel(SftpConstants.SFTP_SUBSYSTEM_NAME);
c.connect();
try {
- try (InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8))) {
- c.put(dataStream, remSrcPath);
- }
+ try (InputStream dataStream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8))) {
+ c.put(dataStream, remSrcPath);
+ }
assertTrue("Source file not created: " + sourcePath, Files.exists(sourcePath));
assertEquals("Mismatched stored data in " + remSrcPath, data, readFile(remSrcPath));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionSelectorTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionSelectorTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionSelectorTest.java
index 02a0533..ed2b3e9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionSelectorTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/SftpVersionSelectorTest.java
@@ -52,15 +52,16 @@ public class SftpVersionSelectorTest extends BaseTestSupport {
for (int expected = SftpSubsystem.LOWER_SFTP_IMPL; expected <= SftpSubsystem.HIGHER_SFTP_IMPL; expected++) {
for (int index = 0; index < available.size(); index++) {
Collections.shuffle(available, rnd);
- assertEquals("Mismatched suffling selected for current=" + expected + ", available=" + available, expected, SftpVersionSelector.CURRENT.selectVersion(expected, available));
+ assertEquals("Mismatched suffling selected for current=" + expected + ", available=" + available,
+ expected, SftpVersionSelector.CURRENT.selectVersion(expected, available));
}
}
}
@Test
public void testFixedVersionSelector() {
- final int FIXED_VALUE = 7365;
- testVersionSelector(SftpVersionSelector.Utils.fixedVersionSelector(FIXED_VALUE), FIXED_VALUE);
+ final int fixedValue = 7365;
+ testVersionSelector(SftpVersionSelector.Utils.fixedVersionSelector(fixedValue), fixedValue);
}
@Test
@@ -87,7 +88,9 @@ public class SftpVersionSelectorTest extends BaseTestSupport {
int version = unavailable.get(0);
int actual = selector.selectVersion(version, unavailable);
fail("Unexpected selected version (" + actual + ")"
- + " for current= " + version + ", available=" + unavailable + ", preferred=" + preferred);
+ + " for current= " + version
+ + ", available=" + unavailable
+ + ", preferred=" + preferred);
} catch (IllegalStateException e) {
// expected
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
index 20ce0cd..a47e5d2 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
@@ -105,13 +105,9 @@ public class AbstractCheckFileExtensionTest extends AbstractSftpClientTestSuppor
}
});
- @Parameters(name = "{0} - dataSize={1}, blockSize={2}")
- public static Collection<Object[]> parameters() {
- return PARAMETERS;
- }
-
private final String algorithm;
- private final int dataSize, blockSize;
+ private final int dataSize;
+ private final int blockSize;
public AbstractCheckFileExtensionTest(String algorithm, int dataSize, int blockSize) throws IOException {
this.algorithm = algorithm;
@@ -119,6 +115,11 @@ public class AbstractCheckFileExtensionTest extends AbstractSftpClientTestSuppor
this.blockSize = blockSize;
}
+ @Parameters(name = "{0} - dataSize={1}, blockSize={2}")
+ public static Collection<Object[]> parameters() {
+ return PARAMETERS;
+ }
+
@Before
public void setUp() throws Exception {
setupServer();
@@ -161,6 +162,7 @@ public class AbstractCheckFileExtensionTest extends AbstractSftpClientTestSuppor
}
}
+ @SuppressWarnings("checkstyle:nestedtrydepth")
private void testCheckFileExtension(NamedFactory<? extends Digest> factory, byte[] data, int hashBlockSize, byte[] expectedHash) throws Exception {
Path targetPath = detectTargetFolder();
Path lclSftp = Utils.resolve(targetPath, SftpConstants.SFTP_SUBSYSTEM_NAME, getClass().getSimpleName());
@@ -231,8 +233,8 @@ public class AbstractCheckFileExtensionTest extends AbstractSftpClientTestSuppor
byte[] actualHash = values.iterator().next();
if (!Arrays.equals(expectedHash, actualHash)) {
fail("Mismatched hashes for " + name
- + ": expected=" + BufferUtils.toHex(':', expectedHash)
- + ", actual=" + BufferUtils.toHex(':', expectedHash));
+ + ": expected=" + BufferUtils.toHex(':', expectedHash)
+ + ", actual=" + BufferUtils.toHex(':', expectedHash));
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
index 8a5fe30..f39bf12 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
@@ -71,6 +71,12 @@ public class AbstractMD5HashExtensionTest extends AbstractSftpClientTestSupport
Integer.valueOf(Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE)
));
+ private final int size;
+
+ public AbstractMD5HashExtensionTest(int size) throws IOException {
+ this.size = size;
+ }
+
@Parameters(name = "dataSize={0}")
public static Collection<Object[]> parameters() {
return parameterize(DATA_SIZES);
@@ -81,12 +87,6 @@ public class AbstractMD5HashExtensionTest extends AbstractSftpClientTestSupport
Assume.assumeTrue("MD5 not supported", BuiltinDigests.md5.isSupported());
}
- private final int size;
-
- public AbstractMD5HashExtensionTest(int size) throws IOException {
- this.size = size;
- }
-
@Before
public void setUp() throws Exception {
setupServer();
@@ -113,6 +113,7 @@ public class AbstractMD5HashExtensionTest extends AbstractSftpClientTestSupport
}
}
+ @SuppressWarnings("checkstyle:nestedtrydepth")
private void testMD5HashExtension(byte[] data) throws Exception {
Digest digest = BuiltinDigests.md5.create();
digest.init();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
index 713c1a9..2ae45a4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
@@ -89,12 +89,9 @@ public class CopyDataExtensionImplTest extends AbstractSftpClientTestSupport {
}
));
- @Parameters(name = "size={0}, readOffset={1}, readLength={2}, writeOffset={3}")
- public static Collection<Object[]> parameters() {
- return PARAMETERS;
- }
-
- private int size, srcOffset, length;
+ private int size;
+ private int srcOffset;
+ private int length;
private long dstOffset;
public CopyDataExtensionImplTest(int size, int srcOffset, int length, long dstOffset) throws IOException {
@@ -104,6 +101,11 @@ public class CopyDataExtensionImplTest extends AbstractSftpClientTestSupport {
this.dstOffset = dstOffset;
}
+ @Parameters(name = "size={0}, readOffset={1}, readLength={2}, writeOffset={3}")
+ public static Collection<Object[]> parameters() {
+ return PARAMETERS;
+ }
+
@Before
public void setUp() throws Exception {
setupServer();
@@ -183,7 +185,8 @@ public class CopyDataExtensionImplTest extends AbstractSftpClientTestSupport {
}
}
- int available = data.length, required = readOffset + readLength;
+ int available = data.length;
+ int required = readOffset + readLength;
if (required > available) {
required = available;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
index 339594e..7a6223c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/openssh/helpers/OpenSSHExtensionsTest.java
@@ -122,19 +122,18 @@ public class OpenSSHExtensionsTest extends AbstractSftpClientTestSupport {
final AtomicReference<String> extensionHolder = new AtomicReference<String>(null);
final OpenSSHStatExtensionInfo expected = new OpenSSHStatExtensionInfo();
- {
- expected.f_bavail = Short.MAX_VALUE;
- expected.f_bfree = Integer.MAX_VALUE;
- expected.f_blocks = Short.MAX_VALUE;
- expected.f_bsize = IoUtils.DEFAULT_COPY_SIZE;
- expected.f_favail = Long.MAX_VALUE;
- expected.f_ffree = Byte.MAX_VALUE;
- expected.f_files = 3777347L;
- expected.f_flag = OpenSSHStatExtensionInfo.SSH_FXE_STATVFS_ST_RDONLY;
- expected.f_frsize = 7365L;
- expected.f_fsid = 1L;
- expected.f_namemax = 256;
- }
+ expected.f_bavail = Short.MAX_VALUE;
+ expected.f_bfree = Integer.MAX_VALUE;
+ expected.f_blocks = Short.MAX_VALUE;
+ expected.f_bsize = IoUtils.DEFAULT_COPY_SIZE;
+ expected.f_favail = Long.MAX_VALUE;
+ expected.f_ffree = Byte.MAX_VALUE;
+ expected.f_files = 3777347L;
+ expected.f_flag = OpenSSHStatExtensionInfo.SSH_FXE_STATVFS_ST_RDONLY;
+ expected.f_frsize = 7365L;
+ expected.f_fsid = 1L;
+ expected.f_namemax = 256;
+
sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory() {
@Override
public Command create() {
@@ -185,18 +184,16 @@ public class OpenSSHExtensionsTest extends AbstractSftpClientTestSupport {
session.auth().verify(5L, TimeUnit.SECONDS);
try (SftpClient sftp = session.createSftpClient()) {
- {
- OpenSSHStatPathExtension pathStat = assertExtensionCreated(sftp, OpenSSHStatPathExtension.class);
- OpenSSHStatExtensionInfo actual = pathStat.stat(srcPath);
- String invokedExtension = extensionHolder.getAndSet(null);
- assertEquals("Mismatched invoked extension", pathStat.getName(), invokedExtension);
- assertOpenSSHStatExtensionInfoEquals(invokedExtension, expected, actual);
- }
+ OpenSSHStatPathExtension pathStat = assertExtensionCreated(sftp, OpenSSHStatPathExtension.class);
+ OpenSSHStatExtensionInfo actual = pathStat.stat(srcPath);
+ String invokedExtension = extensionHolder.getAndSet(null);
+ assertEquals("Mismatched invoked extension", pathStat.getName(), invokedExtension);
+ assertOpenSSHStatExtensionInfoEquals(invokedExtension, expected, actual);
try (CloseableHandle handle = sftp.open(srcPath)) {
OpenSSHStatHandleExtension handleStat = assertExtensionCreated(sftp, OpenSSHStatHandleExtension.class);
- OpenSSHStatExtensionInfo actual = handleStat.stat(handle);
- String invokedExtension = extensionHolder.getAndSet(null);
+ actual = handleStat.stat(handle);
+ invokedExtension = extensionHolder.getAndSet(null);
assertEquals("Mismatched invoked extension", handleStat.getName(), invokedExtension);
assertOpenSSHStatExtensionInfoEquals(invokedExtension, expected, actual);
}
@@ -213,7 +210,9 @@ public class OpenSSHExtensionsTest extends AbstractSftpClientTestSupport {
if (Modifier.isStatic(mod)) {
continue;
}
- Object expValue = f.get(expected), actValue = f.get(actual);
+
+ Object expValue = f.get(expected);
+ Object actValue = f.get(actual);
assertEquals(extension + "[" + name + "]", expValue, actValue);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
index 303bdbc..4879ee5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/PropertyResolverUtilsTest.java
@@ -42,16 +42,16 @@ public class PropertyResolverUtilsTest extends BaseTestSupport {
@Test
public void testResolveAndUpdateClosestPropertyValue() {
- final String NAME = getCurrentTestName();
- final String ROOT_VALUE = getClass().getPackage().getName();
+ final String propName = getCurrentTestName();
+ final String rootValue = getClass().getPackage().getName();
Session resolver = createMockSession();
FactoryManager root = ValidateUtils.checkNotNull(resolver.getFactoryManager(), "No manager");
- assertNull("Unexpected root previous value", PropertyResolverUtils.updateProperty(root, NAME, ROOT_VALUE));
- assertSame("Mismatched root value", ROOT_VALUE, PropertyResolverUtils.getString(resolver, NAME));
+ assertNull("Unexpected root previous value", PropertyResolverUtils.updateProperty(root, propName, rootValue));
+ assertSame("Mismatched root value", rootValue, PropertyResolverUtils.getString(resolver, propName));
- final String NODE_VALUE = getClass().getSimpleName();
- assertNull("Unexpected node previous value", PropertyResolverUtils.updateProperty(resolver, NAME, NODE_VALUE));
- assertSame("Mismatched node value", NODE_VALUE, PropertyResolverUtils.getString(resolver, NAME));
+ final String nodeValue = getClass().getSimpleName();
+ assertNull("Unexpected node previous value", PropertyResolverUtils.updateProperty(resolver, propName, nodeValue));
+ assertSame("Mismatched node value", nodeValue, PropertyResolverUtils.getString(resolver, propName));
}
@Test
@@ -60,34 +60,34 @@ public class PropertyResolverUtilsTest extends BaseTestSupport {
Map<String, ?> props = resolver.getProperties();
assertTrue("Unexpected initial resolver values: " + props, GenericUtils.isEmpty(props));
- final String NAME = getCurrentTestName();
- assertNull("Unexpected initial resolved value", PropertyResolverUtils.getObject(resolver, NAME));
+ final String propName = getCurrentTestName();
+ assertNull("Unexpected initial resolved value", PropertyResolverUtils.getObject(resolver, propName));
- final String PROPKEY = SyspropsMapWrapper.getMappedSyspropKey(NAME);
- assertNull("Unexpected property value for " + PROPKEY, System.getProperty(PROPKEY));
+ final String propKey = SyspropsMapWrapper.getMappedSyspropKey(propName);
+ assertNull("Unexpected property value for " + propKey, System.getProperty(propKey));
try {
long expected = System.currentTimeMillis();
- System.setProperty(PROPKEY, Long.toString(expected));
- testLongProperty(resolver, NAME, expected);
+ System.setProperty(propKey, Long.toString(expected));
+ testLongProperty(resolver, propName, expected);
} finally {
- System.clearProperty(PROPKEY);
+ System.clearProperty(propKey);
}
try {
int expected = 3777347;
- System.setProperty(PROPKEY, Integer.toString(expected));
- testIntegerProperty(resolver, NAME, expected);
+ System.setProperty(propKey, Integer.toString(expected));
+ testIntegerProperty(resolver, propName, expected);
} finally {
- System.clearProperty(PROPKEY);
+ System.clearProperty(propKey);
}
for (final boolean expected : new boolean[]{false, true}) {
try {
- System.setProperty(PROPKEY, Boolean.toString(expected));
- testBooleanProperty(resolver, NAME, expected);
+ System.setProperty(propKey, Boolean.toString(expected));
+ testBooleanProperty(resolver, propName, expected);
} finally {
- System.clearProperty(PROPKEY);
+ System.clearProperty(propKey);
}
}
}
@@ -107,6 +107,7 @@ public class PropertyResolverUtilsTest extends BaseTestSupport {
testLongProperty(session, name, expected);
}
+ @SuppressWarnings("checkstyle:avoidnestedblocks")
private void testLongProperty(PropertyResolver resolver, String name, long expected) {
Map<String, ?> props = resolver.getProperties();
Object value = props.get(name);
@@ -145,6 +146,7 @@ public class PropertyResolverUtilsTest extends BaseTestSupport {
testIntegerProperty(session, name, expected);
}
+ @SuppressWarnings("checkstyle:avoidnestedblocks")
private void testIntegerProperty(PropertyResolver resolver, String name, int expected) {
Map<String, ?> props = resolver.getProperties();
Object value = props.get(name);
@@ -180,6 +182,7 @@ public class PropertyResolverUtilsTest extends BaseTestSupport {
}
}
+ @SuppressWarnings("checkstyle:avoidnestedblocks")
private void testBooleanProperty(PropertyResolver resolver, String name, boolean expected) {
Map<String, ?> props = resolver.getProperties();
Object value = props.get(name);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/SshConstantsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/SshConstantsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/SshConstantsTest.java
index 552418f..86eb6b4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/SshConstantsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/SshConstantsTest.java
@@ -54,7 +54,7 @@ public class SshConstantsTest extends BaseTestSupport {
@Test
public void testAmbiguousOpcodes() throws Exception {
- int[] knownAmbiguities = { 30, 31, 60 };
+ int[] knownAmbiguities = {30, 31, 60};
Collection<Integer> opcodes = SshConstants.getAmbiguousOpcodes();
assertTrue("Not enough ambiguities found", GenericUtils.size(opcodes) >= knownAmbiguities.length);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
index 09de71d..7e12136 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/auth/AuthenticationTest.java
@@ -388,7 +388,7 @@ public class AuthenticationTest extends BaseTestSupport {
challenge.setInteractionInstruction(anchor.getPackage().getName());
challenge.setLanguageTag(Locale.getDefault().getLanguage());
- final Map<String,String> rspMap = new TreeMap<String,String>(String.CASE_INSENSITIVE_ORDER) {
+ final Map<String, String> rspMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER) {
private static final long serialVersionUID = 1L; // we're not serializing it
{
@@ -417,7 +417,7 @@ public class AuthenticationTest extends BaseTestSupport {
assertEquals("Mismatched number of responses", GenericUtils.size(rspMap), GenericUtils.size(responses));
int index = 0;
- for (Map.Entry<String,String> re : rspMap.entrySet()) {
+ for (Map.Entry<String, String> re : rspMap.entrySet()) {
String prompt = re.getKey();
String expected = re.getValue();
String actual = responses.get(index);
@@ -728,31 +728,33 @@ public class AuthenticationTest extends BaseTestSupport {
@Test // see SSHD-620
public void testHostBasedAuthentication() throws Exception {
- final String CLIENT_USERNAME = getClass().getSimpleName();
- final String CLIENT_HOSTNAME = SshdSocketAddress.toAddressString(SshdSocketAddress.getFirstExternalNetwork4Address());
- final KeyPair CLIENT_HOSTKEY = Utils.generateKeyPair("RSA", 1024);
+ final String hostClienUser = getClass().getSimpleName();
+ final String hostClientName = SshdSocketAddress.toAddressString(SshdSocketAddress.getFirstExternalNetwork4Address());
+ final KeyPair hostClientKey = Utils.generateKeyPair("RSA", 1024);
final AtomicInteger invocationCount = new AtomicInteger(0);
sshd.setHostBasedAuthenticator(new HostBasedAuthenticator() {
@Override
public boolean authenticate(ServerSession session, String username,
PublicKey clientHostKey, String clientHostName, String clientUsername, List<X509Certificate> certificates) {
invocationCount.incrementAndGet();
- return CLIENT_USERNAME.equals(clientUsername)
- && CLIENT_HOSTNAME.equals(clientHostName)
- && KeyUtils.compareKeys(CLIENT_HOSTKEY.getPublic(), clientHostKey);
+ return hostClienUser.equals(clientUsername)
+ && hostClientName.equals(clientHostName)
+ && KeyUtils.compareKeys(hostClientKey.getPublic(), clientHostKey);
}
});
sshd.setPasswordAuthenticator(RejectAllPasswordAuthenticator.INSTANCE);
sshd.setKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator.NONE);
sshd.setPublickeyAuthenticator(RejectAllPublickeyAuthenticator.INSTANCE);
- sshd.setUserAuthFactories(Collections.<NamedFactory<org.apache.sshd.server.auth.UserAuth>>singletonList(org.apache.sshd.server.auth.hostbased.UserAuthHostBasedFactory.INSTANCE));
+ sshd.setUserAuthFactories(
+ Collections.<NamedFactory<org.apache.sshd.server.auth.UserAuth>>singletonList(
+ org.apache.sshd.server.auth.hostbased.UserAuthHostBasedFactory.INSTANCE));
try (SshClient client = setupTestClient()) {
org.apache.sshd.client.auth.hostbased.UserAuthHostBasedFactory factory =
new org.apache.sshd.client.auth.hostbased.UserAuthHostBasedFactory();
// TODO factory.setClientHostname(CLIENT_HOSTNAME);
- factory.setClientUsername(CLIENT_USERNAME);
- factory.setClientHostKeys(HostKeyIdentityProvider.Utils.wrap(CLIENT_HOSTKEY));
+ factory.setClientUsername(hostClienUser);
+ factory.setClientHostKeys(HostKeyIdentityProvider.Utils.wrap(hostClientKey));
client.setUserAuthFactories(Collections.<NamedFactory<org.apache.sshd.client.auth.UserAuth>>singletonList(factory));
client.start();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTest.java b/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTest.java
index 0e11331..3d21f80 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTest.java
@@ -36,8 +36,8 @@ import org.apache.sshd.client.channel.ClientChannel;
import org.apache.sshd.client.future.OpenFuture;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
-import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.common.PropertyResolverUtils;
import org.apache.sshd.common.RuntimeSshException;
import org.apache.sshd.common.Service;
import org.apache.sshd.common.io.IoInputStream;
@@ -297,7 +297,7 @@ public class WindowTest extends BaseTestSupport {
}
private static void waitForWindowNotEquals(Window w1, Window w2, String n1, String n2, long maxWait) throws InterruptedException {
- for (long waited = 0L, maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxWait); waited < maxWaitNanos; ) {
+ for (long waited = 0L, maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxWait); waited < maxWaitNanos;) {
if (w1.getSize() != w2.getSize()) {
return;
}
@@ -314,7 +314,7 @@ public class WindowTest extends BaseTestSupport {
}
private static void waitForWindowEquals(Window w1, Window w2, String n1, String n2, long maxWait) throws InterruptedException {
- for (long waited = 0L, maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxWait); waited < maxWaitNanos; ) {
+ for (long waited = 0L, maxWaitNanos = TimeUnit.MILLISECONDS.toNanos(maxWait); waited < maxWaitNanos;) {
if (w1.getSize() == w2.getSize()) {
return;
}
@@ -339,12 +339,12 @@ public class WindowTest extends BaseTestSupport {
public static class TestEchoShell extends EchoShell {
- public static final CountDownLatch latch = new CountDownLatch(1);
+ public static final CountDownLatch LATCH = new CountDownLatch(1);
@Override
public void destroy() {
- if (latch != null) {
- latch.countDown();
+ if (LATCH != null) {
+ LATCH.countDown();
}
super.destroy();
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTimeoutTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTimeoutTest.java b/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTimeoutTest.java
index 137e53b..d834621 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTimeoutTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/channel/WindowTimeoutTest.java
@@ -86,7 +86,7 @@ public class WindowTimeoutTest extends BaseTestSupport {
@Test
public void testWindowWaitForSpaceTimeout() throws Exception {
- try(Window window = channel.getLocalWindow()) {
+ try (Window window = channel.getLocalWindow()) {
window.init(FactoryManager.DEFAULT_WINDOW_SIZE, FactoryManager.DEFAULT_MAX_PACKET_SIZE, null);
window.consume(window.getSize());
assertEquals("Window not empty", 0, window.getSize());
@@ -115,12 +115,11 @@ public class WindowTimeoutTest extends BaseTestSupport {
@Test
public void testWindowWaitAndConsumeTimeout() throws Exception {
- try(Window window = channel.getLocalWindow()) {
+ try (Window window = channel.getLocalWindow()) {
window.init(FactoryManager.DEFAULT_WINDOW_SIZE, FactoryManager.DEFAULT_MAX_PACKET_SIZE, null);
long waitStart = System.nanoTime();
- try
- {
+ try {
window.waitAndConsume(2 * window.getSize(), MAX_WAIT_TIME);
fail("Unexpected timed wait success");
} catch (SocketTimeoutException e) {
[3/5] mina-sshd git commit: [SSHD-655] Apply checkstyle plugin to
test source code as well
Posted by lg...@apache.org.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/cipher/BaseCipherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/cipher/BaseCipherTest.java b/sshd-core/src/test/java/org/apache/sshd/common/cipher/BaseCipherTest.java
index cae4b02..195fcb1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/cipher/BaseCipherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/cipher/BaseCipherTest.java
@@ -19,12 +19,13 @@
package org.apache.sshd.common.cipher;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.InvalidKeyException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.cipher.Cipher.Mode;
import org.apache.sshd.common.util.SecurityUtils;
@@ -71,8 +72,10 @@ public abstract class BaseCipherTest extends BaseTestSupport {
protected void testEncryptDecrypt(NamedFactory<Cipher> factory) throws Exception {
String facName = factory.getName();
Cipher enc = factory.create();
- int keySize = enc.getBlockSize(), ivSize = enc.getIVSize();
- byte[] key = new byte[keySize], iv = new byte[ivSize];
+ int keySize = enc.getBlockSize();
+ int ivSize = enc.getIVSize();
+ byte[] key = new byte[keySize];
+ byte[] iv = new byte[ivSize];
enc.init(Mode.Encrypt, key, iv);
byte[] expected = facName.getBytes(StandardCharsets.UTF_8);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/cipher/BuiltinCiphersTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/cipher/BuiltinCiphersTest.java b/sshd-core/src/test/java/org/apache/sshd/common/cipher/BuiltinCiphersTest.java
index c334de9..a6926b8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/cipher/BuiltinCiphersTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/cipher/BuiltinCiphersTest.java
@@ -208,7 +208,7 @@ public class BuiltinCiphersTest extends BaseTestSupport {
Collections.shuffle(unknown, rnd);
List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size());) {
boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java b/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
index 1d09e3f..d47019b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
@@ -27,6 +27,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
+import com.jcraft.jsch.JSch;
+
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.channel.Channel;
@@ -46,8 +48,6 @@ import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import com.jcraft.jsch.JSch;
-
/**
* Test Cipher algorithms.
*
@@ -88,16 +88,6 @@ public class CipherTest extends BaseTestSupport {
private static final String CRYPT_NAMES = NamedResource.Utils.getNames(TEST_CIPHERS);
- @Parameters(name = "cipher={0}, load={2}")
- public static Collection<Object[]> parameters() {
- return PARAMETERS;
- }
-
- @BeforeClass
- public static void jschInit() {
- JSchLogger.init();
- }
-
private final Random random = Utils.getRandomizerInstance();
private final BuiltinCiphers builtInCipher;
private final Class<? extends com.jcraft.jsch.Cipher> jschCipher;
@@ -109,6 +99,16 @@ public class CipherTest extends BaseTestSupport {
this.loadTestRounds = loadTestRounds;
}
+ @Parameters(name = "cipher={0}, load={2}")
+ public static Collection<Object[]> parameters() {
+ return PARAMETERS;
+ }
+
+ @BeforeClass
+ public static void jschInit() {
+ JSchLogger.init();
+ }
+
@Test
public void testBuiltinCipherSession() throws Exception {
Assume.assumeTrue("No internal support for " + builtInCipher.getName(), builtInCipher.isSupported() && checkCipher(jschCipher.getName()));
@@ -185,10 +185,10 @@ public class CipherTest extends BaseTestSupport {
static boolean checkCipher(String cipher) {
try {
Class<?> c = Class.forName(cipher);
- com.jcraft.jsch.Cipher _c = (com.jcraft.jsch.Cipher) (c.newInstance());
- _c.init(com.jcraft.jsch.Cipher.ENCRYPT_MODE,
- new byte[_c.getBlockSize()],
- new byte[_c.getIVSize()]);
+ com.jcraft.jsch.Cipher jschCipher = (com.jcraft.jsch.Cipher) (c.newInstance());
+ jschCipher.init(com.jcraft.jsch.Cipher.ENCRYPT_MODE,
+ new byte[jschCipher.getBlockSize()],
+ new byte[jschCipher.getIVSize()]);
return true;
} catch (Exception e) {
System.err.println("checkCipher(" + cipher + ") " + e.getClass().getSimpleName() + ": " + e.getMessage());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/compression/BuiltinCompressionsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/compression/BuiltinCompressionsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/compression/BuiltinCompressionsTest.java
index 266cf93..a122518 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/compression/BuiltinCompressionsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/compression/BuiltinCompressionsTest.java
@@ -84,7 +84,7 @@ public class BuiltinCompressionsTest extends BaseTestSupport {
Collections.shuffle(unknown, rnd);
List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size());) {
boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
index e3e56b8..0d7a655 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
@@ -24,6 +24,8 @@ import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
+import com.jcraft.jsch.JSch;
+
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.server.SshServer;
@@ -41,8 +43,6 @@ import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import com.jcraft.jsch.JSch;
-
/**
* Test compression algorithms.
*
@@ -51,11 +51,6 @@ import com.jcraft.jsch.JSch;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(Parameterized.class) // see https://github.com/junit-team/junit/wiki/Parameterized-tests
public class CompressionTest extends BaseTestSupport {
- @Parameters(name = "factory={0}")
- public static List<Object[]> parameters() {
- return parameterize(BuiltinCompressions.VALUES);
- }
-
private final CompressionFactory factory;
private SshServer sshd;
@@ -63,6 +58,11 @@ public class CompressionTest extends BaseTestSupport {
this.factory = factory;
}
+ @Parameters(name = "factory={0}")
+ public static List<Object[]> parameters() {
+ return parameterize(BuiltinCompressions.VALUES);
+ }
+
@BeforeClass
public static void jschInit() {
JSchLogger.init();
@@ -105,8 +105,8 @@ public class CompressionTest extends BaseTestSupport {
try (OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream()) {
- String STR = "this is my command\n";
- byte[] bytes = STR.getBytes(StandardCharsets.UTF_8);
+ String testCommand = "this is my command\n";
+ byte[] bytes = testCommand.getBytes(StandardCharsets.UTF_8);
byte[] data = new byte[bytes.length + Long.SIZE];
for (int i = 1; i <= 10; i++) {
os.write(bytes);
@@ -114,7 +114,7 @@ public class CompressionTest extends BaseTestSupport {
int len = is.read(data);
String str = new String(data, 0, len, StandardCharsets.UTF_8);
- assertEquals("Mismatched read data at iteration #" + i, STR, str);
+ assertEquals("Mismatched read data at iteration #" + i, testCommand, str);
}
} finally {
c.disconnect();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
index 7f5a3ee..dddf907 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/SshConfigFileReaderTest.java
@@ -274,8 +274,10 @@ public class SshConfigFileReaderTest extends BaseTestSupport {
assertTrue("Unexpected unsupported factories: " + unsupported, GenericUtils.isEmpty(unsupported));
assertEquals("Mismatched list size", expected.size(), GenericUtils.size(actual));
for (int index = 0; index < expected.size(); index++) {
- NamedResource e = expected.get(index), a = actual.get(index);
- String n1 = e.getName(), n2 = a.getName();
+ NamedResource e = expected.get(index);
+ String n1 = e.getName();
+ NamedResource a = actual.get(index);
+ String n2 = a.getName();
assertEquals("Mismatched name at index=" + index, n1, n2);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
index 832eacb..8856415 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/TimeValueConfigTest.java
@@ -38,11 +38,11 @@ public class TimeValueConfigTest extends BaseTestSupport {
@Test
public void testDurationOf() {
Object[] values = {
- "600", Long.valueOf(TimeUnit.SECONDS.toMillis(600L)),
- "10m", Long.valueOf(TimeUnit.MINUTES.toMillis(10L)),
- "1h30m", Long.valueOf(TimeUnit.MINUTES.toMillis(90L)),
- "2d", Long.valueOf(TimeUnit.DAYS.toMillis(2L)),
- "3w", Long.valueOf(TimeUnit.DAYS.toMillis(3L * 7L))
+ "600", Long.valueOf(TimeUnit.SECONDS.toMillis(600L)),
+ "10m", Long.valueOf(TimeUnit.MINUTES.toMillis(10L)),
+ "1h30m", Long.valueOf(TimeUnit.MINUTES.toMillis(90L)),
+ "2d", Long.valueOf(TimeUnit.DAYS.toMillis(2L)),
+ "3w", Long.valueOf(TimeUnit.DAYS.toMillis(3L * 7L))
};
for (int index = 0; index < values.length; index += 2) {
String s = (String) values[index];
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntryTest.java
index a40eb1e..8b3340e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeyEntryTest.java
@@ -26,9 +26,6 @@ import java.security.PublicKey;
import java.util.Collection;
import java.util.List;
-import org.apache.sshd.common.config.keys.AuthorizedKeyEntry;
-import org.apache.sshd.common.config.keys.KeyUtils;
-import org.apache.sshd.common.config.keys.PublicKeyEntryResolver;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java
index 54f9022..5a7e2b4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/AuthorizedKeysTestSupport.java
@@ -34,7 +34,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.sshd.common.cipher.ECCurves;
-import org.apache.sshd.common.config.keys.PublicKeyEntry;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.common.util.ValidateUtils;
@@ -62,10 +61,9 @@ public abstract class AuthorizedKeysTestSupport extends BaseTestSupport {
try (Writer w = Files.newBufferedWriter(file, StandardCharsets.UTF_8, options)) {
w.append(PublicKeyEntry.COMMENT_CHAR)
- .append(' ').append(getCurrentTestName())
- .append(' ').append(String.valueOf(keyLines.size())).append(" remaining keys")
- .append(IoUtils.EOL)
- ;
+ .append(' ').append(getCurrentTestName())
+ .append(' ').append(String.valueOf(keyLines.size())).append(" remaining keys")
+ .append(IoUtils.EOL);
for (String l : keyLines) {
w.append(l).append(IoUtils.EOL);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
index b8859ae..27a73ff 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/BuiltinIdentitiesTest.java
@@ -98,7 +98,8 @@ public class BuiltinIdentitiesTest extends BaseTestSupport {
continue;
}
- String name = f.getName(), value = (String) f.get(null);
+ String name = f.getName();
+ String value = (String) f.get(null);
BuiltinIdentities id = BuiltinIdentities.fromName(value);
assertNotNull("No match found for field " + name + "=" + value, id);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsFingerprintGenerationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsFingerprintGenerationTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsFingerprintGenerationTest.java
index fac7b20..1de26f4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsFingerprintGenerationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsFingerprintGenerationTest.java
@@ -59,7 +59,7 @@ public class KeyUtilsFingerprintGenerationTest extends BaseTestSupport {
@Parameters(name = "key={0}, digestFactory={1}, expected={2}")
public static Collection<Object[]> parameters() throws IOException, GeneralSecurityException {
@SuppressWarnings("cast")
- List<Pair<String, List<Pair<DigestFactory, String>>>> KEY_ENTRIES = Collections.unmodifiableList(Arrays.asList(
+ List<Pair<String, List<Pair<DigestFactory, String>>>> keyEntries = Collections.unmodifiableList(Arrays.asList(
new Pair<>(
// CHECKSTYLE:OFF
"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxr3N5fkt966xJINl0hH7Q6lLDRR1D0yMjcXCE5roE9VFut2ctGFuo90TCOxkPOMnwzwConeyScVF4ConZeWsxbG9VtRh61IeZ6R5P5ZTvE9xPdZBgIEWvU1bRfrrOfSMihqF98pODspE6NoTtND2eglwSGwxcYFmpdTAmu+8qgxgGxlEaaCjqwdiNPZhygrH81Mv2ruolNeZkn4Bj+wFFmZTD/waN1pQaMf+SO1+kEYIYFNl5+8JRGuUcr8MhHHJB+gwqMTF2BSBVITJzZUiQR0TMtkK6Vbs7yt1F9hhzDzAFDwhV+rsfNQaOHpl3zP07qH+/99A0XG1CVcEdHqVMw== lgoldstein@LGOLDSTEIN-WIN7",
@@ -108,7 +108,7 @@ public class KeyUtilsFingerprintGenerationTest extends BaseTestSupport {
));
List<Object[]> ret = new ArrayList<>();
- for (Pair<String, List<Pair<DigestFactory, String>>> kentry : KEY_ENTRIES) {
+ for (Pair<String, List<Pair<DigestFactory, String>>> kentry : keyEntries) {
String keyValue = kentry.getFirst();
try {
PublicKey key = PublicKeyEntry.parsePublicKeyEntry(keyValue).resolvePublicKey(PublicKeyEntryResolver.FAILING);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
index afe9268..355358d 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/KeyUtilsTest.java
@@ -232,6 +232,7 @@ public class KeyUtilsTest extends BaseTestSupport {
}
}
+ @SuppressWarnings("checkstyle:avoidnestedblocks")
private static void testKeyPairCloning(String keyType, int keySize, KeyPair kp) throws GeneralSecurityException {
String prefix = keyType + "[" + keySize + "]";
outputDebugMessage("testKeyPairCloning(%s)", prefix);
@@ -241,16 +242,19 @@ public class KeyUtilsTest extends BaseTestSupport {
assertTrue(prefix + ": Cloned pair not equals", KeyUtils.compareKeyPairs(kp, cloned));
{
- PublicKey k1 = kp.getPublic(), k2 = cloned.getPublic();
+ PublicKey k1 = kp.getPublic();
+ PublicKey k2 = cloned.getPublic();
assertNotSame(prefix + ": Public key not cloned", k1, k2);
assertTrue(prefix + ": Cloned public key not equals", KeyUtils.compareKeys(k1, k2));
- String f1 = KeyUtils.getFingerPrint(k1), f2 = KeyUtils.getFingerPrint(k2);
+ String f1 = KeyUtils.getFingerPrint(k1);
+ String f2 = KeyUtils.getFingerPrint(k2);
assertEquals(prefix + ": Mismatched fingerprints", f1, f2);
}
{
- PrivateKey k1 = kp.getPrivate(), k2 = cloned.getPrivate();
+ PrivateKey k1 = kp.getPrivate();
+ PrivateKey k2 = cloned.getPrivate();
assertNotSame(prefix + ": Private key not cloned", k1, k2);
assertTrue(prefix + ": Cloned private key not equals", KeyUtils.compareKeys(k1, k2));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/config/keys/PublicKeyEntryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/PublicKeyEntryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/PublicKeyEntryTest.java
index bd432f2..778b65a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/config/keys/PublicKeyEntryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/config/keys/PublicKeyEntryTest.java
@@ -46,7 +46,7 @@ public class PublicKeyEntryTest extends BaseTestSupport {
GenericUtils.join(
Arrays.asList(getCurrentTestName(), "AAAA", getClass().getSimpleName()), ' '));
for (PublicKeyEntryResolver resolver : new PublicKeyEntryResolver[]{
- null, PublicKeyEntryResolver.FAILING, PublicKeyEntryResolver.IGNORING}) {
+ null, PublicKeyEntryResolver.FAILING, PublicKeyEntryResolver.IGNORING}) {
try {
PublicKey key = entry.resolvePublicKey(resolver);
assertSame("Mismatched successful resolver", PublicKeyEntryResolver.IGNORING, resolver);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
index 00eb39e..a9fddc3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
@@ -53,7 +53,7 @@ public class BasePathTest extends BaseTestSupport {
}
@Test
- public void testbasicPathParsing() {
+ public void testBasicPathParsing() {
assertPathEquals("/", "/");
assertPathEquals("/foo", "/foo");
assertPathEquals("/foo", "/", "foo");
@@ -108,7 +108,7 @@ public class BasePathTest extends BaseTestSupport {
}
@Test
- public void testAbsolutePath_singleName() {
+ public void testAbsolutePathSingleName() {
new PathTester(fileSystem, "/foo")
.root("/")
.names("foo")
@@ -179,7 +179,7 @@ public class BasePathTest extends BaseTestSupport {
}
@Test
- public void testResolve_givenEmptyPath() {
+ public void testResolveGivenEmptyPath() {
assertResolvedPathEquals("/foo", parsePath("/foo"), "");
assertResolvedPathEquals("foo", parsePath("foo"), "");
}
@@ -287,8 +287,8 @@ public class BasePathTest extends BaseTestSupport {
assertPathEquals("/foo/bar/baz", parsePath("///foo/bar/baz"));
}
- private void assertResolvedPathEquals(String expected, Path path, String firstResolvePath,
- String... moreResolvePaths) {
+ private void assertResolvedPathEquals(
+ String expected, Path path, String firstResolvePath, String... moreResolvePaths) {
Path resolved = path.resolve(firstResolvePath);
for (String additionalPath : moreResolvePaths) {
resolved = resolved.resolve(additionalPath);
@@ -329,7 +329,7 @@ public class BasePathTest extends BaseTestSupport {
private static class TestFileSystem extends BaseFileSystem<TestPath> {
- public TestFileSystem(FileSystemProvider fileSystemProvider) {
+ TestFileSystem(FileSystemProvider fileSystemProvider) {
super(fileSystemProvider);
}
@@ -361,7 +361,7 @@ public class BasePathTest extends BaseTestSupport {
private static class TestPath extends BasePath<TestPath, TestFileSystem> {
- public TestPath(TestFileSystem fileSystem, String root, ImmutableList<String> names) {
+ TestPath(TestFileSystem fileSystem, String root, ImmutableList<String> names) {
super(fileSystem, root, names);
}
@@ -466,8 +466,7 @@ public class BasePathTest extends BaseTestSupport {
}
if (parent != null) {
- String parentName = names.size() == 1 ? root :
- string.substring(0, string.lastIndexOf('/'));
+ String parentName = names.size() == 1 ? root : string.substring(0, string.lastIndexOf('/'));
new PathTester(fileSystem, parentName)
.root(root)
.names(names.subList(0, names.size() - 1))
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingLoadTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingLoadTest.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingLoadTest.java
index e7b9162..1c6e615 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingLoadTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingLoadTest.java
@@ -35,6 +35,10 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpVersion;
@@ -60,10 +64,6 @@ import org.junit.runners.MethodSorters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-
/**
* Port forwarding tests
*/
@@ -118,19 +118,20 @@ public class PortForwardingLoadTest extends BaseTestSupport {
}
@Test
+ @SuppressWarnings("checkstyle:nestedtrydepth")
public void testLocalForwardingPayload() throws Exception {
- final int NUM_ITERATIONS = 100;
- final String PAYLOAD_TMP = "This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. ";
- StringBuilder sb = new StringBuilder(PAYLOAD_TMP.length() * 1000);
+ final int numIterations = 100;
+ final String payloadTmpData = "This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. ";
+ StringBuilder sb = new StringBuilder(payloadTmpData.length() * 1000);
for (int i = 0; i < 1000; i++) {
- sb.append(PAYLOAD_TMP);
+ sb.append(payloadTmpData);
}
- final String PAYLOAD = sb.toString();
+ final String payload = sb.toString();
Session session = createSession();
try (final ServerSocket ss = new ServerSocket()) {
@@ -147,24 +148,31 @@ public class PortForwardingLoadTest extends BaseTestSupport {
try {
byte[] buf = new byte[8192];
log.info("Started...");
- for (int i = 0; i < NUM_ITERATIONS; ++i) {
+ for (int i = 0; i < numIterations; ++i) {
try (Socket s = ss.accept()) {
conCount.incrementAndGet();
try (InputStream sockIn = s.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- int l;
- while ((baos.size() < PAYLOAD.length()) && ((l = sockIn.read(buf)) > 0)) {
+ while (baos.size() < payload.length()) {
+ int l = sockIn.read(buf);
+ if (l < 0) {
+ break;
+ }
baos.write(buf, 0, l);
}
- assertEquals("Mismatched received data at iteration #" + i, PAYLOAD, baos.toString());
+ assertEquals("Mismatched received data at iteration #" + i, payload, baos.toString());
try (InputStream inputCopy = new ByteArrayInputStream(baos.toByteArray());
OutputStream sockOut = s.getOutputStream()) {
- while ((l = sockIn.read(buf)) > 0) {
+ while (true) {
+ int l = sockIn.read(buf);
+ if (l < 0) {
+ break;
+ }
sockOut.write(buf, 0, l);
}
}
@@ -181,8 +189,8 @@ public class PortForwardingLoadTest extends BaseTestSupport {
Thread.sleep(50);
byte[] buf = new byte[8192];
- byte[] bytes = PAYLOAD.getBytes(StandardCharsets.UTF_8);
- for (int i = 0; i < NUM_ITERATIONS; i++) {
+ byte[] bytes = payload.getBytes(StandardCharsets.UTF_8);
+ for (int i = 0; i < numIterations; i++) {
log.info("Iteration {}", Integer.valueOf(i));
try (Socket s = new Socket(TEST_LOCALHOST, sinkPort);
OutputStream sockOut = s.getOutputStream()) {
@@ -194,11 +202,14 @@ public class PortForwardingLoadTest extends BaseTestSupport {
try (InputStream sockIn = s.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream(bytes.length)) {
- int l;
- while ((baos.size() < PAYLOAD.length()) && ((l = sockIn.read(buf)) > 0)) {
+ while (baos.size() < payload.length()) {
+ int l = sockIn.read(buf);
+ if (l < 0) {
+ break;
+ }
baos.write(buf, 0, l);
}
- assertEquals("Mismatched payload at iteration #" + i, PAYLOAD, baos.toString());
+ assertEquals("Mismatched payload at iteration #" + i, payload, baos.toString());
}
} catch (Exception e) {
log.error("Error in iteration #" + i, e);
@@ -215,13 +226,12 @@ public class PortForwardingLoadTest extends BaseTestSupport {
@Test
public void testRemoteForwardingPayload() throws Exception {
- final int NUM_ITERATIONS = 100;
- final String PAYLOAD = "This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. This is significantly longer Test Data. This is significantly " +
- "longer Test Data. ";
+ final int numIterations = 100;
+ final String payload = "This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. This is significantly longer Test Data. This is significantly "
+ + "longer Test Data. ";
Session session = createSession();
try (final ServerSocket ss = new ServerSocket()) {
ss.setReuseAddress(true);
@@ -239,8 +249,8 @@ public class PortForwardingLoadTest extends BaseTestSupport {
public void run() {
started[0] = true;
try {
- byte[] bytes = PAYLOAD.getBytes(StandardCharsets.UTF_8);
- for (int i = 0; i < NUM_ITERATIONS; ++i) {
+ byte[] bytes = payload.getBytes(StandardCharsets.UTF_8);
+ for (int i = 0; i < numIterations; ++i) {
try (Socket s = ss.accept()) {
conCount.incrementAndGet();
@@ -259,12 +269,12 @@ public class PortForwardingLoadTest extends BaseTestSupport {
Thread.sleep(50);
assertTrue("Server not started", started[0]);
- final RuntimeException lenOK[] = new RuntimeException[NUM_ITERATIONS];
- final RuntimeException dataOK[] = new RuntimeException[NUM_ITERATIONS];
- byte b2[] = new byte[PAYLOAD.length()];
+ final RuntimeException lenOK[] = new RuntimeException[numIterations];
+ final RuntimeException dataOK[] = new RuntimeException[numIterations];
+ byte b2[] = new byte[payload.length()];
byte b1[] = new byte[b2.length / 2];
- for (int i = 0; i < NUM_ITERATIONS; i++) {
+ for (int i = 0; i < numIterations; i++) {
final int ii = i;
try (Socket s = new Socket(TEST_LOCALHOST, sinkPort);
InputStream sockIn = s.getInputStream()) {
@@ -277,12 +287,12 @@ public class PortForwardingLoadTest extends BaseTestSupport {
int read2 = sockIn.read(b2);
String part2 = new String(b2, 0, read2, StandardCharsets.UTF_8);
int totalRead = read1 + read2;
- lenOK[ii] = (PAYLOAD.length() == totalRead)
+ lenOK[ii] = (payload.length() == totalRead)
? null
- : new IndexOutOfBoundsException("Mismatched length: expected=" + PAYLOAD.length() + ", actual=" + totalRead);
+ : new IndexOutOfBoundsException("Mismatched length: expected=" + payload.length() + ", actual=" + totalRead);
String readData = part1 + part2;
- dataOK[ii] = PAYLOAD.equals(readData) ? null : new IllegalStateException("Mismatched content");
+ dataOK[ii] = payload.equals(readData) ? null : new IllegalStateException("Mismatched content");
if (lenOK[ii] != null) {
throw lenOK[ii];
}
@@ -299,12 +309,12 @@ public class PortForwardingLoadTest extends BaseTestSupport {
}
}
int ok = 0;
- for (int i = 0; i < NUM_ITERATIONS; i++) {
+ for (int i = 0; i < numIterations; i++) {
ok += (lenOK[i] == null) ? 1 : 0;
}
- log.info("Successful iteration: " + ok + " out of " + NUM_ITERATIONS);
+ log.info("Successful iteration: " + ok + " out of " + numIterations);
Thread.sleep(55L);
- for (int i = 0; i < NUM_ITERATIONS; i++) {
+ for (int i = 0; i < numIterations; i++) {
assertNull("Bad length at iteration " + i, lenOK[i]);
assertNull("Bad data at iteration " + i, dataOK[i]);
}
@@ -356,7 +366,7 @@ public class PortForwardingLoadTest extends BaseTestSupport {
final int forwardedPort1 = session.setPortForwardingL(0, host, port);
final int forwardedPort2 = Utils.getFreePort();
session.setPortForwardingR(forwardedPort2, TEST_LOCALHOST, forwardedPort1);
- System.err.println("URL: http://localhost:" + forwardedPort2);
+ outputDebugMessage("URL: http://localhost %s", forwardedPort2);
final CountDownLatch latch = new CountDownLatch(nbThread * nbDownloads * nbLoops);
final Thread[] threads = new Thread[nbThread];
@@ -416,7 +426,7 @@ public class PortForwardingLoadTest extends BaseTestSupport {
if (str.indexOf("</html>") <= 0) {
System.err.println(str);
}
- assertTrue((str.indexOf("</html>") > 0));
+ assertTrue("Missing HTML close tag", str.indexOf("</html>") > 0);
get.releaseConnection();
// url.openConnection().setDefaultUseCaches(false);
// Reader reader = new BufferedReader(new InputStreamReader(url.openStream()));
@@ -435,8 +445,6 @@ public class PortForwardingLoadTest extends BaseTestSupport {
// reader.close();
// }
}
-
-
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
index 7d6cf8d..eeaffd4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/forward/PortForwardingTest.java
@@ -36,6 +36,10 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Session;
+
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.service.IoHandlerAdapter;
@@ -46,8 +50,6 @@ import org.apache.sshd.client.channel.ChannelDirectTcpip;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.PropertyResolverUtils;
-import org.apache.sshd.common.forward.TcpipForwarder;
-import org.apache.sshd.common.forward.TcpipForwarderFactory;
import org.apache.sshd.common.session.ConnectionService;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
@@ -68,10 +70,6 @@ import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.slf4j.LoggerFactory;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Session;
-
/**
* Port forwarding tests
*/
@@ -166,7 +164,7 @@ public class PortForwardingTest extends BaseTestSupport {
}
private void waitForForwardingRequest(String expected, long timeout) throws InterruptedException {
- for (long remaining = timeout; remaining > 0L; ) {
+ for (long remaining = timeout; remaining > 0L;) {
long waitStart = System.currentTimeMillis();
String actual = requestsQ.poll(remaining, TimeUnit.MILLISECONDS);
long waitEnd = System.currentTimeMillis();
@@ -473,27 +471,25 @@ public class PortForwardingTest extends BaseTestSupport {
rudelyDisconnectJschSession(session);
// 4. Make sure the NIOprocessor is not stuck
- {
- Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
- // from here, we need to check all the threads running and find a
- // "NioProcessor-"
- // that is stuck on a PortForward.dispose
- ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
- while (root.getParent() != null) {
- root = root.getParent();
- }
+ Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
+ // from here, we need to check all the threads running and find a
+ // "NioProcessor-"
+ // that is stuck on a PortForward.dispose
+ ThreadGroup root = Thread.currentThread().getThreadGroup().getParent();
+ while (root.getParent() != null) {
+ root = root.getParent();
+ }
- for (int index = 0; ; index++) {
- Collection<Thread> pending = findThreads(root, "NioProcessor-");
- if (GenericUtils.size(pending) <= 0) {
- log.info("Finished after " + index + " iterations");
- break;
- }
- try {
- Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
- } catch (InterruptedException e) {
- // ignored
- }
+ for (int index = 0;; index++) {
+ Collection<Thread> pending = findThreads(root, "NioProcessor-");
+ if (GenericUtils.size(pending) <= 0) {
+ log.info("Finished after " + index + " iterations");
+ break;
+ }
+ try {
+ Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
+ } catch (InterruptedException e) {
+ // ignored
}
}
@@ -554,31 +550,29 @@ public class PortForwardingTest extends BaseTestSupport {
}
private boolean checkThreadForPortForward(Thread thread, String name) {
- if (thread == null)
+ if (thread == null) {
return false;
+ }
+
// does it contain the name we're looking for?
if (thread.getName().contains(name)) {
// look at the stack
StackTraceElement[] stack = thread.getStackTrace();
- if (stack.length == 0)
+ if (stack.length == 0) {
return false;
- else {
- // does it have
- // 'org.apache.sshd.server.session.TcpipForwardSupport.close'?
- for (int i = 0; i < stack.length; ++i) {
- String clazzName = stack[i].getClassName();
- String methodName = stack[i].getMethodName();
- // log.debug("Class: " + clazzName);
- // log.debug("Method: " + methodName);
- if (clazzName
- .equals("org.apache.sshd.server.session.TcpipForwardSupport")
- && (methodName.equals("close") || methodName
- .equals("sessionCreated"))) {
- log.warn(thread.getName() + " stuck at " + clazzName
- + "." + methodName + ": "
- + stack[i].getLineNumber());
- return true;
- }
+ }
+ // does it have 'org.apache.sshd.server.session.TcpipForwardSupport.close'?
+ for (int i = 0; i < stack.length; ++i) {
+ String clazzName = stack[i].getClassName();
+ String methodName = stack[i].getMethodName();
+ // log.debug("Class: " + clazzName);
+ // log.debug("Method: " + methodName);
+ if (clazzName.equals("org.apache.sshd.server.session.TcpipForwardSupport")
+ && (methodName.equals("close") || methodName.equals("sessionCreated"))) {
+ log.warn(thread.getName() + " stuck at " + clazzName
+ + "." + methodName + ": "
+ + stack[i].getLineNumber());
+ return true;
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/future/DefaultSshFutureTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/future/DefaultSshFutureTest.java b/sshd-core/src/test/java/org/apache/sshd/common/future/DefaultSshFutureTest.java
index 6182f55..35a9e63 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/future/DefaultSshFutureTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/future/DefaultSshFutureTest.java
@@ -71,13 +71,13 @@ public class DefaultSshFutureTest extends BaseTestSupport {
}
};
- final int NUM_LISTENERS = Byte.SIZE;
- for (int index = 0; index < NUM_LISTENERS; index++) {
+ final int numListeners = Byte.SIZE;
+ for (int index = 0; index < numListeners; index++) {
future.addListener(listener);
}
future.setValue(expected);
- assertEquals("Mismatched listeners invocation count", NUM_LISTENERS, listenerCount.get());
+ assertEquals("Mismatched listeners invocation count", numListeners, listenerCount.get());
}
@Test
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
index 0439b14..c9bf9e5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/io/DefaultIoServiceFactoryFactoryTest.java
@@ -46,7 +46,8 @@ public class DefaultIoServiceFactoryFactoryTest extends BaseTestSupport {
String name = f.getName();
IoServiceFactoryFactory factoryInstance =
DefaultIoServiceFactoryFactory.newInstance(IoServiceFactoryFactory.class, name);
- Class<?> expected = f.getFactoryClass(), actual = factoryInstance.getClass();
+ Class<?> expected = f.getFactoryClass();
+ Class<?> actual = factoryInstance.getClass();
assertSame(name, expected, actual);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
index bec174d..8b51101 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
@@ -41,7 +41,7 @@ public class Nio2ServiceTest extends BaseTestSupport {
@Test // see SSHD-554
public void testSetSocketOptions() throws Exception {
- try(SshServer sshd = setupTestServer()) {
+ try (SshServer sshd = setupTestServer()) {
PropertyResolverUtils.updateProperty(sshd, FactoryManager.SOCKET_KEEPALIVE, true);
PropertyResolverUtils.updateProperty(sshd, FactoryManager.SOCKET_LINGER, 5);
PropertyResolverUtils.updateProperty(sshd, FactoryManager.SOCKET_RCVBUF, 1024);
@@ -53,7 +53,7 @@ public class Nio2ServiceTest extends BaseTestSupport {
int port = sshd.getPort();
long startTime = System.nanoTime();
- try(Socket s = new Socket(TEST_LOCALHOST, port)) {
+ try (Socket s = new Socket(TEST_LOCALHOST, port)) {
long endTime = System.nanoTime();
long duration = endTime - startTime;
assertTrue("Connect duration is too high: " + duration, duration <= TimeUnit.SECONDS.toNanos(15L));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java b/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
index 91263ce..a406332 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/kex/AbstractDHTest.java
@@ -54,7 +54,8 @@ public class AbstractDHTest extends BaseTestSupport {
data[index] = (byte) index;
byte[] stripped = AbstractDH.stripLeadingZeroes(data);
- String ds = Arrays.toString(data), ss = Arrays.toString(stripped);
+ String ds = Arrays.toString(data);
+ String ss = Arrays.toString(stripped);
assertEquals("Mismatched stripped (" + ss + ") length for " + ds, data.length - index, stripped.length);
for (int i = index, j = 0; j < stripped.length; i++, j++) {
if (data[i] != stripped[j]) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
index b32ca94..8cfb1ee 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/kex/BuiltinDHFactoriesTest.java
@@ -79,7 +79,7 @@ public class BuiltinDHFactoriesTest extends BaseTestSupport {
Collections.shuffle(unknown, rnd);
List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size());) {
boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
index 96b1206..fa95e23 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/kex/KexProposalOptionTest.java
@@ -60,7 +60,7 @@ public class KexProposalOptionTest extends BaseTestSupport {
@Test
public void testFromProposalIndex() {
- for (int index : new int[]{(-1), KexProposalOption.VALUES.size()}) {
+ for (int index : new int[]{-1, KexProposalOption.VALUES.size()}) {
KexProposalOption o = KexProposalOption.fromProposalIndex(index);
assertNull("Unexpected value for index=" + index, o);
}
@@ -82,7 +82,8 @@ public class KexProposalOptionTest extends BaseTestSupport {
KexProposalOption o1 = KexProposalOption.VALUES.get(index - 1);
KexProposalOption o2 = KexProposalOption.VALUES.get(index);
- int i1 = o1.getProposalIndex(), i2 = o2.getProposalIndex();
+ int i1 = o1.getProposalIndex();
+ int i2 = o2.getProposalIndex();
assertTrue("Non increasing index for " + o1 + "[" + i1 + "] vs. " + o2 + "[" + i2 + "]", i1 < i2);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
index 8d6737f..73e3604 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/keyprovider/KeyPairProviderTest.java
@@ -72,7 +72,8 @@ public class KeyPairProviderTest extends BaseTestSupport {
for (Map.Entry<String, KeyPair> pairEntry : pairsMap.entrySet()) {
String keyType = pairEntry.getKey();
- KeyPair expected = pairEntry.getValue(), actual = provider.loadKey(keyType);
+ KeyPair expected = pairEntry.getValue();
+ KeyPair actual = provider.loadKey(keyType);
assertSame(keyType, expected, actual);
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
index 820e434..10af615 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/BuiltinMacsTest.java
@@ -79,7 +79,7 @@ public class BuiltinMacsTest extends BaseTestSupport {
Collections.shuffle(unknown, rnd);
List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size());) {
boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
index 987beb2..89081ae 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
@@ -30,6 +30,8 @@ import java.util.List;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
+import com.jcraft.jsch.JSch;
+
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.util.GenericUtils;
@@ -48,8 +50,6 @@ import org.junit.runners.MethodSorters;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import com.jcraft.jsch.JSch;
-
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.ConnectionInfo;
@@ -61,7 +61,7 @@ import ch.ethz.ssh2.ConnectionInfo;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(Parameterized.class) // see https://github.com/junit-team/junit/wiki/Parameterized-tests
public class MacTest extends BaseTestSupport {
- private static final Collection<String> ganymedMacs =
+ private static final Collection<String> GANYMEDE_MACS =
Collections.unmodifiableSet(new TreeSet<String>(String.CASE_INSENSITIVE_ORDER) {
private static final long serialVersionUID = 1L; // we're not serializing it
@@ -75,6 +75,16 @@ public class MacTest extends BaseTestSupport {
}
});
+ private final MacFactory factory;
+ private final String jschMacClass;
+ private SshServer sshd;
+ private int port;
+
+ public MacTest(MacFactory factory, String jschMacClass) {
+ this.factory = factory;
+ this.jschMacClass = jschMacClass;
+ }
+
@Parameters(name = "factory={0}")
public static Collection<Object[]> parameters() {
List<Object[]> ret = new ArrayList<>();
@@ -114,16 +124,6 @@ public class MacTest extends BaseTestSupport {
JSchLogger.init();
}
- private final MacFactory factory;
- private final String jschMacClass;
- private SshServer sshd;
- private int port;
-
- public MacTest(MacFactory factory, String jschMacClass) {
- this.factory = factory;
- this.jschMacClass = jschMacClass;
- }
-
@Before
public void setUp() throws Exception {
sshd = setupTestServer();
@@ -175,7 +175,7 @@ public class MacTest extends BaseTestSupport {
@Test
public void testWithGanymede() throws Exception {
String macName = factory.getName();
- Assume.assumeTrue("Factory not supported: " + macName, ganymedMacs.contains(macName));
+ Assume.assumeTrue("Factory not supported: " + macName, GANYMEDE_MACS.contains(macName));
ch.ethz.ssh2.log.Logger.enabled = true;
Connection conn = new Connection(TEST_LOCALHOST, port);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java
index 01f517b..da714c5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacVectorsTest.java
@@ -141,25 +141,29 @@ public class MacVectorsTest extends BaseTestSupport {
///////////////// Test Cases for HMAC-SHA-2 ///////////////////////
// see https://tools.ietf.org/html/rfc4231
new VectorTestData(repeat("0b", 20), false, "Hi There",
- Arrays.asList( // test case 1
+ // test case 1
+ Arrays.asList(
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_256,
"b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7"),
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_512,
"87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854"))),
new VectorTestData("Jefe", "what do ya want for nothing?",
- Arrays.asList( // test case 2
+ // test case 2
+ Arrays.asList(
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_256,
"5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843"),
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_512,
"164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737"))),
new VectorTestData(repeat("aa", 20), false, repeat("dd", 50), false,
- Arrays.asList( // test case 3
+ // test case 3
+ Arrays.asList(
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_256,
"773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fe"),
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_512,
"fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb"))),
new VectorTestData("0102030405060708090a0b0c0d0e0f10111213141516171819", false, repeat("cd", 50), false,
- Arrays.asList( // test case 4
+ // test case 4
+ Arrays.asList(
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_256,
"82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665b"),
new Pair<>(BuiltinMacs.Constants.HMAC_SHA2_512,
@@ -196,7 +200,7 @@ public class MacVectorsTest extends BaseTestSupport {
*/
// mark end
- new VectorTestData("", false, "", false, Collections.<Pair<String,String>>emptyList())))) {
+ new VectorTestData("", false, "", false, Collections.<Pair<String, String>>emptyList())))) {
for (Pair<String, String> tc : vector.getResults()) {
ret.add(new Object[]{vector, tc.getFirst(), tc.getSecond()});
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/random/RandomFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/random/RandomFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/random/RandomFactoryTest.java
index 5d56dde..17e420c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/random/RandomFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/random/RandomFactoryTest.java
@@ -40,6 +40,12 @@ import org.junit.runners.Parameterized.Parameters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(Parameterized.class) // see https://github.com/junit-team/junit/wiki/Parameterized-tests
public class RandomFactoryTest extends BaseTestSupport {
+ private final RandomFactory factory;
+
+ public RandomFactoryTest(RandomFactory factory) {
+ this.factory = factory;
+ }
+
@Parameters(name = "type={0}")
public static Collection<Object[]> parameters() {
Collection<RandomFactory> testCases = new LinkedList<>();
@@ -53,12 +59,6 @@ public class RandomFactoryTest extends BaseTestSupport {
return parameterize(testCases);
}
- private final RandomFactory factory;
-
- public RandomFactoryTest(RandomFactory factory) {
- this.factory = factory;
- }
-
@Test
public void testRandomFactory() {
Assume.assumeTrue("Skip unsupported factory: " + factory.getName(), factory.isSupported());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
index 580828e..c8d4a28 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
@@ -39,7 +39,6 @@ import org.apache.sshd.common.io.IoSession;
import org.apache.sshd.common.io.IoWriteFuture;
import org.apache.sshd.common.kex.KexProposalOption;
import org.apache.sshd.common.session.Session;
-import org.apache.sshd.common.session.helpers.AbstractSession;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
@@ -90,7 +89,7 @@ public class AbstractSessionTest extends BaseTestSupport {
@Test
public void testReadIdentWithHeaders() {
- Buffer buf = new ByteArrayBuffer(("a header line\r\nSSH-2.0-software\r\n").getBytes(StandardCharsets.UTF_8));
+ Buffer buf = new ByteArrayBuffer("a header line\r\nSSH-2.0-software\r\n".getBytes(StandardCharsets.UTF_8));
String ident = session.doReadIdentification(buf);
assertEquals("SSH-2.0-software", ident);
}
@@ -107,7 +106,7 @@ public class AbstractSessionTest extends BaseTestSupport {
@Test(expected = IllegalStateException.class)
public void testReadIdentBadLineEnding() {
- Buffer buf = new ByteArrayBuffer(("SSH-2.0-software\ra").getBytes(StandardCharsets.UTF_8));
+ Buffer buf = new ByteArrayBuffer("SSH-2.0-software\ra".getBytes(StandardCharsets.UTF_8));
String ident = session.doReadIdentification(buf);
fail("Unexpected success: " + ident);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
index 375c655..604d76e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/BuiltinSignaturesTest.java
@@ -62,7 +62,7 @@ public class BuiltinSignaturesTest extends BaseTestSupport {
Collections.shuffle(unknown, rnd);
List<String> weavedList = new ArrayList<String>(builtin.size() + unknown.size());
- for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size()); ) {
+ for (int bIndex = 0, uIndex = 0; (bIndex < builtin.size()) || (uIndex < unknown.size());) {
boolean useBuiltin = false;
if (bIndex < builtin.size()) {
useBuiltin = (uIndex < unknown.size()) ? rnd.nextBoolean() : true;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
index a8d5858..949dcd4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureDSSFactoryTest.java
@@ -42,15 +42,15 @@ public class SignatureDSSFactoryTest extends AbstractSignatureFactoryTestSupport
private static final List<NamedFactory<Signature>> FACTORIES =
Collections.unmodifiableList(Collections.<NamedFactory<Signature>>singletonList(BuiltinSignatures.dsa));
+ public SignatureDSSFactoryTest(int keySize) {
+ super(KeyPairProvider.SSH_DSS, keySize);
+ }
+
@Parameters(name = "keySize={0}")
public static Collection<Object[]> parameters() {
return parameterize(DSS_SIZES);
}
- public SignatureDSSFactoryTest(int keySize) {
- super(KeyPairProvider.SSH_DSS, keySize);
- }
-
@Test
public void testDSSPublicKeyAuth() throws Exception {
testKeyPairProvider(DSSPublicKeyEntryDecoder.INSTANCE, FACTORIES);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
index d71a6d3..5958f40 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureECDSAFactoryTest.java
@@ -51,15 +51,15 @@ public class SignatureECDSAFactoryTest extends AbstractSignatureFactoryTestSuppo
BuiltinSignatures.nistp521
));
+ public SignatureECDSAFactoryTest(ECCurves curve) {
+ super(curve.getName(), curve.getKeySize());
+ }
+
@Parameters(name = "keySize={0}")
public static Collection<Object[]> parameters() {
return parameterize(ECCurves.VALUES);
}
- public SignatureECDSAFactoryTest(ECCurves curve) {
- super(curve.getName(), curve.getKeySize());
- }
-
@Test
public void testECDSAPublicKeyAuth() throws Exception {
Assume.assumeTrue("ECC not supported", SecurityUtils.hasEcc());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
index bb687d3..33960ce 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSAFactoryTest.java
@@ -42,15 +42,15 @@ public class SignatureRSAFactoryTest extends AbstractSignatureFactoryTestSupport
private static final List<NamedFactory<Signature>> FACTORIES =
Collections.unmodifiableList(Collections.<NamedFactory<Signature>>singletonList(BuiltinSignatures.rsa));
+ public SignatureRSAFactoryTest(int keySize) {
+ super(KeyPairProvider.SSH_RSA, keySize);
+ }
+
@Parameters(name = "keySize={0}")
public static Collection<Object[]> parameters() {
return parameterize(RSA_SIZES);
}
- public SignatureRSAFactoryTest(int keySize) {
- super(KeyPairProvider.SSH_RSA, keySize);
- }
-
@Test
public void testRSAPublicKeyAuth() throws Exception {
testKeyPairProvider(RSAPublicKeyDecoder.INSTANCE, FACTORIES);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSATest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSATest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSATest.java
index 4cbe017..6496801 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSATest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureRSATest.java
@@ -40,8 +40,10 @@ import org.junit.runners.MethodSorters;
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SignatureRSATest extends BaseTestSupport {
+ @SuppressWarnings("checkstyle:linelength")
private static final byte[] TEST_MSG =
Base64.decodeString("AAAAFPHgK1MeV9zNnok3pwNJhCd8SONqMgAAAAlidWlsZHVzZXIAAAAOc3NoLWNvbm5lY3Rpb24AAAAJcHVibGlja2V5AQAAAAdzc2gtcnNhAAABFQAAAAdzc2gtcnNhAAAAASMAAAEBAMs9HO/NH/Now+6fSnESebaG4wzaYQWA1b/q1TGV1wHNtCg9fGFGVSKs0VxKF4cfVyrSLtgLjnlXQTn+Lm7xiYKGbBbsTQWOqEDaBVBsRbAkxIkpuvr6/EBxwrtDbKmSQYTJZVJSD2bZRYjGsR9gpZXPorOOKFd5EPCMHXsqnhp2hidTGH7cK6RuLk7MNnPISsY0Nbx8/ZvikiPROGcoTZ8bzUv4IaLr3veW6epSeQem8tJqhnrpTHhbLU99zf045M0Gsnk/azjjlBM+qrHZ5FNdC1kowJnLtf2Oy/rUQNpkGJtcBPT8xvreV0wLsn9t3hSxzsc0+VkDNTQRlfU+o3M=");
+ @SuppressWarnings("checkstyle:linelength")
private static final byte[] TEST_SIGNATURE =
Base64.decodeString("AAAAB3NzaC1yc2EAAAD/+Ntnf4qfr2J1voDS6I+u3VRjtMn+LdWJsAZfkLDxRkK1rQxP7QAjLdNqpT4CkWHp8dtoTGFlBFt6NieNJCMTA2KSOxJMZKsX7e/lHkh7C+vhQvJ9eLTKWjCxSFUrcM0NvFhmwbRCffwXSHvAKak4wbmofxQMpd+G4jZkNMz5kGpmeICBcNjRLPb7oXzuGr/g4x/3ge5Qaawqrg/gcZr/sKN6SdE8SszgKYO0SB320N4gcUoShVdLYr9uwdJ+kJoobfkUK6Or171JCctP/cu2nM79lDqVnJw/2jOG8OnTc8zRDXAh0RKoR5rOU8cOHm0Ls2MATsFdnyRU5FGUxqZ+");
private static PublicKey testKey;
@@ -53,6 +55,7 @@ public class SignatureRSATest extends BaseTestSupport {
@BeforeClass
public static void initializeTestKey() throws GeneralSecurityException {
byte[] exp = Base64.decodeString("Iw==");
+ @SuppressWarnings("checkstyle:linelength")
byte[] mod = Base64.decodeString("AMs9HO/NH/Now+6fSnESebaG4wzaYQWA1b/q1TGV1wHNtCg9fGFGVSKs0VxKF4cfVyrSLtgLjnlXQTn+Lm7xiYKGbBbsTQWOqEDaBVBsRbAkxIkpuvr6/EBxwrtDbKmSQYTJZVJSD2bZRYjGsR9gpZXPorOOKFd5EPCMHXsqnhp2hidTGH7cK6RuLk7MNnPISsY0Nbx8/ZvikiPROGcoTZ8bzUv4IaLr3veW6epSeQem8tJqhnrpTHhbLU99zf045M0Gsnk/azjjlBM+qrHZ5FNdC1kowJnLtf2Oy/rUQNpkGJtcBPT8xvreV0wLsn9t3hSxzsc0+VkDNTQRlfU+o3M=");
KeyFactory kf = SecurityUtils.getKeyFactory("RSA");
testKey = kf.generatePublic(new RSAPublicKeySpec(new BigInteger(mod), new BigInteger(exp)));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpConstantsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpConstantsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpConstantsTest.java
index 03e6cd3..1280f5a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpConstantsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpConstantsTest.java
@@ -36,9 +36,10 @@ public class SftpConstantsTest extends BaseTestSupport {
@Test
public void testRenameModesNotMarkedAsOpcodes() {
for (int cmd : new int[]{
- SftpConstants.SSH_FXP_RENAME_OVERWRITE,
- SftpConstants.SSH_FXP_RENAME_ATOMIC,
- SftpConstants.SSH_FXP_RENAME_NATIVE}) {
+ SftpConstants.SSH_FXP_RENAME_OVERWRITE,
+ SftpConstants.SSH_FXP_RENAME_ATOMIC,
+ SftpConstants.SSH_FXP_RENAME_NATIVE
+ }) {
String name = SftpConstants.getCommandMessageName(cmd);
assertFalse("Mismatched name for " + cmd + ": " + name, name.startsWith("SSH_FXP_RENAME_"));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroupTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroupTest.java b/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroupTest.java
index 7ba3b0f..ab48f2b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroupTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroupTest.java
@@ -52,7 +52,7 @@ public class SftpUniversalOwnerAndGroupTest extends BaseTestSupport {
@Test
public void testFromName() {
- for (String name : new String[]{ null, "", getCurrentTestName() }) {
+ for (String name : new String[]{null, "", getCurrentTestName()}) {
assertNull("Unexpected value for '" + name + "'", SftpUniversalOwnerAndGroup.fromName(name));
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/EventListenerUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/EventListenerUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/EventListenerUtilsTest.java
index 6af9c63..772518b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/EventListenerUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/EventListenerUtilsTest.java
@@ -58,13 +58,13 @@ public class EventListenerUtilsTest extends BaseTestSupport {
}
}
- private static interface ProxyListener extends EventListener {
+ interface ProxyListener extends EventListener {
void callMeWithString(String s);
void callMeWithNumber(Number n);
}
- private static class ProxyListenerImpl implements ProxyListener {
+ static class ProxyListenerImpl implements ProxyListener {
private String strValue;
private Number numValue;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
index c8470cc..39776e4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
@@ -51,7 +51,8 @@ public class GenericUtilsTest extends BaseTestSupport {
assertEquals("Mismatched split length for separator=" + sep, expected.size(), GenericUtils.length((Object[]) actual));
for (int index = 0; index < actual.length; index++) {
- String e = expected.get(index), a = actual[index];
+ String e = expected.get(index);
+ String a = actual[index];
if (!e.endsWith(a)) {
fail("Mismatched value at index=" + index + " for separator=" + sep + ": expected=" + e + ", actual=" + a);
}
@@ -80,7 +81,8 @@ public class GenericUtilsTest extends BaseTestSupport {
StringBuilder sb = new StringBuilder().append("||").append(getCurrentTestName()).append("||");
char[] delims = {'\'', '"', '"', '\''};
for (int index = 0; index < delims.length; index += 2) {
- char topDelim = delims[index], innerDelim = delims[index + 1];
+ char topDelim = delims[index];
+ char innerDelim = delims[index + 1];
sb.setCharAt(0, topDelim);
sb.setCharAt(1, innerDelim);
sb.setCharAt(sb.length() - 2, innerDelim);
@@ -130,9 +132,9 @@ public class GenericUtilsTest extends BaseTestSupport {
@Test
public void testAccumulateExceptionOnExistingCurrent() {
RuntimeException[] expected = new RuntimeException[]{
- new IllegalArgumentException(getCurrentTestName()),
- new ClassCastException(getClass().getName()),
- new NoSuchElementException(getClass().getPackage().getName())
+ new IllegalArgumentException(getCurrentTestName()),
+ new ClassCastException(getClass().getName()),
+ new NoSuchElementException(getClass().getPackage().getName())
};
RuntimeException current = new UnsupportedOperationException("top");
for (RuntimeException extra : expected) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
index 017dd30..41e4531 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/SecurityUtilsTest.java
@@ -56,7 +56,7 @@ import org.junit.runners.MethodSorters;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SecurityUtilsTest extends BaseTestSupport {
private static final String DEFAULT_PASSWORD = "super secret passphrase";
- private static final FilePasswordProvider passwordProvider = new FilePasswordProvider() {
+ private static final FilePasswordProvider TEST_PASSWORD_PROVIDER = new FilePasswordProvider() {
@Override
public String getPassword(String file) throws IOException {
return DEFAULT_PASSWORD;
@@ -77,7 +77,8 @@ public class SecurityUtilsTest extends BaseTestSupport {
public void testLoadEncryptedAESPrivateKey() {
Assume.assumeTrue("Bouncycastle not registered", SecurityUtils.isBouncyCastleRegistered());
for (BuiltinCiphers c : new BuiltinCiphers[]{
- BuiltinCiphers.aes128cbc, BuiltinCiphers.aes192cbc, BuiltinCiphers.aes256cbc}) {
+ BuiltinCiphers.aes128cbc, BuiltinCiphers.aes192cbc, BuiltinCiphers.aes256cbc
+ }) {
if (!c.isSupported()) {
System.out.println("Skip unsupported encryption scheme: " + c.getName());
continue;
@@ -152,8 +153,9 @@ public class SecurityUtilsTest extends BaseTestSupport {
return testLoadPrivateKey(file.toString(), provider, pubType, prvType);
}
- private static KeyPair testLoadPrivateKey(String resourceKey, AbstractResourceKeyPairProvider<?> provider, Class<? extends PublicKey> pubType, Class<? extends PrivateKey> prvType) {
- provider.setPasswordFinder(passwordProvider);
+ private static KeyPair testLoadPrivateKey(String resourceKey, AbstractResourceKeyPairProvider<?> provider,
+ Class<? extends PublicKey> pubType, Class<? extends PrivateKey> prvType) {
+ provider.setPasswordFinder(TEST_PASSWORD_PROVIDER);
Iterable<KeyPair> iterator = provider.loadKeys();
List<KeyPair> pairs = new ArrayList<KeyPair>();
for (KeyPair kp : iterator) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
index 2ee8926..5106614 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
@@ -47,17 +47,17 @@ public class SelectorUtilsTest extends BaseTestSupport {
}
private void testApplySlashifyRules(char slash) {
- for (String expected : new String[] {
- null, "", getCurrentTestName(),
- getClass().getSimpleName() + String.valueOf(slash) + getCurrentTestName(),
- String.valueOf(slash) + getClass().getSimpleName(),
- String.valueOf(slash) + getClass().getSimpleName() + String.valueOf(slash) + getCurrentTestName()
- }) {
+ for (String expected : new String[]{
+ null, "", getCurrentTestName(),
+ getClass().getSimpleName() + String.valueOf(slash) + getCurrentTestName(),
+ String.valueOf(slash) + getClass().getSimpleName(),
+ String.valueOf(slash) + getClass().getSimpleName() + String.valueOf(slash) + getCurrentTestName()
+ }) {
String actual = SelectorUtils.applySlashifyRules(expected, slash);
assertSame("Mismatched results for '" + expected + "'", expected, actual);
}
- String[] comps = { getClass().getSimpleName(), getCurrentTestName() };
+ String[] comps = {getClass().getSimpleName(), getCurrentTestName()};
Random rnd = new Random(System.nanoTime());
StringBuilder sb = new StringBuilder(Byte.MAX_VALUE);
for (int index = 0; index < Long.SIZE; index++) {
@@ -115,14 +115,13 @@ public class SelectorUtilsTest extends BaseTestSupport {
public void testTranslateToFileSystemPath() {
String path = getClass().getPackage().getName().replace('.', File.separatorChar)
+ File.separator + getClass().getSimpleName()
- + File.separator + getCurrentTestName()
- ;
- for (String expected : new String[] { null, "", path }) {
+ + File.separator + getCurrentTestName();
+ for (String expected : new String[] {null, "", path}) {
String actual = SelectorUtils.translateToFileSystemPath(expected, File.separator, File.separator);
assertSame("Mismatched instance for translated result", expected, actual);
}
- for (String fsSeparator : new String[] { String.valueOf('.'), "##" }) {
+ for (String fsSeparator : new String[] {String.valueOf('.'), "##"}) {
String expected = path.replace(File.separator, fsSeparator);
String actual = SelectorUtils.translateToFileSystemPath(path, File.separator, fsSeparator);
assertEquals("Mismatched translation result for separator='" + fsSeparator + "'", expected, actual);
@@ -136,7 +135,7 @@ public class SelectorUtilsTest extends BaseTestSupport {
public void testAbsoluteWindowsPathTranslation() {
Assume.assumeTrue("Not tested on Windows", OsUtils.isWin32());
String expected = detectTargetFolder().toString();
- for (String prefix : new String[]{ "", "/" }) {
+ for (String prefix : new String[]{"", "/"}) {
String actual = SelectorUtils.translateToLocalPath(prefix + expected.replace('/', File.separatorChar));
assertEquals("Mismatched result for prefix='" + prefix + "'", expected, actual);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/39a71a15/sshd-core/src/test/java/org/apache/sshd/common/util/TransformerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/TransformerTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/TransformerTest.java
index b8f50f6..a74d2e0 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/TransformerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/TransformerTest.java
@@ -39,7 +39,7 @@ public class TransformerTest extends BaseTestSupport {
@Test
public void testToString() {
assertNull("Invalid null result", Transformer.TOSTRING.transform(null));
- for (Object o : new Object[] { "", getClass(), new Date() }) {
+ for (Object o : new Object[] {"", getClass(), new Date()}) {
String expected = o.toString();
String actual = Transformer.TOSTRING.transform(o);
assertEquals("Mismatched result for type=" + o.getClass().getSimpleName(), expected, actual);
@@ -59,15 +59,15 @@ public class TransformerTest extends BaseTestSupport {
@Test
public void testSingletonIdentityInstance() {
- Transformer<Date,Date> dateTransformer = Transformer.Utils.identity();
- Transformer<String,String> stringTransformer = Transformer.Utils.identity();
+ Transformer<Date, Date> dateTransformer = Transformer.Utils.identity();
+ Transformer<String, String> stringTransformer = Transformer.Utils.identity();
assertSame("Mismatched identity instance", dateTransformer, stringTransformer);
}
@Test
public void testIdentity() {
- Transformer<Object,Object> identity = Transformer.Utils.identity();
- for (Object expected : new Object[] { null, getClass(), getCurrentTestName() }) {
+ Transformer<Object, Object> identity = Transformer.Utils.identity();
+ for (Object expected : new Object[]{null, getClass(), getCurrentTestName()}) {
Object actual = identity.transform(expected);
assertSame("Mismatched identity result", expected, actual);
}