Open Liberty is a lightweight open framework for building fast and efficient cloud-native Java microservices. Find out more at openliberty.io.
+
+
Eclipse MicroProfile
+
+ The Eclipse MicroProfile project is an open community with the aim of optimizing enterprise Java for a microservices architecture.
+ MicroProfile evolves with guidance from the community.
+
+
+ If you want to share your thoughts, you can post straight to the
+ MicroProfile Google group.
+
+
+ For more information about the features used in this application, see the Open Liberty documentation:
+
+
+
+
+
diff --git a/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/test/java/it/io/openliberty/guides/rest/EndpointIT.java b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/test/java/it/io/openliberty/guides/rest/EndpointIT.java
new file mode 100644
index 000000000..56bc66361
--- /dev/null
+++ b/liberty-maven-plugin/src/it/dev-container-it/resources/container-test-project/src/test/java/it/io/openliberty/guides/rest/EndpointIT.java
@@ -0,0 +1,62 @@
+// tag::copyright[]
+/*******************************************************************************
+ * Copyright (c) 2017, 2022 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
+ *******************************************************************************/
+// end::copyright[]
+package it.io.openliberty.guides.rest;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+import jakarta.json.JsonObject;
+
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientBuilder;
+import jakarta.ws.rs.client.WebTarget;
+import jakarta.ws.rs.core.Response;
+
+
+public class EndpointIT extends BaseDevTest {
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ setUpBeforeClass(null, "../resources/basic-dev-project", true, false, null, null);
+
+ File f = new File("liberty/wlp");
+ assertTrue(f.getCanonicalFile() + " exists", f.exists());
+ }
+
+ @AfterClass
+ public static void cleanUpAfterClass() throws Exception {
+ BaseDevTest.cleanUpAfterClass();
+ }
+
+ @Test
+ public void testGetProperties() {
+ String port = System.getProperty("liberty.test.port");
+ String url = "http://localhost:" + port + "/";
+
+ Client client = ClientBuilder.newClient();
+
+ WebTarget target = client.target(url + "system/properties-new");
+ Response response = target.request().get();
+ JsonObject obj = response.readEntity(JsonObject.class);
+
+ assertEquals(200, response.getStatus(), "Incorrect response code from " + url);
+
+ assertEquals("/opt/ol/wlp/output/defaultServer/",
+ obj.getString("server.output.dir"),
+ "The system property for the server output directory should match "
+ + "the Open Liberty container image.");
+
+ response.close();
+ }
+}
diff --git a/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/BaseDevTest.java b/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/BaseDevTest.java
new file mode 100644
index 000000000..99b46d797
--- /dev/null
+++ b/liberty-maven-plugin/src/it/dev-container-it/src/test/java/net/wasdev/wlp/test/it/BaseDevTest.java
@@ -0,0 +1,347 @@
+package net.wasdev.wlp.test.it;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.Scanner;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.io.input.ReversedLinesFileReader;
+import org.apache.commons.io.FileUtils;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+public class BaseDevTest {
+
+ static String customLibertyModule;
+ static String customPomModule;
+ static File basicDevProj;
+ static File logFile;
+ static File logErrorFile;
+ static File targetDir;
+ static File pom;
+ static BufferedWriter writer;
+ static Process process;
+
+ /**
+ * Setup and optionally start dev/run
+ *
+ * @param params Params for the dev/run goal
+ * @param projectRoot The Maven project root
+ * @param isDevMode Use dev if true, use run if false. Ignored if startProcessDuringSetup is false.
+ * @param startProcessDuringSetup If this method should start the actual dev/run process
+ * @param libertyConfigModule For multi module project, the module where Liberty configuration is located
+ * @param pomModule For multi module project, the module where the pom is located. If null, use the project root.
+ * @throws IOException
+ * @throws InterruptedException
+ * @throws FileNotFoundException
+ */
+ protected static void setUpBeforeClass(String params, String projectRoot, boolean isDevMode, boolean startProcessDuringSetup,
+ String libertyConfigModule, String pomModule) throws IOException, InterruptedException, FileNotFoundException {
+ customLibertyModule = libertyConfigModule;
+ customPomModule = pomModule;
+
+ basicDevProj = new File(projectRoot);
+
+ assertTrue(projectRoot+" directory does not exist", basicDevProj.exists());
+
+ logFile = new File(basicDevProj, "logFile.txt");
+ logErrorFile = new File(basicDevProj, "logErrorFile.txt");
+
+ if (customPomModule == null) {
+ pom = new File(basicDevProj, "pom.xml");
+ } else {
+ pom = new File(new File(basicDevProj, customPomModule), "pom.xml");
+ }
+ assertTrue(pom.getCanonicalPath()+" file does not exist", pom.exists());
+
+ replaceVersion();
+
+ if (startProcessDuringSetup) {
+ startProcess(params, isDevMode);
+ }
+ }
+
+ protected static void startProcess(String params, boolean isDevMode) throws IOException, InterruptedException, FileNotFoundException {
+ startProcess(params, isDevMode, "mvn liberty:");
+ }
+
+ protected static void startProcess(String params, boolean isDevMode, String mavenPluginCommand) throws IOException, InterruptedException, FileNotFoundException {
+ startProcess(params, isDevMode, mavenPluginCommand, true);
+ }
+
+ protected static void startProcess(String params, boolean isDevMode, String mavenPluginCommand, boolean verifyServerStart) throws IOException, InterruptedException, FileNotFoundException {
+ // run dev mode on project
+ String goal;
+ if(isDevMode) {
+ goal = "dev";
+ } else {
+ goal = "run";
+ }
+
+ StringBuilder command = new StringBuilder(mavenPluginCommand + goal);
+ if (params != null) {
+ command.append(" " + params);
+ }
+ ProcessBuilder builder = buildProcess(command.toString());
+
+ builder.redirectOutput(logFile);
+ builder.redirectError(logErrorFile);
+ process = builder.start();
+ assertTrue("process is not alive", process.isAlive());
+
+ OutputStream stdin = process.getOutputStream();
+
+ writer = new BufferedWriter(new OutputStreamWriter(stdin));
+
+ if (verifyServerStart) {
+ // check that the server has started
+ assertTrue(getLogTail(), verifyLogMessageExists("CWWKF0011I", 120000));
+ if (isDevMode) {
+ assertTrue(verifyLogMessageExists("Liberty is running in dev mode.", 60000));
+ }
+
+ // verify that the target directory was created
+ if (customLibertyModule == null) {
+ targetDir = new File(basicDevProj, "target");
+ } else {
+ targetDir = new File(new File(basicDevProj, customLibertyModule), "target");
+ }
+ assertTrue("target directory does not exist: "+targetDir.getCanonicalPath(), targetDir.exists());
+ }
+ }
+
+ protected static String getLogTail() throws IOException {
+ return getLogTail(logFile);
+ }
+
+ protected static String getLogTail(File log) throws IOException {
+ int numLines = 100;
+ ReversedLinesFileReader object = null;
+ try {
+ object = new ReversedLinesFileReader(log, StandardCharsets.UTF_8);
+ List