![JAR search and dependency download from the Maven repository](/logo.png)
com.wl4g.infra.common.tests.integration.manager.AssertionITContainerManager Maven / Gradle / Ivy
/**
* Copyright (C) 2023 ~ 2035 the original authors WL4G (James Wong).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wl4g.infra.common.tests.integration.manager;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
import org.apache.rocketmq.common.message.MessageExt;
import org.junit.jupiter.api.Assertions;
import javax.annotation.Nullable;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.function.Consumer;
import java.util.function.Function;
import static com.wl4g.infra.common.serialize.JacksonUtils.parseToNode;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.err;
import static java.util.Collections.singletonList;
import static java.util.Objects.nonNull;
/**
* The {@link AssertionITContainerManager}
*
* @author James Wong
* @since v3.1
**/
@SuppressWarnings({"unused"})
public abstract class AssertionITContainerManager extends GenericITContainerManager {
public AssertionITContainerManager(Class> testClass) {
super(testClass);
}
// --------------------- MQ consuming Assertion Runners --------------
@SuppressWarnings("all")
public Runnable buildKafkaConsumingAssertionRunner(@NotNull CountDownLatch latch,
@NotBlank String kafkaServers,
@NotBlank String topic,
@NotBlank String groupId,
@Nullable Properties overrideProps,
@Min(1) int timeoutSeconds,
@NotNull Function collector,
@Min(1) int exitConsumedThreshold,
@NotNull Consumer