From 82e0ed1ff6e66ce025c5d3b6147cb9df5995a4d6 Mon Sep 17 00:00:00 2001 From: JinHeap Date: Thu, 30 May 2024 15:16:04 +0800 Subject: [PATCH] GH-510: Fix class name in BuiltinIoServiceFactoryFactories The class name for the MinaServiceFactoryFactory was not updated in the refactoring in commit 5cbae28. Add a test that catches such mistakes, and exclude another test from being run with the MinaServiceFactoryFactory because it cannot work with a mocked ExecutorService. Bug: https://github.com/apache/mina-sshd/issues/510 --- .../io/BuiltinIoServiceFactoryFactories.java | 2 +- .../io/BuiltinIoServiceFactoryFactoriesTest.java | 15 +++++++++++++++ sshd-mina/pom.xml | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java index 80fd00e8d..04e8451ac 100644 --- a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java +++ b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java @@ -34,7 +34,7 @@ */ public enum BuiltinIoServiceFactoryFactories implements NamedFactory, OptionalFeature { NIO2(Nio2ServiceFactoryFactory.class), - MINA("org.apache.sshd.common.io.mina.MinaServiceFactoryFactory"), + MINA("org.apache.sshd.mina.MinaServiceFactoryFactory"), NETTY("org.apache.sshd.netty.NettyIoServiceFactoryFactory"); public static final Set VALUES diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java index 411159ed7..43fc0b357 100644 --- a/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java +++ b/sshd-core/src/test/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactoriesTest.java @@ -68,4 +68,19 @@ public void testFromFactoryClass() { assertSame(clazz.getSimpleName(), expected, BuiltinIoServiceFactoryFactories.fromFactoryClass(clazz)); } } + + @Test + public void testClassNames() { + IoServiceFactoryFactory ioServiceProvider = getIoServiceProvider(); + Class providerClass = ioServiceProvider.getClass(); + String providerClassName = providerClass.getName(); + boolean found = false; + for (BuiltinIoServiceFactoryFactories builtin : BuiltinIoServiceFactoryFactories.VALUES) { + if (providerClassName.equals(builtin.getFactoryClassName())) { + found = true; + break; + } + } + assertTrue("No BuiltinIoServiceFactoryFactories match for class name " + providerClassName, found); + } } diff --git a/sshd-mina/pom.xml b/sshd-mina/pom.xml index fcdb73fd0..406c34612 100644 --- a/sshd-mina/pom.xml +++ b/sshd-mina/pom.xml @@ -124,6 +124,8 @@ **/StrictKexInteroperabilityTest.java **/OpenSSHCertificateTest.java + + **/DefaultIoServiceFactoryFactoryTest.java org.apache.sshd.util.test.NoIoTestCase