Skip to content

Commit fdd9579

Browse files
One more test case for channel.open
It's not currently possible to work around ChannelManager's channel number availability checks without making ConsumerWorkPool public so that ChannelN can be constructed directly. Other clients are not as strict about channel number validation.
1 parent 25ab0e8 commit fdd9579

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import com.rabbitmq.client.AMQP;
44
import com.rabbitmq.client.Connection;
55
import com.rabbitmq.client.ConnectionFactory;
6-
import com.rabbitmq.client.impl.AMQConnection;
7-
import com.rabbitmq.client.impl.DefaultExceptionHandler;
8-
import com.rabbitmq.client.impl.SocketFrameHandler;
6+
import com.rabbitmq.client.impl.*;
97
import com.rabbitmq.client.test.BrokerTestCase;
108
import com.rabbitmq.tools.Host;
119

@@ -46,7 +44,7 @@ protected int negotiateChannelMax(int requestedChannelMax, int serverMax) {
4644
}
4745
}
4846

49-
public void testChannelMaxLowerThanServerValue() throws Exception {
47+
public void testChannelMaxLowerThanServerMinimum() throws Exception {
5048
int n = 64;
5149
ConnectionFactory cf = new ConnectionFactory();
5250
cf.setRequestedChannelMax(n);
@@ -70,4 +68,18 @@ public void testChannelMaxGreaterThanServerValue() throws Exception {
7068
Host.rabbitmqctl("eval 'application:set_env(rabbit, channel_max, 0).'");
7169
}
7270
}
71+
72+
public void testOpeningChannelWithIdGreaterThanChannelMaxFails() throws Exception {
73+
int n = 48;
74+
75+
ConnectionFactory cf = new ConnectionFactory();
76+
Connection conn = cf.newConnection();
77+
assertEquals(n, conn.getChannelMax());
78+
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));
84+
}
7385
}

0 commit comments

Comments
 (0)