Skip to content

Commit 3dd0bac

Browse files
Reformat to 4 spaces
1 parent 7e359d8 commit 3dd0bac

File tree

1 file changed

+73
-73
lines changed

1 file changed

+73
-73
lines changed

test/src/com/rabbitmq/client/test/server/ChannelLimitNegotiation.java

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,93 +10,93 @@
1010
import java.util.concurrent.Executors;
1111

1212
public class ChannelLimitNegotiation extends BrokerTestCase {
13-
class SpecialConnection extends AMQConnection {
14-
private final int channelMax;
13+
class SpecialConnection extends AMQConnection {
14+
private final int channelMax;
1515

16-
public SpecialConnection(int channelMax) throws Exception {
17-
this(new ConnectionFactory(), channelMax);
18-
}
16+
public SpecialConnection(int channelMax) throws Exception {
17+
this(new ConnectionFactory(), channelMax);
18+
}
1919

20-
private SpecialConnection(ConnectionFactory factory, int channelMax) throws Exception {
21-
super(factory.getUsername(),
22-
factory.getPassword(),
23-
new SocketFrameHandler(SocketFactory.getDefault().createSocket("localhost", AMQP.PROTOCOL.PORT)),
24-
Executors.newFixedThreadPool(1),
25-
factory.getVirtualHost(),
26-
factory.getClientProperties(),
27-
factory.getRequestedFrameMax(),
28-
channelMax,
29-
factory.getRequestedHeartbeat(),
30-
factory.getSaslConfig(),
31-
new DefaultExceptionHandler());
20+
private SpecialConnection(ConnectionFactory factory, int channelMax) throws Exception {
21+
super(factory.getUsername(),
22+
factory.getPassword(),
23+
new SocketFrameHandler(SocketFactory.getDefault().createSocket("localhost", AMQP.PROTOCOL.PORT)),
24+
Executors.newFixedThreadPool(1),
25+
factory.getVirtualHost(),
26+
factory.getClientProperties(),
27+
factory.getRequestedFrameMax(),
28+
channelMax,
29+
factory.getRequestedHeartbeat(),
30+
factory.getSaslConfig(),
31+
new DefaultExceptionHandler());
3232

33-
this.channelMax = channelMax;
34-
}
33+
this.channelMax = channelMax;
34+
}
3535

36-
/**
37-
* Private API, allows for easier simulation of bogus clients.
38-
*/
39-
@Override
40-
protected int negotiateChannelMax(int requestedChannelMax, int serverMax) {
41-
return this.channelMax;
36+
/**
37+
* Private API, allows for easier simulation of bogus clients.
38+
*/
39+
@Override
40+
protected int negotiateChannelMax(int requestedChannelMax, int serverMax) {
41+
return this.channelMax;
42+
}
4243
}
43-
}
44-
45-
public void testChannelMaxLowerThanServerMinimum() throws Exception {
46-
int n = 64;
47-
ConnectionFactory cf = new ConnectionFactory();
48-
cf.setRequestedChannelMax(n);
4944

50-
Connection conn = cf.newConnection();
51-
assertEquals(n, conn.getChannelMax());
52-
}
45+
public void testChannelMaxLowerThanServerMinimum() throws Exception {
46+
int n = 64;
47+
ConnectionFactory cf = new ConnectionFactory();
48+
cf.setRequestedChannelMax(n);
5349

54-
public void testChannelMaxGreaterThanServerValue() throws Exception {
55-
try {
56-
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 2048).'");
50+
Connection conn = cf.newConnection();
51+
assertEquals(n, conn.getChannelMax());
52+
}
5753

58-
SpecialConnection connection = new SpecialConnection(4096);
54+
public void testChannelMaxGreaterThanServerValue() throws Exception {
5955
try {
60-
connection.start();
61-
fail("expected failure during connection negotiation");
62-
} catch (IOException e) {
63-
// expected
56+
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 2048).'");
57+
58+
SpecialConnection connection = new SpecialConnection(4096);
59+
try {
60+
connection.start();
61+
fail("expected failure during connection negotiation");
62+
} catch (IOException e) {
63+
// expected
64+
}
65+
} finally {
66+
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 0).'");
6467
}
65-
} finally {
66-
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 0).'");
67-
}
68-
}
68+
}
6969

70-
public void testOpeningTooManyChannels() throws Exception {
71-
int n = 48;
70+
public void testOpeningTooManyChannels() throws Exception {
71+
int n = 48;
7272

73-
try {
74-
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, " + n + ").'");
75-
ConnectionFactory cf = new ConnectionFactory();
76-
Connection conn = cf.newConnection();
77-
assertEquals(n, conn.getChannelMax());
73+
try {
74+
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, " + n + ").'");
75+
ConnectionFactory cf = new ConnectionFactory();
76+
Connection conn = cf.newConnection();
77+
assertEquals(n, conn.getChannelMax());
7878

79-
for(int i = 1; i <= n; i++) {
80-
assertNotNull(conn.createChannel(i));
81-
}
82-
// ChannelManager guards against channel.open being sent
83-
assertNull(conn.createChannel(n + 1));
79+
for (int i = 1; i <= n; i++) {
80+
assertNotNull(conn.createChannel(i));
81+
}
82+
// ChannelManager guards against channel.open being sent
83+
assertNull(conn.createChannel(n + 1));
8484

85-
// Construct a channel directly
86-
final ChannelN ch = new ChannelN((AMQConnection)conn, n + 1,
87-
new ConsumerWorkService(Executors.newSingleThreadExecutor()));
88-
conn.addShutdownListener(new ShutdownListener() {
89-
public void shutdownCompleted(ShutdownSignalException cause) {
90-
// make sure channel.open continuation is released
91-
ch.processShutdownSignal(cause, true, true);
85+
// Construct a channel directly
86+
final ChannelN ch = new ChannelN((AMQConnection) conn, n + 1,
87+
new ConsumerWorkService(Executors.newSingleThreadExecutor()));
88+
conn.addShutdownListener(new ShutdownListener() {
89+
public void shutdownCompleted(ShutdownSignalException cause) {
90+
// make sure channel.open continuation is released
91+
ch.processShutdownSignal(cause, true, true);
92+
}
93+
});
94+
ch.open();
95+
fail("expected channel.open to cause a connection exception");
96+
} catch (IOException e) {
97+
checkShutdownSignal(530, e);
98+
} finally {
99+
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 0).'");
92100
}
93-
});
94-
ch.open();
95-
fail("expected channel.open to cause a connection exception");
96-
} catch (IOException e) {
97-
checkShutdownSignal(530, e);
98-
} finally {
99-
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 0).'");
100101
}
101-
}
102102
}

0 commit comments

Comments
 (0)