Search in sources :

Example 1 with ClientParameters

use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.

the class StreamEnvironmentUnitTest method init.

@BeforeEach
void init() {
    AtomicReference<Client.ClientParameters> cpReference = new AtomicReference<>();
    Client.ClientParameters clientParameters = new Client.ClientParameters() {

        @Override
        public Client.ClientParameters shutdownListener(Client.ShutdownListener shutdownListener) {
            StreamEnvironmentUnitTest.this.shutdownListener = shutdownListener;
            return super.shutdownListener(shutdownListener);
        }

        @Override
        Client.ClientParameters duplicate() {
            return cpReference.get();
        }
    };
    cpReference.set(clientParameters);
    mocks = MockitoAnnotations.openMocks(this);
    when(cf.apply(any(Client.ClientParameters.class))).thenReturn(client);
    when(client.getHost()).thenReturn("localhost");
    when(client.getPort()).thenReturn(5552);
    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
    environment = new StreamEnvironment(scheduledExecutorService, clientParameters, Collections.emptyList(), recoveryBackOffDelayPolicy, topologyUpdateBackOffDelayPolicy, host -> host, ProducersCoordinator.MAX_PRODUCERS_PER_CLIENT, ProducersCoordinator.MAX_TRACKING_CONSUMERS_PER_CLIENT, ConsumersCoordinator.MAX_SUBSCRIPTIONS_PER_CLIENT, null, ByteBufAllocator.DEFAULT, false, type -> "locator-connection", cf);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) CsvSource(org.junit.jupiter.params.provider.CsvSource) Arrays(java.util.Arrays) ByteBufAllocator(io.netty.buffer.ByteBufAllocator) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestUtils.latchAssert(com.rabbitmq.stream.impl.TestUtils.latchAssert) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) MockitoAnnotations(org.mockito.MockitoAnnotations) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) StreamException(com.rabbitmq.stream.StreamException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) URI(java.net.URI) LocatorNotAvailableException(com.rabbitmq.stream.impl.StreamEnvironment.LocatorNotAvailableException) Executors(java.util.concurrent.Executors) BackOffDelayPolicy(com.rabbitmq.stream.BackOffDelayPolicy) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) CountDownLatch(java.util.concurrent.CountDownLatch) AfterEach(org.junit.jupiter.api.AfterEach) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Collections(java.util.Collections) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) AtomicReference(java.util.concurrent.atomic.AtomicReference) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ClientParameters

use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.

the class SubEntryBatchingTest method publishConsumeCompressedMessages.

