Skip to content

Commit 0c536e6

Browse files
author
Matthias Radestock
committed
merge bug22628 into default
2 parents cccb6bf + fe622de commit 0c536e6

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,36 @@ protected GetResponse basicGet(String q) throws IOException {
159159
}
160160

161161
protected void basicPublishPersistent(String q) throws IOException {
162-
channel.basicPublish("", q, MessageProperties.PERSISTENT_TEXT_PLAIN, "persistent message".getBytes());
162+
basicPublishPersistent("persistent message".getBytes(), q);
163163
}
164164

165-
protected void basicPublishPersistent(String x, String routingKey) throws IOException {
166-
channel.basicPublish(x, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, "persistent message".getBytes());
165+
protected void basicPublishPersistent(byte[] msg, String q) throws IOException {
166+
basicPublishPersistent(msg, "", q);
167167
}
168168

169+
protected void basicPublishPersistent(String x, String routingKey) throws IOException {
170+
basicPublishPersistent("persistent message".getBytes(), x, routingKey);
171+
}
172+
173+
174+
protected void basicPublishPersistent(byte[] msg, String x, String routingKey) throws IOException {
175+
channel.basicPublish(x, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, msg);
176+
}
177+
169178
protected void basicPublishVolatile(String q) throws IOException {
170-
channel.basicPublish("", q, MessageProperties.TEXT_PLAIN, "not persistent message".getBytes());
179+
basicPublishVolatile("not persistent message".getBytes(), q);
180+
}
181+
182+
protected void basicPublishVolatile(byte[] msg, String q) throws IOException {
183+
basicPublishVolatile(msg, "", q);
171184
}
172185

173186
protected void basicPublishVolatile(String x, String routingKey) throws IOException {
174-
channel.basicPublish(x, routingKey, MessageProperties.TEXT_PLAIN, "not persistent message".getBytes());
187+
basicPublishVolatile("not persistent message".getBytes(), x, routingKey);
188+
}
189+
190+
protected void basicPublishVolatile(byte[] msg, String x, String routingKey) throws IOException {
191+
channel.basicPublish(x, routingKey, MessageProperties.TEXT_PLAIN, msg);
175192
}
176193

177194
protected void declareAndBindDurableQueue(String q, String x, String r) throws IOException {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.rabbitmq.client.test.server;
2+
3+
import java.io.IOException;
4+
5+
public class PersisterRestart6 extends RestartBase {
6+
7+
private static final String q = "Restart6";
8+
9+
public void testRestart() throws IOException, InterruptedException {
10+
declareDurableQueue(q);
11+
basicPublishPersistent("a".getBytes(), q);
12+
basicPublishPersistent("b".getBytes(), q);
13+
basicPublishPersistent("c".getBytes(), q);
14+
forceSnapshot();
15+
restart();
16+
assertTrue(new String(basicGet(q).getBody()).equals("a"));
17+
forceSnapshot();
18+
restart();
19+
restart();
20+
assertTrue(new String(basicGet(q).getBody()).equals("b"));
21+
assertTrue(new String(basicGet(q).getBody()).equals("c"));
22+
deleteQueue(q);
23+
}
24+
25+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public static TestSuite suite() {
4242
suite.addTestSuite(PersisterRestart3.class);
4343
suite.addTestSuite(PersisterRestart4.class);
4444
suite.addTestSuite(PersisterRestart5.class);
45+
suite.addTestSuite(PersisterRestart6.class);
4546
return suite;
4647
}
4748

0 commit comments

Comments
 (0)