Skip to content

Commit 12ce528

Browse files
author
Emile Joubert
committed
Merged bug25538 into stable
2 parents d9b2233 + 4806d4c commit 12ce528

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.rabbitmq.client.ConnectionFactory;
2828
import com.rabbitmq.client.GetResponse;
2929
import com.rabbitmq.client.MessageProperties;
30+
import com.rabbitmq.client.Method;
3031
import com.rabbitmq.client.ShutdownSignalException;
3132
import com.rabbitmq.client.AlreadyClosedException;
3233
import com.rabbitmq.client.impl.ShutdownNotifierComponent;
@@ -82,10 +83,15 @@ protected void releaseResources()
8283
protected void restart()
8384
throws IOException {
8485
tearDown();
85-
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
86+
bareRestart();
8687
setUp();
8788
}
8889

90+
protected void bareRestart()
91+
throws IOException {
92+
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
93+
}
94+
8995
public void openConnection()
9096
throws IOException {
9197
if (connection == null) {
@@ -126,14 +132,20 @@ public void checkShutdownSignal(int expectedCode, AlreadyClosedException ace) {
126132
}
127133

128134
public void checkShutdownSignal(int expectedCode, ShutdownSignalException sse) {
129-
Command closeCommand = (Command) sse.getReason();
135+
Object reason = sse.getReason();
136+
Method method;
137+
if (reason instanceof Command) {
138+
method = ((Command) reason).getMethod();
139+
} else {
140+
method = (Method) reason;
141+
}
130142
channel = null;
131143
if (sse.isHardError()) {
132144
connection = null;
133-
AMQP.Connection.Close closeMethod = (AMQP.Connection.Close) closeCommand.getMethod();
145+
AMQP.Connection.Close closeMethod = (AMQP.Connection.Close) method;
134146
assertEquals(expectedCode, closeMethod.getReplyCode());
135147
} else {
136-
AMQP.Channel.Close closeMethod = (AMQP.Channel.Close) closeCommand.getMethod();
148+
AMQP.Channel.Close closeMethod = (AMQP.Channel.Close) method;
137149
assertEquals(expectedCode, closeMethod.getReplyCode());
138150
}
139151
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ public static void add(TestSuite suite) {
3939
suite.addTestSuite(MessageRecovery.class);
4040
suite.addTestSuite(Firehose.class);
4141
suite.addTestSuite(PersistenceGuarantees.class);
42+
suite.addTestSuite(Shutdown.class);
4243
}
4344
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.rabbitmq.client.test.server;
2+
3+
import com.rabbitmq.client.test.BrokerTestCase;
4+
import com.rabbitmq.client.AMQP;
5+
import com.rabbitmq.client.Channel;
6+
import com.rabbitmq.client.Connection;
7+
8+
import java.io.IOException;
9+
10+
public class Shutdown extends BrokerTestCase {
11+
12+
public void testErrorOnShutdown() throws Exception {
13+
bareRestart();
14+
expectError(AMQP.CONNECTION_FORCED);
15+
}
16+
17+
}

0 commit comments

Comments
 (0)