Skip to content

Commit 4bb21a2

Browse files
authored
feat: add IntegrationTest template to SpringSDK archetype (#1147)
1 parent 186dcbc commit 4bb21a2

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

maven-java/kalix-spring-boot-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
<include>**/*</include>
1313
</includes>
1414
</fileSet>
15+
<fileSet filtered="true">
16+
<directory>src/it/java</directory>
17+
<includes>
18+
<include>**/*</include>
19+
</includes>
20+
</fileSet>
1521
<fileSet filtered="true" encoding="UTF-8">
1622
<directory/>
1723
<includes>

maven-java/kalix-spring-boot-archetype/src/main/resources/archetype-resources/pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
</dependency>
279279
<dependency>
280280
<groupId>io.kalix</groupId>
281-
<artifactId>kalix-java-sdk-testkit</artifactId>
281+
<artifactId>kalix-spring-sdk-testkit</artifactId>
282282
<version>${kalix-sdk.version}</version>
283283
<scope>test</scope>
284284
</dependency>
@@ -296,6 +296,12 @@
296296
<version>5.5.2</version>
297297
<scope>test</scope>
298298
</dependency>
299+
<dependency>
300+
<groupId>org.junit.jupiter</groupId>
301+
<artifactId>junit-jupiter</artifactId>
302+
<version>5.5.2</version>
303+
<scope>test</scope>
304+
</dependency>
299305

300306
</dependencies>
301307
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package ${package};
2+
3+
import ${package}.Main;
4+
import kalix.springsdk.testkit.KalixIntegrationTestKitSupport;
5+
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
8+
import org.junit.runner.RunWith;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.boot.test.context.SpringBootTest;
11+
import org.springframework.test.context.junit4.SpringRunner;
12+
import org.springframework.web.reactive.function.client.WebClient;
13+
14+
15+
/**
16+
* This is a skeleton for implmenting integration tests for a Kalix application built with the Spring SDK.
17+
*
18+
* This test will initiate a Kalix Proxy using testcontainers and therefore it's required to have Docker installed
19+
* on your machine. This test will also start your Spring Boot application.
20+
*
21+
* Since this is an integration tests, it interacts with the application using a WebClient
22+
* (already configured and provided automatically through injection).
23+
*/
24+
@RunWith(SpringRunner.class)
25+
@SpringBootTest(classes = Main.class)
26+
public class IntegrationTest extends KalixIntegrationTestKitSupport {
27+
28+
@Autowired
29+
private WebClient webClient;
30+
31+
@Test
32+
public void test() throws Exception {
33+
// implement your integration tests here by calling your
34+
// REST endpoints using the provided WebClient
35+
}
36+
}

0 commit comments

Comments
 (0)