Skip to content

Using RESTEasy Spring Boot starter integration. This is not just builtin Jersey integration!

Notifications You must be signed in to change notification settings

daggerok/resteasy-spring-boot-starter-example

Repository files navigation

resteasy-spring-boot-starter example CI

Using RESTEasy Spring Boot starter integration. This is not just builtin Jersey integration!

pom.xml

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-spring-boot-starter</artifactId>
    <version>4.5.1.Final</version>
</dependency>

app

@SpringBootApplication
public class RESTEasySpringBootApplication {

  @Component
  @ApplicationPath("/api")
  public static class RESTEasyConfig extends Application {

    @Component
    @Path("/hello")
    @Produces(MediaType.APPLICATION_JSON)
    public static class RESTEasyResource {

      @GET
      public Map<String, String> hello() {
        return Map.of("message", "Hello, World!");
      }
    }
  }

  public static void main(String[] args) {
    SpringApplication.run(RESTEasySpringBootApplication.class, args);
  }
}

tests

@SpringBootTest
class RESTEasySpringBootApplicationTests {

  @Autowired
  WebTestClient webTestClient;

  @Test
  void contextLoads() {
    webTestClient.get()
                 .uri("/api/hello")
                 .exchange()
                 .expectStatus().isOk()
                 .expectBody(new ParameterizedTypeReference<Map<String, String>>() {})
                 .consumeWith(mapEntityExchangeResult -> {
                   var map = mapEntityExchangeResult.getResponseBody();
                   assertThat(map.get("message")).isNotNull()
                                                 .isEqualToIgnoringCase("hello, world!");
                 });

  }
}

or simply

./mvnw spring-boot:run
http :8080/api/hello

resources

About

Using RESTEasy Spring Boot starter integration. This is not just builtin Jersey integration!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages