MicroProfile REST Client for System Testing

MicroProfile REST client provides an alternative to plain JAX-RS client for writing System Tests. A given HTTP endpoint (it doesn't have to be a JAX-RS resource) has to be defined as a Java interface first:

public interface AirhacksWorkshop {
    String websiteContent();

The URI of the service is passed to the RestClientBuilder as parameter, as well as the (AirhacksWorkshop) interface:

package com.airhacks;

import org.eclipse.microprofile.rest.client.RestClientBuilder;
import (...)
public class WorkshopsTests {

    private AirhacksWorkshop workshop;

    public void init() throws MalformedURLException {
        URL apiUrl = new URL("http://airhacks.com");
                = RestClientBuilder

    public void content() {
        String content = this.workshop.websiteContent();
        assertThat(content, containsString("java"));

A System Test is executed within a JUnit runtime and needs the implementation of the MicroProfile REST Client API:


Currently there are Apache CXF, OpenLiberty, Thorntail and RESTEasy (used above) implementations available.

See you at Web, MicroProfile and Java EE Workshops at Munich Airport, Terminal 2 or Virtual Dedicated Workshops / consulting. Is Munich's airport too far? Learn from home: airhacks.io.


Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments