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

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


The following commit(s) were added to refs/heads/master by this push:
     new fb64ae5  [SSHD-1041] Avoid overlapping test source (#149)
fb64ae5 is described below

commit fb64ae592a454d7b065a433f318c89b3e9a6c608
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Mon Jul 27 17:59:49 2020 +0200

    [SSHD-1041] Avoid overlapping test source (#149)
---
 .../sshd/util/test/CommonTestSupportUtils.java     |  7 +++-
 .../apache/sshd/util/test/JUnitTestSupport.java    | 12 ++----
 sshd-core/pom.xml                                  | 24 ++++++++++-
 .../java/org/apache/sshd/WindowAdjustTest.java     |  6 +--
 sshd-mina/pom.xml                                  | 48 ++++++----------------
 sshd-netty/pom.xml                                 | 38 ++---------------
 6 files changed, 50 insertions(+), 85 deletions(-)

diff --git 
a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
 
b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
index d39e76c..6f352af 100644
--- 
a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
+++ 
b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
@@ -314,7 +314,12 @@ public final class CommonTestSupportUtils {
      * @see           #detectTargetFolder(Path)
      */
     public static Path detectTargetFolder(Class<?> anchor) {
-        return detectTargetFolder(getClassContainerLocationPath(anchor));
+        Path path = detectTargetFolder(getClassContainerLocationPath(anchor));
+        if (path == null) {
+            String basedir = System.getProperty("basedir");
+            path = detectTargetFolder(Paths.get(basedir, "target"));
+        }
+        return path;
     }
 
     /**
diff --git 
a/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java 
b/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
index aede6de..cd71bc2 100644
--- a/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
+++ b/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
@@ -22,12 +22,9 @@ package org.apache.sshd.util.test;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.security.Key;
 import java.security.KeyPair;
 import java.security.interfaces.DSAParams;
@@ -201,12 +198,9 @@ public abstract class JUnitTestSupport extends Assert {
     }
 
     protected Path getTestResourcesFolder() {
-        try {
-            URL url = getClass().getResource(getClass().getSimpleName() + 
".class");
-            return Paths.get(url.toURI()).getParent();
-        } catch (URISyntaxException e) {
-            throw new RuntimeException(e);
-        }
+        Path target = detectTargetFolder();
+        String pkgFolder = getClass().getPackage().getName().replace('.', 
File.separatorChar);
+        return target.resolve("test-classes").resolve(pkgFolder);
     }
 
     protected Path getClassResourcesFolder(String resType /* test or main */) {
diff --git a/sshd-core/pom.xml b/sshd-core/pom.xml
index d6fc476..fa3b5f6 100644
--- a/sshd-core/pom.xml
+++ b/sshd-core/pom.xml
@@ -59,14 +59,14 @@
             <optional>true</optional>
         </dependency>
 
-            <!-- For ed25519 support -->
+        <!-- For ed25519 support -->
         <dependency>
             <groupId>net.i2p.crypto</groupId>
             <artifactId>eddsa</artifactId>
             <optional>true</optional>
         </dependency>
 
-            <!-- test dependencies -->
+        <!-- test dependencies -->
         <dependency>
             <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-common</artifactId>
@@ -153,6 +153,7 @@
                 <artifactId>maven-jar-plugin</artifactId>
                 <executions>
                     <execution>
+                        <id>small-test-jar</id>
                         <goals>
                             <goal>test-jar</goal>
                         </goals>
@@ -166,6 +167,25 @@
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>big-test-jar</id>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                        <configuration>
+                            <classifier>reusable-tests</classifier>
+                            
<finalName>${project.build.finalName}-reusable</finalName>
+                            <excludes>
+                                
<exclude>org/apache/sshd/util/test/**/*</exclude>
+                            </excludes>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <redirectTestOutputToFile>true</redirectTestOutputToFile>
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 ffc0603..98afcb8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/WindowAdjustTest.java
@@ -21,8 +21,6 @@ package org.apache.sshd;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.util.Collection;
 import java.util.Deque;
 import java.util.EnumSet;
@@ -42,6 +40,7 @@ import org.apache.sshd.common.io.IoOutputStream;
 import org.apache.sshd.common.io.WritePendingException;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.io.IoUtils;
 import org.apache.sshd.common.util.io.NoCloseOutputStream;
 import org.apache.sshd.common.util.logging.AbstractLoggingBean;
 import org.apache.sshd.common.util.threads.ThreadUtils;
@@ -85,8 +84,7 @@ public class WindowAdjustTest extends BaseTestSupport {
     public void setUp() throws Exception {
         sshServer = setupTestServer();
 
-        byte[] msg = Files.readAllBytes(
-                Paths.get(getClass().getResource("/big-msg.txt").toURI()));
+        byte[] msg = 
IoUtils.toByteArray(getClass().getResourceAsStream("/big-msg.txt"));
         sshServer.setShellFactory(
                 channel -> new FloodingAsyncCommand(msg, BIG_MSG_SEND_COUNT, 
END_FILE));
 
diff --git a/sshd-mina/pom.xml b/sshd-mina/pom.xml
index 54a10d6..ac2b8d4 100644
--- a/sshd-mina/pom.xml
+++ b/sshd-mina/pom.xml
@@ -56,6 +56,14 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sshd</groupId>
+            <artifactId>sshd-core</artifactId>
+            <version>${project.version}</version>
+            <classifier>reusable-tests</classifier>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-common</artifactId>
             <version>${project.version}</version>
             <type>test-jar</type>
@@ -120,40 +128,6 @@
 
     <build>
         <plugins>
-           <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <version>${build-helper-maven-plugin.version}</version>
-                <executions>
-                    <execution>
-                        <id>add-test-source</id>
-                        <phase>generate-test-sources</phase>
-                        <goals>
-                            <goal>add-test-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                
<source>${projectRoot}/sshd-core/src/test/java</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>add-test-resource</id>
-                        <phase>generate-test-resources</phase>
-                        <goals>
-                            <goal>add-test-resource</goal>
-                        </goals>
-                        <configuration>
-                            <resources>
-                                <resource>
-                                    
<directory>${projectRoot}/sshd-core/src/test/resources</directory>
-                                    
<targetPath>${project.build.testOutputDirectory}</targetPath>
-                                </resource>
-                            </resources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
@@ -179,8 +153,12 @@
                         <exclude>**/AsyncAuthTest.java</exclude>
                         <exclude>**/AsyncAuthInteractiveTest.java</exclude>
                     </excludes>
-                        <!-- No need to re-run core tests that do not involve 
session creation -->
+                    <!-- No need to re-run core tests that do not involve 
session creation -->
                     
<excludedGroups>org.apache.sshd.util.test.NoIoTestCase</excludedGroups>
+                    <!-- Tests are located in the sshd-core reusable test jar 
-->
+                    <dependenciesToScan>
+                        <dependency>org.apache.sshd:sshd-core</dependency>
+                    </dependenciesToScan>
                 </configuration>
             </plugin>
             <plugin>
diff --git a/sshd-netty/pom.xml b/sshd-netty/pom.xml
index 3c9595e..ae149aa 100644
--- a/sshd-netty/pom.xml
+++ b/sshd-netty/pom.xml
@@ -137,40 +137,6 @@
     <build>
         <plugins>
             <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <version>${build-helper-maven-plugin.version}</version>
-                <executions>
-                    <execution>
-                        <id>add-test-source</id>
-                        <phase>generate-test-sources</phase>
-                        <goals>
-                            <goal>add-test-source</goal>
-                        </goals>
-                        <configuration>
-                            <sources>
-                                
<source>${projectRoot}/sshd-core/src/test/java</source>
-                            </sources>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>add-test-resource</id>
-                        <phase>generate-test-resources</phase>
-                        <goals>
-                            <goal>add-test-resource</goal>
-                        </goals>
-                        <configuration>
-                            <resources>
-                                <resource>
-                                    
<directory>${projectRoot}/sshd-core/src/test/resources</directory>
-                                    
<targetPath>${project.build.testOutputDirectory}</targetPath>
-                                </resource>
-                            </resources>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
                 <configuration>
@@ -207,6 +173,10 @@
                     </excludes>
                     <!-- No need to re-run core tests that do not involve 
session creation -->
                     
<excludedGroups>org.apache.sshd.util.test.NoIoTestCase</excludedGroups>
+                    <!-- Tests are located in the sshd-core reusable test jar 
-->
+                    <dependenciesToScan>
+                        <dependency>org.apache.sshd:sshd-core</dependency>
+                    </dependenciesToScan>
                 </configuration>
             </plugin>
             <plugin>

Reply via email to