Skip to content

Commit 830d1be

Browse files
author
Matthew Sackman
committed
Added test - verified that this works if we take the guid gen from bug 21673 and use it here - order is preserved by seq id. This fails if the recovered list is not sorted by seqid, and by guid instead, and also fails if the list comprehensions are wrong, as noticed earlier
1 parent cccb6bf commit 830d1be

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 utf8 = "UTF-8";
8+
private static final String q = "Restart6";
9+
10+
public void testRestart() throws IOException, InterruptedException {
11+
declareDurableQueue(q);
12+
basicPublishPersistent("a".getBytes(utf8), q);
13+
basicPublishPersistent("b".getBytes(utf8), q);
14+
basicPublishPersistent("c".getBytes(utf8), q);
15+
forceSnapshot();
16+
restart();
17+
assertTrue(new String(basicGet(q).getBody(), utf8).equals("a"));
18+
forceSnapshot();
19+
restart();
20+
restart();
21+
assertTrue(new String(basicGet(q).getBody(), utf8).equals("b"));
22+
assertTrue(new String(basicGet(q).getBody(), utf8).equals("c"));
23+
deleteQueue(q);
24+
}
25+
26+
}

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)