2929import com .rabbitmq .client .Connection ;
3030import com .rabbitmq .client .ConnectionFactory ;
3131import com .rabbitmq .client .DefaultConsumer ;
32+ import com .rabbitmq .client .DefaultSocketConfigurator ;
3233import com .rabbitmq .client .Envelope ;
3334import com .rabbitmq .client .GetResponse ;
3435import com .rabbitmq .client .MessageProperties ;
3536import com .rabbitmq .client .Method ;
3637import com .rabbitmq .client .ReturnListener ;
3738import com .rabbitmq .client .ShutdownSignalException ;
39+ import com .rabbitmq .client .SocketConfigurator ;
3840import com .rabbitmq .client .impl .AMQConnection ;
3941import com .rabbitmq .client .impl .FrameHandler ;
42+ import com .rabbitmq .client .impl .FrameHandlerFactory ;
4043import com .rabbitmq .client .impl .SocketFrameHandler ;
4144import com .rabbitmq .utility .BlockingCell ;
4245
46+ import javax .net .SocketFactory ;
47+
4348public class TestMain {
4449 public static void main (String [] args ) throws IOException , URISyntaxException {
4550 // Show what version this class was compiled with, to check conformance testing
@@ -75,6 +80,25 @@ private static class TestConnectionFactory extends ConnectionFactory {
7580 private final int protocolMajor ;
7681 private final int protocolMinor ;
7782
83+ private class TestFrameHandlerFactory extends FrameHandlerFactory {
84+ public TestFrameHandlerFactory (int connectionTimeout , SocketFactory factory , SocketConfigurator configurator , boolean ssl ) {
85+ super (connectionTimeout , factory , configurator , ssl );
86+ }
87+
88+ @ Override
89+ public FrameHandler create (Address addr ) throws IOException {
90+ String hostName = addr .getHost ();
91+ int portNumber = addr .getPort ();
92+ if (portNumber == -1 ) portNumber = AMQP .PROTOCOL .PORT ;
93+ return new SocketFrameHandler (getSocketFactory ().createSocket (hostName , portNumber )) {
94+ @ Override
95+ public void sendHeader () throws IOException {
96+ sendHeader (protocolMajor , protocolMinor );
97+ }
98+ };
99+ }
100+ }
101+
78102 public TestConnectionFactory (int major , int minor , String uri )
79103 throws URISyntaxException , NoSuchAlgorithmException , KeyManagementException
80104 {
@@ -83,17 +107,10 @@ public TestConnectionFactory(int major, int minor, String uri)
83107 setUri (uri );
84108 }
85109
86- public FrameHandler createFrameHandler (Address addr )
110+ @ Override
111+ public FrameHandlerFactory createFrameHandlerFactory ()
87112 throws IOException {
88-
89- String hostName = addr .getHost ();
90- int portNumber = addr .getPort ();
91- if (portNumber == -1 ) portNumber = AMQP .PROTOCOL .PORT ;
92- return new SocketFrameHandler (getSocketFactory ().createSocket (hostName , portNumber )) {
93- public void sendHeader () throws IOException {
94- sendHeader (protocolMajor , protocolMinor );
95- }
96- };
113+ return new TestFrameHandlerFactory (10 , SocketFactory .getDefault (), new DefaultSocketConfigurator (), false );
97114 }
98115 }
99116
0 commit comments