18
18
*/
19
19
package org .kie .kogito .springboot .outbox ;
20
20
21
+ import java .nio .file .Path ;
22
+ import java .nio .file .Paths ;
21
23
import java .time .Duration ;
22
24
import java .util .Set ;
23
25
import java .util .concurrent .CountDownLatch ;
24
26
import java .util .concurrent .TimeUnit ;
25
27
import java .util .function .Consumer ;
26
28
29
+ import org .junit .jupiter .api .AfterEach ;
30
+ import org .junit .jupiter .api .BeforeEach ;
27
31
import org .junit .jupiter .api .Disabled ;
28
32
import org .junit .jupiter .api .Test ;
29
33
import org .kie .kogito .test .springboot .kafka .KafkaTestClient ;
30
34
import org .slf4j .Logger ;
31
35
import org .slf4j .LoggerFactory ;
32
- import org .testcontainers .containers .DockerComposeContainer ;
36
+ import org .testcontainers .containers .ComposeContainer ;
33
37
import org .testcontainers .containers .output .OutputFrame ;
34
38
import org .testcontainers .containers .output .Slf4jLogConsumer ;
39
+ import org .testcontainers .containers .wait .strategy .Wait ;
40
+ import org .testcontainers .junit .jupiter .Container ;
41
+ import org .testcontainers .junit .jupiter .Testcontainers ;
35
42
36
43
import com .jayway .jsonpath .JsonPath ;
37
44
42
49
import static org .hamcrest .Matchers .hasSize ;
43
50
import static org .junit .jupiter .api .Assertions .assertTrue ;
44
51
45
- // @Testcontainers
52
+ @ Testcontainers
46
53
public class OutboxIT {
47
54
48
55
private static final Logger LOGGER = LoggerFactory .getLogger (OutboxIT .class );
@@ -55,8 +62,8 @@ public class OutboxIT {
55
62
private static final int KAFKA_PORT = 9092 ;
56
63
private static final int DEBEZIUM_PORT = 8083 ;
57
64
58
- // @Container
59
- private static DockerComposeContainer <?> COMPOSE ;
65
+ @ Container
66
+ private static ComposeContainer COMPOSE ;
60
67
61
68
private int kogitoPort ;
62
69
private int debeziumPort ;
@@ -65,41 +72,39 @@ public class OutboxIT {
65
72
private KafkaTestClient kafkaClient ;
66
73
67
74
static {
68
- // Path path = Paths.get("../../docker-compose.yml");
69
- // if (!path.toFile().exists()) {
70
- // path = Paths.get("docker-compose.yml");
71
- // }
72
- // COMPOSE = new DockerComposeContainer<>(path.toFile());
73
- // COMPOSE.withPull(false);
74
- // COMPOSE.withServices("kafka", "mongodb", "connect", "sidecar", "kogito");
75
- // COMPOSE.withExposedService("kogito", KOGITO_PORT);
76
- // COMPOSE.withExposedService("kafka", KAFKA_PORT);
77
- // COMPOSE.withExposedService("connect", DEBEZIUM_PORT);
78
- // COMPOSE.withLogConsumer("kafka", logger());
79
- // COMPOSE.withLogConsumer("connect", logger());
80
- // COMPOSE.withLogConsumer("sidecar", logger());
81
- // COMPOSE.withLogConsumer("kogito", logger());
82
- // COMPOSE.waitingFor("kafka", Wait.forListeningPort());
83
- // COMPOSE.waitingFor("sidecar", Wait.forListeningPort());
84
- // COMPOSE.waitingFor("kogito", Wait.forListeningPort());
85
- // COMPOSE.withLocalCompose(true);
86
- // //See https://github.com/testcontainers/testcontainers-java/issues/4565
87
- // COMPOSE.withOptions("--compatibility");
75
+ Path path = Paths .get ("../../docker-compose.yml" );
76
+ if (!path .toFile ().exists ()) {
77
+ path = Paths .get ("docker-compose.yml" );
78
+ }
79
+ COMPOSE = new ComposeContainer (path .toFile ());
80
+ COMPOSE .withPull (false );
81
+ COMPOSE .withServices ("kafka" , "mongodb" , "connect" , "sidecar" , "kogito" );
82
+ COMPOSE .withExposedService ("kogito" , KOGITO_PORT );
83
+ COMPOSE .withExposedService ("kafka" , KAFKA_PORT );
84
+ COMPOSE .withExposedService ("connect" , DEBEZIUM_PORT );
85
+ COMPOSE .withLogConsumer ("kafka" , logger ());
86
+ COMPOSE .withLogConsumer ("connect" , logger ());
87
+ COMPOSE .withLogConsumer ("sidecar" , logger ());
88
+ COMPOSE .withLogConsumer ("kogito" , logger ());
89
+ COMPOSE .waitingFor ("kafka" , Wait .forListeningPort ());
90
+ COMPOSE .waitingFor ("sidecar" , Wait .forListeningPort ());
91
+ COMPOSE .waitingFor ("kogito" , Wait .forListeningPort ());
92
+ COMPOSE .withLocalCompose (true );
88
93
}
89
94
90
95
private static Consumer <OutputFrame > logger () {
91
96
return new Slf4jLogConsumer (LOGGER );
92
97
}
93
98
94
- // @BeforeEach
99
+ @ BeforeEach
95
100
void setup () {
96
101
kogitoPort = COMPOSE .getServicePort ("kogito" , KOGITO_PORT );
97
102
debeziumPort = COMPOSE .getServicePort ("connect" , DEBEZIUM_PORT );
98
103
kafkaPort = COMPOSE .getServicePort ("kafka" , KAFKA_PORT );
99
104
kafkaClient = new KafkaTestClient ("localhost:" + kafkaPort );
100
105
}
101
106
102
- // @AfterEach
107
+ @ AfterEach
103
108
void close () {
104
109
if (kafkaClient != null ) {
105
110
kafkaClient .shutdown ();
0 commit comments