Test that NettyBlockHoundIntegration
can be loaded with ServiceLoader
(#9743)
Motivation: If something is mis-configured, the "main" test will fail but it is unclear whether it fails because the integration does not work or it wasn't applied at all. Also see: https://github.com/netty/netty/issues/9738#issuecomment-548416693 Modifications: This change adds a test that uses the same mechanism as BlockHound does (`ServiceLoader`) and checks that `NettyBlockHoundIntegration` is present. Result: It is now clear whether the integration is not working or it wasn't loaded at all.
This commit is contained in:
parent
369e667427
commit
cedfa41f3f
@ -16,10 +16,13 @@
|
|||||||
package io.netty.util.internal;
|
package io.netty.util.internal;
|
||||||
|
|
||||||
import io.netty.util.concurrent.GlobalEventExecutor;
|
import io.netty.util.concurrent.GlobalEventExecutor;
|
||||||
|
import io.netty.util.internal.Hidden.NettyBlockHoundIntegration;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import reactor.blockhound.BlockHound;
|
import reactor.blockhound.BlockHound;
|
||||||
|
import reactor.blockhound.integration.BlockHoundIntegration;
|
||||||
|
|
||||||
|
import java.util.ServiceLoader;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.FutureTask;
|
import java.util.concurrent.FutureTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -35,6 +38,17 @@ public class NettyBlockHoundIntegrationTest {
|
|||||||
BlockHound.install();
|
BlockHound.install();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServiceLoader() {
|
||||||
|
for (BlockHoundIntegration integration : ServiceLoader.load(BlockHoundIntegration.class)) {
|
||||||
|
if (integration instanceof NettyBlockHoundIntegration) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fail("NettyBlockHoundIntegration cannot be loaded with ServiceLoader");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBlockingCallsInNettyThreads() throws Exception {
|
public void testBlockingCallsInNettyThreads() throws Exception {
|
||||||
final FutureTask<Void> future = new FutureTask<>(() -> {
|
final FutureTask<Void> future = new FutureTask<>(() -> {
|
||||||
|
Loading…
Reference in New Issue
Block a user