use of com.yahoo.athenz.common.messaging.DomainChangeMessage 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