Skip to content

Commit 89c543e

Browse files
committed
Generate resource names for each test method
1 parent ca30d3d commit 89c543e

File tree

2 files changed

+28
-21
lines changed

2 files changed

+28
-21
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.rabbitmq.client.Channel;
3131
import com.rabbitmq.client.GetResponse;
3232
import com.rabbitmq.client.QueueingConsumer;
33+
import org.junit.jupiter.api.BeforeEach;
3334

3435
/**
3536
* This tests whether bindings are created and nuked properly.
@@ -41,12 +42,18 @@
4142
*
4243
*/
4344
public class BindingLifecycleBase extends ClusteredTestBase {
44-
protected static final String K = "K-" + System.currentTimeMillis();
4545
protected static final int N = 1;
46-
protected static final String Q = "Q-" + System.currentTimeMillis();
47-
protected static final String X = "X-" + System.currentTimeMillis();
4846
protected static final byte[] payload = ("" + System.currentTimeMillis()).getBytes();
4947

48+
protected String q, x, k;
49+
50+
@BeforeEach
51+
void initNames() {
52+
this.q = generateQueueName();
53+
this.x = generateExchangeName();
54+
this.k = "K-" + System.currentTimeMillis();
55+
}
56+
5057
protected static String randomString() {
5158
return "-" + System.nanoTime();
5259
}

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,28 @@ private void restartPrimary() throws IOException, TimeoutException {
6464
* Tests whether durable bindings are correctly recovered.
6565
*/
6666
@Test public void durableBindingRecovery() throws IOException, TimeoutException {
67-
declareDurableTopicExchange(X);
68-
declareAndBindDurableQueue(Q, X, K);
67+
declareDurableTopicExchange(x);
68+
declareAndBindDurableQueue(q, x, k);
6969

7070
restart();
7171

7272
for (int i = 0; i < N; i++) {
73-
basicPublishVolatile(X, K);
73+
basicPublishVolatile(x, k);
7474
}
7575

7676
AtomicInteger receivedCount = new AtomicInteger(0);
7777
waitAtMost(() -> {
7878
GetResponse r;
79-
r = basicGet(Q);
79+
r = basicGet(q);
8080
if (r != null) {
8181
assertThat(r.getEnvelope().isRedeliver()).isFalse();
8282
receivedCount.incrementAndGet();
8383
}
8484
return receivedCount.get() == N;
8585
});
8686

87-
deleteQueue(Q);
88-
deleteExchange(X);
87+
deleteQueue(q);
88+
deleteExchange(x);
8989
}
9090

9191
/**
@@ -106,24 +106,24 @@ private void restartPrimary() throws IOException, TimeoutException {
106106
* verify that the durable routes have been turfed.
107107
*/
108108
@Test public void durableBindingsDeletion() throws IOException, TimeoutException {
109-
declareDurableTopicExchange(X);
110-
declareAndBindDurableQueue(Q, X, K);
109+
declareDurableTopicExchange(x);
110+
declareAndBindDurableQueue(q, x, k);
111111

112-
deleteExchange(X);
112+
deleteExchange(x);
113113

114114
restart();
115115

116-
declareDurableTopicExchange(X);
116+
declareDurableTopicExchange(x);
117117

118118
for (int i = 0; i < N; i++) {
119-
basicPublishVolatile(X, K);
119+
basicPublishVolatile(x, k);
120120
}
121121

122-
GetResponse response = channel.basicGet(Q, true);
122+
GetResponse response = channel.basicGet(q, true);
123123
assertNull(response, "The initial response SHOULD BE null");
124124

125-
deleteQueue(Q);
126-
deleteExchange(X);
125+
deleteQueue(q);
126+
deleteExchange(x);
127127
}
128128

129129

@@ -135,15 +135,15 @@ private void restartPrimary() throws IOException, TimeoutException {
135135
* publish a message to it using the queue name as a routing key
136136
*/
137137
@Test public void defaultBindingRecovery() throws IOException, TimeoutException {
138-
declareDurableQueue(Q);
138+
declareDurableQueue(q);
139139

140140
restart();
141141

142-
basicPublishVolatile("", Q);
142+
basicPublishVolatile("", q);
143143

144-
waitAtMost(() -> channel.basicGet(Q, true) != null);
144+
waitAtMost(() -> channel.basicGet(q, true) != null);
145145

146-
deleteQueue(Q);
146+
deleteQueue(q);
147147
}
148148

149149
/**

0 commit comments

Comments
 (0)