aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/dcae/common/publishing/DMaapContainer.java8
-rw-r--r--src/test/java/org/onap/dcae/common/publishing/PublisherTest.java16
2 files changed, 18 insertions, 6 deletions
diff --git a/src/test/java/org/onap/dcae/common/publishing/DMaapContainer.java b/src/test/java/org/onap/dcae/common/publishing/DMaapContainer.java
index 404b0ed7..8e1652ad 100644
--- a/src/test/java/org/onap/dcae/common/publishing/DMaapContainer.java
+++ b/src/test/java/org/onap/dcae/common/publishing/DMaapContainer.java
@@ -4,6 +4,7 @@
* =========================================================
* Copyright (C) 2019-2021 Nokia. All rights reserved.
* Copyright (C) 2023 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2023 Deutsche Telekom Intellectual Property. All rights reserved.
* =========================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +26,7 @@ import org.onap.dcae.FileReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.DockerComposeContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
import java.io.File;
import java.net.URI;
@@ -34,8 +36,8 @@ import java.net.URL;
final class DMaapContainer {
private static final String MR_COMPOSE_RESOURCE_NAME = "dmaap-msg-router/message-router-compose.yml";
private static final String DOCKER_COMPOSE_FILE_PATH = getDockerComposeFilePath(MR_COMPOSE_RESOURCE_NAME);
- static final int DMAAP_SERVICE_EXPOSED_PORT = 3904;
- static final String DMAAP_SERVICE_NAME = "onap-dmaap";
+ static final int KAFKA_SERVICE_EXPOSED_PORT = 9092;
+ static final String KAFKA_SERVICE_NAME = "kafka";
private static final Logger log = LoggerFactory.getLogger(DMaapContainer.class);
private DMaapContainer() {}
@@ -51,7 +53,7 @@ final class DMaapContainer {
}
return new DockerComposeContainer(
new File(dockercomposeuri.getPath()))
- .withExposedService(DMAAP_SERVICE_NAME, DMAAP_SERVICE_EXPOSED_PORT)
+ .withExposedService(KAFKA_SERVICE_NAME, KAFKA_SERVICE_EXPOSED_PORT, Wait.forListeningPort())
.withLocalCompose(true);
}
diff --git a/src/test/java/org/onap/dcae/common/publishing/PublisherTest.java b/src/test/java/org/onap/dcae/common/publishing/PublisherTest.java
index be768941..134788b2 100644
--- a/src/test/java/org/onap/dcae/common/publishing/PublisherTest.java
+++ b/src/test/java/org/onap/dcae/common/publishing/PublisherTest.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2021 Nokia. All rights reserved.
* Copyright (C) 2023 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2023 Deutsche Telekom Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +25,7 @@ import com.google.gson.JsonElement;
import io.vavr.collection.List;
import io.vavr.control.Option;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.Assume;
import org.junit.Before;
@@ -34,19 +36,25 @@ import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
+import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
+import uk.org.webcompere.systemstubs.jupiter.SystemStub;
+import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
import java.time.Duration;
import static org.onap.dcae.common.publishing.DMaapContainer.createContainerInstance;
import static org.onap.dcae.common.publishing.DmaapRequestConfiguration.getAsJsonElements;
-
+@ExtendWith(SystemStubsExtension.class)
@Testcontainers(disabledWithoutDocker = true)
public class PublisherTest {
-
+
+ @SystemStub
+ EnvironmentVariables environmentVariables = new EnvironmentVariables();
+
@Container
private final DockerComposeContainer CONTAINER = createContainerInstance();
-
+
@Before
public void linuxOnly() {
Assume.assumeFalse
@@ -56,6 +64,8 @@ public class PublisherTest {
@Test
public void publishEvent_shouldSuccessfullyPublishSingleMessage() {
//given
+ environmentVariables
+ .set("BOOTSTRAP_SERVERS", "localhost:9092");
final Publisher publisher = new Publisher();
final String simpleEvent = "{\"message\":\"message1\"}";
final List<String> twoJsonMessages = List.of(simpleEvent);