Skip to content

Commit 8e7f189

Browse files
author
Simon MacMullen
committed
Don't use that horrible AMQConnection constructor.
1 parent c168378 commit 8e7f189

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

test/src/com/rabbitmq/client/test/functional/SaslMechanisms.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.rabbitmq.client.test.functional;
1818

19-
import com.rabbitmq.client.AMQP;
2019
import com.rabbitmq.client.AuthenticationFailureException;
2120
import com.rabbitmq.client.Connection;
2221
import com.rabbitmq.client.ConnectionFactory;
@@ -26,15 +25,11 @@
2625
import com.rabbitmq.client.SaslMechanism;
2726
import com.rabbitmq.client.impl.AMQConnection;
2827
import com.rabbitmq.client.impl.LongStringHelper;
29-
import com.rabbitmq.client.impl.SocketFrameHandler;
3028
import com.rabbitmq.client.test.BrokerTestCase;
3129

32-
import javax.net.SocketFactory;
3330
import java.io.IOException;
3431
import java.util.Arrays;
35-
import java.util.HashMap;
3632
import java.util.Map;
37-
import java.util.concurrent.Executors;
3833

3934
public class SaslMechanisms extends BrokerTestCase {
4035
private String[] mechanisms;
@@ -123,21 +118,13 @@ public void connectionCloseAuthFailure(String username, String password) throws
123118
// start a connection without capabilities, causing authentication failures
124119
// to be reported by the broker by closing the connection
125120
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();
127125
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();
141128
}
142129

143130
private void loginOk(String name, byte[][] responses) throws IOException {

0 commit comments

Comments
 (0)