Skip to content

Commit

Permalink
Chore/debug jms producer test (springwolf#860)
Browse files Browse the repository at this point in the history
* chore: improve logging in ProducerSystemTest

* chore: log test output to console
  • Loading branch information
timonback authored and ruskaof committed Nov 20, 2024
1 parent c72c628 commit cbde9d7
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
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
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

0 comments on commit cbde9d7

Please sign in to comment.