Skip to content

Commit 8ee8865

Browse files
committed
Fix application context test
1 parent a857fe4 commit 8ee8865

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.MD

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
This project involves Kafka consumer and producer, and Postgresql database and a rest-service
22

33
The tests demonstrate:
4-
1. Calling a rest service that adds a message to a (embedded) Kafka topic, where the message consumer writes to a postgresql database
5-
2. Multithreaded usage of postgresql with Spring Data and JPA and locking of rows.
4+
1. Calling a rest service that adds a message to a (embedded) Kafka topic, where the message consumer writes to a postgresql database (setup using Testcontainers)
5+
2. Multithreaded usage of postgresql with Spring Data and JPA and locking of rows.
6+
7+
You need docker installed to run the tests.
68

79
# TODO:
810
Simulate Kafka calls that result in errors in multithreaded environment to test different kinds of kafka settings and guarentees (e.g. exactly once vs at least once processing)

pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<groupId>org.testcontainers</groupId>
5656
<artifactId>postgresql</artifactId>
5757
<version>1.12.5</version>
58+
<scope>test</scope>
5859
</dependency>
5960
<dependency>
6061
<groupId>org.testcontainers</groupId>
@@ -65,6 +66,11 @@
6566
<groupId>org.postgresql</groupId>
6667
<artifactId>postgresql</artifactId>
6768
</dependency>
69+
<dependency>
70+
<groupId>com.h2database</groupId>
71+
<artifactId>h2</artifactId>
72+
<scope>test</scope>
73+
</dependency>
6874
<dependency>
6975
<groupId>org.awaitility</groupId>
7076
<artifactId>awaitility</artifactId>

src/test/java/no/ainiq/kafkademo/KafkademoApplicationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package no.ainiq.kafkademo;
22

33
import org.junit.jupiter.api.Test;
4+
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
45
import org.springframework.boot.test.context.SpringBootTest;
56

67
@SpringBootTest("kafka-enabled=false")
8+
@AutoConfigureTestDatabase
79
class KafkademoApplicationTests {
810

911
@Test

0 commit comments

Comments
 (0)