11// tag::copyright[]
22/*******************************************************************************
3- * Copyright (c) 2018, 2019 IBM Corporation and others.
3+ * Copyright (c) 2018, 2022 IBM Corporation and others.
44 * All rights reserved. This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License v1.0
66 * which accompanies this distribution, and is available at
1414
1515import static org .junit .jupiter .api .Assertions .assertEquals ;
1616
17- import javax .json .JsonObject ;
18- import javax .ws .rs .client .Client ;
19- import javax .ws .rs .client .ClientBuilder ;
20- import javax .ws .rs .core .Response ;
17+ import jakarta .json .JsonObject ;
18+ import jakarta .ws .rs .client .Client ;
19+ import jakarta .ws .rs .client .ClientBuilder ;
20+ import jakarta .ws .rs .core .Response ;
2121
22- import org .apache .cxf .jaxrs .provider .jsrjsonp .JsrJsonpProvider ;
2322import org .junit .jupiter .api .AfterEach ;
2423import org .junit .jupiter .api .BeforeEach ;
2524import org .junit .jupiter .api .BeforeAll ;
2625import org .junit .jupiter .api .Test ;
2726
2827public class HealthEndpointIT {
29-
28+
3029 private static String baseUrl ;
3130 private static final String HEALTH_ENDPOINT = "/health" ;
3231 private static final String LIVENESS_ENDPOINT = "/health/live" ;
3332 private static final String READINESS_ENDPOINT = "/health/ready" ;
34-
33+
3534 private Client client ;
3635 private Response response ;
37-
36+
3837 @ BeforeAll
3938 public static void oneTimeSetup () {
4039 String port = System .getProperty ("http.port" );
4140 baseUrl = "http://localhost:" + port ;
4241 }
43-
42+
4443 @ BeforeEach
4544 public void setup () {
4645 response = null ;
4746 client = ClientBuilder .newClient ();
48- client .register (JsrJsonpProvider .class );
4947 }
50-
48+
5149 @ AfterEach
5250 public void teardown () {
5351 response .close ();
@@ -59,47 +57,51 @@ public void testHealthEndpoint() {
5957 String healthURL = baseUrl + HEALTH_ENDPOINT ;
6058 response = this .getResponse (baseUrl + HEALTH_ENDPOINT );
6159 this .assertResponse (healthURL , response );
62-
60+
6361 JsonObject healthJson = response .readEntity (JsonObject .class );
6462 String expectedOutcome = "UP" ;
6563 String actualOutcome = healthJson .getString ("status" );
6664 assertEquals (expectedOutcome , actualOutcome , "Application should be healthy" );
67-
65+
6866 JsonObject healthCheck = healthJson .getJsonArray ("checks" ).getJsonObject (0 );
6967 String healthCheckName = healthCheck .getString ("name" );
7068 actualOutcome = healthCheck .getString ("status" );
71- assertEquals (expectedOutcome , actualOutcome , healthCheckName + " wasn't healthy" );
69+ assertEquals (expectedOutcome , actualOutcome ,
70+ healthCheckName + " wasn't healthy" );
7271
7372 healthCheck = healthJson .getJsonArray ("checks" ).getJsonObject (1 );
7473 healthCheckName = healthCheck .getString ("name" );
7574 actualOutcome = healthCheck .getString ("status" );
76- assertEquals (expectedOutcome , actualOutcome , healthCheckName + " wasn't healthy" );
75+ assertEquals (expectedOutcome , actualOutcome ,
76+ healthCheckName + " wasn't healthy" );
7777 }
7878
7979 @ Test
8080 public void testLivenessEndpoint () {
8181 String livenessURL = baseUrl + LIVENESS_ENDPOINT ;
8282 response = this .getResponse (baseUrl + LIVENESS_ENDPOINT );
8383 this .assertResponse (livenessURL , response );
84-
84+
8585 JsonObject healthJson = response .readEntity (JsonObject .class );
8686 String expectedOutcome = "UP" ;
8787 String actualOutcome = healthJson .getString ("status" );
88- assertEquals (expectedOutcome , actualOutcome , "Applications liveness check passed" );
88+ assertEquals (expectedOutcome , actualOutcome ,
89+ "Applications liveness check passed" );
8990 }
9091
9192 @ Test
9293 public void testReadinessEndpoint () {
9394 String readinessURL = baseUrl + READINESS_ENDPOINT ;
9495 response = this .getResponse (baseUrl + READINESS_ENDPOINT );
9596 this .assertResponse (readinessURL , response );
96-
97+
9798 JsonObject healthJson = response .readEntity (JsonObject .class );
9899 String expectedOutcome = "UP" ;
99100 String actualOutcome = healthJson .getString ("status" );
100- assertEquals (expectedOutcome , actualOutcome , "Applications readiness check passed" );
101+ assertEquals (expectedOutcome , actualOutcome ,
102+ "Applications readiness check passed" );
101103 }
102-
104+
103105 /**
104106 * <p>
105107 * Returns response information from the specified URL.
0 commit comments