|
16 | 16 |
|
17 | 17 | package com.rabbitmq.client.test.functional; |
18 | 18 |
|
19 | | -import com.rabbitmq.client.AMQP; |
20 | 19 | import com.rabbitmq.client.AuthenticationFailureException; |
21 | 20 | import com.rabbitmq.client.Connection; |
22 | 21 | import com.rabbitmq.client.ConnectionFactory; |
|
26 | 25 | import com.rabbitmq.client.SaslMechanism; |
27 | 26 | import com.rabbitmq.client.impl.AMQConnection; |
28 | 27 | import com.rabbitmq.client.impl.LongStringHelper; |
29 | | -import com.rabbitmq.client.impl.SocketFrameHandler; |
30 | 28 | import com.rabbitmq.client.test.BrokerTestCase; |
31 | 29 |
|
32 | | -import javax.net.SocketFactory; |
33 | 30 | import java.io.IOException; |
34 | 31 | import java.util.Arrays; |
35 | | -import java.util.HashMap; |
36 | 32 | import java.util.Map; |
37 | | -import java.util.concurrent.Executors; |
38 | 33 |
|
39 | 34 | public class SaslMechanisms extends BrokerTestCase { |
40 | 35 | private String[] mechanisms; |
@@ -123,21 +118,13 @@ public void connectionCloseAuthFailure(String username, String password) throws |
123 | 118 | // start a connection without capabilities, causing authentication failures |
124 | 119 | // to be reported by the broker by closing the connection |
125 | 120 | private Connection connectionWithoutCapabilities(String username, String password) throws IOException { |
126 | | - Map<String, Object> customProperties = connection.getClientProperties(); |
| 121 | + ConnectionFactory customFactory = connectionFactory.clone(); |
| 122 | + customFactory.setUsername(username); |
| 123 | + customFactory.setPassword(password); |
| 124 | + Map<String, Object> customProperties = AMQConnection.defaultClientProperties(); |
127 | 125 | customProperties.remove("capabilities"); |
128 | | - AMQConnection conn = |
129 | | - new AMQConnection(username, |
130 | | - password, |
131 | | - new SocketFrameHandler(SocketFactory.getDefault().createSocket("localhost", AMQP.PROTOCOL.PORT)), |
132 | | - Executors.newFixedThreadPool(1), |
133 | | - connectionFactory.getVirtualHost(), |
134 | | - customProperties, |
135 | | - connectionFactory.getRequestedFrameMax(), |
136 | | - connectionFactory.getRequestedChannelMax(), |
137 | | - connectionFactory.getRequestedHeartbeat(), |
138 | | - connectionFactory.getSaslConfig()); |
139 | | - conn.start(); |
140 | | - return conn; |
| 126 | + customFactory.setClientProperties(customProperties); |
| 127 | + return customFactory.newConnection(); |
141 | 128 | } |
142 | 129 |
|
143 | 130 | private void loginOk(String name, byte[][] responses) throws IOException { |
|
0 commit comments