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:08:01 UTC
[5/5] mina-sshd git commit: [SSHD-655] Apply checkstyle plugin to
test source code as well
[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<>();