You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Readiness
@ApplicationScoped
public class ConnectivityCheck implements HealthCheck {
private final String host;
private final int port;
private final int timeout;
@Inject
public ConnectivityCheck(AppConfig appConfig) throws MalformedURLException {
String url = appConfig.server().baseUrl();
this.host = new URL(url).getHost();
this.port = new URL(url).getPort();
this.timeout = appConfig.healthCheck().timeout();
}
@Override
public HealthCheckResponse call() {
HealthCheckResponseBuilder responseBuilder = HealthCheckResponse
.named("Connectivity");
Log.debugv("Trying to connect to the server at {0} on port {1,number,#}...", host, port);
try (Socket s = new Socket()) {
SocketAddress endpoint = new InetSocketAddress(host, port);
s.connect(endpoint, timeout);
Log.debugv("Successfully connected to the server at {0} on port {1,number,#}.", host, port);
responseBuilder.up();
} catch (IOException e) {
responseBuilder.down()
.withData("Error", e.toString());
Log.error("Failed to connect to the server", e);
}
return responseBuilder.build();
}
}
But I run into the following exception:
jakarta.enterprise.inject.UnsatisfiedResolutionException: No bean found for required type [class org.example.health.ConnectivityCheck] and qualifiers [[]]
I suspect this has to do with the fact that I am not directly calling ConnectivityCheck.call(), but the Quarkus healthcheck endpoint (/q/health/ready) triggers a connection attempt to the server.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am wondering if this should generally be possible? I am trying to mock a Quarkus readiness check for unit testing, as follows:
Test
ConnectivityCheck
But I run into the following exception:
I suspect this has to do with the fact that I am not directly calling ConnectivityCheck.call(), but the Quarkus healthcheck endpoint (/q/health/ready) triggers a connection attempt to the server.
What am I missing?
Thanks in advance :-)
Beta Was this translation helpful? Give feedback.
All reactions