Step 1 - Start the OpenLiberty server and execute the JUnit test

STEP 1: Setup, configure and run the Keycloak server

Reminder: Setup, configure and run the Keycloak server here.

STEP 2: Start the OpenLiberty server in the devepment mode

Open a terminal in the GitHub project folder. Start the OpenLiberty server in the devepment mode liberty:dev.

cd $ROOT_FOLDER/authors-java-jee
mvn clean
mvn liberty:dev

STEP 3: Run the JUnit test

Run the JUnit test by just pressing return button in the terminal session.

[INFO] CWWKM2015I: Match number: 1 is [29/06/2020, 09:06:00:531 CEST] 00000038 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The authorsDevJUnitServer server is ready to run a smarter planet. The authorsDevJUnitServer server started in 9.951 seconds..
[INFO] Press the Enter key to run tests on demand.

Here we see the relevant output in the terminal session.

  1. First we see that we get the bearer token from Keycloak (we can use that token to verify the content with a JWT Decoder on the web).

  2. Then we see that the bearer token content information also from the Authors Microservice output.

  3. Now we see the return value of the Authors Microservice is going to send.

  4. Now JUnit test shows the value of the Authors response we going to compare with expected value in the test.

  5. As the last output we see JUnit test result.

In the output [JUNIT-TEST] indicates outputs from the JUnit test and [INFO] ... [Author] indicates the outputs of the Microservice Authors.

STEP 4 (optional): Open test report

We can open the test report which is created by Maven inside the project. The image below shows, how to locate the file junit-surefire-test-result of the test report and open the report in a browser.

The test report.

Congratulations! We’ve finished the example!

Last updated

Was this helpful?