Skip to content

Commit 75cbc5d

Browse files
committed
Test x-modulus-hash exchange creation if it is available
RabbitMQ 4.3+. References rabbitmq/rabbitmq-server#15849 References #1918 (cherry picked from commit 9c41e2c)
1 parent 8f08cd8 commit 75cbc5d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ public static boolean isVersion310orLater(Connection connection) {
205205
return atLeastVersion("3.10.0", connection);
206206
}
207207

208+
public static boolean isVersion43orLater(Connection connection) {
209+
return atLeastVersion("4.3.0", connection);
210+
}
211+
208212
private static boolean atLeastVersion(String expectedVersion, Connection connection) {
209213
return atLeastVersion(
210214
expectedVersion,

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.jupiter.api.Assertions.assertEquals;
2020

2121
import java.io.IOException;
22+
import java.util.ArrayList;
2223
import java.util.Arrays;
2324
import java.util.HashMap;
2425
import java.util.List;
@@ -85,11 +86,11 @@ public void releaseResources() throws IOException {
8586
verifyNotEquivalent(NAME, "direct", false, true, null);
8687
}
8788

88-
@Test public void exchangeDeclaredWithEnumerationEquivalentOnNonRecoverableConnection() throws IOException, InterruptedException {
89+
@Test public void exchangeDeclaredWithEnumerationEquivalentOnNonRecoverableConnection() throws IOException {
8990
doTestExchangeDeclaredWithEnumerationEquivalent(channel);
9091
}
9192

92-
@Test public void exchangeDeclaredWithEnumerationEquivalentOnRecoverableConnection() throws IOException, TimeoutException, InterruptedException {
93+
@Test public void exchangeDeclaredWithEnumerationEquivalentOnRecoverableConnection() throws IOException, TimeoutException {
9394
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
9495
connectionFactory.setAutomaticRecoveryEnabled(true);
9596
connectionFactory.setTopologyRecoveryEnabled(false);
@@ -102,13 +103,17 @@ public void releaseResources() throws IOException {
102103

103104
}
104105

105-
private void doTestExchangeDeclaredWithEnumerationEquivalent(Channel channel) throws IOException, InterruptedException {
106+
private void doTestExchangeDeclaredWithEnumerationEquivalent(Channel channel) throws IOException {
106107
// Only test AMQP 0-9-1 standard types; plugin and newer core types
107108
// (e.g. x-modulus-hash, x-local-random) may not be available on the test broker
108109
List<BuiltinExchangeType> standardTypes = Arrays.asList(
109110
BuiltinExchangeType.DIRECT, BuiltinExchangeType.FANOUT,
110111
BuiltinExchangeType.TOPIC, BuiltinExchangeType.HEADERS
111112
);
113+
if (TestUtils.isVersion43orLater(channel.getConnection())) {
114+
standardTypes = new ArrayList<>(standardTypes);
115+
standardTypes.add(BuiltinExchangeType.MODULUS_HASH);
116+
}
112117
for (BuiltinExchangeType exchangeType : standardTypes) {
113118
channel.exchangeDeclare(NAME, exchangeType);
114119
verifyEquivalent(NAME, exchangeType.getType(), false, false, null);

0 commit comments

Comments
 (0)