ARTEMIS-4452 make test more robust

This commit is contained in:
Justin Bertram 2024-01-10 13:52:16 -06:00
parent a7f18777a3
commit ebd634ae54
No known key found for this signature in database
GPG Key ID: F41830B875BB8633
2 changed files with 4 additions and 2 deletions

View File

@ -1102,7 +1102,7 @@ public class NettyConnector extends AbstractConnector {
}
}
class HttpHandler extends ChannelDuplexHandler {
public class HttpHandler extends ChannelDuplexHandler {
private Channel channel;

View File

@ -29,6 +29,7 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnector;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.Wait;
import org.junit.Before;
import org.junit.Test;
@ -80,7 +81,8 @@ public class NettyConnectorTest extends ActiveMQTestBase {
Bootstrap bootstrap = connector.getBootStrap();
ChannelPipeline pipeline = bootstrap.register().channel().pipeline();
pipeline.flush();
Object httpHandler = pipeline.get("NettyConnector$HttpHandler#0");
Wait.assertTrue("HttpHandler is null!", () -> pipeline.get(NettyConnector.HttpHandler.class) != null, 500, 25);
Object httpHandler = pipeline.get(NettyConnector.HttpHandler.class);
Method getHeadersMethod = httpHandler.getClass().getMethod("getHeaders", (Class<?>[]) null);
getHeadersMethod.setAccessible(true);
Map<String, String> headers = (Map<String, String>) getHeadersMethod.invoke(httpHandler, (Object[]) null);