diff --git a/pom.xml b/pom.xml
index a60bd2fc..49f509b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,15 +61,15 @@
1.11
5.1.0
1.7.30
- 1.2.3
5.7.1
- 3.0.0-M5
+ 3.1.0
2.14.2
2.8.9
1.21
4.0.3
3.1.0
2.0
+ 1.18.3
--add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
@@ -214,6 +214,13 @@
snakeyaml
${snakeyaml.version}
+
+ org.testcontainers
+ testcontainers-bom
+ ${testcontainers.version}
+ pom
+ import
+
@@ -320,9 +327,6 @@ limitations under the License.]]>
${test.additional.args}
false
-
- ${project.basedir}/src/test/resources/logback-test.xml
-
@@ -330,9 +334,6 @@ limitations under the License.]]>
${surefire.version}
false
-
- ${project.basedir}/src/test/resources/logback-test.xml
-
diff --git a/pulsar-jms/pom.xml b/pulsar-jms/pom.xml
index 8670b1af..d2f7c25b 100644
--- a/pulsar-jms/pom.xml
+++ b/pulsar-jms/pom.xml
@@ -88,23 +88,28 @@
test
- ${pulsar.groupId}
- pulsar-broker
+ org.awaitility
+ awaitility
test
- org.apache.curator
- curator-test
+ org.mockito
+ mockito-core
test
- org.awaitility
- awaitility
+ org.slf4j
+ slf4j-simple
test
- org.mockito
- mockito-core
+ org.testcontainers
+ junit-jupiter
+ test
+
+
+ org.testcontainers
+ pulsar
test
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/AcknowledgementModeTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/AcknowledgementModeTest.java
index d6828730..e2858488 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/AcknowledgementModeTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/AcknowledgementModeTest.java
@@ -20,8 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -38,36 +37,20 @@
import javax.jms.TextMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.impl.BatchMessageIdImpl;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
@Timeout(30)
@Slf4j
public class AcknowledgementModeTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
@Test
public void testAUTO_ACKNOWLEDGE() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
connection.start();
@@ -97,8 +80,7 @@ public void testAUTO_ACKNOWLEDGE() throws Exception {
@Test
public void testAUTO_ACKNOWLEDGE_ackReceipt() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map consumerConfig = new HashMap<>();
consumerConfig.put("ackReceiptEnabled", true);
properties.put("consumerConfig", consumerConfig);
@@ -145,8 +127,7 @@ public void onException(Message message, Exception e) {}
@Test
public void testADUPS_OK_ACKNOWLEDGE() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
connection.start();
@@ -176,8 +157,7 @@ public void testADUPS_OK_ACKNOWLEDGE() throws Exception {
@Test()
public void testACLIENT_ACKNOWLEDGE() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
connection.start();
@@ -225,8 +205,7 @@ public void testACLIENT_ACKNOWLEDGE() throws Exception {
@Test
public void testINDIVIDUAL_ACKNOWLEDGE() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
connection.start();
@@ -290,8 +269,7 @@ public void testINDIVIDUAL_ACKNOWLEDGEWithBatchingWithoutBatchIndexAckEnabled()
private void testINDIVIDUAL_ACKNOWLEDGEWithBatching(boolean batchIndexAckEnabled)
throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map producerConfig = new HashMap<>();
producerConfig.put("batchingEnabled", "true");
producerConfig.put("batchingMaxPublishDelayMicros", "1000000");
@@ -403,8 +381,7 @@ public void onException(Message message, Exception e) {}
@Test
public void testAutoNackWrongType() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (JMSContext session = factory.createContext()) {
Queue destination =
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/BasicServerSideFilterTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/BasicServerSideFilterTest.java
index 57bec93c..c27d90c0 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/BasicServerSideFilterTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/BasicServerSideFilterTest.java
@@ -20,8 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.*;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -40,9 +39,7 @@
import org.apache.pulsar.client.api.SubscriptionType;
import org.apache.pulsar.common.policies.data.AutoTopicCreationOverride;
import org.awaitility.Awaitility;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.internal.util.reflection.Whitebox;
@@ -50,35 +47,16 @@
@Slf4j
public class BasicServerSideFilterTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- public BasicServerSideFilterTest() {}
-
- @BeforeAll
- public static void before() throws Exception {
- cluster =
- new PulsarCluster(
- tempDir,
- (config) -> {
- config.setTransactionCoordinatorEnabled(false);
- config.setAllowAutoTopicCreation(false);
- });
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension()
+ .withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "false")
+ .withEnv("PULSAR_PREFIX_allowAutoTopicCreation", "false");
static int refreshServerSideFiltersPeriod = 10;
private Map buildProperties() {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.useServerSideFiltering", "true");
properties.put("jms.refreshServerSideFiltersPeriod", refreshServerSideFiltersPeriod);
@@ -105,15 +83,11 @@ public void downloadSubscriptionProperties(int numPartitions) throws Exception {
String topicName = "topic-with-sub-" + UUID.randomUUID();
String topicName2 = "topic-with-sub-" + UUID.randomUUID();
if (numPartitions > 0) {
- cluster
- .getService()
- .getAdminClient()
- .topics()
- .createPartitionedTopic(topicName, numPartitions);
-
- cluster
- .getService()
- .getAdminClient()
+
+ pulsarContainer.getAdmin().topics().createPartitionedTopic(topicName, numPartitions);
+
+ pulsarContainer
+ .getAdmin()
.namespaces()
.setAutoTopicCreation(
"public/default",
@@ -123,10 +97,9 @@ public void downloadSubscriptionProperties(int numPartitions) throws Exception {
.allowAutoTopicCreation(true)
.build());
} else {
- cluster.getService().getAdminClient().topics().createNonPartitionedTopic(topicName);
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer.getAdmin().topics().createNonPartitionedTopic(topicName);
+ pulsarContainer
+ .getAdmin()
.namespaces()
.setAutoTopicCreation(
"public/default",
@@ -144,9 +117,8 @@ public void downloadSubscriptionProperties(int numPartitions) throws Exception {
subscriptionProperties.put("jms.filtering", "true");
// create a Subscription with a selector
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer
+ .getAdmin()
.topics()
.createSubscription(
topicName, subscriptionName, MessageId.earliest, false, subscriptionProperties);
@@ -172,7 +144,7 @@ public void downloadSubscriptionProperties(int numPartitions) throws Exception {
}
// unload the topic
- cluster.getService().getAdminClient().topics().unload(topicName);
+ pulsarContainer.getAdmin().topics().unload(topicName);
try (PulsarMessageConsumer consumer1 =
session.createSharedDurableConsumer(destination, subscriptionName, null); ) {
@@ -252,9 +224,8 @@ public void downloadSubscriptionProperties(int numPartitions) throws Exception {
subscriptionProperties.put("jms.selector", newSelector);
subscriptionProperties.put("jms.filtering", "true");
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer
+ .getAdmin()
.topics()
.updateSubscriptionProperties(topicName, subscriptionName, subscriptionProperties);
@@ -275,9 +246,8 @@ public void downloadSubscriptionProperties(int numPartitions) throws Exception {
subscriptionProperties.put("jms.selector", newSelector);
subscriptionProperties.put("jms.filtering", "false");
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer
+ .getAdmin()
.topics()
.updateSubscriptionProperties(topicName, subscriptionName, subscriptionProperties);
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConfigurationTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConfigurationTest.java
index bb39673a..4cff3c2b 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConfigurationTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConfigurationTest.java
@@ -17,43 +17,25 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.jms.Queue;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.Producer;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class ConfigurationTest {
-
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
@Test
public void customizeProducerTest() throws Exception {
Map producerConfig = new HashMap<>();
producerConfig.put("producerName", "the-name");
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("producerConfig", producerConfig);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
PulsarConnection connection = factory.createConnection(); ) {
@@ -67,8 +49,7 @@ public void customizeProducerTest() throws Exception {
public void customizeConsumerTest() throws Exception {
Map consumerConfig = new HashMap<>();
consumerConfig.put("consumerName", "the-consumer-name");
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("consumerConfig", consumerConfig);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
PulsarConnection connection = factory.createConnection();
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionConsumerTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionConsumerTest.java
index 6a19194a..e50a858b 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionConsumerTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionConsumerTest.java
@@ -20,12 +20,9 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import com.google.common.collect.ImmutableMap;
-import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -53,36 +50,17 @@
import org.apache.pulsar.common.policies.data.TopicStats;
import org.apache.pulsar.common.util.FutureUtil;
import org.awaitility.Awaitility;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.mockito.internal.util.reflection.Whitebox;
@Slf4j
public class ConnectionConsumerTest {
-
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster =
- new PulsarCluster(
- tempDir,
- c -> {
- c.setTransactionCoordinatorEnabled(false);
- c.setEntryFilterNames(Collections.emptyList());
- });
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension()
+ .withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "false")
+ .withEnv("PULSAR_PREFIX_entryFilterNames", "");
private interface ConnectionConsumerBuilder {
ConnectionConsumer build(
@@ -189,8 +167,7 @@ private void executeTest(
selector,
maxMessages,
maxMessagesLimitParallelism);
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", true);
properties.put("jms.maxMessagesLimitsParallelism", maxMessagesLimitParallelism);
@@ -276,8 +253,7 @@ public void onException(Message message, Exception e) {
Awaitility.await()
.untilAsserted(
() -> {
- TopicStats stats =
- cluster.getService().getAdminClient().topics().getStats(topicName);
+ TopicStats stats = pulsarContainer.getAdmin().topics().getStats(topicName);
assertEquals(0, stats.getBacklogSize());
});
@@ -311,8 +287,7 @@ public void onException(Message message, Exception e) {
public void testStopTimeoutWithMessageDrivenOnMessageCallbackStuck() throws Exception {
long start = System.currentTimeMillis();
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", true);
properties.put("jms.maxMessagesLimitsParallelism", false);
// we should not be stuck even if connectionConsumerStopTimeout is 0
@@ -392,8 +367,7 @@ public ConnectionConsumer build(
public void testStopTimeoutWithSpoolThreadStuck() throws Exception {
long start = System.currentTimeMillis();
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", true);
properties.put("jms.maxMessagesLimitsParallelism", false);
properties.put("jms.connectionConsumerStopTimeout", 2000);
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionPausedTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionPausedTest.java
index d4f6b730..5660419b 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionPausedTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/ConnectionPausedTest.java
@@ -18,9 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
-import java.util.HashMap;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@@ -38,37 +36,21 @@
import javax.jms.Topic;
import lombok.extern.slf4j.Slf4j;
import org.awaitility.Awaitility;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
@Slf4j
public class ConnectionPausedTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
@Test
@Timeout(60)
public void pausedConnectionTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
// DO NOT START THE CONNECTION
@@ -122,8 +104,7 @@ public void pausedConnectionTest() throws Exception {
@Test
@Timeout(60)
public void stopConnectionMustWaitForPendingReceive() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
CountDownLatch beforeReceive = new CountDownLatch(1);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/DeadLetterQueueTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/DeadLetterQueueTest.java
index 6f147a73..5781a79d 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/DeadLetterQueueTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/DeadLetterQueueTest.java
@@ -19,9 +19,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.lang.reflect.Field;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -44,31 +43,18 @@
import org.apache.pulsar.client.impl.BatchMessageIdImpl;
import org.apache.pulsar.client.impl.TopicMessageIdImpl;
import org.awaitility.Awaitility;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@Slf4j
public class DeadLetterQueueTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir, config -> config.setTransactionCoordinatorEnabled(false));
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension()
+ .withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "false");
@Test
public void deadLetterTestForQueue() throws Exception {
@@ -80,8 +66,7 @@ public void deadLetterTestForQueue() throws Exception {
String queueSubscriptionName = "thesub";
String deadLetterTopic = topic + "-" + queueSubscriptionName + "-DLQ";
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.queueSubscriptionName", queueSubscriptionName);
Map consumerConfig = new HashMap<>();
@@ -109,8 +94,7 @@ public void deadLetterTestForTopic() throws Exception {
String topicSubscriptionName = "thesub";
String deadLetterTopic = topic + "-" + topicSubscriptionName + "-DLQ";
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map consumerConfig = new HashMap<>();
properties.put("consumerConfig", consumerConfig);
@@ -135,8 +119,7 @@ public void deadLetterConfigTest() throws Exception {
String topic = "persistent://public/default/test-" + UUID.randomUUID();
String deadLetterTopic = "persistent://public/default/test-dlq-" + UUID.randomUUID();
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map consumerConfig = new HashMap<>();
properties.put("consumerConfig", consumerConfig);
@@ -249,7 +232,7 @@ public void batchingTest(int numPartitions) throws Exception {
String deadLetterTopic;
if (numPartitions > 0) {
- cluster.getService().getAdminClient().topics().createPartitionedTopic(topic, numPartitions);
+ pulsarContainer.getAdmin().topics().createPartitionedTopic(topic, numPartitions);
// multi:topic1,topic2....
deadLetterTopic =
@@ -265,8 +248,7 @@ public void batchingTest(int numPartitions) throws Exception {
}
log.info("deadLetterTopic {}", deadLetterTopic);
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.queueSubscriptionName", queueSubscriptionName);
Map producerConfig = new HashMap<>();
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSAdminTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSAdminTest.java
index 1062e4d7..12e4d21f 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSAdminTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSAdminTest.java
@@ -25,8 +25,7 @@
import com.datastax.oss.pulsar.jms.api.JMSAdmin;
import com.datastax.oss.pulsar.jms.api.JMSDestinationMetadata;
import com.datastax.oss.pulsar.jms.messages.PulsarTextMessage;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -36,42 +35,21 @@
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.Topic;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
public class JMSAdminTest {
-
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster =
- new PulsarCluster(
- tempDir,
- c -> {
- c.setAllowAutoTopicCreation(false);
- });
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension().withEnv("PULSAR_PREFIX_allowAutoTopicCreation", "false");
@ParameterizedTest(name = "numPartitions {0}")
@ValueSource(ints = {0, 4})
public void adminApiForQueues(int numPartitions) throws Exception {
Map producerConfig = new HashMap<>();
producerConfig.put("producerName", "the-name");
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("producerConfig", producerConfig);
String topic = "test-" + UUID.randomUUID();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
@@ -221,8 +199,7 @@ public void adminApiForQueues(int numPartitions) throws Exception {
public void adminApiForTopic(int numPartitions) throws Exception {
Map producerConfig = new HashMap<>();
producerConfig.put("producerName", "the-name");
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("producerConfig", producerConfig);
String topic = "test-" + UUID.randomUUID();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
@@ -377,8 +354,7 @@ public void adminApiForTopic(int numPartitions) throws Exception {
@ValueSource(ints = {0, 4})
public void describeProducers(int numPartitions) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
String topic = "test-" + UUID.randomUUID();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
JMSAdmin admin = factory.getAdmin();
@@ -471,8 +447,7 @@ private static void verifyProducersMetadata(
@ValueSource(ints = {0, 4})
public void describeConsumers(int numPartitions) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
String topic = "test-" + UUID.randomUUID();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
JMSAdmin admin = factory.getAdmin();
@@ -561,8 +536,7 @@ private static void verifyConsumersMetadata(
private static Map buildProducerProperties(
boolean priority, String priorityMapping) {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableJMSPriority", priority);
properties.put("enableTransaction", true);
properties.put("jms.priorityMapping", priorityMapping);
@@ -571,8 +545,7 @@ private static Map buildProducerProperties(
private static Map buildConsumerProperties(String name, boolean priority) {
Map consumerConfig = new HashMap<>();
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("consumerConfig", consumerConfig);
properties.put("jms.enableJMSPriority", priority);
return properties;
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JNDITest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JNDITest.java
index 4de4b3b0..ce03622c 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JNDITest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JNDITest.java
@@ -25,8 +25,7 @@
import com.datastax.oss.pulsar.jms.jndi.PulsarContext;
import com.datastax.oss.pulsar.jms.jndi.PulsarInitialContextFactory;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
@@ -43,29 +42,14 @@
import javax.naming.InvalidNameException;
import javax.naming.Name;
import org.apache.pulsar.client.api.Producer;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
public class JNDITest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
@ParameterizedTest(name = "autoCloseConnectionFactory {0}")
@ValueSource(strings = {"true", "false", ""})
@@ -74,7 +58,7 @@ public void basicJDNITest(String autoCloseConnectionFactory) throws Exception {
Properties properties = new Properties();
properties.setProperty(
Context.INITIAL_CONTEXT_FACTORY, PulsarInitialContextFactory.class.getName());
- properties.setProperty(Context.PROVIDER_URL, cluster.getAddress());
+ properties.setProperty(Context.PROVIDER_URL, pulsarContainer.getHttpServiceUrl());
if (!autoCloseConnectionFactory.isEmpty()) {
properties.setProperty(
@@ -83,7 +67,8 @@ public void basicJDNITest(String autoCloseConnectionFactory) throws Exception {
Map producerConfig = new HashMap<>();
producerConfig.put("producerName", "the-name");
- properties.put("webServiceUrl", cluster.getAddress());
+ properties.put("webServiceUrl", pulsarContainer.getHttpServiceUrl());
+ properties.put("brokerServiceUrl", pulsarContainer.getBrokerUrl());
properties.put("producerConfig", producerConfig);
String queueName = "test-" + UUID.randomUUID();
@@ -153,7 +138,7 @@ public void testSharedContext(String autoCloseConnectionFactory) throws Exceptio
Properties properties = new Properties();
properties.setProperty(
Context.INITIAL_CONTEXT_FACTORY, PulsarInitialContextFactory.class.getName());
- properties.setProperty(Context.PROVIDER_URL, cluster.getAddress());
+ properties.setProperty(Context.PROVIDER_URL, pulsarContainer.getBrokerUrl());
properties.setProperty(PulsarContext.USE_SHARED_JNDICONTEXT, "true");
properties.setProperty(PulsarContext.AUTOCLOSE_CONNECTION_FACTORY, autoCloseConnectionFactory);
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/MessageListenerTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/MessageListenerTest.java
index 991fb4d1..cc6a60f8 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/MessageListenerTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/MessageListenerTest.java
@@ -23,9 +23,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
-import java.util.HashMap;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -49,37 +47,21 @@
import javax.jms.Session;
import javax.jms.TextMessage;
import lombok.extern.slf4j.Slf4j;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@Slf4j
public class MessageListenerTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
@ParameterizedTest(name = "sessionListenersThreads {0}")
@ValueSource(ints = {0, 4})
public void receiveWithListener(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
@@ -114,8 +96,7 @@ public void receiveWithListener(int sessionListenersThreads) throws Exception {
@ValueSource(ints = {0, 4})
public void listenerForbiddenMethods(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
@@ -186,8 +167,7 @@ public void onMessage(Message message) {
@ValueSource(ints = {0, 4})
public void multipleListenersSameSession(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
@@ -233,8 +213,7 @@ public void multipleListenersSameSession(int sessionListenersThreads) throws Exc
@ValueSource(ints = {0, 4})
public void testJMSContextWithListener(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (JMSContext context = factory.createContext()) {
@@ -265,8 +244,7 @@ public void testJMSContextWithListener(int sessionListenersThreads) throws Excep
@ValueSource(ints = {0, 4})
public void testJMSContextWithListenerBadMethods(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
@@ -336,8 +314,7 @@ public void onMessage(Message message) {
public void testJMSContextAsyncCompletionListenerBadMethods(int sessionListenersThreads)
throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
@@ -413,8 +390,7 @@ public void onException(Message message, Exception e) {
@ValueSource(ints = {0, 4})
public void queueSendRecvMessageListenerTest(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
@@ -451,8 +427,7 @@ public void queueSendRecvMessageListenerTest(int sessionListenersThreads) throws
@ValueSource(ints = {0, 4})
public void closeConsumerOnMessageListener(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
@@ -496,8 +471,7 @@ public void onMessage(Message message) {
@ValueSource(ints = {0, 4})
public void messageListenerInternalError(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
@@ -534,8 +508,7 @@ public void onMessage(Message message) {
@ValueSource(ints = {0, 4})
public void closeSessionMessageListenerStops(int sessionListenersThreads) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.sessionListenersThreads", sessionListenersThreads);
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
Connection connection = factory.createConnection();
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoAutoCreateSubscriptionTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoAutoCreateSubscriptionTest.java
index 18220099..3cf0fa43 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoAutoCreateSubscriptionTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoAutoCreateSubscriptionTest.java
@@ -18,9 +18,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
-import java.util.HashMap;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.Map;
import java.util.UUID;
import javax.jms.Connection;
@@ -32,41 +30,22 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.api.MessageId;
import org.apache.pulsar.common.policies.data.TopicStats;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
@Slf4j
public class NoAutoCreateSubscriptionTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster =
- new PulsarCluster(
- tempDir,
- config -> {
- config.setAllowAutoTopicCreation(false);
- config.setAllowAutoSubscriptionCreation(false);
- });
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension()
+ .withEnv("PULSAR_PREFIX_allowAutoTopicCreation", "false")
+ .withEnv("PULSAR_PREFIX_allowAutoSubscriptionCreation", "false");
@Test
public void doNotPrecreateQueueSubscriptionTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.queueSubscriptionName", "default-sub-name");
properties.put("jms.precreateQueueSubscription", "false");
properties.put("operationTimeoutMs", "5000");
@@ -77,7 +56,7 @@ public void doNotPrecreateQueueSubscriptionTest() throws Exception {
try (Session session = connection.createSession(); ) {
String shortTopicName = "test-" + UUID.randomUUID();
- cluster.getService().getAdminClient().topics().createNonPartitionedTopic(shortTopicName);
+ pulsarContainer.getAdmin().topics().createNonPartitionedTopic(shortTopicName);
Queue destinationWithSubscription = session.createQueue(shortTopicName + ":sub1");
@@ -94,9 +73,8 @@ public void doNotPrecreateQueueSubscriptionTest() throws Exception {
}
// manually create the subscription topic:sub1
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer
+ .getAdmin()
.topics()
.createSubscription(shortTopicName, "sub1", MessageId.earliest);
@@ -106,8 +84,7 @@ public void doNotPrecreateQueueSubscriptionTest() throws Exception {
}
// verify that we have 1 subscription
- TopicStats stats =
- cluster.getService().getAdminClient().topics().getStats(shortTopicName);
+ TopicStats stats = pulsarContainer.getAdmin().topics().getStats(shortTopicName);
log.info("Subscriptions {}", stats.getSubscriptions().keySet());
assertNotNull(stats.getSubscriptions().get("sub1"));
}
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoLocalTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoLocalTest.java
index 185cd15f..0fc474b2 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoLocalTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/NoLocalTest.java
@@ -20,8 +20,7 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
-import java.nio.file.Path;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -36,31 +35,15 @@
import javax.jms.Topic;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.api.SubscriptionType;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@Slf4j
public class NoLocalTest {
-
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
private static Stream combinations() {
return Stream.of(
@@ -75,8 +58,7 @@ private static Stream combinations() {
public void sendMessageReceiveFromQueueWithNoLocal(
boolean useServerSideFiltering, boolean enableBatching) throws Exception {
useServerSideFiltering = false;
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", !useServerSideFiltering);
properties.put("jms.useServerSideFiltering", useServerSideFiltering);
Map producerConfig = new HashMap<>();
@@ -122,8 +104,7 @@ public void sendMessageReceiveFromQueueWithNoLocal(
public void sendMessageReceiveFromTopicWithNoLocal(
boolean useServerSideFiltering, boolean enableBatching) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", !useServerSideFiltering);
properties.put("jms.useServerSideFiltering", useServerSideFiltering);
Map producerConfig = new HashMap<>();
@@ -170,8 +151,7 @@ public void sendMessageReceiveFromTopicWithNoLocal(
public void sendMessageReceiveFromExclusiveSubscriptionWithSelector(
boolean useServerSideFiltering, boolean enableBatching) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", !useServerSideFiltering);
properties.put("jms.useServerSideFiltering", useServerSideFiltering);
Map producerConfig = new HashMap<>();
@@ -218,8 +198,7 @@ public void sendMessageReceiveFromExclusiveSubscriptionWithSelector(
@MethodSource("combinations")
public void sendMessageReceiveFromSharedSubscriptionWithNoLocal(
boolean useServerSideFiltering, boolean enableBatching) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", !useServerSideFiltering);
properties.put("jms.useServerSideFiltering", useServerSideFiltering);
Map producerConfig = new HashMap<>();
@@ -282,8 +261,7 @@ public void acknowledgeRejectedMessagesTest(
boolean useServerSideFiltering, boolean enableBatching, boolean acknowledgeRejectedMessages)
throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableClientSideEmulation", !useServerSideFiltering);
properties.put("jms.useServerSideFiltering", useServerSideFiltering);
Map producerConfig = new HashMap<>();
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/OverrideConsumerConfigurationTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/OverrideConsumerConfigurationTest.java
index f94d2501..df37a2f8 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/OverrideConsumerConfigurationTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/OverrideConsumerConfigurationTest.java
@@ -19,9 +19,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import com.google.common.collect.ImmutableMap;
-import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -34,40 +33,21 @@
import javax.jms.Session;
import javax.jms.Topic;
import lombok.extern.slf4j.Slf4j;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
@Slf4j
public class OverrideConsumerConfigurationTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster =
- new PulsarCluster(
- tempDir,
- (config) -> {
- config.setTransactionCoordinatorEnabled(false);
- });
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension()
+ .withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "false");
@Test
public void overrideDQLConfigurationWithJMSContext() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
PulsarJMSContext primaryContext =
(PulsarJMSContext) factory.createContext(JMSContext.CLIENT_ACKNOWLEDGE)) {
@@ -119,8 +99,7 @@ public void overrideDQLConfigurationWithJMSContext() throws Exception {
@Test
public void overrideDQLConfigurationWithSession() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties);
PulsarConnection connection = factory.createConnection();
PulsarSession primarySession = connection.createSession(Session.CLIENT_ACKNOWLEDGE)) {
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PriorityTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PriorityTest.java
index aab9dfcc..2dadad43 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PriorityTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PriorityTest.java
@@ -20,33 +20,30 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
+import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.jms.*;
+import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.common.policies.data.PartitionedTopicStats;
import org.apache.pulsar.common.policies.data.PersistentTopicInternalStats;
import org.apache.pulsar.common.policies.data.TenantInfo;
-import org.apache.pulsar.common.policies.data.TopicType;
import org.apache.pulsar.common.util.FutureUtil;
import org.apache.pulsar.common.util.ObjectMapperFactory;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@@ -60,41 +57,30 @@ public class PriorityTest {
static int LOW_PRIORITY = 4;
static int HIGH_PRIORITY = 9;
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster =
- new PulsarCluster(
- tempDir,
- config -> {
- config.setAllowAutoTopicCreation(true);
- config.setAllowAutoTopicCreationType(TopicType.PARTITIONED);
- config.setDefaultNumPartitions(10);
- config.setTransactionCoordinatorEnabled(false);
- });
- cluster.start();
-
- cluster
- .getService()
- .getAdminClient()
- .tenants()
- .createTenant(
- "foo",
- TenantInfo.builder()
- .allowedClusters(
- ImmutableSet.of(cluster.getService().getConfiguration().getClusterName()))
- .build());
- cluster.getService().getAdminClient().namespaces().createNamespace(SYSTEM_NAMESPACE_OVERRIDDEN);
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer =
+ new PulsarContainerExtension()
+ .withEnv("PULSAR_PREFIX_allowAutoTopicCreation", "true")
+ .withEnv("PULSAR_PREFIX_allowAutoTopicCreationType", "partitioned")
+ .withEnv("PULSAR_PREFIX_defaultNumPartitions", "10")
+ .withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "false")
+ .withOnContainerReady(
+ new Consumer() {
+ @Override
+ @SneakyThrows
+ public void accept(PulsarContainerExtension pulsarContainerExtension) {
+ pulsarContainerExtension
+ .getAdmin()
+ .tenants()
+ .createTenant(
+ "foo",
+ TenantInfo.builder().allowedClusters(ImmutableSet.of("pulsar")).build());
+ pulsarContainerExtension
+ .getAdmin()
+ .namespaces()
+ .createNamespace(SYSTEM_NAMESPACE_OVERRIDDEN);
+ }
+ });
private static Stream combinations() {
return Stream.of(
@@ -108,8 +94,7 @@ private static Stream combinations() {
@MethodSource("combinations")
public void basicTest(int numPartitions, String mapping) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableJMSPriority", true);
properties.put("jms.priorityMapping", mapping);
properties.put("jms.systemNamespace", SYSTEM_NAMESPACE_OVERRIDDEN);
@@ -128,9 +113,8 @@ public void basicTest(int numPartitions, String mapping) throws Exception {
try (Session session = connection.createSession(); ) {
Queue destination = session.createQueue(topicName);
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer
+ .getAdmin()
.topics()
.createPartitionedTopic(factory.getPulsarTopicName(destination), numPartitions);
@@ -204,8 +188,7 @@ public void basicTest(int numPartitions, String mapping) throws Exception {
@ValueSource(strings = {"linear", "non-linear"})
public void basicPriorityBigBacklogTest(String mapping) throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableJMSPriority", true);
properties.put("jms.priorityMapping", mapping);
properties.put(
@@ -221,9 +204,8 @@ public void basicPriorityBigBacklogTest(String mapping) throws Exception {
try (Session session = connection.createSession(Session.AUTO_ACKNOWLEDGE); ) {
Queue destination = session.createQueue("test-" + UUID.randomUUID());
- cluster
- .getService()
- .getAdminClient()
+ pulsarContainer
+ .getAdmin()
.topics()
.createPartitionedTopic(factory.getPulsarTopicName(destination), 10);
@@ -280,11 +262,7 @@ public void onException(Message message, Exception e) {
if (!receivedTexts.add(msg.getText())) {
String topicName = factory.getPulsarTopicName(destination);
PartitionedTopicStats partitionedStats =
- cluster
- .getService()
- .getAdminClient()
- .topics()
- .getPartitionedStats(topicName, true);
+ pulsarContainer.getAdmin().topics().getPartitionedStats(topicName, true);
log.info("topicName {}", topicName);
log.info(
"stats {}",
@@ -292,7 +270,7 @@ public void onException(Message message, Exception e) {
for (int j = 0; j < 10; j++) {
String partition = topicName + "-partition-" + j;
PersistentTopicInternalStats internalStats =
- cluster.getService().getAdminClient().topics().getInternalStats(partition);
+ pulsarContainer.getAdmin().topics().getInternalStats(partition);
log.info("partition {}", partition);
log.info(
@@ -362,8 +340,7 @@ private static void verifyPriorities(List received) throws JMSException
@Test
public void basicPriorityMultiTopicTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableJMSPriority", true);
properties.put("jms.systemNamespace", SYSTEM_NAMESPACE_OVERRIDDEN);
properties.put("consumerConfig", ImmutableMap.of("receiverQueueSize", 10));
@@ -456,8 +433,7 @@ private static void testMultiTopicConsumer(Session session, int numMessages, Que
@Test
public void basicPriorityJMSContextTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
properties.put("jms.enableJMSPriority", true);
properties.put("consumerConfig", ImmutableMap.of("receiverQueueSize", 10));
properties.put(
diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PulsarInteropTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PulsarInteropTest.java
index abd0937e..bfe2dd33 100644
--- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PulsarInteropTest.java
+++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/PulsarInteropTest.java
@@ -18,9 +18,8 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import com.datastax.oss.pulsar.jms.utils.PulsarCluster;
+import com.datastax.oss.pulsar.jms.utils.PulsarContainerExtension;
import java.nio.charset.StandardCharsets;
-import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@ -44,56 +43,43 @@
import org.apache.pulsar.client.api.Schema;
import org.apache.pulsar.common.schema.KeyValue;
import org.apache.pulsar.common.schema.KeyValueEncodingType;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.api.extension.RegisterExtension;
public class PulsarInteropTest {
- @TempDir public static Path tempDir;
- private static PulsarCluster cluster;
-
- @BeforeAll
- public static void before() throws Exception {
- cluster = new PulsarCluster(tempDir);
- cluster.start();
- }
-
- @AfterAll
- public static void after() throws Exception {
- if (cluster != null) {
- cluster.close();
- }
- }
+ @RegisterExtension
+ static PulsarContainerExtension pulsarContainer = new PulsarContainerExtension();
@Test
public void sendFromJMSReceiveFromPulsarClientTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (Connection connection = factory.createConnection()) {
try (Session session = connection.createSession(); ) {
String topic = "persistent://public/default/test-" + UUID.randomUUID();
Destination destination = session.createTopic(topic);
- PulsarClient client =
- cluster
- .getService()
- .getClient(); // do not close this client, it is internal to the broker
-
- try (Consumer consumer =
- client.newConsumer(Schema.STRING).subscriptionName("test").topic(topic).subscribe()) {
-
- try (MessageProducer producer = session.createProducer(destination); ) {
- TextMessage textMsg = session.createTextMessage("foo");
- textMsg.setStringProperty("JMSXGroupID", "bar");
- producer.send(textMsg);
-
- Message receivedMessage = consumer.receive();
- assertEquals("foo", receivedMessage.getValue());
- assertEquals("bar", receivedMessage.getKey());
+ try (PulsarClient client =
+ PulsarClient.builder().serviceUrl(pulsarContainer.getBrokerUrl()).build(); ) {
+
+ try (Consumer consumer =
+ client
+ .newConsumer(Schema.STRING)
+ .subscriptionName("test")
+ .topic(topic)
+ .subscribe()) {
+
+ try (MessageProducer producer = session.createProducer(destination); ) {
+ TextMessage textMsg = session.createTextMessage("foo");
+ textMsg.setStringProperty("JMSXGroupID", "bar");
+ producer.send(textMsg);
+
+ Message receivedMessage = consumer.receive();
+ assertEquals("foo", receivedMessage.getValue());
+ assertEquals("bar", receivedMessage.getKey());
+ }
}
}
}
@@ -104,29 +90,27 @@ public void sendFromJMSReceiveFromPulsarClientTest() throws Exception {
@Test
public void sendFromPulsarClientReceiveWithJMS() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
try (PulsarConnectionFactory factory = new PulsarConnectionFactory(properties); ) {
try (JMSContext context = factory.createContext()) {
String topic = "persistent://public/default/test-" + UUID.randomUUID();
Destination destination = context.createTopic(topic);
- PulsarClient client =
- cluster
- .getService()
- .getClient(); // do not close this client, it is internal to the broker
- try (JMSConsumer consumer = context.createConsumer(destination)) {
-
- try (Producer producer =
- client.newProducer(Schema.STRING).topic(topic).create(); ) {
- producer.newMessage().value("foo").key("bar").send();
-
- // the JMS client reads raw messages always as BytesMessage
- BytesMessage message = (BytesMessage) consumer.receive();
- assertArrayEquals(
- "foo".getBytes(StandardCharsets.UTF_8), message.getBody(byte[].class));
- assertEquals("bar", message.getStringProperty("JMSXGroupID"));
+ try (PulsarClient client =
+ PulsarClient.builder().serviceUrl(pulsarContainer.getBrokerUrl()).build(); ) {
+ try (JMSConsumer consumer = context.createConsumer(destination)) {
+
+ try (Producer producer =
+ client.newProducer(Schema.STRING).topic(topic).create(); ) {
+ producer.newMessage().value("foo").key("bar").send();
+
+ // the JMS client reads raw messages always as BytesMessage
+ BytesMessage message = (BytesMessage) consumer.receive();
+ assertArrayEquals(
+ "foo".getBytes(StandardCharsets.UTF_8), message.getBody(byte[].class));
+ assertEquals("bar", message.getStringProperty("JMSXGroupID"));
+ }
}
}
}
@@ -136,8 +120,7 @@ public void sendFromPulsarClientReceiveWithJMS() throws Exception {
@Test
public void stringSchemaTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map consumerConfig = new HashMap<>();
properties.put("consumerConfig", consumerConfig);
consumerConfig.put("useSchema", true);
@@ -148,19 +131,18 @@ public void stringSchemaTest() throws Exception {
String topic = "persistent://public/default/test-" + UUID.randomUUID();
Destination destination = context.createTopic(topic);
- PulsarClient client =
- cluster
- .getService()
- .getClient(); // do not close this client, it is internal to the broker
- try (JMSConsumer consumer = context.createConsumer(destination)) {
- try (Producer producer =
- client.newProducer(Schema.STRING).topic(topic).create(); ) {
- producer.newMessage().value("foo").key("bar").send();
-
- // the JMS client reads Schema String as TextMessage
- TextMessage message = (TextMessage) consumer.receive();
- assertEquals("foo", message.getText());
- assertEquals("bar", message.getStringProperty("JMSXGroupID"));
+ try (PulsarClient client =
+ PulsarClient.builder().serviceUrl(pulsarContainer.getBrokerUrl()).build(); ) {
+ try (JMSConsumer consumer = context.createConsumer(destination)) {
+ try (Producer producer =
+ client.newProducer(Schema.STRING).topic(topic).create(); ) {
+ producer.newMessage().value("foo").key("bar").send();
+
+ // the JMS client reads Schema String as TextMessage
+ TextMessage message = (TextMessage) consumer.receive();
+ assertEquals("foo", message.getText());
+ assertEquals("bar", message.getStringProperty("JMSXGroupID"));
+ }
}
}
}
@@ -170,8 +152,7 @@ public void stringSchemaTest() throws Exception {
@Test
public void longSchemaTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map consumerConfig = new HashMap<>();
properties.put("consumerConfig", consumerConfig);
consumerConfig.put("useSchema", true);
@@ -182,18 +163,18 @@ public void longSchemaTest() throws Exception {
String topic = "persistent://public/default/test-" + UUID.randomUUID();
Destination destination = context.createTopic(topic);
- PulsarClient client =
- cluster
- .getService()
- .getClient(); // do not close this client, it is internal to the broker
- try (JMSConsumer consumer = context.createConsumer(destination)) {
- try (Producer producer = client.newProducer(Schema.INT64).topic(topic).create(); ) {
- producer.newMessage().value(23432424L).key("bar").send();
-
- // the JMS client reads Schema INT64 as ObjectMessage
- ObjectMessage message = (ObjectMessage) consumer.receive();
- assertEquals(23432424L, message.getObject());
- assertEquals("bar", message.getStringProperty("JMSXGroupID"));
+ try (PulsarClient client =
+ PulsarClient.builder().serviceUrl(pulsarContainer.getBrokerUrl()).build(); ) {
+ try (JMSConsumer consumer = context.createConsumer(destination)) {
+ try (Producer producer =
+ client.newProducer(Schema.INT64).topic(topic).create(); ) {
+ producer.newMessage().value(23432424L).key("bar").send();
+
+ // the JMS client reads Schema INT64 as ObjectMessage
+ ObjectMessage message = (ObjectMessage) consumer.receive();
+ assertEquals(23432424L, message.getObject());
+ assertEquals("bar", message.getStringProperty("JMSXGroupID"));
+ }
}
}
}
@@ -216,8 +197,7 @@ static final class Pojo {
@Test
public void avroSchemaTest() throws Exception {
- Map properties = new HashMap<>();
- properties.put("webServiceUrl", cluster.getAddress());
+ Map properties = pulsarContainer.buildJMSConnectionProperties();
Map consumerConfig = new HashMap<>();
properties.put("consumerConfig", consumerConfig);
consumerConfig.put("useSchema", true);
@@ -228,42 +208,41 @@ public void avroSchemaTest() throws Exception {
String topic = "persistent://public/default/test-" + UUID.randomUUID();
Destination destination = context.createTopic(topic);
- PulsarClient client =
- cluster
- .getService()
- .getClient(); // do not close this client, it is internal to the broker
- try (JMSConsumer consumer = context.createConsumer(destination)) {
- try (Producer producer =
- client.newProducer(Schema.AVRO(Pojo.class)).topic(topic).create(); ) {
- Pojo pojo = new Pojo();
- pojo.setName("foo");
- Nested nested = new Nested();
- nested.setAge(23);
-
- Pojo pojo2 = new Pojo();
- pojo2.setName("foo2");
- nested.setPojo(pojo2);
-
- pojo.setNested(nested);
- pojo.setNestedList(Arrays.asList(nested));
- producer.newMessage().value(pojo).key("bar").send();
-
- // the JMS client reads Schema AVRO as TextMessage
- MapMessage message = (MapMessage) consumer.receive();
- assertEquals("foo", message.getString("name"));
- Map nestedValue = (Map) message.getObject("nested");
- assertEquals(23, nestedValue.get("age"));
- assertEquals("bar", message.getStringProperty("JMSXGroupID"));
- Map nestedPojo = (Map) nestedValue.get("pojo");
- assertEquals("foo2", nestedPojo.get("name"));
-
- List