简体   繁体   中英

Quarkus reading application.properties from the @QuarkusTest

In my application.properties I have

quarkus.http.root-path=/my-service/api/v2

and it works when I run the app and hit the url. (It reads the config on start).

But when I run it from the test:

@QuarkusTest
@Tag("integration")
public class MyResourceTest {
    @Test
    public void testMyEndpoint() {

        given()
                .when().get("/my-service/api/v2/init")
                .then()
                .statusCode(200)
                .body(is("{}"));
    }

I got 404 . But it works if do get("/init")

Seems that the Test does not know about the application.properties .

I tried to put application.properties to test/resources folder (similar to what I would do if work with Spring Bootstrap app)

I tried this, assuming it uses the test profile when I run test (did not work):

%test.quarkus.http.root-path=/my-service/api/v2

UPDATE: I was able to read my database config though, adding %test to the test/resources/application.properties

#test
%test.quarkus.datasource.url=vertx-reactive:postgresql://mydb-url:5432/mydb

But the quarkus.http.root seems different thing.

Question is:

  • how to read quarkus.http.root from properties files for from the integration test? (could not find it in the doc).

This is because the Restassured integration is aware of the modified root path, so it transparently adjusts the requests it sends. When you request /init it will automatically map to /my-service/api/v2/init

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM