Control queue type with annotation in JMS tests
This commit is contained in:
parent
d574e66dcc
commit
7d8f83c919
|
@ -21,6 +21,7 @@ import static com.rabbitmq.amqp.tests.jms.TestUtils.protonConnection;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
import com.rabbitmq.amqp.tests.jms.TestUtils.Classic;
|
||||
import com.rabbitmq.qpid.protonj2.client.Client;
|
||||
import com.rabbitmq.qpid.protonj2.client.Delivery;
|
||||
import com.rabbitmq.qpid.protonj2.client.Receiver;
|
||||
|
@ -150,7 +151,7 @@ public class JmsTest {
|
|||
// Test that Request/reply pattern using a TemporaryQueue works.
|
||||
// https://jakarta.ee/specifications/messaging/3.1/jakarta-messaging-spec-3.1#requestreply-pattern-using-a-temporaryqueue-jakarta-ee
|
||||
@Test
|
||||
public void temporary_queue_rpc(Queue requestQueue) throws Exception {
|
||||
public void temporary_queue_rpc(@Classic Queue requestQueue) throws Exception {
|
||||
try (JMSContext clientContext = factory.createContext()) {
|
||||
Destination responseQueue = clientContext.createTemporaryQueue();
|
||||
JMSConsumer clientConsumer = clientContext.createConsumer(responseQueue);
|
||||
|
|
|
@ -20,6 +20,7 @@ import static java.util.Collections.singletonMap;
|
|||
|
||||
import com.rabbitmq.client.amqp.Connection;
|
||||
import com.rabbitmq.client.amqp.Environment;
|
||||
import com.rabbitmq.client.amqp.Management;
|
||||
import com.rabbitmq.client.amqp.impl.AmqpEnvironmentBuilder;
|
||||
import jakarta.jms.ConnectionFactory;
|
||||
import jakarta.jms.Queue;
|
||||
|
@ -55,6 +56,12 @@ final class JmsTestInfrastructureExtension
|
|||
return Queue.class.isAssignableFrom(parameter.getType());
|
||||
}
|
||||
|
||||
private static Management.QueueType queueType(Parameter parameter) {
|
||||
return parameter.isAnnotationPresent(TestUtils.Classic.class)
|
||||
? Management.QueueType.CLASSIC
|
||||
: Management.QueueType.QUORUM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
if (context.getTestMethod().isPresent()) {
|
||||
|
@ -66,7 +73,8 @@ final class JmsTestInfrastructureExtension
|
|||
try (Environment environment = new AmqpEnvironmentBuilder().build();
|
||||
Connection connection =
|
||||
environment.connectionBuilder().uri(TestUtils.brokerUri()).build()) {
|
||||
connection.management().queue(queueName).declare();
|
||||
Management.QueueType type = queueType(parameter);
|
||||
connection.management().queue(queueName).type(type).declare();
|
||||
}
|
||||
store(context).put("queueName", queueName);
|
||||
Context jndiContext = TestUtils.context(singletonMap("queue." + queueName, queueAddress));
|
||||
|
|
|
@ -21,6 +21,7 @@ import static java.lang.String.format;
|
|||
import com.rabbitmq.qpid.protonj2.client.Client;
|
||||
import com.rabbitmq.qpid.protonj2.client.ConnectionOptions;
|
||||
import com.rabbitmq.qpid.protonj2.client.exceptions.ClientException;
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -126,4 +127,9 @@ final class TestUtils {
|
|||
return format(
|
||||
"%s_%s%s", testClass.getSimpleName(), testMethod, uuid.substring(uuid.length() / 2));
|
||||
}
|
||||
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@interface Classic {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue