Skip to content

Commit

Permalink
GH-510: Fix class name in BuiltinIoServiceFactoryFactories
Browse files Browse the repository at this point in the history
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: #510
  • Loading branch information
JinHeap authored and tomaswolf committed May 31, 2024
1 parent f0f2e4c commit 82e0ed1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public enum BuiltinIoServiceFactoryFactories implements NamedFactory<IoServiceFactoryFactory>, 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<BuiltinIoServiceFactoryFactories> VALUES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions sshd-mina/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
<exclude>**/StrictKexInteroperabilityTest.java</exclude>
<!-- reading files from classpath doesn't work correctly w/ reusable test jar -->
<exclude>**/OpenSSHCertificateTest.java</exclude>
<!-- A MinaServiceFactory cannot be instantiated with a mock CloseableExecutorService. -->
<exclude>**/DefaultIoServiceFactoryFactoryTest.java</exclude>
</excludes>
<!-- No need to re-run core tests that do not involve session creation -->
<excludedGroups>org.apache.sshd.util.test.NoIoTestCase</excludedGroups>
Expand Down

0 comments on commit 82e0ed1

Please sign in to comment.