1717
1818import static org .assertj .core .api .Assertions .assertThatThrownBy ;
1919
20+ import com .rabbitmq .client .Address ;
21+ import com .rabbitmq .client .AddressResolver ;
2022import com .rabbitmq .client .ConnectionFactory ;
23+ import com .rabbitmq .client .ListAddressResolver ;
2124import com .rabbitmq .client .MalformedFrameException ;
2225import io .netty .bootstrap .ServerBootstrap ;
2326import io .netty .buffer .ByteBuf ;
3134import io .netty .channel .socket .SocketChannel ;
3235import io .netty .channel .socket .nio .NioServerSocketChannel ;
3336import io .netty .util .ReferenceCountUtil ;
37+ import java .util .Collections ;
3438import java .util .concurrent .TimeUnit ;
3539import org .junit .jupiter .params .ParameterizedTest ;
3640import org .junit .jupiter .params .provider .MethodSource ;
41+ import org .slf4j .Logger ;
42+ import org .slf4j .LoggerFactory ;
3743
3844public class ProtocolVersionMismatch {
3945
46+ private static final Logger LOGGER = LoggerFactory .getLogger (ProtocolVersionMismatch .class );
47+
4048 @ ParameterizedTest
4149 @ MethodSource ("com.rabbitmq.client.test.TestUtils#ioLayers" )
4250 void connectionShouldFailWithProtocolVersionMismatch (String ioLayer ) throws Exception {
@@ -45,7 +53,10 @@ void connectionShouldFailWithProtocolVersionMismatch(String ioLayer) throws Exce
4553 ConnectionFactory cf = TestUtils .connectionFactory ();
4654 TestUtils .setIoLayer (cf , ioLayer );
4755 cf .setPort (port );
48- assertThatThrownBy (cf ::newConnection ).hasRootCauseInstanceOf (MalformedFrameException .class );
56+ AddressResolver addressResolver =
57+ new ListAddressResolver (Collections .singletonList (new Address ("localhost" , port )));
58+ assertThatThrownBy (() -> cf .newConnection (addressResolver ))
59+ .hasRootCauseInstanceOf (MalformedFrameException .class );
4960 }
5061 }
5162
@@ -69,6 +80,7 @@ protected void initChannel(SocketChannel ch) {
6980 new ChannelInboundHandlerAdapter () {
7081 @ Override
7182 public void channelRead (ChannelHandlerContext ctx , Object msg ) {
83+ LOGGER .debug ("Client connection in test AMQP 1.0 server" );
7284 // discard the data
7385 ReferenceCountUtil .release (msg );
7486 ByteBuf b = ctx .alloc ().buffer (AMQP_HEADER .length );
0 commit comments