Skip to content

Commit f826ec9

Browse files
committed
Also test sshd-mina using mina-core 2.2.4
Frankly said I don't quite understand why this even works. The code certainly doesn't compile against 2.2.4: there's a new (abstract) method in interface IoHandler, and our MinaService inherits that but doesn't implement it. Apparently at runtime this can still work as long as the new method isn't called? (In mina-core 2.2.5, that method will be a default method, and then everything should be totally fine.) Also tell dependabot to give us only patch version updates for mina-core. We want to keep the minimum requirement at 2.0.X.
1 parent d67c565 commit f826ec9

3 files changed

Lines changed: 82 additions & 7 deletions

File tree

.github/dependabot.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ updates:
3535
versions: [ ">= 2.0.0" ]
3636
- dependency-name: "ch.qos.logback:*"
3737
versions: [ ">= 1.3.0" ]
38+
# We *do* test against 2.2.X. We only want to get patch version updates for mina-core
39+
- dependency-name: "org.apache.mina:mina-core"
40+
update-types: [ "version-update:semver-major", "version-update:semver-minor" ]

sshd-mina/pom.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,71 @@
150150
</plugin>
151151
</plugins>
152152
</build>
153+
154+
<profiles>
155+
<profile>
156+
<id>test-mina-2.2.X</id>
157+
<activation>
158+
<property>
159+
<name>test.mina22</name>
160+
<value>!disable</value>
161+
</property>
162+
</activation>
163+
<build>
164+
<plugins>
165+
<plugin>
166+
<groupId>org.apache.maven.plugins</groupId>
167+
<artifactId>maven-surefire-plugin</artifactId>
168+
<executions>
169+
<execution>
170+
<id>test-mina-2.2.X</id>
171+
<goals>
172+
<goal>test</goal>
173+
</goals>
174+
<configuration>
175+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
176+
<reportsDirectory>${project.build.directory}/surefire-reports-mina-22</reportsDirectory>
177+
<forkCount>1</forkCount>
178+
<reuseForks>false</reuseForks>
179+
<excludes>
180+
<!-- These tests use NIO2 explicitly -->
181+
<exclude>**/Nio2ServiceTest.java</exclude>
182+
<!-- testcontainers filesystem building from classpath doesn't work from reusable test jar classpath -->
183+
<exclude>**/ArcFourOpenSshTest.java</exclude>
184+
<exclude>**/ClientOpenSSHCertificatesTest.java</exclude>
185+
<exclude>**/SessionReKeyHostKeyExchangeTest.java</exclude>
186+
<exclude>**/HostBoundPubKeyAuthTest.java</exclude>
187+
<exclude>**/OpenSshCipherTest.java</exclude>
188+
<exclude>**/OpenSshMlKemTest.java</exclude>
189+
<exclude>**/PortForwardingWithOpenSshTest.java</exclude>
190+
<exclude>**/StrictKexInteroperabilityTest.java</exclude>
191+
<!-- reading files from classpath doesn't work correctly w/ reusable test jar -->
192+
<exclude>**/OpenSSHCertificateTest.java</exclude>
193+
<!-- A MinaServiceFactory cannot be instantiated with a mock CloseableExecutorService. -->
194+
<exclude>**/DefaultIoServiceFactoryFactoryTest.java</exclude>
195+
</excludes>
196+
<!-- No need to re-run core tests that do not involve session creation -->
197+
<excludedGroups>NoIoTestCase</excludedGroups>
198+
<!-- Tests are located in the sshd-core reusable test jar -->
199+
<dependenciesToScan>
200+
<dependency>org.apache.sshd:sshd-core</dependency>
201+
</dependenciesToScan>
202+
<classpathDependencyExcludes>
203+
<classpathDependencyExclude>org.apache.mina:mina-core</classpathDependencyExclude>
204+
</classpathDependencyExcludes>
205+
<additionalClasspathDependencies>
206+
<additionalClasspathDependency>
207+
<groupId>org.apache.mina</groupId>
208+
<artifactId>mina-core</artifactId>
209+
<version>2.2.4</version>
210+
</additionalClasspathDependency>
211+
</additionalClasspathDependencies>
212+
</configuration>
213+
</execution>
214+
</executions>
215+
</plugin>
216+
</plugins>
217+
</build>
218+
</profile>
219+
</profiles>
153220
</project>

sshd-mina/src/test/java/org/apache/sshd/mina/MinaSessionTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,35 @@
2020
package org.apache.sshd.mina;
2121

2222
import java.lang.reflect.Field;
23+
import java.util.stream.Stream;
2324

25+
import org.apache.mina.core.service.IoHandler;
2426
import org.apache.mina.core.service.IoProcessor;
2527
import org.apache.sshd.client.SshClient;
2628
import org.apache.sshd.common.helpers.AbstractFactoryManager;
2729
import org.apache.sshd.common.io.IoServiceFactory;
2830
import org.apache.sshd.server.SshServer;
2931
import org.apache.sshd.util.test.BaseTestSupport;
30-
import org.junit.jupiter.api.MethodOrderer.MethodName;
32+
import org.junit.jupiter.api.BeforeAll;
3133
import org.junit.jupiter.api.Test;
32-
import org.junit.jupiter.api.TestMethodOrder;
33-
34-
import static org.junit.jupiter.api.Assertions.assertTrue;
3534

3635
/**
3736
* Tests specific to the MINA connection back-end.
3837
*
3938
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
4039
*/
41-
@TestMethodOrder(MethodName.class)
42-
public class MinaSessionTest extends BaseTestSupport {
40+
class MinaSessionTest extends BaseTestSupport {
4341

44-
public MinaSessionTest() {
42+
MinaSessionTest() {
4543
super();
4644
}
4745

46+
@BeforeAll
47+
static void minaVersion() {
48+
boolean is22x = Stream.of(IoHandler.class.getMethods()).anyMatch(m -> "event".equals(m.getName()));
49+
System.err.println("Testing with MINA " + (is22x ? "2.2.X" : "2.0.X"));
50+
}
51+
4852
private IoProcessor<?> getProcessor(AbstractFactoryManager manager) throws Exception {
4953
IoServiceFactory ioServiceFactory = manager.getIoServiceFactory();
5054
assertTrue(ioServiceFactory instanceof MinaServiceFactory, "Unexpected type " + ioServiceFactory.getClass());
@@ -70,4 +74,5 @@ void ioProcessorClosed() throws Exception {
7074
}
7175
assertTrue(ioProcessor.isDisposed() || ioProcessor.isDisposing(), "MINA server IoProcessor should be closed");
7276
}
77+
7378
}

0 commit comments

Comments
 (0)