Skip to content

Commit 2d80614

Browse files
committed
merge bug23029 into default
2 parents b5302a1 + 579ae0b commit 2d80614

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

test/src/com/rabbitmq/client/test/BrokerTestCase.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
import com.rabbitmq.client.GetResponse;
4343
import com.rabbitmq.client.MessageProperties;
4444
import com.rabbitmq.client.ShutdownSignalException;
45-
45+
import com.rabbitmq.client.AlreadyClosedException;
46+
import com.rabbitmq.client.impl.ShutdownNotifierComponent;
4647
import com.rabbitmq.client.AMQP;
4748

4849
public class BrokerTestCase extends TestCase
@@ -128,6 +129,16 @@ public void closeChannel()
128129

129130
public void checkShutdownSignal(int expectedCode, IOException ioe) {
130131
ShutdownSignalException sse = (ShutdownSignalException) ioe.getCause();
132+
checkShutdownSignal(expectedCode, sse);
133+
}
134+
135+
public void checkShutdownSignal(int expectedCode, AlreadyClosedException ace) {
136+
ShutdownNotifierComponent snc = (ShutdownNotifierComponent) ace.getReference();
137+
ShutdownSignalException sse = snc.getCloseReason();
138+
checkShutdownSignal(expectedCode, sse);
139+
}
140+
141+
public void checkShutdownSignal(int expectedCode, ShutdownSignalException sse) {
131142
Command closeCommand = (Command) sse.getReason();
132143
channel = null;
133144
if (sse.isHardError()) {
@@ -140,6 +151,20 @@ public void checkShutdownSignal(int expectedCode, IOException ioe) {
140151
}
141152
}
142153

154+
public void expectChannelError(int error) {
155+
try {
156+
channel.basicQos(0);
157+
fail("Expected channel error " + error);
158+
} catch (IOException ioe) {
159+
// If we get a channel close back when flushing it with the
160+
// synchronous basicQos above.
161+
checkShutdownSignal(error, ioe);
162+
} catch (AlreadyClosedException ace) {
163+
// If it has already closed of its own accord before we got there.
164+
checkShutdownSignal(error, ace);
165+
}
166+
}
167+
143168
protected void assertDelivered(String q, int count) throws IOException {
144169
assertDelivered(q, count, false);
145170
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.rabbitmq.client.test.functional;
22

33
import com.rabbitmq.client.AMQP;
4-
import com.rabbitmq.client.GetResponse;
54
import com.rabbitmq.client.test.BrokerTestCase;
65

76
import java.io.IOException;
@@ -32,15 +31,6 @@ public void testDoubleAck()
3231
expectChannelError(AMQP.PRECONDITION_FAILED);
3332
}
3433

35-
private void expectChannelError(int error) {
36-
try {
37-
channel.queueDeclare();
38-
fail("Expected channel error " + error);
39-
} catch (IOException e) {
40-
checkShutdownSignal(error, e);
41-
}
42-
}
43-
4434
public void testCrazyAck()
4535
throws IOException
4636
{

0 commit comments

Comments
 (0)