@ParameterizedTest
@MethodSource("compressionCodecFactories")
void publishConsumeCompressedMessages(CompressionCodecFactory compressionCodecFactory, TestInfo info) {
    Map<Compression, Integer> compressionToReadBytes = new HashMap<>();
    for (Compression compression : Compression.values()) {
        int batchCount = 100;
        int messagesInBatch = 30;
        int messageCount = batchCount * messagesInBatch;
        CountDownLatch publishLatch = new CountDownLatch(batchCount);
        Client publisher = cf.get(new ClientParameters().compressionCodecFactory(compressionCodecFactory).publishConfirmListener((publisherId, publishingId) -> publishLatch.countDown()));
        String s = TestUtils.streamName(info) + "_" + compression.name();
        try {
            Response response = publisher.create(s);
            assertThat(response.isOk()).isTrue();
            response = publisher.declarePublisher(b(0), null, s);
            assertThat(response.isOk()).isTrue();
            Set<String> publishedBodies = ConcurrentHashMap.newKeySet(messageCount);
            IntStream.range(0, batchCount).forEach(batchIndex -> {
                MessageBatch messageBatch = new MessageBatch(compression);
                IntStream.range(0, messagesInBatch).forEach(messageIndex -> {
                    String body = "batch " + batchIndex + " message " + messageIndex;
                    messageBatch.add(publisher.messageBuilder().addData(body.getBytes(UTF8)).build());
                    publishedBodies.add(body);
                });
                publisher.publishBatches(b(0), Collections.singletonList(messageBatch));
            });
            assertThat(latchAssert(publishLatch)).completes();
            Set<String> consumedBodies = ConcurrentHashMap.newKeySet(batchCount * messagesInBatch);
            CountDownLatch consumeLatch = new CountDownLatch(batchCount * messagesInBatch);
            CountMetricsCollector metricsCollector = new CountMetricsCollector();
            Client consumer = cf.get(new ClientParameters().compressionCodecFactory(compressionCodecFactory).chunkListener((client, subscriptionId, offset, messageCount1, dataSize) -> client.credit(subscriptionId, 1)).messageListener((subscriptionId, offset, chunkTimestamp, message) -> {
                consumedBodies.add(new String(message.getBodyAsBinary(), UTF8));
                consumeLatch.countDown();
            }).metricsCollector(metricsCollector));
            response = consumer.subscribe(b(1), s, OffsetSpecification.first(), 2);
            assertThat(response.isOk()).isTrue();
            assertThat(latchAssert(consumeLatch)).completes();
            assertThat(consumedBodies).hasSize(messageCount).hasSameSizeAs(publishedBodies);
            publishedBodies.forEach(publishedBody -> assertThat(consumedBodies.contains(publishedBody)).isTrue());
            compressionToReadBytes.put(compression, metricsCollector.readBytes.get());
        } finally {
            Response response = publisher.delete(s);
            assertThat(response.isOk()).isTrue();
        }
    }
    int plainReadBytes = compressionToReadBytes.get(Compression.NONE);
    Arrays.stream(Compression.values()).filter(comp -> comp != Compression.NONE).forEach(compression -> {
        assertThat(compressionToReadBytes.get(compression)).isLessThan(plainReadBytes);
    });
}
Also used : IntStream(java.util.stream.IntStream) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestUtils.latchAssert(com.rabbitmq.stream.impl.TestUtils.latchAssert) CommonsCompressCompressionCodecFactory(com.rabbitmq.stream.compression.CommonsCompressCompressionCodecFactory) HashMap(java.util.HashMap) Response(com.rabbitmq.stream.impl.Client.Response) TestUtils.b(com.rabbitmq.stream.impl.TestUtils.b) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) Charset(java.nio.charset.Charset) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) DefaultCompressionCodecFactory(com.rabbitmq.stream.compression.DefaultCompressionCodecFactory) MethodSource(org.junit.jupiter.params.provider.MethodSource) MetricsCollector(com.rabbitmq.stream.metrics.MetricsCollector) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Compression(com.rabbitmq.stream.compression.Compression) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) TestInfo(org.junit.jupiter.api.TestInfo) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) CompressionCodecFactory(com.rabbitmq.stream.compression.CompressionCodecFactory) Stream(java.util.stream.Stream) Collections(java.util.Collections) OffsetSpecification(com.rabbitmq.stream.OffsetSpecification) Compression(com.rabbitmq.stream.compression.Compression) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Response(com.rabbitmq.stream.impl.Client.Response) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with ClientParameters

use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.

the class OffsetTrackingTest method consumeAndStore.

