Skip to content

Update MessagingHealthTest to use Nima WebClient instead of Reactive WebClient #6814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions microprofile/messaging/health/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,18 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.reactive.webclient</groupId>
<artifactId>helidon-reactive-webclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.reactive.media</groupId>
<artifactId>helidon-reactive-media-jsonp</artifactId>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.reactive.media</groupId>
<artifactId>helidon-reactive-media-jsonb</artifactId>
<groupId>io.helidon.nima.webclient</groupId>
<artifactId>helidon-nima-webclient</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.tests</groupId>
<artifactId>helidon-microprofile-tests-junit5</artifactId>
<groupId>io.helidon.nima.http.media</groupId>
<artifactId>helidon-nima-http-media-jsonp</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2022 Oracle and/or its affiliates.
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,8 +30,9 @@
import io.helidon.microprofile.tests.junit5.AddExtensions;
import io.helidon.microprofile.tests.junit5.DisableDiscovery;
import io.helidon.microprofile.tests.junit5.HelidonTest;
import io.helidon.reactive.media.jsonp.JsonpSupport;
import io.helidon.reactive.webclient.WebClient;
import io.helidon.nima.webclient.WebClient;
import io.helidon.nima.webclient.http1.Http1Client;
import io.helidon.nima.webclient.http1.Http1ClientResponse;

import jakarta.enterprise.inject.se.SeContainer;
import jakarta.enterprise.inject.spi.CDI;
Expand Down Expand Up @@ -82,16 +83,14 @@
public class MessagingHealthTest {

private static final String ERROR_MESSAGE = "BOOM!";

private WebClient client;
private Http1Client client;

@BeforeEach
void setUp() {
ServerCdiExtension server = CDI.current().select(ServerCdiExtension.class).get();
client = WebClient.builder()
.baseUri("http://localhost:" + server.port())
.addReader(JsonpSupport.reader())
.build();
.baseUri("http://localhost:" + server.port())
.build();
}

@Test
Expand Down Expand Up @@ -154,18 +153,14 @@ private void assertMessagingHealth(HealthCheckResponse.Status rootState, Map<Str
}

private JsonObject getHealthCheck(String checkName) {
return client.get()
.path("/health")
.submit()
.await(5, TimeUnit.SECONDS)
.content()
.as(JsonObject.class)
.await(500, TimeUnit.MILLISECONDS)
.getValue("/checks")
.asJsonArray().stream()
.map(JsonValue::asJsonObject)
.filter(check -> check.getString("name").equals(checkName))
.findFirst()
.orElseThrow(() -> new AssertionFailedError("Health check 'messaging' is missing!"));
try (Http1ClientResponse response = client.get("/health").request()) {
JsonObject jsonObject = response.as(JsonObject.class);
return jsonObject.getValue("/checks")
.asJsonArray().stream()
.map(JsonValue::asJsonObject)
.filter(check -> check.getString("name").equals(checkName))
.findFirst()
.orElseThrow(() -> new AssertionFailedError("Health check 'messaging' is missing!"));
}
}
}