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 2015/05/18 12:38:03 UTC
[1/3] mina-sshd git commit: [SSHD-464] Make BaseTest extend
org.junit.Assert instead of TestWatcher
Repository: mina-sshd
Updated Branches:
refs/heads/master 3689f72f1 -> bd1d975ad
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BaseTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BaseTest.java b/sshd-core/src/test/java/org/apache/sshd/util/BaseTest.java
deleted file mode 100644
index 1b8d02f..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/util/BaseTest.java
+++ /dev/null
@@ -1,267 +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.util;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.security.Key;
-import java.security.KeyPair;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPrivateKey;
-import java.security.interfaces.DSAPublicKey;
-import java.security.interfaces.ECKey;
-import java.security.interfaces.ECPrivateKey;
-import java.security.interfaces.ECPublicKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.ECField;
-import java.security.spec.ECParameterSpec;
-import java.security.spec.ECPoint;
-import java.security.spec.EllipticCurve;
-import java.util.List;
-
-import org.apache.sshd.common.util.GenericUtils;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.rules.TestName;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-
-/**
- * TODO Add javadoc
- *
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class BaseTest extends TestWatcher {
- @Rule public TestWatcher rule = this;
- @Rule public final TestName TEST_NAME_HOLDER = new TestName();
- private long startTime;
-
- protected BaseTest() {
- super();
- }
-
- public final String getCurrentTestName() {
- return TEST_NAME_HOLDER.getMethodName();
- }
-
- @Override
- protected void starting(Description description) {
- System.out.println("\nStarting " + description.getClassName() + ":" + description.getMethodName() + "...\n");
- startTime = System.currentTimeMillis();
- }
-
- @Override
- protected void finished(Description description) {
- long duration = System.currentTimeMillis() - startTime;
- System.out.println("\nFinished " + description.getClassName() + ":" + description.getMethodName() + " in " + duration + " ms\n");
- }
-
- /* ------------------- Useful extra test helpers ---------------------- */
-
- public static String shuffleCase(CharSequence cs) {
- if (GenericUtils.isEmpty(cs)) {
- return "";
- }
-
- StringBuilder sb = new StringBuilder(cs.length());
- for (int index = 0; index < cs.length(); index++) {
- char ch = cs.charAt(index);
- double v = Math.random();
- if (Double.compare(v, 0.3d) < 0) {
- ch = Character.toUpperCase(ch);
- } else if ((Double.compare(v, 0.3d) >= 0) && (Double.compare(v, 0.6d) < 0)) {
- ch = Character.toLowerCase(ch);
- }
- sb.append(ch);
- }
-
- return sb.toString();
- }
-
- /* ----------------------- Useful extra assertions --------------------- */
-
- public static File assertHierarchyTargetFolderExists(File folder) {
- if (!folder.exists()) {
- assertTrue("Failed to create hierarchy of " + folder.getAbsolutePath(), folder.mkdirs());
- }
-
- return folder;
- }
-
- public static void assertObjectInstanceOf(String message, Class<?> expected, Object obj) {
- assertNotNull(message + " - no actual object", obj);
-
- Class<?> actual=obj.getClass();
- if (!expected.isAssignableFrom(actual)) {
- fail(message + " - actual object type (" + actual.getName() + ") incompatible with expected (" + expected.getName() + ")");
- }
- }
-
- public static <E> void assertListEquals(String message, List<? extends E> expected, List<? extends E> actual) {
- int expSize=GenericUtils.size(expected), actSize=GenericUtils.size(actual);
- Assert.assertEquals(message + "[size]", expSize, actSize);
-
- for (int index=0; index < expSize; index++) {
- E expValue=expected.get(index), actValue=actual.get(index);
- Assert.assertEquals(message + "[" + index + "]", expValue, actValue);
- }
- }
-
- public static void assertKeyPairEquals(String message, KeyPair expected, KeyPair actual) {
- assertKeyEquals(message + "[public]", expected.getPublic(), actual.getPublic());
- assertKeyEquals(message + "[private]", expected.getPrivate(), actual.getPrivate());
- }
-
- public static final <T extends Key> void assertKeyEquals(String message, T expected, T actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[algorithm]", expected.getAlgorithm(), actual.getAlgorithm());
-
- if (expected instanceof RSAPublicKey) {
- assertRSAPublicKeyEquals(message, RSAPublicKey.class.cast(expected), RSAPublicKey.class.cast(actual));
- } else if (expected instanceof DSAPublicKey) {
- assertDSAPublicKeyEquals(message, DSAPublicKey.class.cast(expected), DSAPublicKey.class.cast(actual));
- } else if (expected instanceof ECPublicKey) {
- assertECPublicKeyEquals(message, ECPublicKey.class.cast(expected), ECPublicKey.class.cast(actual));
- } else if (expected instanceof RSAPrivateKey) {
- assertRSAPrivateKeyEquals(message, RSAPrivateKey.class.cast(expected), RSAPrivateKey.class.cast(actual));
- } else if (expected instanceof ECPrivateKey) {
- assertECPrivateKeyEquals(message, ECPrivateKey.class.cast(expected), ECPrivateKey.class.cast(actual));
- }
- assertArrayEquals(message + "[encdoded-data]", expected.getEncoded(), actual.getEncoded());
- }
-
- public static final void assertRSAPublicKeyEquals(String message, RSAPublicKey expected, RSAPublicKey actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[e]", expected.getPublicExponent(), actual.getPublicExponent());
- assertEquals(message + "[n]", expected.getModulus(), actual.getModulus());
- }
-
- public static final void assertDSAPublicKeyEquals(String message, DSAPublicKey expected, DSAPublicKey actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[y]", expected.getY(), actual.getY());
- assertDSAParamsEquals(message + "[params]", expected.getParams(), actual.getParams());
- }
-
- public static final void assertECPublicKeyEquals(String message, ECPublicKey expected, ECPublicKey actual) {
- if (expected == actual) {
- return;
- }
-
- assertECPointEquals(message + "[W]", expected.getW(), actual.getW());
- assertECParameterSpecEquals(message, expected, actual);
- }
-
- public static final void assertRSAPrivateKeyEquals(String message, RSAPrivateKey expected, RSAPrivateKey actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[d]", expected.getPrivateExponent(), actual.getPrivateExponent());
- assertEquals(message + "[n]", expected.getModulus(), actual.getModulus());
- }
-
- public static final void assertDSAPrivateKeyEquals(String message, DSAPrivateKey expected, DSAPrivateKey actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[x]", expected.getX(), actual.getX());
- assertDSAParamsEquals(message + "[params]", expected.getParams(), actual.getParams());
- }
-
- public static final void assertDSAParamsEquals(String message, DSAParams expected, DSAParams actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[g]", expected.getG(), actual.getG());
- assertEquals(message + "[p]", expected.getP(), actual.getP());
- assertEquals(message + "[q]", expected.getQ(), actual.getQ());
- }
-
- public static final void assertECPrivateKeyEquals(String message, ECPrivateKey expected, ECPrivateKey actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[S]", expected.getS(), actual.getS());
- assertECParameterSpecEquals(message, expected, actual);
- }
-
- public static final 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) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[order]", expected.getOrder(), actual.getOrder());
- assertEquals(message + "[cofactor]", expected.getCofactor(), actual.getCofactor());
- assertECPointEquals(message + "[generator]", expected.getGenerator(), actual.getGenerator());
- assertCurveEquals(message + "[curve]", expected.getCurve(), actual.getCurve());
- }
-
- public static final void assertCurveEquals(String message, EllipticCurve expected, EllipticCurve actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[A]", expected.getA(), actual.getA());
- assertEquals(message + "[B]", expected.getB(), actual.getB());
- assertArrayEquals(message + "[seed]", expected.getSeed(), actual.getSeed());
- assertECFieldEquals(message + "[field]", expected.getField(), actual.getField());
- }
-
- public static final void assertECFieldEquals(String message, ECField expected, ECField actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[size]", expected.getFieldSize(), actual.getFieldSize());
- }
-
- public static final void assertECPointEquals(String message, ECPoint expected, ECPoint actual) {
- if (expected == actual) {
- return;
- }
-
- assertEquals(message + "[x]", expected.getAffineX(), actual.getAffineX());
- assertEquals(message + "[y]", expected.getAffineY(), actual.getAffineY());
- }
-}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
new file mode 100644
index 0000000..af37b07
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BaseTestSupport.java
@@ -0,0 +1,264 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.security.Key;
+import java.security.KeyPair;
+import java.security.interfaces.DSAParams;
+import java.security.interfaces.DSAPrivateKey;
+import java.security.interfaces.DSAPublicKey;
+import java.security.interfaces.ECKey;
+import java.security.interfaces.ECPrivateKey;
+import java.security.interfaces.ECPublicKey;
+import java.security.interfaces.RSAPrivateKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.ECField;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECPoint;
+import java.security.spec.EllipticCurve;
+import java.util.List;
+
+import org.apache.sshd.common.util.GenericUtils;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.rules.TestName;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+/**
+ * TODO Add javadoc
+ *
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class BaseTestSupport extends Assert {
+ @Rule public final TestWatcher rule = new TestWatcher() {
+ // TODO consider using a ThreadLocal storage for the start time - provided
+ // the code is assured to call starting/finished on the same thread
+ private long startTime;
+
+ @Override
+ protected void starting(Description description) {
+ System.out.println("\nStarting " + description.getClassName() + ":" + description.getMethodName() + "...\n");
+ startTime = System.currentTimeMillis();
+ }
+
+ @Override
+ protected void finished(Description description) {
+ long duration = System.currentTimeMillis() - startTime;
+ System.out.println("\nFinished " + description.getClassName() + ":" + description.getMethodName() + " in " + duration + " ms\n");
+ }
+ };
+ @Rule public final TestName TEST_NAME_HOLDER = new TestName();
+
+ protected BaseTestSupport() {
+ super();
+ }
+
+ public final String getCurrentTestName() {
+ return TEST_NAME_HOLDER.getMethodName();
+ }
+
+ /* ------------------- Useful extra test helpers ---------------------- */
+
+ public static String shuffleCase(CharSequence cs) {
+ if (GenericUtils.isEmpty(cs)) {
+ return "";
+ }
+
+ StringBuilder sb = new StringBuilder(cs.length());
+ for (int index = 0; index < cs.length(); index++) {
+ char ch = cs.charAt(index);
+ double v = Math.random();
+ if (Double.compare(v, 0.3d) < 0) {
+ ch = Character.toUpperCase(ch);
+ } else if ((Double.compare(v, 0.3d) >= 0) && (Double.compare(v, 0.6d) < 0)) {
+ ch = Character.toLowerCase(ch);
+ }
+ sb.append(ch);
+ }
+
+ return sb.toString();
+ }
+
+ /* ----------------------- Useful extra assertions --------------------- */
+
+ public static File assertHierarchyTargetFolderExists(File folder) {
+ if (!folder.exists()) {
+ assertTrue("Failed to create hierarchy of " + folder.getAbsolutePath(), folder.mkdirs());
+ }
+
+ return folder;
+ }
+
+ public static void assertObjectInstanceOf(String message, Class<?> expected, Object obj) {
+ assertNotNull(message + " - no actual object", obj);
+
+ Class<?> actual=obj.getClass();
+ if (!expected.isAssignableFrom(actual)) {
+ fail(message + " - actual object type (" + actual.getName() + ") incompatible with expected (" + expected.getName() + ")");
+ }
+ }
+
+ public static <E> void assertListEquals(String message, List<? extends E> expected, List<? extends E> actual) {
+ int expSize=GenericUtils.size(expected), 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);
+ assertEquals(message + "[" + index + "]", expValue, actValue);
+ }
+ }
+
+ public static void assertKeyPairEquals(String message, KeyPair expected, KeyPair actual) {
+ assertKeyEquals(message + "[public]", expected.getPublic(), actual.getPublic());
+ assertKeyEquals(message + "[private]", expected.getPrivate(), actual.getPrivate());
+ }
+
+ public static final <T extends Key> void assertKeyEquals(String message, T expected, T actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[algorithm]", expected.getAlgorithm(), actual.getAlgorithm());
+
+ if (expected instanceof RSAPublicKey) {
+ assertRSAPublicKeyEquals(message, RSAPublicKey.class.cast(expected), RSAPublicKey.class.cast(actual));
+ } else if (expected instanceof DSAPublicKey) {
+ assertDSAPublicKeyEquals(message, DSAPublicKey.class.cast(expected), DSAPublicKey.class.cast(actual));
+ } else if (expected instanceof ECPublicKey) {
+ assertECPublicKeyEquals(message, ECPublicKey.class.cast(expected), ECPublicKey.class.cast(actual));
+ } else if (expected instanceof RSAPrivateKey) {
+ assertRSAPrivateKeyEquals(message, RSAPrivateKey.class.cast(expected), RSAPrivateKey.class.cast(actual));
+ } else if (expected instanceof ECPrivateKey) {
+ assertECPrivateKeyEquals(message, ECPrivateKey.class.cast(expected), ECPrivateKey.class.cast(actual));
+ }
+ assertArrayEquals(message + "[encdoded-data]", expected.getEncoded(), actual.getEncoded());
+ }
+
+ public static final void assertRSAPublicKeyEquals(String message, RSAPublicKey expected, RSAPublicKey actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[e]", expected.getPublicExponent(), actual.getPublicExponent());
+ assertEquals(message + "[n]", expected.getModulus(), actual.getModulus());
+ }
+
+ public static final void assertDSAPublicKeyEquals(String message, DSAPublicKey expected, DSAPublicKey actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[y]", expected.getY(), actual.getY());
+ assertDSAParamsEquals(message + "[params]", expected.getParams(), actual.getParams());
+ }
+
+ public static final void assertECPublicKeyEquals(String message, ECPublicKey expected, ECPublicKey actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertECPointEquals(message + "[W]", expected.getW(), actual.getW());
+ assertECParameterSpecEquals(message, expected, actual);
+ }
+
+ public static final void assertRSAPrivateKeyEquals(String message, RSAPrivateKey expected, RSAPrivateKey actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[d]", expected.getPrivateExponent(), actual.getPrivateExponent());
+ assertEquals(message + "[n]", expected.getModulus(), actual.getModulus());
+ }
+
+ public static final void assertDSAPrivateKeyEquals(String message, DSAPrivateKey expected, DSAPrivateKey actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[x]", expected.getX(), actual.getX());
+ assertDSAParamsEquals(message + "[params]", expected.getParams(), actual.getParams());
+ }
+
+ public static final void assertDSAParamsEquals(String message, DSAParams expected, DSAParams actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[g]", expected.getG(), actual.getG());
+ assertEquals(message + "[p]", expected.getP(), actual.getP());
+ assertEquals(message + "[q]", expected.getQ(), actual.getQ());
+ }
+
+ public static final void assertECPrivateKeyEquals(String message, ECPrivateKey expected, ECPrivateKey actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[S]", expected.getS(), actual.getS());
+ assertECParameterSpecEquals(message, expected, actual);
+ }
+
+ public static final 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) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[order]", expected.getOrder(), actual.getOrder());
+ assertEquals(message + "[cofactor]", expected.getCofactor(), actual.getCofactor());
+ assertECPointEquals(message + "[generator]", expected.getGenerator(), actual.getGenerator());
+ assertCurveEquals(message + "[curve]", expected.getCurve(), actual.getCurve());
+ }
+
+ public static final void assertCurveEquals(String message, EllipticCurve expected, EllipticCurve actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[A]", expected.getA(), actual.getA());
+ assertEquals(message + "[B]", expected.getB(), actual.getB());
+ assertArrayEquals(message + "[seed]", expected.getSeed(), actual.getSeed());
+ assertECFieldEquals(message + "[field]", expected.getField(), actual.getField());
+ }
+
+ public static final void assertECFieldEquals(String message, ECField expected, ECField actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[size]", expected.getFieldSize(), actual.getFieldSize());
+ }
+
+ public static final void assertECPointEquals(String message, ECPoint expected, ECPoint actual) {
+ if (expected == actual) {
+ return;
+ }
+
+ assertEquals(message + "[x]", expected.getAffineX(), actual.getAffineX());
+ assertEquals(message + "[y]", expected.getAffineY(), actual.getAffineY());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BogusChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BogusChannel.java b/sshd-core/src/test/java/org/apache/sshd/util/BogusChannel.java
index ce47b18..92c3158 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BogusChannel.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BogusChannel.java
@@ -29,24 +29,31 @@ public class BogusChannel extends AbstractChannel {
@Override
protected void doWriteData(byte[] data, int off, int len) throws IOException {
+ // ignored
}
@Override
protected void doWriteExtendedData(byte[] data, int off, int len) throws IOException {
+ // ignored
}
@Override
protected void sendWindowAdjust(int len) throws IOException {
+ // ignored
}
+ @Override
public OpenFuture open(int recipient, int rwsize, int rmpsize, Buffer buffer) {
return new DefaultOpenFuture(this.lock);
}
+ @Override
public void handleOpenSuccess(int recipient, int rwsize, int rmpsize, Buffer buffer) throws IOException {
+ // ignored
}
+ @Override
public void handleOpenFailure(Buffer buffer) throws IOException {
+ // ignored
}
-
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BogusEnvironment.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BogusEnvironment.java b/sshd-core/src/test/java/org/apache/sshd/util/BogusEnvironment.java
index d7458cf..a38ebfd 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BogusEnvironment.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BogusEnvironment.java
@@ -29,26 +29,32 @@ import org.apache.sshd.server.SignalListener;
public class BogusEnvironment implements Environment {
+ @Override
public Map<String, String> getEnv() {
return Collections.emptyMap();
}
+ @Override
public Map<PtyMode, Integer> getPtyModes() {
return Collections.emptyMap();
}
+ @Override
public void addSignalListener(SignalListener listener, Signal... signal) {
// ignored
}
+ @Override
public void addSignalListener(SignalListener listener, Collection<Signal> signals) {
// ignored
}
+ @Override
public void addSignalListener(SignalListener listener) {
// ignored
}
+ @Override
public void removeSignalListener(SignalListener listener) {
// ignored
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BogusExitCallback.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BogusExitCallback.java b/sshd-core/src/test/java/org/apache/sshd/util/BogusExitCallback.java
index 9279acf..4b8fd48 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BogusExitCallback.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BogusExitCallback.java
@@ -24,10 +24,12 @@ public class BogusExitCallback implements ExitCallback {
private boolean exited;
+ @Override
public void onExit(int exitValue) {
this.exited = true;
}
+ @Override
public void onExit(int exitValue, String exitMessage) {
this.exited = true;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BogusForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BogusForwardingFilter.java b/sshd-core/src/test/java/org/apache/sshd/util/BogusForwardingFilter.java
index 6e25706..7fa734a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BogusForwardingFilter.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BogusForwardingFilter.java
@@ -28,18 +28,22 @@ import org.apache.sshd.common.SshdSocketAddress;
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
public class BogusForwardingFilter implements ForwardingFilter {
+ @Override
public boolean canForwardAgent(Session session) {
return true;
}
+ @Override
public boolean canForwardX11(Session session) {
return true;
}
+ @Override
public boolean canConnect(SshdSocketAddress address, Session session) {
return true;
}
+ @Override
public boolean canListen(SshdSocketAddress address, Session session) {
return true;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BogusInvertedShell.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BogusInvertedShell.java b/sshd-core/src/test/java/org/apache/sshd/util/BogusInvertedShell.java
index 63cfabd..4d38f6a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BogusInvertedShell.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BogusInvertedShell.java
@@ -44,31 +44,38 @@ public class BogusInvertedShell implements InvertedShell {
this.err = err;
}
+ @Override
public void start(Map<String, String> env) throws IOException {
this.started = true;
this.env = Collections.unmodifiableMap(env);
}
+ @Override
public OutputStream getInputStream() {
return in;
}
+ @Override
public InputStream getOutputStream() {
return out;
}
+ @Override
public InputStream getErrorStream() {
return err;
}
+ @Override
public boolean isAlive() {
return alive;
}
+ @Override
public int exitValue() {
return 0;
}
+ @Override
public void destroy() {
IoUtils.closeQuietly(in);
IoUtils.closeQuietly(out);
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/BogusPublickeyAuthenticator.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/BogusPublickeyAuthenticator.java b/sshd-core/src/test/java/org/apache/sshd/util/BogusPublickeyAuthenticator.java
index f8a902c..15a649a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/BogusPublickeyAuthenticator.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/BogusPublickeyAuthenticator.java
@@ -30,6 +30,7 @@ import org.apache.sshd.server.session.ServerSession;
*/
public class BogusPublickeyAuthenticator implements PublickeyAuthenticator {
+ @Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
return true;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java b/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
index 742d2b6..74bf954 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/EchoShellFactory.java
@@ -37,6 +37,7 @@ import org.apache.sshd.server.ExitCallback;
*/
public class EchoShellFactory implements Factory<Command> {
+ @Override
public Command create() {
return new EchoShell();
}
@@ -66,32 +67,39 @@ public class EchoShellFactory implements Factory<Command> {
return environment;
}
+ @Override
public void setInputStream(InputStream in) {
this.in = in;
}
+ @Override
public void setOutputStream(OutputStream out) {
this.out = out;
}
+ @Override
public void setErrorStream(OutputStream err) {
this.err = err;
}
+ @Override
public void setExitCallback(ExitCallback callback) {
this.callback = callback;
}
+ @Override
public void start(Environment env) throws IOException {
environment = env;
thread = new Thread(this, "EchoShell");
thread.start();
}
+ @Override
public void destroy() {
thread.interrupt();
}
+ @Override
public void run() {
BufferedReader r = new BufferedReader(new InputStreamReader(in));
try {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java b/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
index 8477ccd..a356dbc 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/JSchLogger.java
@@ -31,8 +31,9 @@ public class JSchLogger implements Logger {
JSch.setLogger(new JSchLogger());
}
- private org.slf4j.Logger log = LoggerFactory.getLogger("org.jcraft.jsch.JSch");
+ private final org.slf4j.Logger log = LoggerFactory.getLogger("org.jcraft.jsch.JSch");
+ @Override
public boolean isEnabled(int level) {
switch (level) {
case DEBUG: return log.isDebugEnabled();
@@ -40,10 +41,11 @@ public class JSchLogger implements Logger {
case WARN: return log.isWarnEnabled();
case ERROR: return log.isErrorEnabled();
case FATAL: return log.isErrorEnabled();
+ default : return false;
}
- return false;
}
+ @Override
public void log(int level, String message) {
switch (level) {
case DEBUG: log.debug(message); break;
@@ -51,6 +53,7 @@ public class JSchLogger implements Logger {
case WARN: log.warn(message); break;
case ERROR: log.error(message); break;
case FATAL: log.error(message); break;
+ default: log.error("[LEVEL=" + level + "]: " + message);
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java b/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
index 834be2e..9980c4a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/SimpleUserInfo.java
@@ -34,29 +34,37 @@ public class SimpleUserInfo implements UserInfo, UIKeyboardInteractive {
this.password = password;
}
+ @Override
public String getPassphrase() {
return null;
}
+ @Override
public String getPassword() {
return password;
}
+ @Override
public boolean promptPassword(String message) {
return true;
}
+ @Override
public boolean promptPassphrase(String message) {
return false;
}
+ @Override
public boolean promptYesNo(String message) {
return true;
}
+ @Override
public void showMessage(String message) {
+ // ignored
}
+ @Override
public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
return new String[] { password };
}
[2/3] mina-sshd git commit: [SSHD-464] Make BaseTest extend
org.junit.Assert instead of TestWatcher
Posted by lg...@apache.org.
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 1b46453..feef53e 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
@@ -33,15 +33,14 @@ import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.cipher.BuiltinCiphers.ParseResult;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class BuiltinCiphersTest extends BaseTest {
+public class BuiltinCiphersTest extends BaseTestSupport {
public BuiltinCiphersTest() {
super();
}
@@ -53,7 +52,7 @@ public class BuiltinCiphersTest extends BaseTest {
for (int index=0; index < name.length(); index++) {
BuiltinCiphers actual=BuiltinCiphers.fromString(name);
- Assert.assertSame(name + " - mismatched enum values", expected, actual);
+ assertSame(name + " - mismatched enum values", expected, actual);
name = shuffleCase(name); // prepare for next time
}
}
@@ -66,7 +65,7 @@ public class BuiltinCiphersTest extends BaseTest {
for (int index=0; index < name.length(); index++) {
BuiltinCiphers actual=BuiltinCiphers.fromFactoryName(name);
- Assert.assertSame(name + " - mismatched enum values", expected, actual);
+ assertSame(name + " - mismatched enum values", expected, actual);
name = shuffleCase(name); // prepare for next time
}
}
@@ -81,10 +80,10 @@ public class BuiltinCiphersTest extends BaseTest {
}
NamedFactory<Cipher> factory=expected;
- Assert.assertEquals(expected.name() + " - mismatched factory names", expected.getName(), factory.getName());
+ assertEquals(expected.name() + " - mismatched factory names", expected.getName(), factory.getName());
BuiltinCiphers actual=BuiltinCiphers.fromFactory(factory);
- Assert.assertSame(expected.getName() + " - mismatched enum values", expected, actual);
+ assertSame(expected.getName() + " - mismatched enum values", expected, actual);
}
}
@@ -95,11 +94,11 @@ public class BuiltinCiphersTest extends BaseTest {
for (Field f : fields) {
String name=(String) f.get(null);
BuiltinCiphers value=BuiltinCiphers.fromFactoryName(name);
- Assert.assertNotNull("No match found for " + name, value);
- Assert.assertTrue(name + " re-specified", avail.add(value));
+ assertNotNull("No match found for " + name, value);
+ assertTrue(name + " re-specified", avail.add(value));
}
- Assert.assertEquals("Incomplete coverage", BuiltinCiphers.VALUES, avail);
+ assertEquals("Incomplete coverage", BuiltinCiphers.VALUES, avail);
}
@Test
@@ -157,7 +156,7 @@ public class BuiltinCiphersTest extends BaseTest {
for (NamedFactory<Cipher> expected : BuiltinCiphers.VALUES) {
String name=expected.getName();
NamedFactory<Cipher> actual=BuiltinCiphers.resolveFactory(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -166,7 +165,7 @@ public class BuiltinCiphersTest extends BaseTest {
for (CipherFactory expected : BuiltinCiphers.VALUES) {
try {
BuiltinCiphers.registerExtension(expected);
- Assert.fail("Unexpected sucess for " + expected.getName());
+ fail("Unexpected sucess for " + expected.getName());
} catch(IllegalArgumentException e) {
// expected - ignored
}
@@ -182,7 +181,7 @@ public class BuiltinCiphersTest extends BaseTest {
try {
for (int index=1; index <= Byte.SIZE; index++) {
BuiltinCiphers.registerExtension(expected);
- Assert.assertEquals("Unexpected success at attempt #" + index, 1, index);
+ assertEquals("Unexpected success at attempt #" + index, 1, index);
}
} finally {
BuiltinCiphers.unregisterExtension(name);
@@ -196,27 +195,27 @@ public class BuiltinCiphersTest extends BaseTest {
String name=expected.getName();
try {
- Assert.assertNull("Extension already registered", BuiltinCiphers.resolveFactory(name));
+ assertNull("Extension already registered", BuiltinCiphers.resolveFactory(name));
BuiltinCiphers.registerExtension(expected);
NamedFactory<Cipher> actual=BuiltinCiphers.resolveFactory(name);
- Assert.assertSame("Mismatched resolved instance", expected, actual);
+ assertSame("Mismatched resolved instance", expected, actual);
} finally {
NamedFactory<Cipher> actual=BuiltinCiphers.unregisterExtension(name);
- Assert.assertSame("Mismatched unregistered instance", expected, actual);
- Assert.assertNull("Extension not un-registered", BuiltinCiphers.resolveFactory(name));
+ assertSame("Mismatched unregistered instance", expected, actual);
+ assertNull("Extension not un-registered", BuiltinCiphers.resolveFactory(name));
}
}
@Test
public void testFac2NamedTransformer() {
- Assert.assertNull("Invalid null transformation", CipherFactory.FAC2NAMED.transform(null));
+ assertNull("Invalid null transformation", CipherFactory.FAC2NAMED.transform(null));
for (CipherFactory expected : BuiltinCiphers.VALUES) {
NamedFactory<Cipher> actual=CipherFactory.FAC2NAMED.transform(expected);
- Assert.assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
+ assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
}
CipherFactory mock=Mockito.mock(CipherFactory.class);
- Assert.assertSame("Mismatched transformed mocked instance", mock, CipherFactory.FAC2NAMED.transform(mock));
+ assertSame("Mismatched transformed mocked instance", mock, CipherFactory.FAC2NAMED.transform(mock));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 601b28f..83e46f2 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
@@ -32,15 +32,14 @@ import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.compression.BuiltinCompressions.ParseResult;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class BuiltinCompressionsTest extends BaseTest {
+public class BuiltinCompressionsTest extends BaseTestSupport {
public BuiltinCompressionsTest() {
super();
}
@@ -52,7 +51,7 @@ public class BuiltinCompressionsTest extends BaseTest {
for (int index=0; index < name.length(); index++) {
BuiltinCompressions actual=BuiltinCompressions.fromFactoryName(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
name = shuffleCase(name);
}
}
@@ -64,11 +63,11 @@ public class BuiltinCompressionsTest extends BaseTest {
for (Field f : fields) {
String name=(String) f.get(null);
BuiltinCompressions value=BuiltinCompressions.fromFactoryName(name);
- Assert.assertNotNull("No match found for " + name, value);
- Assert.assertTrue(name + " re-specified", avail.add(value));
+ assertNotNull("No match found for " + name, value);
+ assertTrue(name + " re-specified", avail.add(value));
}
- Assert.assertEquals("Incomplete coverage", BuiltinCompressions.VALUES, avail);
+ assertEquals("Incomplete coverage", BuiltinCompressions.VALUES, avail);
}
@Test
@@ -112,7 +111,7 @@ public class BuiltinCompressionsTest extends BaseTest {
for (NamedFactory<Compression> expected : BuiltinCompressions.VALUES) {
String name=expected.getName();
NamedFactory<Compression> actual=BuiltinCompressions.resolveFactory(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -121,7 +120,7 @@ public class BuiltinCompressionsTest extends BaseTest {
for (CompressionFactory expected : BuiltinCompressions.VALUES) {
try {
BuiltinCompressions.registerExtension(expected);
- Assert.fail("Unexpected sucess for " + expected.getName());
+ fail("Unexpected sucess for " + expected.getName());
} catch(IllegalArgumentException e) {
// expected - ignored
}
@@ -137,7 +136,7 @@ public class BuiltinCompressionsTest extends BaseTest {
try {
for (int index=1; index <= Byte.SIZE; index++) {
BuiltinCompressions.registerExtension(expected);
- Assert.assertEquals("Unexpected success at attempt #" + index, 1, index);
+ assertEquals("Unexpected success at attempt #" + index, 1, index);
}
} finally {
BuiltinCompressions.unregisterExtension(name);
@@ -151,27 +150,27 @@ public class BuiltinCompressionsTest extends BaseTest {
String name=expected.getName();
try {
- Assert.assertNull("Extension already registered", BuiltinCompressions.resolveFactory(name));
+ assertNull("Extension already registered", BuiltinCompressions.resolveFactory(name));
BuiltinCompressions.registerExtension(expected);
NamedFactory<Compression> actual=BuiltinCompressions.resolveFactory(name);
- Assert.assertSame("Mismatched resolved instance", expected, actual);
+ assertSame("Mismatched resolved instance", expected, actual);
} finally {
NamedFactory<Compression> actual=BuiltinCompressions.unregisterExtension(name);
- Assert.assertSame("Mismatched unregistered instance", expected, actual);
- Assert.assertNull("Extension not un-registered", BuiltinCompressions.resolveFactory(name));
+ assertSame("Mismatched unregistered instance", expected, actual);
+ assertNull("Extension not un-registered", BuiltinCompressions.resolveFactory(name));
}
}
@Test
public void testFac2NamedTransformer() {
- Assert.assertNull("Invalid null transformation", CompressionFactory.FAC2NAMED.transform(null));
+ assertNull("Invalid null transformation", CompressionFactory.FAC2NAMED.transform(null));
for (CompressionFactory expected : BuiltinCompressions.VALUES) {
NamedFactory<Compression> actual=CompressionFactory.FAC2NAMED.transform(expected);
- Assert.assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
+ assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
}
CompressionFactory mock=Mockito.mock(CompressionFactory.class);
- Assert.assertSame("Mismatched transformed mocked instance", mock, CompressionFactory.FAC2NAMED.transform(mock));
+ assertSame("Mismatched transformed mocked instance", mock, CompressionFactory.FAC2NAMED.transform(mock));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 9ae5fd4..2fa32b2 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
@@ -18,8 +18,6 @@
*/
package org.apache.sshd.common.compression;
-import static org.junit.Assert.assertEquals;
-
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
@@ -27,7 +25,7 @@ import java.util.Arrays;
import org.apache.sshd.SshServer;
import org.apache.sshd.common.NamedFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.JSchLogger;
@@ -43,7 +41,7 @@ import com.jcraft.jsch.JSch;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class CompressionTest extends BaseTest {
+public class CompressionTest extends BaseTestSupport {
private SshServer sshd;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 4c61be3..375023b 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
@@ -44,14 +44,13 @@ import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.mac.BuiltinMacs;
import org.apache.sshd.common.signature.BuiltinSignatures;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SshConfigFileReaderTest extends BaseTest {
+public class SshConfigFileReaderTest extends BaseTestSupport {
public SshConfigFileReaderTest() {
super();
}
@@ -59,18 +58,18 @@ public class SshConfigFileReaderTest extends BaseTest {
@Test
public void testReadFromURL() throws IOException {
URL url=getClass().getResource("sshd_config");
- Assert.assertNotNull("Cannot locate test file", url);
+ assertNotNull("Cannot locate test file", url);
Properties props=SshConfigFileReader.readConfigFile(url);
- Assert.assertFalse("No properties read", props.isEmpty());
- Assert.assertTrue("Unexpected commented property data", GenericUtils.isEmpty(props.getProperty("ListenAddress")));
- Assert.assertTrue("Unexpected non-existing property data", GenericUtils.isEmpty(props.getProperty(getCurrentTestName())));
+ assertFalse("No properties read", props.isEmpty());
+ assertTrue("Unexpected commented property data", GenericUtils.isEmpty(props.getProperty("ListenAddress")));
+ assertTrue("Unexpected non-existing property data", GenericUtils.isEmpty(props.getProperty(getCurrentTestName())));
String keysList=props.getProperty("HostKey");
- Assert.assertFalse("No host keys", GenericUtils.isEmpty(keysList));
+ assertFalse("No host keys", GenericUtils.isEmpty(keysList));
String[] keys=GenericUtils.split(keysList, ',');
- Assert.assertTrue("No multiple keys", GenericUtils.length((Object[]) keys) > 1);
+ assertTrue("No multiple keys", GenericUtils.length((Object[]) keys) > 1);
}
@Test
@@ -112,8 +111,8 @@ public class SshConfigFileReaderTest extends BaseTest {
props.setProperty(SshConfigFileReader.COMPRESSION_PROP, expected.name().toLowerCase());
NamedResource actual=SshConfigFileReader.getCompression(props);
- Assert.assertNotNull("No match for " + expected.name(), actual);
- Assert.assertEquals(expected.name(), expected.getName(), actual.getName());
+ assertNotNull("No match for " + expected.name(), actual);
+ assertEquals(expected.name(), expected.getName(), actual.getName());
}
}
@@ -128,7 +127,7 @@ public class SshConfigFileReaderTest extends BaseTest {
};
// must be lenient since we do not cover the full default spectrum
AbstractFactoryManager actual=SshConfigFileReader.configure(expected, props, true, true);
- Assert.assertSame("Mismatched configured result", expected, actual);
+ assertSame("Mismatched configured result", expected, actual);
validateAbstractFactoryManagerConfiguration(expected, props, true);
}
@@ -144,7 +143,7 @@ public class SshConfigFileReaderTest extends BaseTest {
getCurrentTestName(),
false,
true);
- Assert.fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getCipherFactories()));
+ fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getCipherFactories()));
}
@Test(expected=IllegalArgumentException.class)
@@ -159,7 +158,7 @@ public class SshConfigFileReaderTest extends BaseTest {
getCurrentTestName(),
false,
true);
- Assert.fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getSignatureFactories()));
+ fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getSignatureFactories()));
}
@Test(expected=IllegalArgumentException.class)
@@ -174,7 +173,7 @@ public class SshConfigFileReaderTest extends BaseTest {
getCurrentTestName(),
false,
true);
- Assert.fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getMacFactories()));
+ fail("Unexpected success: " + NamedResource.Utils.getNames(manager.getMacFactories()));
}
@Test
@@ -199,8 +198,8 @@ public class SshConfigFileReaderTest extends BaseTest {
false,
true);
List<NamedFactory<Compression>> compressions=manager.getCompressionFactories();
- Assert.assertEquals(prefix + "(size)", 1, GenericUtils.size(compressions));
- Assert.assertSame(prefix + "[instance]", expected, compressions.get(0));
+ assertEquals(prefix + "(size)", 1, GenericUtils.size(compressions));
+ assertSame(prefix + "[instance]", expected, compressions.get(0));
}
}
@@ -248,7 +247,7 @@ public class SshConfigFileReaderTest extends BaseTest {
private static <M extends FactoryManager> M validateFactoryManagerCompressions(M manager, String value, boolean lenient) {
NamedFactory<Compression> factory=CompressionConfigValue.fromName(value);
- Assert.assertTrue("Unknown compression: " + value, lenient || (factory != null));
+ assertTrue("Unknown compression: " + value, lenient || (factory != null));
if (factory != null) {
validateFactoryManagerFactories(Compression.class, Collections.singletonList(factory), manager.getCompressionFactories());
}
@@ -269,12 +268,12 @@ public class SshConfigFileReaderTest extends BaseTest {
private static <T extends NamedResource> List<T> testParsedFactoriesList(
List<? extends NamedResource> expected, List<T> actual, Collection<String> unsupported) {
- Assert.assertTrue("Unexpected unsupported factories: " + unsupported, GenericUtils.isEmpty(unsupported));
- Assert.assertEquals("Mismatched list size", expected.size(), GenericUtils.size(actual));
+ 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();
- Assert.assertEquals("Mismatched name at index=" + index, n1, n2);
+ assertEquals("Mismatched name at index=" + index, n1, n2);
}
return actual;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 27c8add..c702d6b 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
@@ -21,14 +21,13 @@ package org.apache.sshd.common.config;
import java.util.concurrent.TimeUnit;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class TimeValueConfigTest extends BaseTest {
+public class TimeValueConfigTest extends BaseTestSupport {
public TimeValueConfigTest() {
super();
}
@@ -46,7 +45,7 @@ public class TimeValueConfigTest extends BaseTest {
String s=(String) values[index];
Number expected=(Number) values[index + 1];
long actual=TimeValueConfig.durationOf(s);
- Assert.assertEquals(s, expected.longValue(), actual);
+ assertEquals(s, expected.longValue(), actual);
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 55c6b74..94f0a5c 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
@@ -31,17 +31,11 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class BasePathTest {
+public class BasePathTest extends BaseTestSupport {
private TestFileSystem fileSystem;
@@ -232,12 +226,14 @@ public class BasePathTest {
parsePath("/foo/bar").relativize(parsePath("foo"));
fail();
} catch (IllegalArgumentException expected) {
+ // ignored
}
try {
parsePath("foo").relativize(parsePath("/foo/bar"));
fail();
} catch (IllegalArgumentException expected) {
+ // ignored
}
}
@@ -336,7 +332,7 @@ public class BasePathTest {
@Override
public void close() throws IOException {
-
+ // ignored
}
@Override
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/future/FutureTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/future/FutureTest.java b/sshd-core/src/test/java/org/apache/sshd/common/future/FutureTest.java
index 145088f..047b70a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/future/FutureTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/future/FutureTest.java
@@ -18,14 +18,12 @@
*/
package org.apache.sshd.common.future;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
-import static junit.framework.Assert.assertNotNull;
-
/**
*/
-public class FutureTest extends BaseTest {
+public class FutureTest extends BaseTestSupport {
@Test
public void testAwaitUnint() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 04d17a5..c921e03 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
@@ -31,15 +31,14 @@ import java.util.Set;
import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.kex.BuiltinDHFactories.ParseResult;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class BuiltinDHFactoriesTest extends BaseTest {
+public class BuiltinDHFactoriesTest extends BaseTestSupport {
public BuiltinDHFactoriesTest() {
super();
}
@@ -49,7 +48,7 @@ public class BuiltinDHFactoriesTest extends BaseTest {
for (BuiltinDHFactories expected : BuiltinDHFactories.VALUES) {
String name = expected.getName();
BuiltinDHFactories actual = BuiltinDHFactories.fromFactoryName(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -60,11 +59,11 @@ public class BuiltinDHFactoriesTest extends BaseTest {
for (Field f : fields) {
String name=(String) f.get(null);
BuiltinDHFactories value=BuiltinDHFactories.fromFactoryName(name);
- Assert.assertNotNull("No match found for " + name, value);
- Assert.assertTrue(name + " re-specified", avail.add(value));
+ assertNotNull("No match found for " + name, value);
+ assertTrue(name + " re-specified", avail.add(value));
}
- Assert.assertEquals("Incomplete coverage", BuiltinDHFactories.VALUES, avail);
+ assertEquals("Incomplete coverage", BuiltinDHFactories.VALUES, avail);
}
@Test
@@ -108,7 +107,7 @@ public class BuiltinDHFactoriesTest extends BaseTest {
for (DHFactory expected : BuiltinDHFactories.VALUES) {
String name=expected.getName();
DHFactory actual=BuiltinDHFactories.resolveFactory(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -117,7 +116,7 @@ public class BuiltinDHFactoriesTest extends BaseTest {
for (DHFactory expected : BuiltinDHFactories.VALUES) {
try {
BuiltinDHFactories.registerExtension(expected);
- Assert.fail("Unexpected sucess for " + expected.getName());
+ fail("Unexpected sucess for " + expected.getName());
} catch(IllegalArgumentException e) {
// expected - ignored
}
@@ -133,7 +132,7 @@ public class BuiltinDHFactoriesTest extends BaseTest {
try {
for (int index=1; index <= Byte.SIZE; index++) {
BuiltinDHFactories.registerExtension(expected);
- Assert.assertEquals("Unexpected success at attempt #" + index, 1, index);
+ assertEquals("Unexpected success at attempt #" + index, 1, index);
}
} finally {
BuiltinDHFactories.unregisterExtension(name);
@@ -147,15 +146,15 @@ public class BuiltinDHFactoriesTest extends BaseTest {
String name=expected.getName();
try {
- Assert.assertNull("Extension already registered", BuiltinDHFactories.resolveFactory(name));
+ assertNull("Extension already registered", BuiltinDHFactories.resolveFactory(name));
BuiltinDHFactories.registerExtension(expected);
DHFactory actual=BuiltinDHFactories.resolveFactory(name);
- Assert.assertSame("Mismatched resolved instance", expected, actual);
+ assertSame("Mismatched resolved instance", expected, actual);
} finally {
DHFactory actual=BuiltinDHFactories.unregisterExtension(name);
- Assert.assertSame("Mismatched unregistered instance", expected, actual);
- Assert.assertNull("Extension not un-registered", BuiltinDHFactories.resolveFactory(name));
+ assertSame("Mismatched unregistered instance", expected, actual);
+ assertNull("Extension not un-registered", BuiltinDHFactories.resolveFactory(name));
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 a93f73e..6fd7d58 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
@@ -33,15 +33,14 @@ import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.mac.BuiltinMacs.ParseResult;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class BuiltinMacsTest extends BaseTest {
+public class BuiltinMacsTest extends BaseTestSupport {
public BuiltinMacsTest() {
super();
}
@@ -51,7 +50,7 @@ public class BuiltinMacsTest extends BaseTest {
for (BuiltinMacs expected : BuiltinMacs.VALUES) {
String name = expected.getName();
BuiltinMacs actual = BuiltinMacs.fromFactoryName(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -62,11 +61,11 @@ public class BuiltinMacsTest extends BaseTest {
for (Field f : fields) {
String name=(String) f.get(null);
BuiltinMacs value=BuiltinMacs.fromFactoryName(name);
- Assert.assertNotNull("No match found for " + name, value);
- Assert.assertTrue(name + " re-specified", avail.add(value));
+ assertNotNull("No match found for " + name, value);
+ assertTrue(name + " re-specified", avail.add(value));
}
- Assert.assertEquals("Incomplete coverage", BuiltinMacs.VALUES, avail);
+ assertEquals("Incomplete coverage", BuiltinMacs.VALUES, avail);
}
@Test
@@ -110,7 +109,7 @@ public class BuiltinMacsTest extends BaseTest {
for (MacFactory expected : BuiltinMacs.VALUES) {
String name=expected.getName();
MacFactory actual=BuiltinMacs.resolveFactory(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -119,7 +118,7 @@ public class BuiltinMacsTest extends BaseTest {
for (MacFactory expected : BuiltinMacs.VALUES) {
try {
BuiltinMacs.registerExtension(expected);
- Assert.fail("Unexpected sucess for " + expected.getName());
+ fail("Unexpected sucess for " + expected.getName());
} catch(IllegalArgumentException e) {
// expected - ignored
}
@@ -135,7 +134,7 @@ public class BuiltinMacsTest extends BaseTest {
try {
for (int index=1; index <= Byte.SIZE; index++) {
BuiltinMacs.registerExtension(expected);
- Assert.assertEquals("Unexpected success at attempt #" + index, 1, index);
+ assertEquals("Unexpected success at attempt #" + index, 1, index);
}
} finally {
BuiltinMacs.unregisterExtension(name);
@@ -149,27 +148,27 @@ public class BuiltinMacsTest extends BaseTest {
String name=expected.getName();
try {
- Assert.assertNull("Extension already registered", BuiltinMacs.resolveFactory(name));
+ assertNull("Extension already registered", BuiltinMacs.resolveFactory(name));
BuiltinMacs.registerExtension(expected);
MacFactory actual=BuiltinMacs.resolveFactory(name);
- Assert.assertSame("Mismatched resolved instance", expected, actual);
+ assertSame("Mismatched resolved instance", expected, actual);
} finally {
MacFactory actual=BuiltinMacs.unregisterExtension(name);
- Assert.assertSame("Mismatched unregistered instance", expected, actual);
- Assert.assertNull("Extension not un-registered", BuiltinMacs.resolveFactory(name));
+ assertSame("Mismatched unregistered instance", expected, actual);
+ assertNull("Extension not un-registered", BuiltinMacs.resolveFactory(name));
}
}
@Test
public void testFac2NamedTransformer() {
- Assert.assertNull("Invalid null transformation", MacFactory.FAC2NAMED.transform(null));
+ assertNull("Invalid null transformation", MacFactory.FAC2NAMED.transform(null));
for (MacFactory expected : BuiltinMacs.VALUES) {
NamedFactory<Mac> actual=MacFactory.FAC2NAMED.transform(expected);
- Assert.assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
+ assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
}
MacFactory mock=Mockito.mock(MacFactory.class);
- Assert.assertSame("Mismatched transformed mocked instance", mock, MacFactory.FAC2NAMED.transform(mock));
+ assertSame("Mismatched transformed mocked instance", mock, MacFactory.FAC2NAMED.transform(mock));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 155c7c8..5f1d35d 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
@@ -30,15 +30,14 @@ import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.Signature;
import org.apache.sshd.common.signature.BuiltinSignatures.ParseResult;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class BuiltinSignaturesTest extends BaseTest {
+public class BuiltinSignaturesTest extends BaseTestSupport {
public BuiltinSignaturesTest() {
super();
}
@@ -48,7 +47,7 @@ public class BuiltinSignaturesTest extends BaseTest {
for (BuiltinSignatures expected : BuiltinSignatures.VALUES) {
String name = expected.getName();
BuiltinSignatures actual = BuiltinSignatures.fromFactoryName(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -93,7 +92,7 @@ public class BuiltinSignaturesTest extends BaseTest {
for (SignatureFactory expected : BuiltinSignatures.VALUES) {
String name=expected.getName();
SignatureFactory actual=BuiltinSignatures.resolveFactory(name);
- Assert.assertSame(name, expected, actual);
+ assertSame(name, expected, actual);
}
}
@@ -102,7 +101,7 @@ public class BuiltinSignaturesTest extends BaseTest {
for (SignatureFactory expected : BuiltinSignatures.VALUES) {
try {
BuiltinSignatures.registerExtension(expected);
- Assert.fail("Unexpected sucess for " + expected.getName());
+ fail("Unexpected sucess for " + expected.getName());
} catch(IllegalArgumentException e) {
// expected - ignored
}
@@ -118,7 +117,7 @@ public class BuiltinSignaturesTest extends BaseTest {
try {
for (int index=1; index <= Byte.SIZE; index++) {
BuiltinSignatures.registerExtension(expected);
- Assert.assertEquals("Unexpected success at attempt #" + index, 1, index);
+ assertEquals("Unexpected success at attempt #" + index, 1, index);
}
} finally {
BuiltinSignatures.unregisterExtension(name);
@@ -132,27 +131,27 @@ public class BuiltinSignaturesTest extends BaseTest {
String name=expected.getName();
try {
- Assert.assertNull("Extension already registered", BuiltinSignatures.resolveFactory(name));
+ assertNull("Extension already registered", BuiltinSignatures.resolveFactory(name));
BuiltinSignatures.registerExtension(expected);
SignatureFactory actual=BuiltinSignatures.resolveFactory(name);
- Assert.assertSame("Mismatched resolved instance", expected, actual);
+ assertSame("Mismatched resolved instance", expected, actual);
} finally {
SignatureFactory actual=BuiltinSignatures.unregisterExtension(name);
- Assert.assertSame("Mismatched unregistered instance", expected, actual);
- Assert.assertNull("Extension not un-registered", BuiltinSignatures.resolveFactory(name));
+ assertSame("Mismatched unregistered instance", expected, actual);
+ assertNull("Extension not un-registered", BuiltinSignatures.resolveFactory(name));
}
}
@Test
public void testFac2NamedTransformer() {
- Assert.assertNull("Invalid null transformation", SignatureFactory.FAC2NAMED.transform(null));
+ assertNull("Invalid null transformation", SignatureFactory.FAC2NAMED.transform(null));
for (SignatureFactory expected : BuiltinSignatures.VALUES) {
NamedFactory<Signature> actual=SignatureFactory.FAC2NAMED.transform(expected);
- Assert.assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
+ assertSame("Mismatched transformed instance for " + expected.getName(), expected, actual);
}
SignatureFactory mock=Mockito.mock(SignatureFactory.class);
- Assert.assertSame("Mismatched transformed mocked instance", mock, SignatureFactory.FAC2NAMED.transform(mock));
+ assertSame("Mismatched transformed mocked instance", mock, SignatureFactory.FAC2NAMED.transform(mock));
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java
index 481c117..a8dc3c6 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/BufferTest.java
@@ -18,17 +18,15 @@
*/
package org.apache.sshd.common.util;
-import static org.junit.Assert.assertEquals;
-
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.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
-public class BufferTest extends BaseTest {
+public class BufferTest extends BaseTestSupport {
@Test
public void testGetLong() throws Exception {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
index 3bb8994..518cf6b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/CloseableUtilsTest.java
@@ -28,14 +28,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.sshd.common.Closeable;
import org.apache.sshd.common.future.CloseFuture;
import org.apache.sshd.common.future.DefaultCloseFuture;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class CloseableUtilsTest extends BaseTest {
+public class CloseableUtilsTest extends BaseTestSupport {
public CloseableUtilsTest() {
super();
}
@@ -43,15 +42,18 @@ public class CloseableUtilsTest extends BaseTest {
@Test
public void testCloseImmediateNotCalledIfAlreadyClosed() throws IOException {
Closeable closeable=new CloseableUtils.IoBaseCloseable() {
+ @Override
public CloseFuture close(boolean immediately) {
- Assert.fail("Unexpected call to close(" + immediately + ")");
+ fail("Unexpected call to close(" + immediately + ")");
return null;
}
+ @Override
public boolean isClosed() {
return true;
}
+ @Override
public boolean isClosing() {
return false;
}
@@ -62,15 +64,18 @@ public class CloseableUtilsTest extends BaseTest {
@Test
public void testCloseImmediateNotCalledIfIsClosing() throws IOException {
Closeable closeable=new CloseableUtils.IoBaseCloseable() {
+ @Override
public CloseFuture close(boolean immediately) {
- Assert.fail("Unexpected call to close(" + immediately + ")");
+ fail("Unexpected call to close(" + immediately + ")");
return null;
}
+ @Override
public boolean isClosed() {
return false;
}
+ @Override
public boolean isClosing() {
return true;
}
@@ -83,16 +88,19 @@ public class CloseableUtilsTest extends BaseTest {
final DefaultCloseFuture future=new DefaultCloseFuture(this);
final AtomicInteger callsCount=new AtomicInteger(0);
final Closeable closeable=new CloseableUtils.IoBaseCloseable() {
+ @Override
public CloseFuture close(boolean immediately) {
- Assert.assertTrue("Closure is not immediate", immediately);
- Assert.assertEquals("Multiple close immediate calls", 1, callsCount.incrementAndGet());
+ assertTrue("Closure is not immediate", immediately);
+ assertEquals("Multiple close immediate calls", 1, callsCount.incrementAndGet());
return future;
}
+ @Override
public boolean isClosed() {
return false;
}
+ @Override
public boolean isClosing() {
return false;
}
@@ -100,6 +108,7 @@ public class CloseableUtilsTest extends BaseTest {
ExecutorService service=ThreadUtils.newSingleThreadExecutor(getCurrentTestName());
try {
Future<?> task=service.submit(new Runnable() {
+ @Override
public void run() {
try {
closeable.close();
@@ -110,7 +119,7 @@ public class CloseableUtilsTest extends BaseTest {
});
future.setClosed(); // signal close complete
task.get(5L, TimeUnit.SECONDS); // make sure #await call terminated
- Assert.assertEquals("Close immediate not called", 1, callsCount.get());
+ assertEquals("Close immediate not called", 1, callsCount.get());
} finally {
service.shutdownNow();
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 862e2b7..778bcde 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
@@ -23,14 +23,13 @@ import java.util.ArrayList;
import java.util.EventListener;
import java.util.List;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class EventListenerUtilsTest extends BaseTest {
+public class EventListenerUtilsTest extends BaseTestSupport {
public EventListenerUtilsTest() {
super();
}
@@ -51,8 +50,8 @@ public class EventListenerUtilsTest extends BaseTest {
for (int index = 0; index < impls.size(); index++) {
ProxyListenerImpl l = impls.get(index);
- Assert.assertSame("Mismatched string at listener #" + index, expStr, l.getStringValue());
- Assert.assertSame("Mismatched number at listener #" + index, expNum, l.getNumberValue());
+ assertSame("Mismatched string at listener #" + index, expStr, l.getStringValue());
+ assertSame("Mismatched number at listener #" + index, expNum, l.getNumberValue());
}
}
@@ -70,6 +69,7 @@ public class EventListenerUtilsTest extends BaseTest {
return strValue;
}
+ @Override
public void callMeWithString(String s) {
strValue = s;
}
@@ -78,6 +78,7 @@ public class EventListenerUtilsTest extends BaseTest {
return numValue;
}
+ @Override
public void callMeWithNumber(Number n) {
numValue = n;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 3a9b035..1b594f5 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
@@ -23,14 +23,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class GenericUtilsTest extends BaseTest {
+public class GenericUtilsTest extends BaseTestSupport {
public GenericUtilsTest() {
super();
}
@@ -45,12 +44,12 @@ public class GenericUtilsTest extends BaseTest {
String sep=String.valueOf(ch);
String s=GenericUtils.join(expected, sep);
String[] actual=GenericUtils.split(s, ch);
- Assert.assertEquals("Mismatched split length for separator=" + sep, expected.size(), GenericUtils.length((Object[]) actual));
+ 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];
if (!e.endsWith(a)) {
- Assert.fail("Mismatched value at index=" + index + " for separator=" + sep + ": expected=" + e + ", actual=" + a);
+ fail("Mismatched value at index=" + index + " for separator=" + sep + ": expected=" + e + ", actual=" + a);
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/util/SttySupportTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/SttySupportTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/SttySupportTest.java
index 31d4811..18fe689 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/SttySupportTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/SttySupportTest.java
@@ -23,7 +23,7 @@ import java.io.Reader;
import java.util.Map;
import org.apache.sshd.common.PtyMode;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
@@ -31,7 +31,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SttySupportTest extends BaseTest {
+public class SttySupportTest extends BaseTestSupport {
@Test
public void parseOutput1() throws Exception {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/util/ThreadUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/ThreadUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/ThreadUtilsTest.java
index cb05322..7af65d5 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/ThreadUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/ThreadUtilsTest.java
@@ -23,14 +23,13 @@ import java.util.Collection;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ThreadUtilsTest extends BaseTest {
+public class ThreadUtilsTest extends BaseTestSupport {
public ThreadUtilsTest() {
super();
}
@@ -38,25 +37,25 @@ public class ThreadUtilsTest extends BaseTest {
@Test
public void testProtectExecutorServiceShutdown() {
for (boolean shutdownOnExit : new boolean[] { true, false }) {
- Assert.assertNull("Unexpected instance for shutdown=" + shutdownOnExit, ThreadUtils.protectExecutorServiceShutdown(null, shutdownOnExit));
+ assertNull("Unexpected instance for shutdown=" + shutdownOnExit, ThreadUtils.protectExecutorServiceShutdown(null, shutdownOnExit));
}
ExecutorService service=Executors.newSingleThreadExecutor();
try {
- Assert.assertSame("Unexpected wrapped instance", service, ThreadUtils.protectExecutorServiceShutdown(service, true));
+ assertSame("Unexpected wrapped instance", service, ThreadUtils.protectExecutorServiceShutdown(service, true));
ExecutorService wrapped=ThreadUtils.protectExecutorServiceShutdown(service, false);
try {
- Assert.assertNotSame("No wrapping occurred", service, wrapped);
+ assertNotSame("No wrapping occurred", service, wrapped);
wrapped.shutdown();
- Assert.assertTrue("Wrapped service not shutdown", wrapped.isShutdown());
- Assert.assertFalse("Protected service is shutdown", service.isShutdown());
+ assertTrue("Wrapped service not shutdown", wrapped.isShutdown());
+ assertFalse("Protected service is shutdown", service.isShutdown());
Collection<?> running=wrapped.shutdownNow();
- Assert.assertTrue("Non-empty runners list", running.isEmpty());
- Assert.assertTrue("Wrapped service not shutdownNow", wrapped.isShutdown());
- Assert.assertFalse("Protected service is shutdownNow", service.isShutdown());
+ assertTrue("Non-empty runners list", running.isEmpty());
+ assertTrue("Wrapped service not shutdownNow", wrapped.isShutdown());
+ assertFalse("Protected service is shutdownNow", service.isShutdown());
} finally {
wrapped.shutdownNow(); // just in case
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/util/ValidateUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/ValidateUtilsTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/ValidateUtilsTest.java
index 8e8b9a3..af9d7ee 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/ValidateUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/ValidateUtilsTest.java
@@ -19,12 +19,12 @@
package org.apache.sshd.common.util;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ValidateUtilsTest extends BaseTest {
+public class ValidateUtilsTest extends BaseTestSupport {
public ValidateUtilsTest() {
super();
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 f2dfc68..a15a3ab 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
@@ -43,10 +43,12 @@ public class ClientUserAuthServiceOld extends CloseableUtils.AbstractCloseable i
public static class Factory implements ServiceFactory {
+ @Override
public String getName() {
return "ssh-userauth";
}
+ @Override
public Service create(Session session) throws IOException {
return new ClientUserAuthServiceOld(session);
}
@@ -79,10 +81,12 @@ public class ClientUserAuthServiceOld extends CloseableUtils.AbstractCloseable i
authFuture = new DefaultAuthFuture(lock);
}
+ @Override
public ClientSessionImpl getSession() {
return session;
}
+ @Override
public void start() {
synchronized (lock) {
log.debug("accepted");
@@ -91,6 +95,7 @@ public class ClientUserAuthServiceOld extends CloseableUtils.AbstractCloseable i
}
}
+ @Override
public void process(byte cmd, Buffer buffer) throws Exception {
if (this.authFuture.isSuccess()) {
throw new IllegalStateException("UserAuth message delivered to authenticated client");
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 126b1b3..918db97 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
@@ -18,15 +18,19 @@
*/
package org.apache.sshd.deprecated;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_USERAUTH_FAILURE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_USERAUTH_INFO_REQUEST;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_USERAUTH_INFO_RESPONSE;
+import static org.apache.sshd.common.SshConstants.SSH_MSG_USERAUTH_SUCCESS;
+
import java.io.IOException;
+import java.util.Arrays;
import org.apache.sshd.client.UserInteraction;
import org.apache.sshd.client.session.ClientSessionImpl;
import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.util.buffer.Buffer;
-import static org.apache.sshd.common.SshConstants.*;
-
/**
* Userauth with keyboard-interactive method.
*
@@ -42,6 +46,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
this.password = password;
}
+ @Override
public Result next(Buffer buffer) throws IOException {
if (buffer == null) {
log.debug("Send SSH_MSG_USERAUTH_REQUEST for password");
@@ -69,7 +74,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
prompt[i] = buffer.getString();
echo[i] = (buffer.getByte() != 0);
}
- log.debug("Promt: {}", prompt);
+ log.debug("Promt: {}", Arrays.toString(prompt));
log.debug("Echo: {}", echo);
String[] rep = null;
@@ -102,7 +107,7 @@ public class UserAuthKeyboardInteractive extends AbstractUserAuth {
log.debug("Received SSH_MSG_USERAUTH_FAILURE");
return Result.Failure;
default:
- log.debug("Received unknown packet {}", cmd);
+ log.debug("Received unknown packet {}", Byte.valueOf(cmd));
return Result.Continued;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 43aec24..60ac764 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
@@ -42,6 +42,7 @@ public class UserAuthPassword extends AbstractUserAuth {
this.password = password;
}
+ @Override
public Result next(Buffer buffer) throws IOException {
if (buffer == null) {
log.debug("Send SSH_MSG_USERAUTH_REQUEST for password");
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 15bb12c..447413e 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
@@ -18,9 +18,6 @@
*/
package org.apache.sshd.server.channel;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.Collection;
@@ -29,11 +26,11 @@ import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.server.Signal;
import org.apache.sshd.server.SignalListener;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusChannel;
import org.junit.Test;
-public class ChannelSessionTest extends BaseTest {
+public class ChannelSessionTest extends BaseTestSupport {
private boolean expanded = false;
@@ -45,16 +42,18 @@ public class ChannelSessionTest extends BaseTest {
final Buffer buffer = new ByteArrayBuffer();
buffer.putInt(1234);
- final ChannelSession channelSession = new ChannelSession();
- channelSession.asyncOut = new ChannelAsyncOutputStream(new BogusChannel(), (byte) 0) {
- @Override
- public void onWindowExpanded() throws IOException {
- expanded = true;
- super.onWindowExpanded();
- }
- };
- channelSession.handleWindowAdjust(buffer);
- assertTrue(expanded);
+ try(ChannelSession channelSession = new ChannelSession()) {
+ channelSession.asyncOut = new ChannelAsyncOutputStream(new BogusChannel(), (byte) 0) {
+ @SuppressWarnings("synthetic-access")
+ @Override
+ public void onWindowExpanded() throws IOException {
+ expanded = true;
+ super.onWindowExpanded();
+ }
+ };
+ channelSession.handleWindowAdjust(buffer);
+ assertTrue(expanded);
+ }
}
@Test
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 5c497c5..0bba1d4 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
@@ -23,15 +23,14 @@ import java.util.concurrent.ExecutorService;
import org.apache.sshd.common.scp.ScpHelper;
import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ScpCommandFactoryTest extends BaseTest {
+public class ScpCommandFactoryTest extends BaseTestSupport {
public ScpCommandFactoryTest() {
super();
}
@@ -43,11 +42,11 @@ public class ScpCommandFactoryTest extends BaseTest {
@Test
public void testBuilderDefaultFactoryValues() {
ScpCommandFactory factory = new ScpCommandFactory.Builder().build();
- Assert.assertNull("Mismatched delegate", factory.getDelegateCommandFactory());
- Assert.assertNull("Mismatched executor", factory.getExecutorService());
- Assert.assertEquals("Mismatched send size", ScpHelper.MIN_SEND_BUFFER_SIZE, factory.getSendBufferSize());
- Assert.assertEquals("Mismatched receive size", ScpHelper.MIN_RECEIVE_BUFFER_SIZE, factory.getReceiveBufferSize());
- Assert.assertFalse("Mismatched shutdown state", factory.isShutdownOnExit());
+ assertNull("Mismatched delegate", factory.getDelegateCommandFactory());
+ assertNull("Mismatched executor", factory.getExecutorService());
+ assertEquals("Mismatched send size", ScpHelper.MIN_SEND_BUFFER_SIZE, factory.getSendBufferSize());
+ assertEquals("Mismatched receive size", ScpHelper.MIN_RECEIVE_BUFFER_SIZE, factory.getReceiveBufferSize());
+ assertFalse("Mismatched shutdown state", factory.isShutdownOnExit());
}
/**
@@ -65,11 +64,11 @@ public class ScpCommandFactoryTest extends BaseTest {
.withReceiveBufferSize(receiveSize)
.withShutdownOnExit(true)
.build();
- Assert.assertSame("Mismatched delegate", delegate, factory.getDelegateCommandFactory());
- Assert.assertSame("Mismatched executor", service, factory.getExecutorService());
- Assert.assertEquals("Mismatched send size", sendSize, factory.getSendBufferSize());
- Assert.assertEquals("Mismatched receive size", receiveSize, factory.getReceiveBufferSize());
- Assert.assertTrue("Mismatched shutdown state", factory.isShutdownOnExit());
+ assertSame("Mismatched delegate", delegate, factory.getDelegateCommandFactory());
+ assertSame("Mismatched executor", service, factory.getExecutorService());
+ assertEquals("Mismatched send size", sendSize, factory.getSendBufferSize());
+ assertEquals("Mismatched receive size", receiveSize, factory.getReceiveBufferSize());
+ assertTrue("Mismatched shutdown state", factory.isShutdownOnExit());
}
/**
@@ -90,11 +89,11 @@ public class ScpCommandFactoryTest extends BaseTest {
ScpCommandFactory.Builder builder = new ScpCommandFactory.Builder();
ScpCommandFactory f1 = builder.withDelegate(dummyFactory()).build();
ScpCommandFactory f2 = builder.build();
- Assert.assertNotSame("No new instance built", f1, f2);
- Assert.assertSame("Mismatched delegate", f1.getDelegateCommandFactory(), f2.getDelegateCommandFactory());
+ assertNotSame("No new instance built", f1, f2);
+ assertSame("Mismatched delegate", f1.getDelegateCommandFactory(), f2.getDelegateCommandFactory());
ScpCommandFactory f3=builder.withDelegate(dummyFactory()).build();
- Assert.assertNotSame("Delegate not changed", f1.getDelegateCommandFactory(), f3.getDelegateCommandFactory());
+ assertNotSame("Delegate not changed", f1.getDelegateCommandFactory(), f3.getDelegateCommandFactory());
}
private static ExecutorService dummyExecutor() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 69691d4..e700b52 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
@@ -33,26 +33,22 @@ import javax.security.auth.login.Configuration;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
/**
* TODO Add javadoc
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class JaasPasswordAuthenticatorTest extends BaseTest {
+public class JaasPasswordAuthenticatorTest extends BaseTestSupport {
@Before
public void setUp() {
Configuration config = new Configuration() {
+ @Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] {
new AppConfigurationEntry(DummyLoginModule.class.getName(),
@@ -60,7 +56,9 @@ public class JaasPasswordAuthenticatorTest extends BaseTest {
new HashMap<String,Object>())
};
}
+ @Override
public void refresh() {
+ // ignored
}
};
Configuration.setConfiguration(config);
@@ -90,11 +88,13 @@ public class JaasPasswordAuthenticatorTest extends BaseTest {
public DummyLoginModule() {
}
+ @Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
this.subject = subject;
this.callbackHandler = callbackHandler;
}
+ @Override
public boolean login() throws LoginException {
Callback[] callbacks = new Callback[2];
callbacks[0] = new NameCallback("Username: ");
@@ -111,14 +111,17 @@ public class JaasPasswordAuthenticatorTest extends BaseTest {
return user.equals(new String(tmpPassword));
}
+ @Override
public boolean commit() throws LoginException {
return true;
}
+ @Override
public boolean abort() throws LoginException {
return true;
}
+ @Override
public boolean logout() throws LoginException {
return true;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 73cd8c4..84427c7 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
@@ -18,20 +18,18 @@
*/
package org.apache.sshd.server.keyprovider;
-import static org.junit.Assert.assertEquals;
-
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.KeyPair;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-public class AbstractGeneratorHostKeyProviderTest extends BaseTest {
+public class AbstractGeneratorHostKeyProviderTest extends BaseTestSupport {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 33a0c82..39fb3e7 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
@@ -18,9 +18,6 @@
*/
package org.apache.sshd.server.keyprovider;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.security.KeyPair;
import java.security.PublicKey;
@@ -30,7 +27,7 @@ import java.security.spec.ECGenParameterSpec;
import org.apache.sshd.common.KeyPairProvider;
import org.apache.sshd.common.util.SecurityUtils;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Assume;
import org.junit.Test;
@@ -39,7 +36,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class PEMGeneratorHostKeyProviderTest extends BaseTest {
+public class PEMGeneratorHostKeyProviderTest extends BaseTestSupport {
@Test
public void testDSA() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 67bc71a..8c8d352 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
@@ -18,9 +18,6 @@
*/
package org.apache.sshd.server.keyprovider;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.security.KeyPair;
import java.security.spec.AlgorithmParameterSpec;
@@ -28,7 +25,7 @@ import java.security.spec.ECGenParameterSpec;
import org.apache.sshd.common.KeyPairProvider;
import org.apache.sshd.common.util.SecurityUtils;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Assume;
import org.junit.Test;
@@ -37,7 +34,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SimpleGeneratorHostKeyProviderTest extends BaseTest {
+public class SimpleGeneratorHostKeyProviderTest extends BaseTestSupport {
@Test
public void testDSA() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/server/sftp/SftpSubsystemFactoryTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/sftp/SftpSubsystemFactoryTest.java b/sshd-core/src/test/java/org/apache/sshd/server/sftp/SftpSubsystemFactoryTest.java
index dcd9fcb..157b3fa 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/sftp/SftpSubsystemFactoryTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/sftp/SftpSubsystemFactoryTest.java
@@ -21,15 +21,14 @@ package org.apache.sshd.server.sftp;
import java.util.concurrent.ExecutorService;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SftpSubsystemFactoryTest extends BaseTest {
+public class SftpSubsystemFactoryTest extends BaseTestSupport {
public SftpSubsystemFactoryTest() {
super();
}
@@ -41,9 +40,9 @@ public class SftpSubsystemFactoryTest extends BaseTest {
@Test
public void testBuilderDefaultFactoryValues() {
SftpSubsystemFactory factory = new SftpSubsystemFactory.Builder().build();
- Assert.assertNull("Mismatched executor", factory.getExecutorService());
- Assert.assertFalse("Mismatched shutdown state", factory.isShutdownOnExit());
- Assert.assertSame("Mismatched unsupported attribute policy", SftpSubsystemFactory.DEFAULT_POLICY, factory.getUnsupportedAttributePolicy());
+ assertNull("Mismatched executor", factory.getExecutorService());
+ assertFalse("Mismatched shutdown state", factory.isShutdownOnExit());
+ assertSame("Mismatched unsupported attribute policy", SftpSubsystemFactory.DEFAULT_POLICY, factory.getUnsupportedAttributePolicy());
}
/**
@@ -56,12 +55,12 @@ public class SftpSubsystemFactoryTest extends BaseTest {
SftpSubsystemFactory factory = builder.withExecutorService(service)
.withShutdownOnExit(true)
.build();
- Assert.assertSame("Mismatched executor", service, factory.getExecutorService());
- Assert.assertTrue("Mismatched shutdown state", factory.isShutdownOnExit());
+ assertSame("Mismatched executor", service, factory.getExecutorService());
+ assertTrue("Mismatched shutdown state", factory.isShutdownOnExit());
for (UnsupportedAttributePolicy policy : UnsupportedAttributePolicy.VALUES) {
SftpSubsystemFactory actual = builder.withUnsupportedAttributePolicy(policy).build();
- Assert.assertSame("Mismatched unsupported attribute policy", policy, actual.getUnsupportedAttributePolicy());
+ assertSame("Mismatched unsupported attribute policy", policy, actual.getUnsupportedAttributePolicy());
}
}
@@ -83,11 +82,11 @@ public class SftpSubsystemFactoryTest extends BaseTest {
SftpSubsystemFactory.Builder builder = new SftpSubsystemFactory.Builder();
SftpSubsystemFactory f1 = builder.withExecutorService(dummyExecutor()).build();
SftpSubsystemFactory f2 = builder.build();
- Assert.assertNotSame("No new instance built", f1, f2);
- Assert.assertSame("Mismatched executors", f1.getExecutorService(), f2.getExecutorService());
+ assertNotSame("No new instance built", f1, f2);
+ assertSame("Mismatched executors", f1.getExecutorService(), f2.getExecutorService());
SftpSubsystemFactory f3 = builder.withExecutorService(dummyExecutor()).build();
- Assert.assertNotSame("Executor service not changed", f1.getExecutorService(), f3.getExecutorService());
+ assertNotSame("Executor service not changed", f1.getExecutorService(), f3.getExecutorService());
}
private static ExecutorService dummyExecutor() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 b153ff1..40922cc 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
@@ -21,15 +21,13 @@ package org.apache.sshd.server.shell;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusEnvironment;
import org.apache.sshd.util.BogusExitCallback;
import org.apache.sshd.util.BogusInvertedShell;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
-
-public class InvertedShellWrapperTest extends BaseTest {
+public class InvertedShellWrapperTest extends BaseTestSupport {
@Test
public void testStreamsAreFlushedBeforeClosing() throws Exception {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/util/AsyncEchoShellFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/AsyncEchoShellFactory.java b/sshd-core/src/test/java/org/apache/sshd/util/AsyncEchoShellFactory.java
index dc86ab9..f1bbe1d 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/AsyncEchoShellFactory.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/AsyncEchoShellFactory.java
@@ -73,18 +73,22 @@ public class AsyncEchoShellFactory implements Factory<Command> {
@Override
public void setInputStream(InputStream in) {
+ // ignored
}
@Override
public void setOutputStream(OutputStream out) {
+ // ignored
}
@Override
public void setErrorStream(OutputStream err) {
+ // ignored
}
@Override
public void setIoInputStream(IoInputStream in) {
+ // ignored
}
@Override
@@ -116,6 +120,7 @@ public class AsyncEchoShellFactory implements Factory<Command> {
@Override
public void close() throws IOException {
out.close(false).addListener(new SshFutureListener<CloseFuture>() {
+ @SuppressWarnings("synthetic-access")
@Override
public void operationComplete(CloseFuture future) {
callback.onExit(0);
@@ -125,6 +130,7 @@ public class AsyncEchoShellFactory implements Factory<Command> {
@Override
public void destroy() {
+ // ignored
}
@Override
[3/3] mina-sshd git commit: [SSHD-464] Make BaseTest extend
org.junit.Assert instead of TestWatcher
Posted by lg...@apache.org.
[SSHD-464] Make BaseTest extend org.junit.Assert instead of TestWatcher
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/bd1d975a
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/bd1d975a
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/bd1d975a
Branch: refs/heads/master
Commit: bd1d975ad3b6fd35113855a30e2d54dbdf7e29d2
Parents: 3689f72
Author: Lyor Goldstein <lg...@vmware.com>
Authored: Mon May 18 13:37:49 2015 +0300
Committer: Lyor Goldstein <lg...@vmware.com>
Committed: Mon May 18 13:37:49 2015 +0300
----------------------------------------------------------------------
.../sshd/common/channel/AbstractChannel.java | 4 +-
.../org/apache/sshd/AbstractSessionTest.java | 18 +-
.../test/java/org/apache/sshd/AgentTest.java | 6 +-
.../org/apache/sshd/AuthenticationTest.java | 13 +-
.../test/java/org/apache/sshd/CipherTest.java | 8 +-
.../test/java/org/apache/sshd/ClientTest.java | 10 +-
.../test/java/org/apache/sshd/EcdsaTest.java | 4 +-
.../java/org/apache/sshd/KeepAliveTest.java | 187 +++++++------
.../java/org/apache/sshd/KeyReExchangeTest.java | 208 ++++++++-------
.../src/test/java/org/apache/sshd/LoadTest.java | 6 +-
.../src/test/java/org/apache/sshd/MacTest.java | 29 +-
.../org/apache/sshd/PortForwardingLoadTest.java | 16 +-
.../org/apache/sshd/PortForwardingTest.java | 13 +-
.../test/java/org/apache/sshd/ProxyTest.java | 7 +-
.../test/java/org/apache/sshd/RandomTest.java | 4 +-
.../src/test/java/org/apache/sshd/ScpTest.java | 9 +-
.../test/java/org/apache/sshd/ServerTest.java | 16 +-
.../org/apache/sshd/SftpFileSystemTest.java | 11 +-
.../src/test/java/org/apache/sshd/SftpTest.java | 13 +-
.../apache/sshd/SinglePublicKeyAuthTest.java | 14 +-
.../java/org/apache/sshd/SpringConfigTest.java | 4 +-
.../java/org/apache/sshd/SshBuilderTest.java | 19 +-
.../java/org/apache/sshd/SshServerTest.java | 64 ++---
.../java/org/apache/sshd/WelcomeBannerTest.java | 11 +-
.../java/org/apache/sshd/WindowAdjustTest.java | 49 +++-
.../test/java/org/apache/sshd/WindowTest.java | 7 +-
.../org/apache/sshd/client/kex/KexTest.java | 7 +-
.../channel/ChannelPipedInputStreamTest.java | 34 ++-
.../sshd/common/cipher/BaseCipherTest.java | 7 +-
.../sshd/common/cipher/BuiltinCiphersTest.java | 39 ++-
.../compression/BuiltinCompressionsTest.java | 33 ++-
.../common/compression/CompressionTest.java | 6 +-
.../common/config/SshConfigFileReaderTest.java | 41 ++-
.../sshd/common/config/TimeValueConfigTest.java | 7 +-
.../sshd/common/file/util/BasePathTest.java | 14 +-
.../apache/sshd/common/future/FutureTest.java | 6 +-
.../sshd/common/kex/BuiltinDHFactoriesTest.java | 27 +-
.../apache/sshd/common/mac/BuiltinMacsTest.java | 33 ++-
.../common/signature/BuiltinSignaturesTest.java | 27 +-
.../org/apache/sshd/common/util/BufferTest.java | 6 +-
.../sshd/common/util/CloseableUtilsTest.java | 25 +-
.../common/util/EventListenerUtilsTest.java | 11 +-
.../sshd/common/util/GenericUtilsTest.java | 9 +-
.../sshd/common/util/SttySupportTest.java | 4 +-
.../sshd/common/util/ThreadUtilsTest.java | 21 +-
.../sshd/common/util/ValidateUtilsTest.java | 4 +-
.../deprecated/ClientUserAuthServiceOld.java | 5 +
.../deprecated/UserAuthKeyboardInteractive.java | 13 +-
.../sshd/deprecated/UserAuthPassword.java | 1 +
.../sshd/server/channel/ChannelSessionTest.java | 29 +-
.../server/command/ScpCommandFactoryTest.java | 31 ++-
.../jaas/JaasPasswordAuthenticatorTest.java | 17 +-
.../AbstractGeneratorHostKeyProviderTest.java | 6 +-
.../PEMGeneratorHostKeyProviderTest.java | 7 +-
.../SimpleGeneratorHostKeyProviderTest.java | 7 +-
.../server/sftp/SftpSubsystemFactoryTest.java | 23 +-
.../server/shell/InvertedShellWrapperTest.java | 6 +-
.../apache/sshd/util/AsyncEchoShellFactory.java | 6 +
.../java/org/apache/sshd/util/BaseTest.java | 267 -------------------
.../org/apache/sshd/util/BaseTestSupport.java | 264 ++++++++++++++++++
.../java/org/apache/sshd/util/BogusChannel.java | 9 +-
.../org/apache/sshd/util/BogusEnvironment.java | 6 +
.../org/apache/sshd/util/BogusExitCallback.java | 2 +
.../apache/sshd/util/BogusForwardingFilter.java | 4 +
.../apache/sshd/util/BogusInvertedShell.java | 7 +
.../sshd/util/BogusPublickeyAuthenticator.java | 1 +
.../org/apache/sshd/util/EchoShellFactory.java | 8 +
.../java/org/apache/sshd/util/JSchLogger.java | 7 +-
.../org/apache/sshd/util/SimpleUserInfo.java | 8 +
69 files changed, 960 insertions(+), 885 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index 88ff823..51a8a08 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -219,7 +219,9 @@ public abstract class AbstractChannel extends CloseableUtils.AbstractInnerClosea
@Override
protected void doCloseImmediately() {
- service.unregisterChannel(AbstractChannel.this);
+ if (service != null) {
+ service.unregisterChannel(AbstractChannel.this);
+ }
super.doCloseImmediately();
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/AbstractSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/AbstractSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/AbstractSessionTest.java
index 5f9428d..15ff2a3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/AbstractSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/AbstractSessionTest.java
@@ -18,15 +18,12 @@
*/
package org.apache.sshd;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
import java.io.IOException;
import org.apache.sshd.common.session.AbstractSession;
import org.apache.sshd.common.util.buffer.Buffer;
import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Before;
import org.junit.Test;
@@ -35,7 +32,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class AbstractSessionTest extends BaseTest {
+public class AbstractSessionTest extends BaseTestSupport {
private MySession session;
@@ -79,6 +76,7 @@ public class AbstractSessionTest extends BaseTest {
public void testReadIdentBadLineEnding() {
Buffer buf = new ByteArrayBuffer(("SSH-2.0-software\ra").getBytes());
String ident = session.doReadIdentification(buf);
+ fail("Unexpected success: " + ident);
}
@Test(expected = IllegalStateException.class)
@@ -91,6 +89,7 @@ public class AbstractSessionTest extends BaseTest {
"01234567890123456789012345678901234567890123456789" +
"01234567890123456789012345678901234567890123456789").getBytes());
String ident = session.doReadIdentification(buf);
+ fail("Unexpected success: " + ident);
}
@Test(expected = IllegalStateException.class)
@@ -102,14 +101,18 @@ public class AbstractSessionTest extends BaseTest {
sb.append("SSH-2.0-software\r\n");
Buffer buf = new ByteArrayBuffer(sb.toString().getBytes());
String ident = session.doReadIdentification(buf);
+ fail("Unexpected success: " + ident);
}
public static class MySession extends AbstractSession {
public MySession() {
super(true, SshServer.setUpDefaultServer(), null);
}
+ @Override
protected void handleMessage(Buffer buffer) throws Exception {
+ // ignored
}
+ @Override
protected boolean readIdentification(Buffer buffer) {
return false;
}
@@ -118,18 +121,23 @@ public class AbstractSessionTest extends BaseTest {
}
@Override
protected void sendKexInit() throws IOException {
+ // ignored
}
@Override
protected void checkKeys() {
+ // ignored
}
@Override
protected void receiveKexInit(Buffer buffer) throws IOException {
+ // ignored
}
@Override
public void startService(String name) throws Exception {
+ // ignored
}
@Override
public void resetIdleTimeout() {
+ // ignored
}
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/AgentTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/AgentTest.java b/sshd-core/src/test/java/org/apache/sshd/AgentTest.java
index d4549aa..041ac15 100644
--- a/sshd-core/src/test/java/org/apache/sshd/AgentTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/AgentTest.java
@@ -20,8 +20,6 @@ package org.apache.sshd;
import static org.apache.sshd.util.Utils.createTestKeyPairProvider;
import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeThat;
import java.io.ByteArrayOutputStream;
@@ -41,14 +39,14 @@ import org.apache.sshd.common.KeyPairProvider;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.BogusPublickeyAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.Utils;
import org.junit.Test;
-public class AgentTest extends BaseTest {
+public class AgentTest extends BaseTestSupport {
@Test
public void testAgent() throws Exception {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
index 4a86365..5a3752e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/AuthenticationTest.java
@@ -36,7 +36,7 @@ import org.apache.sshd.deprecated.UserAuthPublicKey;
import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.session.SessionFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.BogusPublickeyAuthenticator;
import org.apache.sshd.util.Utils;
@@ -44,11 +44,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class AuthenticationTest extends BaseTest {
+public class AuthenticationTest extends BaseTestSupport {
private static final String WELCOME = "Welcome to SSHD";
@@ -61,8 +57,8 @@ public class AuthenticationTest extends BaseTest {
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
sshd.setPublickeyAuthenticator(new BogusPublickeyAuthenticator());
- sshd.getProperties().put(SshServer.WELCOME_BANNER, WELCOME);
- sshd.getProperties().put(SshServer.AUTH_METHODS, "publickey,password publickey,keyboard-interactive");
+ sshd.getProperties().put(ServerFactoryManager.WELCOME_BANNER, WELCOME);
+ sshd.getProperties().put(ServerFactoryManager.AUTH_METHODS, "publickey,password publickey,keyboard-interactive");
sshd.setSessionFactory(new SessionFactory() {
@Override
protected AbstractSession doCreateSession(IoSession ioSession) throws Exception {
@@ -179,6 +175,7 @@ public class AuthenticationTest extends BaseTest {
public TestSession(ServerFactoryManager server, IoSession ioSession) throws Exception {
super(server, ioSession);
}
+ @Override
public void handleMessage(Buffer buffer) throws Exception {
super.handleMessage(buffer);
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/CipherTest.java b/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
index faa2c1f..eb200a9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/CipherTest.java
@@ -28,7 +28,7 @@ import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.Random;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.random.BouncyCastleRandom;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.JSchLogger;
@@ -37,14 +37,12 @@ import org.apache.sshd.util.Utils;
import org.junit.After;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
/**
* Test Cipher algorithms.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class CipherTest extends BaseTest {
+public class CipherTest extends BaseTestSupport {
private SshServer sshd;
private int port;
@@ -164,7 +162,7 @@ public class CipherTest extends BaseTest {
static boolean checkCipher(String cipher){
try{
- Class c=Class.forName(cipher);
+ 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()],
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
index 5c75dc5..872ae6c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
@@ -18,12 +18,6 @@
*/
package org.apache.sshd;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -86,7 +80,7 @@ import org.apache.sshd.server.session.ServerConnectionService;
import org.apache.sshd.server.session.ServerSession;
import org.apache.sshd.server.session.ServerUserAuthService;
import org.apache.sshd.util.AsyncEchoShellFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.BogusPublickeyAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -101,7 +95,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ClientTest extends BaseTest {
+public class ClientTest extends BaseTestSupport {
private SshServer sshd;
private SshClient client;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/EcdsaTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/EcdsaTest.java b/sshd-core/src/test/java/org/apache/sshd/EcdsaTest.java
index e5d5b1a..9e59b7a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/EcdsaTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/EcdsaTest.java
@@ -35,7 +35,7 @@ import org.apache.sshd.common.signature.BuiltinSignatures;
import org.apache.sshd.common.util.SecurityUtils;
import org.apache.sshd.server.PublickeyAuthenticator;
import org.apache.sshd.server.session.ServerSession;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.Utils;
import org.junit.After;
@@ -48,7 +48,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class EcdsaTest extends BaseTest {
+public class EcdsaTest extends BaseTestSupport {
private SshServer sshd;
private SshClient client;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 0b51c33..6f9c81c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeepAliveTest.java
@@ -20,11 +20,13 @@ package org.apache.sshd;
import java.io.ByteArrayOutputStream;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.apache.sshd.client.ClientFactoryManager;
+import org.apache.sshd.common.FactoryManager;
+import org.apache.sshd.common.FactoryManagerUtils;
import org.apache.sshd.server.Command;
-import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.BogusPublickeyAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -33,14 +35,12 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
/**
* TODO Add javadoc
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class KeepAliveTest extends BaseTest {
+public class KeepAliveTest extends BaseTestSupport {
private SshServer sshd;
private int port;
@@ -52,7 +52,7 @@ public class KeepAliveTest extends BaseTest {
@Before
public void setUp() throws Exception {
sshd = SshServer.setUpDefaultServer();
- sshd.getProperties().put(ServerFactoryManager.IDLE_TIMEOUT, Integer.toString(timeout));
+ sshd.getProperties().put(FactoryManager.IDLE_TIMEOUT, Integer.toString(timeout));
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setShellFactory(new TestEchoShellFactory());
sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
@@ -72,66 +72,82 @@ public class KeepAliveTest extends BaseTest {
public void testClient() throws Exception {
SshClient client = SshClient.setUpDefaultClient();
client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-
- int state = channel.waitFor(ClientChannel.CLOSED, wait);
- assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF, state);
-
- channel.close(false);
- client.stop();
+
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
+ int state = channel.waitFor(ClientChannel.CLOSED, wait);
+ assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF, state);
+
+ channel.close(false);
+ }
+ } finally {
+ client.stop();
+ }
}
@Test
public void testClientNew() throws Exception {
SshClient client = SshClient.setUpDefaultClient();
client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
-
- int state = channel.waitFor(ClientChannel.CLOSED, wait);
- assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF, state);
-
- channel.close(false);
- client.stop();
+
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
+ int state = channel.waitFor(ClientChannel.CLOSED, wait);
+ assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF, state);
+
+ channel.close(false);
+ }
+ } finally {
+ client.stop();
+ }
}
@Test
public void testClientWithHeartBeat() throws Exception {
SshClient client = SshClient.setUpDefaultClient();
- client.getProperties().put(ClientFactoryManager.HEARTBEAT_INTERVAL, Integer.toString(heartbeat));
+ FactoryManagerUtils.updateProperty(client, ClientFactoryManager.HEARTBEAT_INTERVAL, heartbeat);
client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
- int state = channel.waitFor(ClientChannel.CLOSED, wait);
- assertEquals("Wrong channel state", ClientChannel.TIMEOUT, state);
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
- channel.close(false);
- client.stop();
+ try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
+ int state = channel.waitFor(ClientChannel.CLOSED, wait);
+ assertEquals("Wrong channel state", ClientChannel.TIMEOUT, state);
+
+ channel.close(false);
+ }
+ } finally {
+ client.stop();
+ }
}
@Test
public void testClientWithHeartBeatNew() throws Exception {
SshClient client = SshClient.setUpDefaultClient();
- client.getProperties().put(ClientFactoryManager.HEARTBEAT_INTERVAL, Integer.toString(heartbeat));
+ FactoryManagerUtils.updateProperty(client, ClientFactoryManager.HEARTBEAT_INTERVAL, heartbeat);
client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
- int state = channel.waitFor(ClientChannel.CLOSED, wait);
- assertEquals("Wrong channel state", ClientChannel.TIMEOUT, state);
-
- channel.close(false);
- client.stop();
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL)) {
+ int state = channel.waitFor(ClientChannel.CLOSED, wait);
+ assertEquals("Wrong channel state", ClientChannel.TIMEOUT, state);
+
+ channel.close(false);
+ }
+ } finally {
+ client.stop();
+ }
}
@Test
@@ -140,23 +156,28 @@ public class KeepAliveTest extends BaseTest {
SshClient client = SshClient.setUpDefaultClient();
client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ByteArrayOutputStream err = new ByteArrayOutputStream();
- channel.setOut(out);
- channel.setErr(err);
- channel.open().await();
-
-
- TestEchoShellFactory.TestEchoShell.latch.await();
- int state = channel.waitFor(ClientChannel.CLOSED, wait);
- assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF | ClientChannel.OPENED, state);
-
- channel.close(false);
- client.stop();
+
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream()) {
+
+ channel.setOut(out);
+ channel.setErr(err);
+ channel.open().await();
+
+ assertTrue("Latch time out", TestEchoShellFactory.TestEchoShell.latch.await(10L, TimeUnit.SECONDS));
+ int state = channel.waitFor(ClientChannel.CLOSED, wait);
+ assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF | ClientChannel.OPENED, state);
+
+ channel.close(false);
+ }
+ } finally {
+ client.stop();
+ }
}
@Test
@@ -165,31 +186,36 @@ public class KeepAliveTest extends BaseTest {
SshClient client = SshClient.setUpDefaultClient();
client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ByteArrayOutputStream err = new ByteArrayOutputStream();
- channel.setOut(out);
- channel.setErr(err);
- channel.open().await();
-
-
- TestEchoShellFactory.TestEchoShell.latch.await();
- int state = channel.waitFor(ClientChannel.CLOSED, wait);
- assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF | ClientChannel.OPENED, state);
-
- channel.close(false);
- client.stop();
- }
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream()) {
+
+ channel.setOut(out);
+ channel.setErr(err);
+ channel.open().await();
+
+ assertTrue("Latch time out", TestEchoShellFactory.TestEchoShell.latch.await(10L, TimeUnit.SECONDS));
+ int state = channel.waitFor(ClientChannel.CLOSED, wait);
+ assertEquals("Wrong channel state", ClientChannel.CLOSED | ClientChannel.EOF | ClientChannel.OPENED, state);
+
+ channel.close(false);
+ }
+ } finally {
+ client.stop();
+ }
+ }
public static class TestEchoShellFactory extends EchoShellFactory {
@Override
public Command create() {
return new TestEchoShell();
}
+
public static class TestEchoShell extends EchoShell {
public static CountDownLatch latch;
@@ -203,5 +229,4 @@ public class KeepAliveTest extends BaseTest {
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 34e1560..5acf117 100644
--- a/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/KeyReExchangeTest.java
@@ -23,14 +23,16 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import com.jcraft.jsch.JSch;
+
import org.apache.sshd.client.channel.ChannelShell;
import org.apache.sshd.common.Session;
import org.apache.sshd.common.SessionListener;
import org.apache.sshd.server.ServerFactoryManager;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.JSchLogger;
@@ -40,16 +42,12 @@ import org.apache.sshd.util.Utils;
import org.junit.After;
import org.junit.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
/**
* Test key exchange algorithms.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class KeyReExchangeTest extends BaseTest {
+public class KeyReExchangeTest extends BaseTestSupport {
private SshServer sshd;
private int port;
@@ -105,104 +103,124 @@ public class KeyReExchangeTest extends BaseTest {
public void testReExchangeFromNativeClient() throws Exception {
setUp(0, 0);
- SshClient client = SshClient.setUpDefaultClient();
- client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ChannelShell channel = session.createShellChannel();
-
- ByteArrayOutputStream sent = new ByteArrayOutputStream();
- PipedOutputStream pipedIn = new PipedOutputStream();
- channel.setIn(new PipedInputStream(pipedIn));
- OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ByteArrayOutputStream err = new ByteArrayOutputStream();
- channel.setOut(out);
- channel.setErr(err);
- channel.open();
-
- teeOut.write("this is my command\n".getBytes());
- teeOut.flush();
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < 10; i++) {
- sb.append("0123456789");
- }
- sb.append("\n");
-
- for (int i = 0; i < 10; i++) {
- teeOut.write(sb.toString().getBytes());
- teeOut.flush();
- session.reExchangeKeys();
+ try(SshClient client = SshClient.setUpDefaultClient()) {
+ client.start();
+
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ChannelShell channel = session.createShellChannel();
+ ByteArrayOutputStream sent = new ByteArrayOutputStream();
+ PipedOutputStream pipedIn = new PipedOutputStream();
+ InputStream inPipe = new PipedInputStream(pipedIn);
+ OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream()) {
+
+ channel.setIn(inPipe);
+ channel.setOut(out);
+ channel.setErr(err);
+ channel.open();
+
+ teeOut.write("this is my command\n".getBytes());
+ teeOut.flush();
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < 10; i++) {
+ sb.append("0123456789");
+ }
+ sb.append("\n");
+
+ byte[] data=sb.toString().getBytes();
+ for (int i = 0; i < 10; i++) {
+ teeOut.write(data);
+ teeOut.flush();
+ session.reExchangeKeys();
+ }
+ teeOut.write("exit\n".getBytes());
+ teeOut.flush();
+
+ channel.waitFor(ClientChannel.CLOSED, 0);
+
+ channel.close(false);
+
+ assertArrayEquals("Mismatched sent data content", sent.toByteArray(), out.toByteArray());
+ }
+ } finally {
+ client.stop();
+ }
}
- teeOut.write("exit\n".getBytes());
- teeOut.flush();
-
- channel.waitFor(ClientChannel.CLOSED, 0);
-
- channel.close(false);
- client.stop();
-
- assertArrayEquals(sent.toByteArray(), out.toByteArray());
}
@Test
public void testReExchangeFromServer() throws Exception {
setUp(8192, 0);
- SshClient client = SshClient.setUpDefaultClient();
- client.start();
- ClientSession session = client.connect("smx", "localhost", port).await().getSession();
- session.addPasswordIdentity("smx");
- session.auth().verify();
- ChannelShell channel = session.createShellChannel();
-
- ByteArrayOutputStream sent = new ByteArrayOutputStream();
- PipedOutputStream pipedIn = new PipedOutputStream();
- channel.setIn(new PipedInputStream(pipedIn));
- OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ByteArrayOutputStream err = new ByteArrayOutputStream();
- channel.setOut(out);
- channel.setErr(err);
- channel.open();
-
- teeOut.write("this is my command\n".getBytes());
- teeOut.flush();
-
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < 100; i++) {
- sb.append("0123456789");
- }
- sb.append("\n");
-
- final AtomicInteger exchanges = new AtomicInteger();
- session.addListener(new SessionListener() {
- public void sessionCreated(Session session) {
- }
- public void sessionEvent(Session session, Event event) {
- if (event == Event.KeyEstablished) {
- exchanges.incrementAndGet();
+ try(SshClient client = SshClient.setUpDefaultClient()) {
+ client.start();
+
+ try(ClientSession session = client.connect("smx", "localhost", port).await().getSession()) {
+ session.addPasswordIdentity("smx");
+ session.auth().verify(5L, TimeUnit.SECONDS);
+
+ try(ChannelShell channel = session.createShellChannel();
+ ByteArrayOutputStream sent = new ByteArrayOutputStream();
+ PipedOutputStream pipedIn = new PipedOutputStream();
+ OutputStream teeOut = new TeeOutputStream(sent, pipedIn);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream err = new ByteArrayOutputStream();
+ InputStream inPipe = new PipedInputStream(pipedIn)) {
+
+ channel.setIn(inPipe);
+ channel.setOut(out);
+ channel.setErr(err);
+ channel.open();
+
+ teeOut.write("this is my command\n".getBytes());
+ teeOut.flush();
+
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < 100; i++) {
+ sb.append("0123456789");
+ }
+ sb.append("\n");
+
+ final AtomicInteger exchanges = new AtomicInteger();
+ session.addListener(new SessionListener() {
+ @Override
+ public void sessionCreated(Session session) {
+ // ignored
+ }
+ @Override
+ public void sessionEvent(Session session, Event event) {
+ if (event == Event.KeyEstablished) {
+ exchanges.incrementAndGet();
+ }
+ }
+ @Override
+ public void sessionClosed(Session session) {
+ // ignored
+ }
+ });
+ for (int i = 0; i < 100; i++) {
+ teeOut.write(sb.toString().getBytes());
+ teeOut.flush();
+ }
+ teeOut.write("exit\n".getBytes());
+ teeOut.flush();
+
+ channel.waitFor(ClientChannel.CLOSED, 0);
+
+ channel.close(false);
+
+ assertTrue("Expected rekeying", exchanges.get() > 0);
+ assertEquals("Mismatched sent data length", sent.toByteArray().length, out.toByteArray().length);
+ assertArrayEquals("Mismatched sent data content", sent.toByteArray(), out.toByteArray());
}
+ } finally {
+ client.stop();
}
- public void sessionClosed(Session session) {
- }
- });
- for (int i = 0; i < 100; i++) {
- teeOut.write(sb.toString().getBytes());
- teeOut.flush();
}
- teeOut.write("exit\n".getBytes());
- teeOut.flush();
-
- channel.waitFor(ClientChannel.CLOSED, 0);
-
- channel.close(false);
- client.stop();
-
- assertTrue("Expected rekeying", exchanges.get() > 0);
- assertEquals(sent.toByteArray().length, out.toByteArray().length);
- assertArrayEquals(sent.toByteArray(), out.toByteArray());
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 cc156b7..4a4e2ca 100644
--- a/sshd-core/src/test/java/org/apache/sshd/LoadTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/LoadTest.java
@@ -32,7 +32,7 @@ import org.apache.sshd.common.FactoryManagerUtils;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.kex.BuiltinDHFactories;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.Utils;
@@ -40,9 +40,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertArrayEquals;
-
-public class LoadTest extends BaseTest {
+public class LoadTest extends BaseTestSupport {
private SshServer sshd;
private int port;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/MacTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/MacTest.java b/sshd-core/src/test/java/org/apache/sshd/MacTest.java
index c8d97d3..bba527a 100644
--- a/sshd-core/src/test/java/org/apache/sshd/MacTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/MacTest.java
@@ -30,7 +30,7 @@ import org.apache.sshd.common.Random;
import org.apache.sshd.common.cipher.BuiltinCiphers;
import org.apache.sshd.common.mac.BuiltinMacs;
import org.apache.sshd.common.random.BouncyCastleRandom;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.JSchLogger;
@@ -40,14 +40,12 @@ import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
/**
* Test Cipher algorithms.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class MacTest extends BaseTest {
+public class MacTest extends BaseTestSupport {
private SshServer sshd;
private int port;
@@ -147,17 +145,20 @@ public class MacTest extends BaseTest {
s.connect();
com.jcraft.jsch.Channel c = s.openChannel("shell");
c.connect();
- OutputStream os = c.getOutputStream();
- InputStream is = c.getInputStream();
- for (int i = 0; i < 10; i++) {
- os.write("this is my command\n".getBytes());
- os.flush();
+ try(OutputStream os = c.getOutputStream();
+ InputStream is = c.getInputStream()) {
+
byte[] data = new byte[512];
- int len = is.read(data);
- String str = new String(data, 0, len);
- assertEquals("this is my command\n", str);
+ for (int i = 0; i < 10; i++) {
+ os.write("this is my command\n".getBytes());
+ os.flush();
+ int len = is.read(data);
+ String str = new String(data, 0, len);
+ assertEquals("this is my command\n", str);
+ }
+ } finally {
+ c.disconnect();
}
- c.disconnect();
} finally {
s.disconnect();
}
@@ -165,7 +166,7 @@ public class MacTest extends BaseTest {
static boolean checkCipher(String cipher){
try{
- Class c=Class.forName(cipher);
+ 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()],
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java b/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
index af63b0c..e6d6b41 100644
--- a/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/PortForwardingLoadTest.java
@@ -46,7 +46,7 @@ import org.apache.mina.core.service.IoAcceptor;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusForwardingFilter;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -54,19 +54,16 @@ import org.apache.sshd.util.JSchLogger;
import org.apache.sshd.util.SimpleUserInfo;
import org.apache.sshd.util.Utils;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import static org.apache.sshd.util.Utils.getFreePort;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
/**
* Port forwarding tests
*/
-public class PortForwardingLoadTest extends BaseTest {
+public class PortForwardingLoadTest extends BaseTestSupport {
private final org.slf4j.Logger log = LoggerFactory.getLogger(getClass());
@@ -136,6 +133,7 @@ public class PortForwardingLoadTest extends BaseTest {
final AtomicInteger conCount = new AtomicInteger(0);
new Thread() {
+ @Override
public void run() {
try {
for (int i = 0; i < NUM_ITERATIONS; ++i) {
@@ -212,6 +210,7 @@ public class PortForwardingLoadTest extends BaseTest {
final AtomicInteger conCount = new AtomicInteger(0);
new Thread() {
+ @Override
public void run() {
started[0] = true;
try {
@@ -228,7 +227,7 @@ public class PortForwardingLoadTest extends BaseTest {
}
}.start();
Thread.sleep(50);
- Assert.assertTrue("Server not started", started[0]);
+ assertTrue("Server not started", started[0]);
final boolean lenOK[] = new boolean[NUM_ITERATIONS];
final boolean dataOK[] = new boolean[NUM_ITERATIONS];
@@ -261,8 +260,8 @@ public class PortForwardingLoadTest extends BaseTest {
}
Thread.sleep(50);
for (int i = 0; i < NUM_ITERATIONS; i++) {
- Assert.assertTrue(lenOK[i]);
- Assert.assertTrue(dataOK[i]);
+ assertTrue(lenOK[i]);
+ assertTrue(dataOK[i]);
}
session.delPortForwardingR(forwardedPort);
ss.close();
@@ -317,6 +316,7 @@ public class PortForwardingLoadTest extends BaseTest {
final List<Throwable> errors = new CopyOnWriteArrayList<Throwable>();
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread() {
+ @Override
public void run() {
for (int j = 0; j < nbLoops; j++) {
final MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
index 5905340..7f85d08 100644
--- a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
@@ -19,8 +19,6 @@
package org.apache.sshd;
import static org.apache.sshd.util.Utils.getFreePort;
-import static org.junit.Assert.assertEquals;
-
import java.lang.reflect.Field;
import java.net.InetSocketAddress;
import java.net.Socket;
@@ -35,7 +33,7 @@ import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.apache.sshd.client.channel.ChannelDirectTcpip;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.SshdSocketAddress;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusForwardingFilter;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -43,7 +41,6 @@ import org.apache.sshd.util.JSchLogger;
import org.apache.sshd.util.SimpleUserInfo;
import org.apache.sshd.util.Utils;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
@@ -55,7 +52,7 @@ import com.jcraft.jsch.Session;
/**
* Port forwarding tests
*/
-public class PortForwardingTest extends BaseTest {
+public class PortForwardingTest extends BaseTestSupport {
private final org.slf4j.Logger log = LoggerFactory.getLogger(getClass());
@@ -331,10 +328,10 @@ public class PortForwardingTest extends BaseTest {
fSocket.setAccessible(true);
try(Socket socket = (Socket) fSocket.get(session)) {
- Assert.assertTrue("socket is not connected", socket.isConnected());
- Assert.assertFalse("socket should not be closed", socket.isClosed());
+ assertTrue("socket is not connected", socket.isConnected());
+ assertFalse("socket should not be closed", socket.isClosed());
socket.close();
- Assert.assertTrue("socket has not closed", socket.isClosed());
+ assertTrue("socket has not closed", socket.isClosed());
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java b/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
index f597b09..ad073ec 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ProxyTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sshd;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
@@ -33,7 +30,7 @@ import org.apache.mina.core.session.IoSession;
import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.SshdSocketAddress;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusForwardingFilter;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -45,7 +42,7 @@ import org.junit.Test;
/**
* Port forwarding tests
*/
-public class ProxyTest extends BaseTest {
+public class ProxyTest extends BaseTestSupport {
private SshServer sshd;
private int sshPort;
private int echoPort;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/RandomTest.java b/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
index 2d82ef1..77d5190 100644
--- a/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/RandomTest.java
@@ -21,7 +21,7 @@ package org.apache.sshd;
import org.apache.sshd.common.Random;
import org.apache.sshd.common.random.BouncyCastleRandom;
import org.apache.sshd.common.random.JceRandom;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
@@ -29,7 +29,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class RandomTest extends BaseTest {
+public class RandomTest extends BaseTestSupport {
@Test
public void testJce() {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ScpTest.java b/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
index 3efc51d..b059aef 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
@@ -41,7 +41,7 @@ import org.apache.sshd.client.ScpClient;
import org.apache.sshd.common.scp.ScpTransferEventListener;
import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.server.command.ScpCommandFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.JSchLogger;
@@ -55,17 +55,12 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
/**
* Test for SCP support.
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ScpTest extends BaseTest {
+public class ScpTest extends BaseTestSupport {
private SshServer sshd;
private int port;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
index 9190800..6abbccc 100644
--- a/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sshd;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -64,12 +59,11 @@ import org.apache.sshd.server.ExitCallback;
import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.command.ScpCommandFactory;
import org.apache.sshd.server.sftp.SftpSubsystemFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.Utils;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@@ -80,7 +74,7 @@ import org.slf4j.LoggerFactory;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class ServerTest extends BaseTest {
+public class ServerTest extends BaseTestSupport {
private SshServer sshd;
private SshClient client;
@@ -358,8 +352,8 @@ public class ServerTest extends BaseTest {
try(ClientSession s = client.connect("test", "localhost", port).await().getSession()) {
s.addPasswordIdentity("test");
s.auth().verify(5L, TimeUnit.SECONDS);
- Assert.assertEquals("Mismatched client events count", 1, clientEventCount.get());
- Assert.assertEquals("Mismatched server events count", 1, serverEventCount.get());
+ assertEquals("Mismatched client events count", 1, clientEventCount.get());
+ assertEquals("Mismatched server events count", 1, serverEventCount.get());
s.close(false);
}
}
@@ -428,7 +422,7 @@ public class ServerTest extends BaseTest {
}
}
- Assert.fail("No success to authenticate");
+ fail("No success to authenticate");
}
public static class TestEchoShellFactory extends EchoShellFactory {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/SftpFileSystemTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SftpFileSystemTest.java b/sshd-core/src/test/java/org/apache/sshd/SftpFileSystemTest.java
index 1e0dd98..1ad515b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SftpFileSystemTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SftpFileSystemTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sshd;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
import java.net.URI;
@@ -51,16 +47,15 @@ import org.apache.sshd.common.util.OsUtils;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.command.ScpCommandFactory;
import org.apache.sshd.server.sftp.SftpSubsystemFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.Utils;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-public class SftpFileSystemTest extends BaseTest {
+public class SftpFileSystemTest extends BaseTestSupport {
private SshServer sshd;
private int port;
@@ -187,7 +182,7 @@ public class SftpFileSystemTest extends BaseTest {
Files.write(file, "Hello world\n".getBytes());
Map<String, Object> attrs = Files.readAttributes(file, "posix:*");
- Assert.assertNotNull("NO attributes read for " + file, attrs);
+ assertNotNull("NO attributes read for " + file, attrs);
Files.setAttribute(file, "basic:size", Long.valueOf(2l));
Files.setAttribute(file, "posix:permissions", PosixFilePermissions.fromString("rwxr-----"));
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SftpTest.java b/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
index cec1d11..7de6da4 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SftpTest.java
@@ -22,13 +22,6 @@ import static org.apache.sshd.common.sftp.SftpConstants.SSH_FX_FILE_ALREADY_EXIS
import static org.apache.sshd.common.sftp.SftpConstants.SSH_FX_NO_SUCH_FILE;
import static org.apache.sshd.common.sftp.SftpConstants.S_IRUSR;
import static org.apache.sshd.common.sftp.SftpConstants.S_IWUSR;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -47,7 +40,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.command.ScpCommandFactory;
import org.apache.sshd.server.sftp.SftpSubsystemFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.JSchLogger;
@@ -62,7 +55,7 @@ import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.SftpException;
-public class SftpTest extends BaseTest {
+public class SftpTest extends BaseTestSupport {
private SshServer sshd;
private int port;
@@ -435,7 +428,7 @@ public class SftpTest extends BaseTest {
URI base = new File(System.getProperty("user.dir")).getAbsoluteFile().toURI();
String path = new File(base.relativize(url).getPath()).getParent() + "/";
path = path.replace('\\', '/');
- Vector res = c.ls(path);
+ Vector<?> res = c.ls(path);
for (Object f : res) {
System.out.println(f.toString());
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
index 240ba1f..aa288a9 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SinglePublicKeyAuthTest.java
@@ -29,25 +29,23 @@ import org.apache.sshd.common.util.KeyUtils;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.CommandFactory;
import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.ServerFactoryManager;
import org.apache.sshd.server.auth.CachingPublicKeyAuthenticator;
import org.apache.sshd.server.command.UnknownCommand;
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
import org.apache.sshd.server.session.ServerSession;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.Utils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
/**
* TODO Add javadoc
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SinglePublicKeyAuthTest extends BaseTest {
+public class SinglePublicKeyAuthTest extends BaseTestSupport {
private SshServer sshd;
private int port = 0;
@@ -60,12 +58,14 @@ public class SinglePublicKeyAuthTest extends BaseTest {
sshd = SshServer.setUpDefaultServer();
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setCommandFactory(new CommandFactory() {
+ @Override
public Command createCommand(String command) {
return new UnknownCommand(command);
}
});
- sshd.getProperties().put(SshServer.AUTH_METHODS, "publickey");
+ sshd.getProperties().put(ServerFactoryManager.AUTH_METHODS, "publickey");
sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
+ @Override
public boolean authenticate(String username, PublicKey key, ServerSession session) {
return delegate.authenticate(username, key, session);
}
@@ -85,6 +85,7 @@ public class SinglePublicKeyAuthTest extends BaseTest {
public void testPublicKeyAuthWithCache() throws Exception {
final ConcurrentHashMap<String, AtomicInteger> count = new ConcurrentHashMap<String, AtomicInteger>();
TestCachingPublicKeyAuthenticator auth = new TestCachingPublicKeyAuthenticator(new PublickeyAuthenticator() {
+ @Override
public boolean authenticate(String username, PublicKey key,
ServerSession session) {
count.putIfAbsent(KeyUtils.getFingerPrint(key), new AtomicInteger());
@@ -113,6 +114,7 @@ public class SinglePublicKeyAuthTest extends BaseTest {
public void testPublicKeyAuthWithoutCache() throws Exception {
final ConcurrentHashMap<String, AtomicInteger> count = new ConcurrentHashMap<String, AtomicInteger>();
delegate = new PublickeyAuthenticator() {
+ @Override
public boolean authenticate(String username, PublicKey key,
ServerSession session) {
count.putIfAbsent(KeyUtils.getFingerPrint(key), new AtomicInteger());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java b/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
index f5b493b..0c197db 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SpringConfigTest.java
@@ -22,7 +22,7 @@ import java.io.OutputStream;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.JSch;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.JSchLogger;
import org.apache.sshd.util.SimpleUserInfo;
import org.junit.After;
@@ -35,7 +35,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SpringConfigTest extends BaseTest {
+public class SpringConfigTest extends BaseTestSupport {
private ClassPathXmlApplicationContext context;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java b/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
index d7204de..9307def 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SshBuilderTest.java
@@ -33,14 +33,13 @@ import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.mac.BuiltinMacs;
import org.apache.sshd.common.signature.BuiltinSignatures;
import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Test;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class SshBuilderTest extends BaseTest {
+public class SshBuilderTest extends BaseTestSupport {
public SshBuilderTest() {
super();
}
@@ -53,7 +52,7 @@ public class SshBuilderTest extends BaseTest {
public void testAllBuiltinCiphersListed() {
Set<BuiltinCiphers> all=EnumSet.allOf(BuiltinCiphers.class);
// The 'none' cipher is not listed as preferred - it is implied
- Assert.assertTrue("Missing " + BuiltinCiphers.Constants.NONE + " cipher in all values", all.remove(BuiltinCiphers.none));
+ assertTrue("Missing " + BuiltinCiphers.Constants.NONE + " cipher in all values", all.remove(BuiltinCiphers.none));
testAllInstancesListed(all, BaseBuilder.DEFAULT_CIPHERS_PREFERENCE);
}
@@ -85,9 +84,9 @@ public class SshBuilderTest extends BaseTest {
}
private static <E extends Enum<E>> void testAllInstancesListed(Set<? extends E> expValues, Collection<? extends E> actValues) {
- Assert.assertEquals("Mismatched actual values size", expValues.size(), actValues.size());
+ assertEquals("Mismatched actual values size", expValues.size(), actValues.size());
for (E expected : expValues) {
- Assert.assertTrue(expected.name() + " not found in actual values", actValues.contains(expected));
+ assertTrue(expected.name() + " not found in actual values", actValues.contains(expected));
}
}
@@ -103,7 +102,7 @@ public class SshBuilderTest extends BaseTest {
int numCiphers=GenericUtils.size(ciphers);
// make sure returned list size matches expected count
if (ignoreUnsupported) {
- Assert.assertEquals("Incomplete full ciphers size", BaseBuilder.DEFAULT_CIPHERS_PREFERENCE.size(), numCiphers);
+ assertEquals("Incomplete full ciphers size", BaseBuilder.DEFAULT_CIPHERS_PREFERENCE.size(), numCiphers);
} else {
int expectedCount=0;
for (BuiltinCiphers c : BaseBuilder.DEFAULT_CIPHERS_PREFERENCE) {
@@ -111,7 +110,7 @@ public class SshBuilderTest extends BaseTest {
expectedCount++;
}
}
- Assert.assertEquals("Incomplete supported ciphers size", expectedCount, numCiphers);
+ assertEquals("Incomplete supported ciphers size", expectedCount, numCiphers);
}
// make sure order is according to the default preference list
@@ -123,10 +122,10 @@ public class SshBuilderTest extends BaseTest {
}
String expectedName=c.getName();
- Assert.assertTrue("Out of actual ciphers for expected=" + expectedName, nameIndex < numCiphers);
+ assertTrue("Out of actual ciphers for expected=" + expectedName, nameIndex < numCiphers);
String actualName=cipherNames.get(nameIndex);
- Assert.assertEquals("Mismatched cipher at position " + nameIndex + " for ignoreUnsupported=" + ignoreUnsupported, expectedName, actualName);
+ assertEquals("Mismatched cipher at position " + nameIndex + " for ignoreUnsupported=" + ignoreUnsupported, expectedName, actualName);
nameIndex++;
}
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java b/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
index 71a9e43..dbc3614 100644
--- a/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/SshServerTest.java
@@ -21,66 +21,66 @@ package org.apache.sshd;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.Utils;
import org.junit.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-
/**
* @author Kohsuke Kawaguchi
* @author Michael Heemskerk
*/
-public class SshServerTest extends BaseTest {
+public class SshServerTest extends BaseTestSupport {
@Test
public void stopMethodShouldBeIdempotent() throws Exception {
- SshServer sshd = new SshServer();
- sshd.stop();
- sshd.stop();
- sshd.stop();
+ try(SshServer sshd = new SshServer()) {
+ sshd.stop();
+ sshd.stop();
+ sshd.stop();
+ }
}
@Test
public void testExecutorShutdownFalse() throws Exception {
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
- SshServer sshd = createTestServer();
- sshd.setScheduledExecutorService(executorService);
-
- sshd.start();
- sshd.stop();
-
- assertFalse(executorService.isShutdown());
- executorService.shutdownNow();
+ try(SshServer sshd = createTestServer()) {
+ sshd.setScheduledExecutorService(executorService);
+
+ sshd.start();
+ sshd.stop();
+
+ assertFalse(executorService.isShutdown());
+ executorService.shutdownNow();
+ }
}
@Test
public void testExecutorShutdownTrue() throws Exception {
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
- SshServer sshd = createTestServer();
- sshd.setScheduledExecutorService(executorService, true);
-
- sshd.start();
- sshd.stop();
-
- assertTrue(executorService.isShutdown());
+ try(SshServer sshd = createTestServer()) {
+ sshd.setScheduledExecutorService(executorService, true);
+
+ sshd.start();
+ sshd.stop();
+
+ assertTrue(executorService.isShutdown());
+ }
}
@Test
public void testDynamicPort() throws Exception {
- SshServer sshd = createTestServer();
- sshd.setHost("localhost");
- sshd.start();
-
- assertNotEquals(0, sshd.getPort());
-
- sshd.stop();
+ try(SshServer sshd = createTestServer()) {
+ sshd.setHost("localhost");
+ sshd.start();
+
+ assertNotEquals(0, sshd.getPort());
+
+ sshd.stop();
+ }
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java b/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
index 9fae759..eccd879 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WelcomeBannerTest.java
@@ -21,7 +21,8 @@ package org.apache.sshd;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.sshd.client.UserInteraction;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.server.ServerFactoryManager;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.BogusPublickeyAuthenticator;
import org.apache.sshd.util.Utils;
@@ -29,9 +30,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
-
-public class WelcomeBannerTest extends BaseTest {
+public class WelcomeBannerTest extends BaseTestSupport {
private static final String WELCOME = "Welcome to SSHD";
@@ -44,7 +43,7 @@ public class WelcomeBannerTest extends BaseTest {
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setPasswordAuthenticator(new BogusPasswordAuthenticator());
sshd.setPublickeyAuthenticator(new BogusPublickeyAuthenticator());
- sshd.getProperties().put(SshServer.WELCOME_BANNER, WELCOME);
+ sshd.getProperties().put(ServerFactoryManager.WELCOME_BANNER, WELCOME);
sshd.start();
port = sshd.getPort();
}
@@ -61,9 +60,11 @@ public class WelcomeBannerTest extends BaseTest {
final AtomicReference<String> welcome = new AtomicReference<String>();
SshClient client = SshClient.setUpDefaultClient();
client.setUserInteraction(new UserInteraction() {
+ @Override
public void welcome(String banner) {
welcome.set(banner);
}
+ @Override
public String[] interactive(String destination, String name, String instruction, String[] prompt, boolean[] echo) {
return null;
}
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 cf56589..1b33f48 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
@@ -65,6 +65,7 @@ public class WindowAdjustTest {
Paths.get(getClass().getResource("/big-msg.txt").toURI()));
sshServer.setShellFactory(new Factory<Command>() {
+ @Override
public Command create() {
return new FloodingAsyncCommand(msg, 10000, END_FILE);
}
@@ -134,12 +135,18 @@ public class WindowAdjustTest {
this.lastMsg = lastMsg;
}
- public void setIoInputStream(IoInputStream in) {}
+ @Override
+ public void setIoInputStream(IoInputStream in) {
+ // ignored
+ }
+ @Override
public void setIoOutputStream(IoOutputStream out) {
final AsyncInPendingWrapper a = new AsyncInPendingWrapper(out);
new Thread(new Runnable() {
+ @SuppressWarnings("synthetic-access")
+ @Override
public void run() {
for (int i = 0; i < sendCount; i++) {
a.write(new ByteArrayBuffer(msg));
@@ -149,19 +156,40 @@ public class WindowAdjustTest {
}).start();
}
- public void setIoErrorStream(IoOutputStream err) {}
+ @Override
+ public void setIoErrorStream(IoOutputStream err) {
+ // ignored
+ }
- public void setInputStream(InputStream in) {}
+ @Override
+ public void setInputStream(InputStream in) {
+ // ignored
+ }
- public void setOutputStream(OutputStream out) {}
+ @Override
+ public void setOutputStream(OutputStream out) {
+ // ignored
+ }
- public void setErrorStream(OutputStream err) {}
+ @Override
+ public void setErrorStream(OutputStream err) {
+ // ignored
+ }
- public void setExitCallback(ExitCallback callback) {}
+ @Override
+ public void setExitCallback(ExitCallback callback) {
+ // ignored
+ }
- public void start(Environment env) throws IOException {}
+ @Override
+ public void start(Environment env) throws IOException {
+ // ignored
+ }
- public void destroy() {}
+ @Override
+ public void destroy() {
+ // ignored
+ }
}
/**
@@ -172,6 +200,9 @@ public class WindowAdjustTest {
// Order has to be preserved for queued writes
private final Deque<Buffer> pending = new LinkedList<Buffer>() {
+ // we don't expect to serialize it
+ private static final long serialVersionUID = 1L;
+
@Override
public boolean add(Buffer o) {
return super.add(o);
@@ -198,6 +229,8 @@ public class WindowAdjustTest {
private void writeWithPendingDetection(final Buffer msg, final boolean wasPending) {
try {
asyncIn.write(msg).addListener(new SshFutureListener<IoWriteFuture>() {
+ @SuppressWarnings("synthetic-access")
+ @Override
public void operationComplete(final IoWriteFuture future) {
if(wasPending) {
pending.remove();
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/WindowTest.java b/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
index 762caa0..f964208 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WindowTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sshd;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -51,7 +48,7 @@ import org.apache.sshd.server.command.UnknownCommand;
import org.apache.sshd.server.session.ServerConnectionService;
import org.apache.sshd.server.session.ServerUserAuthService;
import org.apache.sshd.util.AsyncEchoShellFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.BogusPublickeyAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
@@ -65,7 +62,7 @@ import org.junit.Test;
*
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class WindowTest extends BaseTest {
+public class WindowTest extends BaseTestSupport {
private SshServer sshd;
private SshClient client;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/client/kex/KexTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/kex/KexTest.java b/sshd-core/src/test/java/org/apache/sshd/client/kex/KexTest.java
index e9ab522..51d6371 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/kex/KexTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/kex/KexTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sshd.client.kex;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
@@ -36,7 +33,7 @@ import org.apache.sshd.common.KeyExchange;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.kex.BuiltinDHFactories;
import org.apache.sshd.common.kex.DHFactory;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusPasswordAuthenticator;
import org.apache.sshd.util.EchoShellFactory;
import org.apache.sshd.util.TeeOutputStream;
@@ -49,7 +46,7 @@ import org.junit.Test;
* Test client key exchange algorithms.
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public class KexTest extends BaseTest {
+public class KexTest extends BaseTestSupport {
private SshServer sshd;
private int port;
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
index d1138a9..a91bcb0 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/channel/ChannelPipedInputStreamTest.java
@@ -20,32 +20,28 @@ package org.apache.sshd.common.channel;
import java.util.Arrays;
-import org.apache.sshd.util.BaseTest;
+import org.apache.sshd.util.BaseTestSupport;
import org.apache.sshd.util.BogusChannel;
import org.junit.Test;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-public class ChannelPipedInputStreamTest extends BaseTest {
+public class ChannelPipedInputStreamTest extends BaseTestSupport {
@Test
public void testAvailable() throws Exception {
Window window = new Window(new BogusChannel(), null, true, true);
- ChannelPipedInputStream stream = new ChannelPipedInputStream(window);
-
- byte[] b = "test".getBytes();
- stream.receive(b, 0, b.length);
- assertEquals(b.length, stream.available());
-
- stream.eof();
- assertEquals(b.length, stream.available());
-
- final byte[] readBytes = new byte[50];
- assertEquals(b.length, stream.read(readBytes));
- assertStreamEquals(b, readBytes);
- assertEquals(-1, stream.available());
+ try(ChannelPipedInputStream stream = new ChannelPipedInputStream(window)) {
+ byte[] b = "test".getBytes();
+ stream.receive(b, 0, b.length);
+ assertEquals(b.length, stream.available());
+
+ stream.eof();
+ assertEquals(b.length, stream.available());
+
+ final byte[] readBytes = new byte[50];
+ assertEquals(b.length, stream.read(readBytes));
+ assertStreamEquals(b, readBytes);
+ assertEquals(-1, stream.available());
+ }
}
private void assertStreamEquals(byte[] expected, byte[] read) {
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/bd1d975a/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 b0814fb..5ca20dd 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
@@ -29,15 +29,14 @@ import org.apache.sshd.common.Cipher;
import org.apache.sshd.common.Cipher.Mode;
import org.apache.sshd.common.NamedFactory;
import org.apache.sshd.common.util.SecurityUtils;
-import org.apache.sshd.util.BaseTest;
-import org.junit.Assert;
+import org.apache.sshd.util.BaseTestSupport;
import org.junit.Assume;
import org.junit.internal.AssumptionViolatedException;
/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public abstract class BaseCipherTest extends BaseTest {
+public abstract class BaseCipherTest extends BaseTestSupport {
protected BaseCipherTest() {
super();
}
@@ -88,6 +87,6 @@ public abstract class BaseCipherTest extends BaseTest {
byte[] actual=workBuf.clone();
dec.update(actual, 0, actual.length);
- Assert.assertArrayEquals(facName, expected, actual);
+ assertArrayEquals(facName, expected, actual);
}
}