@ParameterizedTest
@MethodSource
void consumeAndStore(BiConsumer<String, Client> streamCreator, TestInfo info) throws Exception {
    String s = streamName(info);
    int batchSize = 100;
    int batchCount = 1_000;
    int messageCount = batchSize * batchCount;
    CountDownLatch publishLatch = new CountDownLatch(messageCount);
    Client publisher = cf.get(new ClientParameters().publishConfirmListener((publisherId, publishingId) -> publishLatch.countDown()));
    ExecutorService executorService = Executors.newCachedThreadPool();
    try {
        streamCreator.accept(s, publisher);
        byte[] body = new byte[100];
        AtomicInteger messageIdSequence = new AtomicInteger();
        // publishing a bunch of messages
        AtomicLong lastMessageId = new AtomicLong();
        publisher.declarePublisher(b(0), null, s);
        IntStream.range(0, batchCount).forEach(batchIndex -> publisher.publish(b(0), IntStream.range(0, batchSize).map(i -> messageIdSequence.incrementAndGet()).mapToObj(messageId -> {
            lastMessageId.set(messageId);
            return publisher.messageBuilder().addData(body).properties().messageId(messageId).messageBuilder().build();
        }).collect(Collectors.toList())));
        boolean done = publishLatch.await(2, TimeUnit.SECONDS);
        assertThat(done).isTrue();
        Stream<Tuple3<Integer, Integer, String>> testConfigurations = Stream.of(// { storeEvery, consumeCountFirst, reference }
        Tuple.of(100, messageCount / 10, "ref-1"), Tuple.of(50, messageCount / 20, "ref-2"), Tuple.of(10, messageCount / 100, "ref-3"));
        Function<Tuple3<Integer, Integer, String>, Callable<Void>> testConfigurationToTask = testConfiguration -> () -> {
            int storeEvery = testConfiguration._1;
            int consumeCountFirst = testConfiguration._2;
            String reference = testConfiguration._3;
            AtomicInteger consumeCount = new AtomicInteger();
            AtomicLong lastStoredOffset = new AtomicLong();
            AtomicLong lastConsumedMessageId = new AtomicLong();
            AtomicReference<Client> consumerReference = new AtomicReference<>();
            Set<Long> messageIdsSet = ConcurrentHashMap.newKeySet(messageCount);
            Collection<Long> messageIdsCollection = new ConcurrentLinkedQueue<>();
            CountDownLatch consumeLatch = new CountDownLatch(1);
            MessageListener messageListener = (subscriptionId, offset, chunkTimestamp, message) -> {
                if (consumeCount.get() <= consumeCountFirst) {
                    consumeCount.incrementAndGet();
                    long messageId = message.getProperties().getMessageIdAsLong();
                    messageIdsSet.add(messageId);
                    messageIdsCollection.add(messageId);
                    lastConsumedMessageId.set(messageId);
                    if (consumeCount.get() % storeEvery == 0) {
                        consumerReference.get().storeOffset(reference, s, offset);
                        lastStoredOffset.set(offset);
                    }
                } else {
                    consumeLatch.countDown();
                }
            };
            Client consumer = cf.get(new ClientParameters().creditNotification((subscriptionId, responseCode) -> LOGGER.debug("Received notification for subscription {}: {}", subscriptionId, responseCode)).chunkListener((client, subscriptionId, offset, messageCount1, dataSize) -> client.credit(subscriptionId, 1)).messageListener(messageListener));
            consumerReference.set(consumer);
            consumer.subscribe(b(0), s, OffsetSpecification.offset(0), 1);
            assertThat(consumeLatch.await(10, TimeUnit.SECONDS)).isTrue();
            Response response = consumer.unsubscribe(b(0));
            assertThat(response.isOk()).isTrue();
            assertThat(lastStoredOffset.get()).isPositive();
            waitAtMost(5, () -> lastStoredOffset.get() == consumerReference.get().queryOffset(reference, s).getOffset(), () -> "expecting last stored offset to be " + lastStoredOffset + ", but got " + consumerReference.get().queryOffset(reference, s));
            consumer.close();
            CountDownLatch consumeLatchSecondWave = new CountDownLatch(1);
            AtomicLong firstOffset = new AtomicLong(-1);
            messageListener = (subscriptionId, offset, chunkTimestamp, message) -> {
                firstOffset.compareAndSet(-1, offset);
                long messageId = message.getProperties().getMessageIdAsLong();
                if (lastConsumedMessageId.get() < messageId) {
                    messageIdsSet.add(messageId);
                    messageIdsCollection.add(messageId);
                    consumeCount.incrementAndGet();
                    if (message.getProperties().getMessageIdAsLong() == lastMessageId.get()) {
                        consumeLatchSecondWave.countDown();
                    }
                }
            };
            consumer = cf.get(new ClientParameters().chunkListener((client, subscriptionId, offset, messageCount1, dataSize) -> client.credit(subscriptionId, 1)).messageListener(messageListener));
            long offsetToStartFrom = consumer.queryOffset(reference, s).getOffset() + 1;
            consumer.subscribe(b(0), s, OffsetSpecification.offset(offsetToStartFrom), 1);
            assertThat(consumeLatchSecondWave.await(10, TimeUnit.SECONDS)).isTrue();
            // there can be a non-message entry that is skipped and makes
            // the first received message offset higher
            assertThat(firstOffset.get()).isGreaterThanOrEqualTo(offsetToStartFrom);
            response = consumer.unsubscribe(b(0));
            assertThat(response.isOk()).isTrue();
            assertThat(consumeCount.get()).as("check received all messages").isEqualTo(messageCount);
            assertThat(messageIdsCollection).as("check there are no duplicates").hasSameSizeAs(messageIdsSet);
            return null;
        };
        List<Future<Void>> futures = testConfigurations.map(testConfigurationToTask).map(task -> executorService.submit(task)).collect(Collectors.toList());
        forEach(futures, (i, task) -> {
            assertThatNoException().as("task " + i + " failed").isThrownBy(() -> task.get(10, TimeUnit.SECONDS));
        });
    } finally {
        publisher.delete(s);
        executorService.shutdownNow();
    }
}
Also used : IntStream(java.util.stream.IntStream) CsvSource(org.junit.jupiter.params.provider.CsvSource) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) TestUtils.latchAssert(com.rabbitmq.stream.impl.TestUtils.latchAssert) Callable(java.util.concurrent.Callable) Response(com.rabbitmq.stream.impl.Client.Response) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) TestUtils.b(com.rabbitmq.stream.impl.TestUtils.b) TestUtils.streamName(com.rabbitmq.stream.impl.TestUtils.streamName) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) Future(java.util.concurrent.Future) Assertions.assertThatNoException(org.assertj.core.api.Assertions.assertThatNoException) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TestUtils.forEach(com.rabbitmq.stream.impl.TestUtils.forEach) BiConsumer(java.util.function.BiConsumer) QueryOffsetResponse(com.rabbitmq.stream.impl.Client.QueryOffsetResponse) ExecutorService(java.util.concurrent.ExecutorService) MethodSource(org.junit.jupiter.params.provider.MethodSource) TestUtils.waitAtMost(com.rabbitmq.stream.impl.TestUtils.waitAtMost) Tuple(io.vavr.Tuple) Logger(org.slf4j.Logger) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) MessageListener(com.rabbitmq.stream.impl.Client.MessageListener) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) TestInfo(org.junit.jupiter.api.TestInfo) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) Tuple3(io.vavr.Tuple3) TestUtils.responseCode(com.rabbitmq.stream.impl.TestUtils.responseCode) StreamParametersBuilder(com.rabbitmq.stream.impl.Client.StreamParametersBuilder) Constants(com.rabbitmq.stream.Constants) Collections(java.util.Collections) OffsetSpecification(com.rabbitmq.stream.OffsetSpecification) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Set(java.util.Set) MessageListener(com.rabbitmq.stream.impl.Client.MessageListener) Callable(java.util.concurrent.Callable) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Response(com.rabbitmq.stream.impl.Client.Response) QueryOffsetResponse(com.rabbitmq.stream.impl.Client.QueryOffsetResponse) AtomicLong(java.util.concurrent.atomic.AtomicLong) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Tuple3(io.vavr.Tuple3) ExecutorService(java.util.concurrent.ExecutorService) Collection(java.util.Collection) Future(java.util.concurrent.Future) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with ClientParameters

