Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/debug jms producer test #860

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ allprojects {

useJUnitPlatform()
testLogging {
// showStandardStreams = true
showStandardStreams = true

events "skipped", "failed"
exceptionFormat = 'full'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.springwolf.examples.amqp.consumers.ExampleConsumer;
import io.github.springwolf.examples.amqp.dtos.ExamplePayloadDto;
import io.github.springwolf.plugins.amqp.producer.SpringwolfAmqpProducer;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -42,8 +43,10 @@
@DirtiesContext
@TestMethodOrder(OrderAnnotation.class)
@TestPropertySource(properties = {"spring.rabbitmq.host=localhost"})
@Slf4j
// @Ignore("Uncomment this line if you have issues running this test on your local machine.")
public class ProducerSystemTest {
private static final String AMQP_NAME = "amqp";

@Autowired
SpringwolfAmqpProducer springwolfAmqpProducer;
Expand All @@ -52,8 +55,9 @@ public class ProducerSystemTest {
ExampleConsumer exampleConsumer;

@Container
public static DockerComposeContainer<?> environment =
new DockerComposeContainer<>(new File("docker-compose.yml")).withServices("amqp");
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withServices(AMQP_NAME)
.withLogConsumer(AMQP_NAME, l -> log.debug("amqp: {}", l.getUtf8StringWithoutLineEnding()));

@Test
@Order(1)
Expand Down
3 changes: 3 additions & 0 deletions springwolf-examples/springwolf-jms-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ dependencies {

testImplementation "org.testcontainers:testcontainers:${testcontainersVersion}"
testImplementation "org.testcontainers:junit-jupiter:${testcontainersVersion}"

testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
testCompileOnly "org.projectlombok:lombok:${lombokVersion}"
}

docker {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.examples.jms;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.web.client.RestTemplate;
import org.testcontainers.containers.DockerComposeContainer;
Expand All @@ -23,6 +24,7 @@
* the setup uses a full docker-compose context with a real jms instance.
*/
@Testcontainers
@Slf4j
// @Ignore("Uncomment this line if you have issues running this test on your local machine.")
public class ApiSystemTest {

Expand All @@ -43,9 +45,10 @@ public class ApiSystemTest {
}

@Container
public DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV);
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));

private String baseUrl() {
String host = environment.getServiceHost(APP_NAME, APP_PORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.github.springwolf.examples.jms.consumers.ExampleConsumer;
import io.github.springwolf.examples.jms.dtos.ExamplePayloadDto;
import io.github.springwolf.plugins.jms.producer.SpringwolfJmsProducer;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -34,8 +35,10 @@
@Testcontainers
@DirtiesContext
@TestMethodOrder(OrderAnnotation.class)
@Slf4j
// @Ignore("Uncomment this line if you have issues running this test on your local machine.")
public class ProducerSystemTest {
private static final String APP_JMS = "activemq";

@Autowired
SpringwolfJmsProducer springwolfJmsProducer;
Expand All @@ -45,8 +48,9 @@ public class ProducerSystemTest {

@Container
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withServices("activemq")
.waitingFor("activemq", Wait.forLogMessage(".*Artemis Console available.*", 1));
.withServices(APP_JMS)
.withLogConsumer(APP_JMS, l -> log.debug("jms: {}", l.getUtf8StringWithoutLineEnding()))
.waitingFor(APP_JMS, Wait.forLogMessage(".*Artemis Console available.*", 1));

@Test
@Order(2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.github.springwolf.examples.kafka.dtos.ExamplePayloadDto;
import io.github.springwolf.plugins.kafka.configuration.properties.SpringwolfKafkaConfigProperties;
import io.github.springwolf.plugins.kafka.producer.SpringwolfKafkaProducer;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.admin.KafkaAdminClient;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
Expand Down Expand Up @@ -48,8 +49,11 @@
@Testcontainers
@TestPropertySource(properties = {"spring.kafka.bootstrap-servers=localhost:9092"})
@TestMethodOrder(OrderAnnotation.class)
@Slf4j
// @Ignore("Uncomment this line if you have issues running this test on your local machine.")
public class ProducerSystemTest {
private static final String KAFKA_NAME = "kafka";

private static final boolean USE_SCHEMA_REGISTRY = false;

@Autowired
Expand All @@ -69,7 +73,8 @@ public class ProducerSystemTest {

@Container
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withServices("kafka", USE_SCHEMA_REGISTRY ? "kafka-schema-registry" : "");
.withServices(KAFKA_NAME, USE_SCHEMA_REGISTRY ? "kafka-schema-registry" : "")
.withLogConsumer(KAFKA_NAME, l -> log.debug("kafka: {}", l.getUtf8StringWithoutLineEnding()));

@Test
@Order(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ApiSystemTest {
}

@Container
public DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ApiSystemTest {
}

@Container
public DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
@Slf4j
// @Ignore("Uncomment this line if you have issues running this test on your local machine.")
public class ProducerSystemTest {
private static final String LOCALSTACK_NAME = "localstack";

@Autowired
SpringwolfSqsProducer springwolfSqsProducer;
Expand All @@ -60,10 +61,10 @@ public class ProducerSystemTest {

@Container
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withOptions()
.withEnv(ENV)
.withLogConsumer("localstack", l -> log.debug("localstack: {}", l.getUtf8StringWithoutLineEnding()))
.waitingFor("localstack", Wait.forLogMessage(".*Ready.*", 1));
.withServices(LOCALSTACK_NAME)
.withLogConsumer(LOCALSTACK_NAME, l -> log.debug("localstack: {}", l.getUtf8StringWithoutLineEnding()))
.waitingFor(LOCALSTACK_NAME, Wait.forLogMessage(".*Ready.*", 1));

@Test
void producerCanUseSpringwolfConfigurationToSendMessage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class ApiSystemTest {
}

@Container
public DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
public static DockerComposeContainer<?> environment = new DockerComposeContainer<>(new File("docker-compose.yml"))
.withExposedService(APP_NAME, APP_PORT)
.withEnv(ENV)
.withLogConsumer(APP_NAME, l -> log.debug("APP: {}", l.getUtf8StringWithoutLineEnding()));
Expand Down