This is an automated email from the ASF dual-hosted git repository.

lgoldstein pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mina-sshd.git

commit 27c3af2f0cad69cc91cea18d3b7d59340313bb27
Author: Lyor Goldstein <[email protected]>
AuthorDate: Wed Feb 13 09:35:21 2019 +0200

    [SSHD-822] Added capability to control unit tests running according to 
current IoServiceFactory provider type (NIO2, MINA, NETTY)
---
 assembly/pom.xml                                   |  2 --
 sshd-cli/pom.xml                                   |  2 --
 sshd-common/pom.xml                                |  2 --
 sshd-contrib/pom.xml                               |  2 --
 sshd-core/pom.xml                                  |  2 --
 .../org/apache/sshd/util/test/BaseTestSupport.java | 39 ++++++++++++++++++++++
 sshd-git/pom.xml                                   |  2 --
 sshd-ldap/pom.xml                                  |  4 +--
 sshd-mina/pom.xml                                  |  2 --
 sshd-openpgp/pom.xml                               |  2 --
 sshd-putty/pom.xml                                 |  2 --
 sshd-scp/pom.xml                                   |  4 ---
 .../java/org/apache/sshd/client/scp/ScpTest.java   | 10 ++++--
 sshd-sftp/pom.xml                                  |  5 +--
 sshd-spring-sftp/pom.xml                           |  2 --
 15 files changed, 48 insertions(+), 34 deletions(-)

diff --git a/assembly/pom.xml b/assembly/pom.xml
index 8d4bcf4..c6cb79c 100644
--- a/assembly/pom.xml
+++ b/assembly/pom.xml
@@ -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
diff --git a/sshd-cli/pom.xml b/sshd-cli/pom.xml
index ae6cdec..7153587 100644
--- a/sshd-cli/pom.xml
+++ b/sshd-cli/pom.xml
@@ -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
diff --git a/sshd-common/pom.xml b/sshd-common/pom.xml
index b66b878..23ab842 100644
--- a/sshd-common/pom.xml
+++ b/sshd-common/pom.xml
@@ -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
diff --git a/sshd-contrib/pom.xml b/sshd-contrib/pom.xml
index 3e96f9e..0df44a4 100644
--- a/sshd-contrib/pom.xml
+++ b/sshd-contrib/pom.xml
@@ -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
diff --git a/sshd-core/pom.xml b/sshd-core/pom.xml
index 555f5af..dad48d6 100644
--- a/sshd-core/pom.xml
+++ b/sshd-core/pom.xml
@@ -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
diff --git 
a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java 
b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
index 589ab2f..4587ea3 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
@@ -18,11 +18,17 @@
  */
 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);
+    }
 }
diff --git a/sshd-git/pom.xml b/sshd-git/pom.xml
index 05d64a2..4721629 100644
--- a/sshd-git/pom.xml
+++ b/sshd-git/pom.xml
@@ -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
diff --git a/sshd-ldap/pom.xml b/sshd-ldap/pom.xml
index b637bdd..99fdaa6 100644
--- a/sshd-ldap/pom.xml
+++ b/sshd-ldap/pom.xml
@@ -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>
diff --git a/sshd-mina/pom.xml b/sshd-mina/pom.xml
index 9a2ddc0..1e40fa9 100644
--- a/sshd-mina/pom.xml
+++ b/sshd-mina/pom.xml
@@ -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
diff --git a/sshd-openpgp/pom.xml b/sshd-openpgp/pom.xml
index 138c9a3..141abf3 100644
--- a/sshd-openpgp/pom.xml
+++ b/sshd-openpgp/pom.xml
@@ -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
diff --git a/sshd-putty/pom.xml b/sshd-putty/pom.xml
index 5542afe..069ea6a 100644
--- a/sshd-putty/pom.xml
+++ b/sshd-putty/pom.xml
@@ -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
diff --git a/sshd-scp/pom.xml b/sshd-scp/pom.xml
index 4aefd32..179a651 100644
--- a/sshd-scp/pom.xml
+++ b/sshd-scp/pom.xml
@@ -201,10 +201,6 @@
                                     <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>
diff --git a/sshd-scp/src/test/java/org/apache/sshd/client/scp/ScpTest.java 
b/sshd-scp/src/test/java/org/apache/sshd/client/scp/ScpTest.java
index b6b27a9..8e6cbcb 100644
--- a/sshd-scp/src/test/java/org/apache/sshd/client/scp/ScpTest.java
+++ b/sshd-scp/src/test/java/org/apache/sshd/client/scp/ScpTest.java
@@ -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()) {
diff --git a/sshd-sftp/pom.xml b/sshd-sftp/pom.xml
index 8632f97..4abbcb8 100644
--- a/sshd-sftp/pom.xml
+++ b/sshd-sftp/pom.xml
@@ -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
@@ -199,9 +197,8 @@
                                                        
<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>
diff --git a/sshd-spring-sftp/pom.xml b/sshd-spring-sftp/pom.xml
index 413d9aa..f51582e 100644
--- a/sshd-spring-sftp/pom.xml
+++ b/sshd-spring-sftp/pom.xml
@@ -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

Reply via email to