use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.

the class PublisherTest method queryPublisherSequence.

@Test
void queryPublisherSequence() throws Exception {
    String publisherReference = UUID.randomUUID().toString();
    int messageCount = 10_000;
    int duplicatedCount = messageCount / 10;
    AtomicReference<CountDownLatch> publishLatch = new AtomicReference<>();
    Client c = cf.get(new ClientParameters().publishConfirmListener((pubId, publishingId) -> publishLatch.get().countDown()));
    Response response = c.declarePublisher(b(1), publisherReference, stream);
    assertThat(response.isOk()).isTrue();
    AtomicLong publishingSequence = new AtomicLong(0);
    ToLongFunction<Object> publishingSequenceFunction = o -> publishingSequence.incrementAndGet();
    assertThat(c.queryPublisherSequence(publisherReference, stream)).isEqualTo(0);
    publishLatch.set(new CountDownLatch(messageCount));
    IntConsumer publishing = i -> c.publish(b(1), Collections.singletonList(c.messageBuilder().addData("".getBytes()).build()), publishingSequenceFunction);
    IntStream.range(0, messageCount).forEach(publishing);
    assertThat(publishLatch.get().await(10, TimeUnit.SECONDS)).isTrue();
    assertThat(c.queryPublisherSequence(publisherReference, stream)).isEqualTo(publishingSequence.get());
    long previousSequenceValue = publishingSequence.get();
    publishLatch.set(new CountDownLatch(duplicatedCount));
    publishingSequence.addAndGet(-duplicatedCount);
    IntStream.range(0, duplicatedCount).forEach(publishing);
    assertThat(publishLatch.get().await(10, TimeUnit.SECONDS)).isTrue();
    assertThat(c.queryPublisherSequence(publisherReference, stream)).isEqualTo(previousSequenceValue);
    publishLatch.set(new CountDownLatch(messageCount));
    IntStream.range(0, messageCount).forEach(publishing);
    assertThat(publishLatch.get().await(10, TimeUnit.SECONDS)).isTrue();
    assertThat(c.queryPublisherSequence(publisherReference, stream)).isEqualTo(publishingSequence.get());
}
Also used : IntStream(java.util.stream.IntStream) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IntConsumer(java.util.function.IntConsumer) Response(com.rabbitmq.stream.impl.Client.Response) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestUtils.b(com.rabbitmq.stream.impl.TestUtils.b) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ToLongFunction(java.util.function.ToLongFunction) MethodSource(org.junit.jupiter.params.provider.MethodSource) ValueSource(org.junit.jupiter.params.provider.ValueSource) NullAndEmptySource(org.junit.jupiter.params.provider.NullAndEmptySource) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) UUID(java.util.UUID) Arguments(org.junit.jupiter.params.provider.Arguments) TestInfo(org.junit.jupiter.api.TestInfo) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) Constants(com.rabbitmq.stream.Constants) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) OffsetSpecification(com.rabbitmq.stream.OffsetSpecification) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) IntConsumer(java.util.function.IntConsumer) Response(com.rabbitmq.stream.impl.Client.Response) AtomicLong(java.util.concurrent.atomic.AtomicLong) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ClientParameters

