1

I'm creating a test that is trying to invoke an endpoint in my system.


the flow is like that
when i run the test i see that Quarkus test web server is listening on localhost
INFO: Quarkus 2.4.1.Final on JVM started in 25.464s. Listening on: http://localhost:8081

Im addressing (with rest assured) the subdomain subdomain.localhost

@QuarkusTest
class TestClass {

    @Test
    public void someTest() {

       RestAssured.given().log().all()
             .baseUri("http://subdomain.localhost:8081") <--
             .basePath("/api")
             .contentType(ContentType.JSON)
             .accept(ContentType.JSON)
             .get("/endpoint")
             .then()
             .statusCode(200);
    }
}

and getting exception:

java.net.UnknownHostException: subdomain.localhost: nodename nor servname provided, or not known

i found that if adding the subdomain to the hosts file (on mac \etc\hosts)
127.0.0.1 subdomain.localhost
it works but I'm looking for a different solution


is there any way to make Quarkus test web server listen to subdomain as well?

Bentz
  • 103
  • 7
  • localhost does not have subdomains, you can define subdomains like https://stackoverflow.com/a/19016600/175554 and after that you can write a server to listen to **sub.localhost** domain which does not feel very useful. if you want to separate rest endpoints you can use context path **localhost/context1** and **localhost/context2** or api/v1 api/v2 etc.. – ozkanpakdil Oct 27 '22 at 21:04

0 Answers0