use of com.yahoo.athenz.common.messaging.pulsar.client.AthenzPulsarClient.TlsConfig in project athenz by yahoo.
the class PulsarChangeSubscriberTest method test_subscriber_creation.
@Test
public void test_subscriber_creation() throws IOException, InterruptedException {
System.setProperty(PROP_MESSAGING_CLI_SERVICE_URL, "some-service");
PulsarChangeSubscriber<DomainChangeMessage> subscriber = new PulsarChangeSubscriber<>("service-url", "topic", "subs", SubscriptionType.Exclusive, new TlsConfig("cert", "key", "trust"));
assertNotNull(getPulsarConsumer(subscriber));
}
use of com.yahoo.athenz.common.messaging.pulsar.client.AthenzPulsarClient.TlsConfig in project athenz by yahoo.
the class PulsarChangePublisherTest method test_publisher_creation.
@Test
public void test_publisher_creation() {
System.setProperty(PROP_MESSAGING_CLI_SERVICE_URL, "some-service");
PulsarChangePublisher<DomainChangeMessage> publisher = new PulsarChangePublisher<>(serviceUrl(), "some-topic", new TlsConfig("cert", "key", "trust"));
publisher.publish(new DomainChangeMessage());
publisher.close();
assertNotNull(getPulsarProducer(publisher));
System.clearProperty(PROP_MESSAGING_CLI_SERVICE_URL);
}
use of com.yahoo.athenz.common.messaging.pulsar.client.AthenzPulsarClient.TlsConfig in project athenz by yahoo.
the class PulsarChangePublisherTest method test_validate_publisher.
@Test
public void test_validate_publisher() {
try {
new PulsarChangePublisher<>(null, "topic", new TlsConfig("cert", "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid service configured");
}
try {
new PulsarChangePublisher<>("service-url", null, new TlsConfig("cert", "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid topic configured");
}
try {
new PulsarChangePublisher<>("service-url", "topic", new TlsConfig(null, "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid tls configured");
}
try {
new PulsarChangePublisher<>("service-url", "topic", null);
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid tls configured");
}
}
use of com.yahoo.athenz.common.messaging.pulsar.client.AthenzPulsarClient.TlsConfig in project athenz by yahoo.
the class PulsarChangeSubscriberTest method test_validate_subscriber.
@Test
public void test_validate_subscriber() {
try {
new PulsarChangeSubscriber<>("service-url", null, "subs", SubscriptionType.Exclusive, new TlsConfig("cert", "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid topic configured");
}
try {
new PulsarChangeSubscriber<>(null, "topic", "subs", SubscriptionType.Exclusive, new TlsConfig("cert", "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid service configured");
}
try {
new PulsarChangeSubscriber<>("service-url", "topic", null, SubscriptionType.Exclusive, new TlsConfig("cert", "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid subscription name configured");
}
try {
new PulsarChangeSubscriber<>("service-url", "topic", "subs", null, new TlsConfig("cert", "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid subscription type configured");
}
try {
new PulsarChangeSubscriber<>("service-url", "topic", "subs", SubscriptionType.Exclusive, null);
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid tls configured");
}
try {
new PulsarChangeSubscriber<>("service-url", "topic", "subs", SubscriptionType.Exclusive, new TlsConfig(null, "key", "trust"));
fail();
} catch (IllegalArgumentException e) {
assertEquals(e.getMessage(), "invalid tls configured");
}
}
use of com.yahoo.athenz.common.messaging.pulsar.client.AthenzPulsarClient.TlsConfig in project athenz by yahoo.
the class PulsarChangeSubscriberTest method test_subscribe_to_mock_msg.
@Test
public void test_subscribe_to_mock_msg() throws IOException, InterruptedException {
System.setProperty(PROP_MESSAGING_CLI_SERVICE_URL, "some-service");
PulsarChangeSubscriber<DomainChangeMessage> subscriber = new PulsarChangeSubscriber<>("service-url", "topic", "subs", SubscriptionType.Exclusive, new TlsConfig("cert", "key", "trust"));
// init subscriber
subscriber.init(this::assertDomainMessage, DomainChangeMessage.class);
ExecutorService service = Executors.newSingleThreadExecutor();
service.submit(subscriber);
Thread.sleep(500);
subscriber.close();
Consumer<byte[]> pulsarConsumer = getPulsarConsumer(subscriber);
assertNotNull(pulsarConsumer);
ArgumentCaptor<Message<DomainChangeMessage>> messageCapture = ArgumentCaptor.forClass(Message.class);
verify(pulsarConsumer, Mockito.atLeastOnce()).acknowledge(messageCapture.capture());
assertDomainMessage(new ObjectMapper().readValue(messageCapture.getValue().getData(), DomainChangeMessage.class));
System.clearProperty(PROP_MESSAGING_CLI_SERVICE_URL);
}
Aggregations