From 54097233e6a2b5be60c200d8e3a86cba5f3e6601 Mon Sep 17 00:00:00 2001 From: Enrico Olivelli Date: Thu, 11 Apr 2024 11:38:13 +0200 Subject: [PATCH] clean up --- .../oss/pulsar/jms/selectors/JMSPublishFilters.java | 7 +++++-- .../oss/pulsar/jms/JMSPublishFiltersTest.java | 3 ++- .../pulsar/jms/utils/PulsarContainerExtension.java | 12 +++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pulsar-jms-filters/src/main/java/com/datastax/oss/pulsar/jms/selectors/JMSPublishFilters.java b/pulsar-jms-filters/src/main/java/com/datastax/oss/pulsar/jms/selectors/JMSPublishFilters.java index 6abff26e..a2f5975c 100644 --- a/pulsar-jms-filters/src/main/java/com/datastax/oss/pulsar/jms/selectors/JMSPublishFilters.java +++ b/pulsar-jms-filters/src/main/java/com/datastax/oss/pulsar/jms/selectors/JMSPublishFilters.java @@ -46,10 +46,13 @@ public class JMSPublishFilters implements BrokerInterceptor { private boolean enabled = false; @Override - public void initialize(PulsarService pulsarService) throws Exception { + public void initialize(PulsarService pulsarService) { enabled = Boolean.parseBoolean( - pulsarService.getConfiguration().getProperty("jmsApplyFiltersOnPublish") + ""); + pulsarService + .getConfiguration() + .getProperties() + .getProperty("jmsApplyFiltersOnPublish", "true")); log.info("jmsApplyFiltersOnPublish={}", enabled); } diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSPublishFiltersTest.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSPublishFiltersTest.java index 3f111f2c..117b6e84 100644 --- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSPublishFiltersTest.java +++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/JMSPublishFiltersTest.java @@ -43,7 +43,8 @@ public class JMSPublishFiltersTest { .withEnv("PULSAR_PREFIX_transactionCoordinatorEnabled", "false") .withEnv("PULSAR_PREFIX_brokerInterceptorsDirectory", "/pulsar/interceptors") .withEnv("PULSAR_PREFIX_brokerInterceptors", "jms-publish-filters") - .withEnv("PULSAR_LOG_LEVEL", "info"); + .withEnv("PULSAR_PREFIX_jmsApplyFiltersOnPublish", "true") + .withLogContainerOutput(true); private Map buildProperties() { Map properties = pulsarContainer.buildJMSConnectionProperties(); diff --git a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/utils/PulsarContainerExtension.java b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/utils/PulsarContainerExtension.java index 52fd1d7a..02d37bd0 100644 --- a/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/utils/PulsarContainerExtension.java +++ b/pulsar-jms/src/test/java/com/datastax/oss/pulsar/jms/utils/PulsarContainerExtension.java @@ -43,6 +43,7 @@ public class PulsarContainerExtension implements BeforeAllCallback, AfterAllCall private Network network; private PulsarAdmin admin; + private boolean logContainerOutput = false; public PulsarContainerExtension() { env.put("PULSAR_PREFIX_acknowledgmentAtBatchIndexLevelEnabled", "true"); @@ -85,7 +86,11 @@ public void beforeAll(ExtensionContext extensionContext) { if (text.contains("messaging service is ready")) { pulsarReady.countDown(); } - log.info(text); + if (logContainerOutput) { + log.info(text); + } else { + log.debug(text); + } }) .withCopyFileToContainer( MountableFile.forHostPath("target/classes/filters"), "/pulsar/filters") @@ -109,6 +114,11 @@ public PulsarContainerExtension withOnContainerReady( return this; } + public PulsarContainerExtension withLogContainerOutput(boolean logContainerOutput) { + this.logContainerOutput = logContainerOutput; + return this; + } + public PulsarContainerExtension withEnv(String key, String value) { this.env.put(key, value); return this;