Skip to content

Commit 9461764

Browse files
Add test to make sure the endpoint runs using HTTP/2
1 parent 76388ee commit 9461764

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

sdk-spring-boot-kotlin-starter/src/test/kotlin/dev/restate/sdk/springboot/kotlin/RestateHttpEndpointBeanTest.kt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ package dev.restate.sdk.springboot.kotlin
1010

1111
import com.fasterxml.jackson.databind.ObjectMapper
1212
import dev.restate.sdk.core.generated.manifest.EndpointManifestSchema
13-
import dev.restate.sdk.core.generated.manifest.Service
1413
import dev.restate.sdk.springboot.RestateHttpEndpointBean
1514
import java.io.IOException
1615
import java.net.URI
1716
import java.net.http.HttpClient
1817
import java.net.http.HttpRequest
1918
import java.net.http.HttpResponse
20-
import org.assertj.core.api.Assertions
2119
import org.assertj.core.api.Assertions.assertThat
2220
import org.junit.jupiter.api.Test
2321
import org.springframework.beans.factory.annotation.Autowired
@@ -36,26 +34,23 @@ class RestateHttpEndpointBeanTest {
3634
assertThat(restateHttpEndpointBean.actualPort()).isPositive()
3735

3836
// Check if discovery replies containing the Greeter service
39-
val client = HttpClient.newHttpClient()
37+
val client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_2).build()
4038
val response =
41-
client.send<String?>(
39+
client.send(
4240
HttpRequest.newBuilder()
4341
.GET()
42+
.version(HttpClient.Version.HTTP_2)
4443
.uri(
45-
URI.create(
46-
("http://localhost:" + restateHttpEndpointBean.actualPort()).toString() +
47-
"/discover"))
44+
URI.create("http://localhost:${restateHttpEndpointBean.actualPort()}/discover"))
4845
.header("Accept", "application/vnd.restate.endpointmanifest.v1+json")
4946
.build(),
5047
HttpResponse.BodyHandlers.ofString())
51-
Assertions.assertThat(response.statusCode()).isEqualTo(200)
48+
assertThat(response.version()).isEqualTo(HttpClient.Version.HTTP_2)
49+
assertThat(response.statusCode()).isEqualTo(200)
5250

5351
val endpointManifest =
54-
ObjectMapper()
55-
.readValue<EndpointManifestSchema>(response.body(), EndpointManifestSchema::class.java)
52+
ObjectMapper().readValue(response.body(), EndpointManifestSchema::class.java)
5653

57-
Assertions.assertThat<Service?>(endpointManifest.services)
58-
.map<String> { it?.name }
59-
.containsOnly("greeter")
54+
assertThat(endpointManifest.services).map<String> { it?.name }.containsOnly("greeter")
6055
}
6156
}

sdk-spring-boot-starter/src/test/java/dev/restate/sdk/springboot/java/RestateHttpEndpointBeanTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,19 @@ public void httpEndpointShouldBeRunning() throws IOException, InterruptedExcepti
3535
assertThat(restateHttpEndpointBean.actualPort()).isPositive();
3636

3737
// Check if discovery replies containing the Greeter service
38-
var client = HttpClient.newHttpClient();
38+
var client = HttpClient.newBuilder().version(HttpClient.Version.HTTP_2).build();
3939
var response =
4040
client.send(
4141
HttpRequest.newBuilder()
4242
.GET()
43+
.version(HttpClient.Version.HTTP_2)
4344
.uri(
4445
URI.create(
4546
"http://localhost:" + restateHttpEndpointBean.actualPort() + "/discover"))
4647
.header("Accept", "application/vnd.restate.endpointmanifest.v1+json")
4748
.build(),
4849
HttpResponse.BodyHandlers.ofString());
50+
assertThat(response.version()).isEqualTo(HttpClient.Version.HTTP_2);
4951
assertThat(response.statusCode()).isEqualTo(200);
5052

5153
var endpointManifest =

0 commit comments

Comments
 (0)