From bec3fee01957e6f69090d0d24f1b81c4c2679a93 Mon Sep 17 00:00:00 2001 From: Hank Ibell Date: Fri, 21 Apr 2023 00:10:05 -0400 Subject: [PATCH 01/55] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6716ba..11e02dd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Open Liberty logo](https://github.com/OpenLiberty/logos/blob/main/combomark/png/OL_logo_green_on_white.png) -# Open Liberty Getting Started sample +# Open Liberty Getting Started Sample ## Overview The sample application provides a simple example of how to get started with Open Liberty. It provides a REST API that retrieves the system properties in the JVM and a web based UI for viewing them. It also uses MicroProfile Config, MicroProfile Health and MicroProfile Metrics to demonstrate how to use these specifications in an application that maybe deployed to kubernetes. From aa64a096c2a125054ec1a14d60f27591a603e08e Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:05:42 -0400 Subject: [PATCH 02/55] trigger pipeline From 1f7c018bbfb9600c069d9810a5396a5223a20f33 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:14:07 -0400 Subject: [PATCH 03/55] trigger pipeline From 56f81f1db8fd9c87a41793077c5bb27610350a7e Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:17:25 -0400 Subject: [PATCH 04/55] trigger pipeline From 482cd0d14a5425d019ed9187f5a06c45741fbddf Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:22:49 -0400 Subject: [PATCH 05/55] trigger pipeline From 2bdca2196d7c1aa08a793b676e78b02ac0d7c4ab Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:25:31 -0400 Subject: [PATCH 06/55] trigger pipeline From 359dbc136e1e0f7b96589595b2be02a204a0254b Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:39:20 -0400 Subject: [PATCH 07/55] trigger pipeline From 67981729906846e1a7b781350a17a9645f086cbd Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:39:45 -0400 Subject: [PATCH 08/55] trigger pipeline From 0c1fb6436408839deb4575db11d95256f0f4b698 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:43:34 -0400 Subject: [PATCH 09/55] trigger pipeline From 8ef84dc93578aac943f46c2975f57fda181cb239 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Thu, 18 May 2023 23:48:27 -0400 Subject: [PATCH 10/55] trigger pipeline From bee1a8b8b27f75c7b2af21812a54ba9811177c65 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 09:43:27 -0400 Subject: [PATCH 11/55] trigger pipeline From e62a6688fe36896c834a65becfa087648c06e3ab Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 10:07:40 -0400 Subject: [PATCH 12/55] trigger pipeline From eca292bdccb221b61261490cb4ee4a43271b6424 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 10:25:30 -0400 Subject: [PATCH 13/55] trigger pipeline From d8bf58b9c387fada5a7ea465e02e1277dc9138cc Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 11:34:00 -0400 Subject: [PATCH 14/55] trigger pipeline From 01e3278551ca86fac637ae8491a7d40d1bedf9bd Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 11:42:38 -0400 Subject: [PATCH 15/55] trigger pipeline From 99768ed538ed1d3262a0ac864ed1f2f6ebf30c2b Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 12:06:24 -0400 Subject: [PATCH 16/55] Remove tests --- .../openliberty/sample/health/HealthIT.java | 62 ------------- .../sample/health/HealthUtilIT.java | 91 ------------------- 2 files changed, 153 deletions(-) delete mode 100644 src/test/java/it/io/openliberty/sample/health/HealthIT.java delete mode 100644 src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java diff --git a/src/test/java/it/io/openliberty/sample/health/HealthIT.java b/src/test/java/it/io/openliberty/sample/health/HealthIT.java deleted file mode 100644 index dab0412..0000000 --- a/src/test/java/it/io/openliberty/sample/health/HealthIT.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, 2020 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial implementation - *******************************************************************************/ - -package it.io.openliberty.sample.health; - -import java.util.HashMap; -import javax.json.JsonArray; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; - -public class HealthIT { - - private JsonArray servicesstatus; - private static HashMap dataWhenServicesUP, dataWhenServicesDown; - - static { - dataWhenServicesUP = new HashMap(); - dataWhenServicesDown = new HashMap(); - dataWhenServicesUP.put("SystemResource", "UP"); - dataWhenServicesDown.put("SystemResource", "DOWN"); - } - - @Test - public void testIfServicesAreUp() { - servicesstatus = HealthUtilIT.connectToHealthEnpoint(200); - checkServicesstatus(dataWhenServicesUP, servicesstatus); - } - - @Test - public void testIfServicesAreDown() { - servicesstatus = HealthUtilIT.connectToHealthEnpoint(200); - checkServicesstatus(dataWhenServicesUP, servicesstatus); - HealthUtilIT.changeProperty(HealthUtilIT.INV_MAINTENANCE_FALSE, HealthUtilIT.INV_MAINTENANCE_TRUE); - servicesstatus = HealthUtilIT.connectToHealthEnpoint(503); - checkServicesstatus(dataWhenServicesDown, servicesstatus); - } - - private void checkServicesstatus(HashMap testData, JsonArray servicesstatus) { - testData.forEach((service, expectedState) -> { - assertEquals(expectedState, HealthUtilIT.getActualState(service, servicesstatus), - "The state of " + service + " service is not matching the "); - }); - - } - - @AfterEach - public void teardown() { - HealthUtilIT.cleanUp(); - } - -} diff --git a/src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java b/src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java deleted file mode 100644 index fab513a..0000000 --- a/src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018, 2020 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - Initial implementation - *******************************************************************************/ - -package it.io.openliberty.sample.health; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; - -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.core.Response; - -import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider; - -public class HealthUtilIT { - - private static String port; - private static String contextRoot; - private static String baseUrl; - private final static String HEALTH_ENDPOINT = "health"; - public static final String INV_MAINTENANCE_FALSE = "io_openliberty_sample_system_inMaintenance\":false"; - public static final String INV_MAINTENANCE_TRUE = "io_openliberty_sample_system_inMaintenance\":true"; - - static { - port = System.getProperty("http.port"); - contextRoot = System.getProperty("app.context.root"); - baseUrl = "http://localhost:" + port + contextRoot; - } - - public static JsonArray connectToHealthEnpoint(int expectedResponseCode) { - String healthURL = baseUrl + HEALTH_ENDPOINT; - Client client = ClientBuilder.newClient().register(JsrJsonpProvider.class); - Response response = client.target(healthURL).request().get(); - assertEquals(expectedResponseCode, response.getStatus(), "Response code is not matching " + healthURL); - JsonArray servicesstatus = response.readEntity(JsonObject.class).getJsonArray("checks"); - response.close(); - client.close(); - return servicesstatus; - } - - public static String getActualState(String service, JsonArray servicesstatus) { - String state = ""; - for (Object obj : servicesstatus) { - if (obj instanceof JsonObject) { - if (service.equals(((JsonObject) obj).getString("name"))) { - state = ((JsonObject) obj).getString("status"); - } - } - } - return state; - } - - public static void changeProperty(String oldValue, String newValue) { - try { - String fileName = System.getProperty("user.dir").split("target")[0] + "/resources/CustomConfigSource.json"; - BufferedReader reader = new BufferedReader(new FileReader(new File(fileName))); - String line = ""; - String oldContent = "", newContent = ""; - while ((line = reader.readLine()) != null) { - oldContent += line + "\r\n"; - } - reader.close(); - newContent = oldContent.replaceAll(oldValue, newValue); - FileWriter writer = new FileWriter(fileName); - writer.write(newContent); - writer.close(); - Thread.sleep(600); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public static void cleanUp() { - changeProperty(INV_MAINTENANCE_TRUE, INV_MAINTENANCE_FALSE); - } - -} From e8d7c16611aede905f12ad466006767049caf6de Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 12:24:50 -0400 Subject: [PATCH 17/55] trigger pipeline From bdc31411a3638a281c1eccf020cdec8b24cec1ec Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 12:29:45 -0400 Subject: [PATCH 18/55] trigger pipeline From 10ee24c923107c8583297aa1dfa94eb15a533b80 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 13:10:57 -0400 Subject: [PATCH 19/55] trigger pipeline From 87ee27c00652c0cd08d577e4d643ee235a21b8e5 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 13:30:21 -0400 Subject: [PATCH 20/55] trigger pipeline From 11e105b3c9695a53106a0ed9e439aaca10dfbed4 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 14:05:36 -0400 Subject: [PATCH 21/55] trigger pipeline From 733506d56971811227f914e6cbc1e68ddc1ca6fe Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 14:07:01 -0400 Subject: [PATCH 22/55] trigger pipeline From 9436d77eb173bc60e35e98b7de3f65b4546cc155 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 15:15:03 -0400 Subject: [PATCH 23/55] trigger pipeline From 987dfc692fe09e7019db6fc9fb53cf2d54950ce8 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 15:21:24 -0400 Subject: [PATCH 24/55] trigger pipeline From c162c6953082e202bd1267af0ab6e102dc8bffac Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 22 May 2023 21:51:11 -0400 Subject: [PATCH 25/55] trigger pipeline From cb3993e8e481adbef278d893077eeb7e254127fa Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 23 May 2023 12:13:13 -0400 Subject: [PATCH 26/55] trigger pipeline From 22f88867bc05095e51bca1fbbe05da02d299f52f Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 23 May 2023 12:18:01 -0400 Subject: [PATCH 27/55] trigger pipeline From 387e018bedc9ce5566f132a5253b89e238c20bc5 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 23 May 2023 12:32:53 -0400 Subject: [PATCH 28/55] trigger pipeline From 4d4c7814e0ae28a31b02a3892a8a06a852d20a01 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 30 May 2023 14:07:25 -0400 Subject: [PATCH 29/55] trigger pipeline From bd4cae761357ffec1916ccb0a297c8ce6d3b68b2 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 30 May 2023 14:08:45 -0400 Subject: [PATCH 30/55] trigger pipeline From 2ef0ea9756de6bed70968290b83b9557a6f531ac Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 30 May 2023 14:24:17 -0400 Subject: [PATCH 31/55] trigger pipeline From ee08bc3ec2b2d426e6dd607714907680dc54381f Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 30 May 2023 14:43:35 -0400 Subject: [PATCH 32/55] trigger pipeline From 4a3876ca38e0c96a222a97810947e42cdc565c76 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 09:21:05 -0400 Subject: [PATCH 33/55] trigger pipeline From 76a9290c910604b51239afcbe6b5287eb365ed7b Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 10:46:33 -0400 Subject: [PATCH 34/55] trigger pipeline From acc54b24ed342ef740af48a4939cdaeccd6d7db4 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 10:49:32 -0400 Subject: [PATCH 35/55] trigger pipeline From 65b56cbe09acf3dd661f2a98a6921344563c4783 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 14:18:27 -0400 Subject: [PATCH 36/55] trigger pipeline From 218f15a58d5b56a5108f650d07035b1a8a5f12ec Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 14:24:48 -0400 Subject: [PATCH 37/55] trigger pipeline From 3f0dfacba5aa8db17bc7937f2c45bd7440dc293f Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 14:26:54 -0400 Subject: [PATCH 38/55] trigger pipeline From cc72bb518d00e5ececb6ddfc5a9d062b938968ae Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Wed, 31 May 2023 14:29:43 -0400 Subject: [PATCH 39/55] trigger pipeline From 01cc2fe6d20f32759a06dd123fd1a0aa115dbb68 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Fri, 7 Jul 2023 15:02:59 -0400 Subject: [PATCH 40/55] trigger pipeline From 95042a67342c06bf80736ccef70973b604b510b0 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Fri, 14 Jul 2023 15:32:49 -0400 Subject: [PATCH 41/55] trigger pipeline From ee1f8b22d21816c59ece281e909db97433ac9315 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Fri, 14 Jul 2023 23:30:48 -0400 Subject: [PATCH 42/55] trigger pipeline From c5012f89e9cbe42dd8e0c8c2768496b285b5b797 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Fri, 14 Jul 2023 23:45:37 -0400 Subject: [PATCH 43/55] trigger pipeline From c9a96c9fd6f2d9808085ef9e51ae3f95e6d07b88 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Sat, 15 Jul 2023 00:02:38 -0400 Subject: [PATCH 44/55] trigger pipeline From 16ef49d168a32ed2d3cc69b15f0ebf10f9e21445 Mon Sep 17 00:00:00 2001 From: Hank Ibell Date: Sat, 15 Jul 2023 08:36:35 -0400 Subject: [PATCH 45/55] Update README.md Test PR --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 11e02dd..7177c61 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## Overview The sample application provides a simple example of how to get started with Open Liberty. It provides a REST API that retrieves the system properties in the JVM and a web based UI for viewing them. It also uses MicroProfile Config, MicroProfile Health and MicroProfile Metrics to demonstrate how to use these specifications in an application that maybe deployed to kubernetes. -## Project structure +## Project Structure - `src/main/java` - the Java code for the Project - `io/openliberty/sample` From 8dc8953b1de1c12637c9a99c630cf95e17cac884 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Sat, 15 Jul 2023 16:21:29 -0400 Subject: [PATCH 46/55] trigger pipeline From 959aecc0c947e17c30a0acd6384de050c6179cf8 Mon Sep 17 00:00:00 2001 From: Hank Ibell Date: Sun, 16 Jul 2023 09:56:01 -0400 Subject: [PATCH 47/55] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7177c61..6467893 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ if you just want to build it run: mvnw package ``` -## Run the Sample in a container +## Run the Sample in a Container To run the sample using docker run: From 46144d4c745b1b521bb666324e83b53f60a81b64 Mon Sep 17 00:00:00 2001 From: Hank Ibell Date: Sun, 16 Jul 2023 10:03:18 -0400 Subject: [PATCH 48/55] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6467893..15d3823 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ podman run -p 9080:9080 icr.io/appcafe/open-liberty/samples/getting-started ``` -### Access the application +### Access the Application Open a browser to http://localhost:9080 ![image](https://user-images.githubusercontent.com/3076261/117993383-4f34c980-b305-11eb-94b5-fa7319bc2850.png) From 709978250283bf2bb6a1cba8e5a0a2946a93f81b Mon Sep 17 00:00:00 2001 From: Hank Ibell Date: Tue, 18 Jul 2023 11:12:30 -0400 Subject: [PATCH 49/55] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15d3823..4912c87 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Open Liberty logo](https://github.com/OpenLiberty/logos/blob/main/combomark/png/OL_logo_green_on_white.png) -# Open Liberty Getting Started Sample +# Open Liberty Getting Started Sample Test ## Overview The sample application provides a simple example of how to get started with Open Liberty. It provides a REST API that retrieves the system properties in the JVM and a web based UI for viewing them. It also uses MicroProfile Config, MicroProfile Health and MicroProfile Metrics to demonstrate how to use these specifications in an application that maybe deployed to kubernetes. From a95cd1c51b87d513596a393c263c9070fa4a3e42 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Mon, 31 Jul 2023 00:11:34 -0400 Subject: [PATCH 50/55] trigger pipeline From d79a86a688467263f9e48c8481df181c67c8623b Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 8 Aug 2023 10:33:06 -0400 Subject: [PATCH 51/55] trigger pipeline From 29bedf690a43b8469ebbb2eb8c6bad51855026d4 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 8 Aug 2023 10:42:04 -0400 Subject: [PATCH 52/55] trigger pipeline From 08ddbc1ddcdfb1756c1bed1263017f1e26b61896 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 8 Aug 2023 13:57:18 -0400 Subject: [PATCH 53/55] trigger pipeline From 263d2b5f23f9284871399e83c3820afbc4a08888 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 8 Aug 2023 14:20:18 -0400 Subject: [PATCH 54/55] Revert "Remove tests" This reverts commit 99768ed538ed1d3262a0ac864ed1f2f6ebf30c2b. --- .../openliberty/sample/health/HealthIT.java | 62 +++++++++++++ .../sample/health/HealthUtilIT.java | 91 +++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 src/test/java/it/io/openliberty/sample/health/HealthIT.java create mode 100644 src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java diff --git a/src/test/java/it/io/openliberty/sample/health/HealthIT.java b/src/test/java/it/io/openliberty/sample/health/HealthIT.java new file mode 100644 index 0000000..dab0412 --- /dev/null +++ b/src/test/java/it/io/openliberty/sample/health/HealthIT.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2018, 2020 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial implementation + *******************************************************************************/ + +package it.io.openliberty.sample.health; + +import java.util.HashMap; +import javax.json.JsonArray; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; + +public class HealthIT { + + private JsonArray servicesstatus; + private static HashMap dataWhenServicesUP, dataWhenServicesDown; + + static { + dataWhenServicesUP = new HashMap(); + dataWhenServicesDown = new HashMap(); + dataWhenServicesUP.put("SystemResource", "UP"); + dataWhenServicesDown.put("SystemResource", "DOWN"); + } + + @Test + public void testIfServicesAreUp() { + servicesstatus = HealthUtilIT.connectToHealthEnpoint(200); + checkServicesstatus(dataWhenServicesUP, servicesstatus); + } + + @Test + public void testIfServicesAreDown() { + servicesstatus = HealthUtilIT.connectToHealthEnpoint(200); + checkServicesstatus(dataWhenServicesUP, servicesstatus); + HealthUtilIT.changeProperty(HealthUtilIT.INV_MAINTENANCE_FALSE, HealthUtilIT.INV_MAINTENANCE_TRUE); + servicesstatus = HealthUtilIT.connectToHealthEnpoint(503); + checkServicesstatus(dataWhenServicesDown, servicesstatus); + } + + private void checkServicesstatus(HashMap testData, JsonArray servicesstatus) { + testData.forEach((service, expectedState) -> { + assertEquals(expectedState, HealthUtilIT.getActualState(service, servicesstatus), + "The state of " + service + " service is not matching the "); + }); + + } + + @AfterEach + public void teardown() { + HealthUtilIT.cleanUp(); + } + +} diff --git a/src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java b/src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java new file mode 100644 index 0000000..fab513a --- /dev/null +++ b/src/test/java/it/io/openliberty/sample/health/HealthUtilIT.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2018, 2020 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Initial implementation + *******************************************************************************/ + +package it.io.openliberty.sample.health; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; + +import javax.json.JsonArray; +import javax.json.JsonObject; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.core.Response; + +import org.apache.cxf.jaxrs.provider.jsrjsonp.JsrJsonpProvider; + +public class HealthUtilIT { + + private static String port; + private static String contextRoot; + private static String baseUrl; + private final static String HEALTH_ENDPOINT = "health"; + public static final String INV_MAINTENANCE_FALSE = "io_openliberty_sample_system_inMaintenance\":false"; + public static final String INV_MAINTENANCE_TRUE = "io_openliberty_sample_system_inMaintenance\":true"; + + static { + port = System.getProperty("http.port"); + contextRoot = System.getProperty("app.context.root"); + baseUrl = "http://localhost:" + port + contextRoot; + } + + public static JsonArray connectToHealthEnpoint(int expectedResponseCode) { + String healthURL = baseUrl + HEALTH_ENDPOINT; + Client client = ClientBuilder.newClient().register(JsrJsonpProvider.class); + Response response = client.target(healthURL).request().get(); + assertEquals(expectedResponseCode, response.getStatus(), "Response code is not matching " + healthURL); + JsonArray servicesstatus = response.readEntity(JsonObject.class).getJsonArray("checks"); + response.close(); + client.close(); + return servicesstatus; + } + + public static String getActualState(String service, JsonArray servicesstatus) { + String state = ""; + for (Object obj : servicesstatus) { + if (obj instanceof JsonObject) { + if (service.equals(((JsonObject) obj).getString("name"))) { + state = ((JsonObject) obj).getString("status"); + } + } + } + return state; + } + + public static void changeProperty(String oldValue, String newValue) { + try { + String fileName = System.getProperty("user.dir").split("target")[0] + "/resources/CustomConfigSource.json"; + BufferedReader reader = new BufferedReader(new FileReader(new File(fileName))); + String line = ""; + String oldContent = "", newContent = ""; + while ((line = reader.readLine()) != null) { + oldContent += line + "\r\n"; + } + reader.close(); + newContent = oldContent.replaceAll(oldValue, newValue); + FileWriter writer = new FileWriter(fileName); + writer.write(newContent); + writer.close(); + Thread.sleep(600); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void cleanUp() { + changeProperty(INV_MAINTENANCE_TRUE, INV_MAINTENANCE_FALSE); + } + +} From 9f58fd7e66937efa1f3b10b4d9cf9b35e6860d48 Mon Sep 17 00:00:00 2001 From: Hank W Ibell Date: Tue, 8 Aug 2023 14:27:20 -0400 Subject: [PATCH 55/55] Testing 123 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4912c87..e5095ee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![Open Liberty logo](https://github.com/OpenLiberty/logos/blob/main/combomark/png/OL_logo_green_on_white.png) +![Open Liberty logo](https://github.com/OpenLiberty/logos/blob/main/combomark/png/OL_logo_green_on_white.png) Test 123 # Open Liberty Getting Started Sample Test