[SSHD-822] Added capability to control unit tests running according to current IoServ...
authorLyor Goldstein <lgoldstein@apache.org>
Wed, 13 Feb 2019 07:35:21 +0000 (09:35 +0200)
committerLyor Goldstein <lgoldstein@apache.org>
Wed, 13 Feb 2019 11:40:27 +0000 (13:40 +0200)
15 files changed:
assembly/pom.xml
sshd-cli/pom.xml
sshd-common/pom.xml
sshd-contrib/pom.xml
sshd-core/pom.xml
sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
sshd-git/pom.xml
sshd-ldap/pom.xml
sshd-mina/pom.xml
sshd-openpgp/pom.xml
sshd-putty/pom.xml
sshd-scp/pom.xml
sshd-scp/src/test/java/org/apache/sshd/client/scp/ScpTest.java
sshd-sftp/pom.xml
sshd-spring-sftp/pom.xml

index 8d4bcf4..c6cb79c 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index ae6cdec..7153587 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index b66b878..23ab842 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index 3e96f9e..0df44a4 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index 555f5af..dad48d6 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index 589ab2f..4587ea3 100644 (file)
  */
 package org.apache.sshd.util.test;
 
+import java.util.Collection;
+
 import org.apache.sshd.client.SshClient;
+import org.apache.sshd.common.helpers.AbstractFactoryManager;
+import org.apache.sshd.common.io.BuiltinIoServiceFactoryFactories;
 import org.apache.sshd.common.io.DefaultIoServiceFactoryFactory;
 import org.apache.sshd.common.io.IoServiceFactoryFactory;
+import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.net.SshdSocketAddress;
 import org.apache.sshd.server.SshServer;
+import org.junit.Assume;
 import org.junit.Rule;
 import org.junit.rules.TestWatcher;
 import org.junit.runner.Description;
@@ -74,9 +80,42 @@ public abstract class BaseTestSupport extends JUnitTestSupport {
         return CoreTestSupportUtils.setupTestClient(getClass());
     }
 
+    protected void assumeNotIoServiceProvider(Collection<BuiltinIoServiceFactoryFactories> excluded) {
+        assumeNotIoServiceProvider(getCurrentTestName(), excluded);
+    }
+
     public static IoServiceFactoryFactory getIoServiceProvider() {
         DefaultIoServiceFactoryFactory factory =
             DefaultIoServiceFactoryFactory.getDefaultIoServiceFactoryFactoryInstance();
         return factory.getIoServiceProvider();
     }
+
+    public static void assumeNotIoServiceProvider(
+            String message, Collection<BuiltinIoServiceFactoryFactories> excluded) {
+        if (GenericUtils.isEmpty(excluded)) {
+            return;
+        }
+
+        assumeNotIoServiceProvider(message, getIoServiceProvider(), excluded);
+    }
+
+    public static void assumeNotIoServiceProvider(
+            String message, AbstractFactoryManager manager, Collection<BuiltinIoServiceFactoryFactories> excluded) {
+        assumeNotIoServiceProvider(message, manager.getIoServiceFactoryFactory(), excluded);
+    }
+
+    public static void assumeNotIoServiceProvider(
+            String message, IoServiceFactoryFactory provider, Collection<BuiltinIoServiceFactoryFactories> excluded) {
+        if (GenericUtils.isEmpty(excluded)) {
+            return;
+        }
+
+        Class<?> clazz = provider.getClass();
+        String clazzName = clazz.getName();
+        BuiltinIoServiceFactoryFactories match = excluded.stream()
+            .filter(f -> clazzName.equals(f.getFactoryClassName()))
+            .findFirst()
+            .orElse(null);
+        Assume.assumeTrue(message + " - skip factory=" + match, match == null);
+    }
 }
index 05d64a2..4721629 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index b637bdd..99fdaa6 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
@@ -59,7 +57,7 @@
                     </exclusion>
                 </exclusions>
             </dependency>
-            
+
             <dependency>
                 <groupId>org.apache.directory.shared</groupId>
                 <artifactId>shared-cursor</artifactId>
index 9a2ddc0..1e40fa9 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index 138c9a3..141abf3 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index 5542afe..069ea6a 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
index 4aefd32..179a651 100644 (file)
                                     <systemProperties>
                                         <org.apache.sshd.common.io.IoServiceFactoryFactory>org.apache.sshd.netty.NettyIoServiceFactoryFactory</org.apache.sshd.common.io.IoServiceFactoryFactory>
                                     </systemProperties>
-                                    <excludes>
-                                        <!-- TODO need some more research as to why this fails intermittently on Netty but not on NIO2 or MINA -->
-                                        <exclude>**/ScpTest.java</exclude>
-                                    </excludes>
                                 </configuration>
                             </execution>
                         </executions>
index b6b27a9..8e6cbcb 100644 (file)
@@ -46,6 +46,7 @@ import org.apache.sshd.common.Factory;
 import org.apache.sshd.common.channel.Channel;
 import org.apache.sshd.common.file.FileSystemFactory;
 import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory;
+import org.apache.sshd.common.io.BuiltinIoServiceFactoryFactories;
 import org.apache.sshd.common.random.Random;
 import org.apache.sshd.common.scp.ScpException;
 import org.apache.sshd.common.scp.ScpFileOpener;
@@ -71,7 +72,6 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.FixMethodOrder;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runners.MethodSorters;
 
@@ -101,7 +101,6 @@ public class ScpTest extends BaseTestSupport {
         public void startFileEvent(
                 Session s, FileOperation op, Path file, long length, Set<PosixFilePermission> perms) {
             logEvent("startFileEvent", s, op, file, true, length, perms, null);
-
         }
 
         @Override
@@ -384,8 +383,10 @@ public class ScpTest extends BaseTestSupport {
     }
 
     @Test
-    @Ignore("TODO investigate why this fails often")
     public void testScpNativeOnSingleFile() throws Exception {
+        // see SSHD-822
+        assumeNotIoServiceProvider(EnumSet.of(BuiltinIoServiceFactoryFactories.NETTY));
+
         String data = getClass().getName() + "#" + getCurrentTestName() + IoUtils.EOL;
 
         Path targetPath = detectTargetFolder();
@@ -441,6 +442,9 @@ public class ScpTest extends BaseTestSupport {
 
     @Test
     public void testScpNativeOnMultipleFiles() throws Exception {
+        // see SSHD-822
+        assumeNotIoServiceProvider(EnumSet.of(BuiltinIoServiceFactoryFactories.MINA, BuiltinIoServiceFactoryFactories.NETTY));
+
         try (ClientSession session = client.connect(getCurrentTestName(), TEST_LOCALHOST, port)
                     .verify(CONNECT_TIMEOUT, TimeUnit.SECONDS)
                     .getSession()) {
index 8632f97..4abbcb8 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more
                                                        <org.apache.sshd.common.io.IoServiceFactoryFactory>org.apache.sshd.netty.NettyIoServiceFactoryFactory</org.apache.sshd.common.io.IoServiceFactoryFactory>
                                                    </systemProperties>
                                                    <excludes>
-                                                           <!-- TODO need some more research as to why this fails frequently on Netty -->
+                                                           <!-- TODO (SSHD-822) need some more research as to why this fails frequently on Netty -->
                                                        <exclude>**/AbstractCheckFileExtensionTest.java</exclude>
-                                        <exclude>**/SftpVersionsTest.java</exclude>
                                                    </excludes>
                                 </configuration>
                             </execution>
index 413d9aa..f51582e 100644 (file)
@@ -1,6 +1,4 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-
     <!--
 
         Licensed to the Apache Software Foundation (ASF) under one or more