Skip to content

Commit

Permalink
Ensure no NPE is thrown when using RestClient with Micrometer disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rsvoboda committed Jun 8, 2022
1 parent 1c2bb72 commit 708be0e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
4 changes: 4 additions & 0 deletions http/rest-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jsonb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,43 @@
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import io.quarkus.test.bootstrap.RestService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.QuarkusApplication;

@QuarkusScenario
public class ClientBookResourceIT {

@QuarkusApplication
static RestService app = new RestService();

@QuarkusApplication
static RestService appWithMicrometerDisabled = new RestService().withProperty("quarkus.micrometer.enabled", "false");

@Test
public void shouldGetBookFromRestClientXml() {
given().get("/client/book/xml").then().statusCode(HttpStatus.SC_OK)
app.given().get("/client/book/xml").then().statusCode(HttpStatus.SC_OK)
.body(is(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><book><title>Title in Xml</title></book>"));
}

@Test
public void shouldGetBookFromRestClientJson() {
given().get("/client/book/json").then().statusCode(HttpStatus.SC_OK)
app.given().get("/client/book/json").then().statusCode(HttpStatus.SC_OK)
.body(is("{\"title\":\"Title in Json\"}"));
}

@Test
@Tag("QUARKUS-1376")
public void notFoundShouldNotReturnAnyResteasyImplementationDetails() {
String body = given().get("/notFound").then().statusCode(HttpStatus.SC_NOT_FOUND).extract().body().asString();
String body = app.given().get("/notFound").then().statusCode(HttpStatus.SC_NOT_FOUND).extract().body().asString();
Assertions.assertFalse(body.contains("RESTEASY"),
"Not found resource should not return any Resteasy implementation details, but was: " + body);
}

@Test
@Tag("QUARKUS-2127")
public void noNullPointerExceptionForRestClientUsageWithDisabledMicrometer() {
appWithMicrometerDisabled.given().get("/client/book/xml").then().statusCode(HttpStatus.SC_OK);
}
}

0 comments on commit 708be0e

Please sign in to comment.