use of com.rabbitmq.stream.impl.Client.ClientParameters in project rabbitmq-stream-java-client by rabbitmq.

the class PublisherTest method declarePublisher.

@ParameterizedTest
@NullAndEmptySource
@ValueSource(strings = { "publisher-reference" })
void declarePublisher(String publisherReference) throws Exception {
    int messageCount = 10_000;
    CountDownLatch publishLatch = new CountDownLatch(messageCount);
    CountDownLatch consumerLatch = new CountDownLatch(messageCount);
    Client c = cf.get(new ClientParameters().publishConfirmListener((publisherId, publishingId) -> publishLatch.countDown()).chunkListener((client, subscriptionId, offset, messageCount1, dataSize) -> client.credit(subscriptionId, 1)).messageListener((subscriptionId, offset, chunkTimestamp, message) -> consumerLatch.countDown()));
    Response response = c.declarePublisher(b(1), publisherReference, stream);
    assertThat(response.isOk()).isTrue();
    c.declarePublisher(b(1), null, stream);
    IntStream.range(0, messageCount).forEach(i -> c.publish(b(1), Collections.singletonList(c.messageBuilder().addData("".getBytes()).build())));
    assertThat(publishLatch.await(10, TimeUnit.SECONDS)).isTrue();
    response = c.deletePublisher(b(1));
    assertThat(response.isOk()).isTrue();
    response = c.subscribe(b(1), stream, OffsetSpecification.first(), 10);
    assertThat(response.isOk()).isTrue();
    assertThat(consumerLatch.await(10, TimeUnit.SECONDS)).isTrue();
}
Also used : IntStream(java.util.stream.IntStream) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IntConsumer(java.util.function.IntConsumer) Response(com.rabbitmq.stream.impl.Client.Response) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestUtils.b(com.rabbitmq.stream.impl.TestUtils.b) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ToLongFunction(java.util.function.ToLongFunction) MethodSource(org.junit.jupiter.params.provider.MethodSource) ValueSource(org.junit.jupiter.params.provider.ValueSource) NullAndEmptySource(org.junit.jupiter.params.provider.NullAndEmptySource) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) UUID(java.util.UUID) Arguments(org.junit.jupiter.params.provider.Arguments) TestInfo(org.junit.jupiter.api.TestInfo) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicLong(java.util.concurrent.atomic.AtomicLong) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) Constants(com.rabbitmq.stream.Constants) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) OffsetSpecification(com.rabbitmq.stream.OffsetSpecification) Response(com.rabbitmq.stream.impl.Client.Response) ClientParameters(com.rabbitmq.stream.impl.Client.ClientParameters) CountDownLatch(java.util.concurrent.CountDownLatch) NullAndEmptySource(org.junit.jupiter.params.provider.NullAndEmptySource) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ClientParameters (com.rabbitmq.stream.impl.Client.ClientParameters)19 Test (org.junit.jupiter.api.Test)19 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)13 CountDownLatch (java.util.concurrent.CountDownLatch)12 TestUtils.b (com.rabbitmq.stream.impl.TestUtils.b)11 Collections (java.util.Collections)11 IntStream (java.util.stream.IntStream)11 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)11 OffsetSpecification (com.rabbitmq.stream.OffsetSpecification)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)10 TestInfo (org.junit.jupiter.api.TestInfo)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 Response (com.rabbitmq.stream.impl.Client.Response)8 TestUtils.latchAssert (com.rabbitmq.stream.impl.TestUtils.latchAssert)8 StandardCharsets (java.nio.charset.StandardCharsets)7 Set (java.util.Set)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 AtomicReference (java.util.concurrent.atomic.AtomicReference)7 Stream (java.util.stream.Stream)7