Issue #23507 server-mgmgt tests transformed from testNG to junit5
diff --git a/nucleus/admin/server-mgmt/pom.xml b/nucleus/admin/server-mgmt/pom.xml
index fb075b4..ecfd822 100644
--- a/nucleus/admin/server-mgmt/pom.xml
+++ b/nucleus/admin/server-mgmt/pom.xml
@@ -61,15 +61,15 @@
             <artifactId>admin-cli</artifactId>
             <version>${project.version}</version>
         </dependency>
-
-        <dependency>
-            <groupId>org.testng</groupId>
-            <artifactId>testng</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.glassfish.annotations</groupId>
             <artifactId>logging-annotation-processor</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest</artifactId>
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/domain/TestDomainPortValidator.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/domain/DomainPortValidatorTest.java
similarity index 64%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/domain/TestDomainPortValidator.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/domain/DomainPortValidatorTest.java
index 0c394a3..2543ae7 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/domain/TestDomainPortValidator.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/domain/DomainPortValidatorTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,56 +18,62 @@
 
 import java.util.Properties;
 
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import com.sun.enterprise.admin.servermgmt.DomainConfig;
 import com.sun.enterprise.admin.servermgmt.DomainException;
 
-public class TestDomainPortValidator {
+public class DomainPortValidatorTest {
 
-    private DomainPortValidator _portValidator = null;
+    private DomainPortValidator portValidator;
 
-    @Test (expectedExceptions = DomainException.class)
+    @Test
     public void testForNullPorts() throws Exception {
         DomainConfig domainConfig = new DomainConfig("test", null);
         domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
-        _portValidator = new DomainPortValidator(domainConfig, new Properties());
-        _portValidator.validateAndSetPorts();
+        portValidator = new DomainPortValidator(domainConfig, new Properties());
+        assertThrows(DomainException.class, () -> portValidator.validateAndSetPorts());
     }
 
-    @Test (expectedExceptions = DomainException.class)
+
+    @Test
     public void testForNonNumericPort() throws Exception {
         DomainConfig domainConfig = new DomainConfig("test", null);
         domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
         domainConfig.add(DomainConfig.K_ADMIN_PORT, "admin2");
-        _portValidator = new DomainPortValidator(domainConfig, new Properties());
-        _portValidator.validateAndSetPorts();
+        portValidator = new DomainPortValidator(domainConfig, new Properties());
+        assertThrows(DomainException.class, () -> portValidator.validateAndSetPorts());
     }
 
-    @Test (expectedExceptions = DomainException.class)
+
+    @Test
     public void testForNegativePort() throws Exception {
         DomainConfig domainConfig = new DomainConfig("test", null);
         domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
         domainConfig.add(DomainConfig.K_ADMIN_PORT, "-2");
-        _portValidator = new DomainPortValidator(domainConfig, new Properties());
-        _portValidator.validateAndSetPorts();
+        portValidator = new DomainPortValidator(domainConfig, new Properties());
+        assertThrows(DomainException.class, () -> portValidator.validateAndSetPorts());
     }
 
-    @Test (expectedExceptions = DomainException.class)
+
+    @Test
     public void testForPortValueZero() throws Exception {
         DomainConfig domainConfig = new DomainConfig("test", null);
         domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
         domainConfig.add(DomainConfig.K_ADMIN_PORT, "0");
-        _portValidator = new DomainPortValidator(domainConfig, new Properties());
-        _portValidator.validateAndSetPorts();
+        portValidator = new DomainPortValidator(domainConfig, new Properties());
+        assertThrows(DomainException.class, () -> portValidator.validateAndSetPorts());
     }
 
-    @Test (expectedExceptions = DomainException.class)
+
+    @Test
     public void testForMaxPort() throws Exception {
         DomainConfig domainConfig = new DomainConfig("test", null);
         domainConfig.add(DomainConfig.K_VALIDATE_PORTS, Boolean.TRUE);
         domainConfig.add(DomainConfig.K_ADMIN_PORT, String.valueOf((DomainPortValidator.PORT_MAX_VAL + 1)));
-        _portValidator = new DomainPortValidator(domainConfig, new Properties());
-        _portValidator.validateAndSetPorts();
+        portValidator = new DomainPortValidator(domainConfig, new Properties());
+        assertThrows(DomainException.class, () -> portValidator.validateAndSetPorts());
     }
 }
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/StringSubstitutionFactoryTest.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/StringSubstitutionFactoryTest.java
new file mode 100644
index 0000000..0b2be9b
--- /dev/null
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/StringSubstitutionFactoryTest.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.admin.servermgmt.stringsubs;
+
+import com.sun.enterprise.admin.servermgmt.stringsubs.impl.AttributePreprocessorImpl;
+import com.sun.enterprise.admin.servermgmt.stringsubs.impl.StringSubstitutionEngineTest;
+import com.sun.enterprise.admin.servermgmt.stringsubs.impl.SubstituableFactoryImpl;
+import com.sun.enterprise.admin.servermgmt.test.ServerMgmgtTestFiles;
+import com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+/**
+ * Unit Test class for {@link StringSubstitutionFactory}.
+ */
+public class StringSubstitutionFactoryTest {
+
+    private static final ServerMgmgtTestFiles TEST_FILES = new ServerMgmgtTestFiles(StringSubstitutionEngineTest.class);
+    private static final String TEST_FILE_NAME = "testStringSubs.txt";
+    private static final String TEST_ARCHIVE_NAME = "testStringSubsArchive.jar";
+    private static final String VALID_GROUP_ID = "valid_group";
+    private static final Map<String, String> SUBSTITUTION_MAP = Map.of(
+            "JAVA", "REPLACED_JAVA",
+            "JAVA_HOME", "REPLACED_JAVA_HOME",
+            "MW_HOME", "REPLACED_MW_HOME",
+            "TEST_FILE_DIR_PATH", TEST_FILES.getBasePackageAbsolutePath().toString());
+
+
+    /**
+     * Test String substitution for invalid stream.
+     */
+    @Test
+    public void testStringSubstitutorInvalidStream() throws Exception {
+        try (InputStream invalidStream = TEST_FILES.openInputStream(TEST_FILES.getBaseClass().getSimpleName() + ".class")) {
+            StringSubstitutionFactory.createStringSubstitutor(invalidStream);
+            fail("No exception thrown for invalid stream.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("Failed to parse given stream against the schema xsd/schema/stringsubs.xsd.", e.getMessage());
+        }
+    }
+
+    /**
+     * Test String substitution for null stream.
+     */
+    @Test
+    public void testStringSubstitutorNullStream() {
+        try {
+            StringSubstitutionFactory.createStringSubstitutor(null);
+            fail("No exception thrown for null stream.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("InputStream is null", e.getMessage());
+        }
+    }
+
+    /**
+     * Test String substitution for valid stream.
+     * @throws StringSubstitutionException
+     * @throws IOException
+     */
+    @Test
+    public void testStringSubstitutorValidStream() throws StringSubstitutionException, IOException {
+        final StringSubstitutor substitutor;
+        try (InputStream validStream = TEST_FILES.openInputStream("stringsubs.xml")) {
+            substitutor = StringSubstitutionFactory.createStringSubstitutor(validStream);
+        }
+        substitutor.setAttributePreprocessor(new AttributePreprocessorImpl(SUBSTITUTION_MAP));
+        backUpTestFile();
+        try {
+            substitutor.substituteAll();
+            for (Group group : substitutor.getStringSubsDefinition().getGroup()) {
+                if (group.getId().equals(VALID_GROUP_ID)) {
+                    validateSubstitutedArchiveEntries(group);
+                }
+            }
+        } finally {
+            restoreTestFile();
+        }
+    }
+
+    /**
+     * Validate if the substitution occurred properly in the test file.
+     */
+    private void validateTestFile(File testFile) throws IOException {
+        final List<String> lines = Files.readAllLines(testFile.toPath());
+        assertEquals(2, lines.size());
+        assertEquals("Substitute REPLACED_JAVA_HOME REPLACED_JAVA @MW_", lines.get(0));
+        assertEquals("HOME@", lines.get(1));
+    }
+
+    /**
+     * Validate all the substitutable archive entries.
+     */
+    private void validateSubstitutedArchiveEntries(Group group) throws IOException {
+        List<? extends Substitutable> substituables = new SubstituableFactoryImpl().getArchiveEntrySubstitutable(group.getArchive().get(0));
+        for (Substitutable substituable : substituables) {
+            validateTestFile(new File(substituable.getName()));
+            substituable.finish();
+        }
+    }
+
+    /**
+     * Restore the archive by performing reverse substitution.
+     */
+    private void backUpTestFile() {
+        try {
+            for (File file : TEST_FILES.getBasePackageDirectory().listFiles()) {
+                if (file.getName().endsWith(TEST_ARCHIVE_NAME) || file.getName().endsWith(TEST_FILE_NAME)) {
+                    Files.copy(file.toPath(), new File(file.getAbsolutePath() + ".bkp").toPath());
+                }
+            }
+        } catch (Exception e) {
+            throw new IllegalStateException("Error occured while creating a backup archive before subsitution.", e);
+        }
+    }
+
+    private void restoreTestFile() {
+        try {
+            for (File file : TEST_FILES.getBasePackageDirectory().listFiles()) {
+                if (file.getName().endsWith(TEST_ARCHIVE_NAME) || file.getName().endsWith(TEST_FILE_NAME)) {
+                    file.delete();
+                }
+            }
+            for (File file : TEST_FILES.getBasePackageDirectory().listFiles()) {
+                if (file.getAbsolutePath().endsWith(".bkp")) {
+                    file.renameTo(new File(file.getAbsolutePath().replace(".bkp", "")));
+                }
+            }
+        } catch (Exception e) {
+            throw new IllegalStateException("Error occured while restoring the archive after subsitution.", e);
+        }
+    }
+}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/TestStringSubstitutionFactory.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/TestStringSubstitutionFactory.java
deleted file mode 100644
index b9edd83..0000000
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/TestStringSubstitutionFactory.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.enterprise.admin.servermgmt.stringsubs;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.nio.channels.FileChannel;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.sun.enterprise.admin.servermgmt.stringsubs.impl.AttributePreprocessorImpl;
-import com.sun.enterprise.admin.servermgmt.stringsubs.impl.SubstituableFactoryImpl;
-import com.sun.enterprise.admin.servermgmt.stringsubs.impl.TestStringSubstitutionEngine;
-import com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry;
-import com.sun.enterprise.admin.servermgmt.xml.stringsubs.Group;
-
-/**
- * Unit Test class for {@link StringSubstitutionFactory}.
- */
-public class TestStringSubstitutionFactory {
-
-    private final static String _stringSubsPath = TestStringSubstitutionEngine.class.getPackage().getName().replace(".", "/")
-            + "/stringsubs.xml";
-    private Map<String, String> _substitutionMap = new HashMap<String, String>();
-    private static final String _testFileName = "testStringSubs.txt";
-    private static final String _testArchiveName = "testStringSubsArchive.jar";
-    private static final String VALID_GROUP_ID = "valid_group";
-    private String _testFileDirPath = null;
-
-    @BeforeClass
-    public void init() throws Exception {
-        URL url = TestStringSubstitutionFactory.class.getClassLoader().getResource(_stringSubsPath);
-        _testFileDirPath = new File(url.getPath()).getParentFile().getAbsolutePath();
-        _substitutionMap.put("JAVA", "REPLACED_JAVA");
-        _substitutionMap.put("JAVA_HOME", "REPLACED_JAVA_HOME");
-        _substitutionMap.put("MW_HOME", "REPLACED_MW_HOME");
-        _substitutionMap.put("TEST_FILE_DIR_PATH", _testFileDirPath);
-    }
-
-    /**
-     * Test String substitution for invalid stream.
-     */
-    @Test
-    public void testStringSubstitutorInvalidStream() {
-        StringBuffer pathBuffer = new StringBuffer();
-        pathBuffer.append(TestStringSubstitutionFactory.class.getPackage().getName().replace(".", "/"));
-        pathBuffer.append(File.separator);
-        pathBuffer.append(this.getClass().getSimpleName());
-        pathBuffer.append(".class");
-        InputStream invalidStream = TestStringSubstitutionFactory.class.getClassLoader().getResourceAsStream(pathBuffer.toString());
-        try {
-            StringSubstitutionFactory.createStringSubstitutor(invalidStream);
-        }
-        catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("No exception thrown for invalid stream.");
-    }
-
-    /**
-     * Test String substitution for null stream.
-     */
-    @Test
-    public void testStringSubstitutorNullStream() {
-        try {
-            StringSubstitutionFactory.createStringSubstitutor(null);
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("No exception thrown for null stream.");
-    }
-
-    /**
-     * Test String substitution for valid stream.
-     */
-    @Test
-    public void testStringSubstitutorValidStream() {
-        InputStream invalidStream = TestStringSubstitutionFactory.class.getClassLoader().
-                getResourceAsStream(_stringSubsPath);
-        try {
-            StringSubstitutor substitutor = StringSubstitutionFactory.createStringSubstitutor(invalidStream);
-            substitutor.setAttributePreprocessor(new AttributePreprocessorImpl(_substitutionMap));
-            backUpTestFile();
-            substitutor.substituteAll();
-            for (Group group : substitutor.getStringSubsDefinition().getGroup()) {
-                if (group.getId().equals(VALID_GROUP_ID)) {
-                    validateSubstitutedArchiveEntries(group);
-                    for (FileEntry fileEntry : group.getFileEntry()) {
-                        if (fileEntry.getName().equalsIgnoreCase(_testFileName) &&
-                                !validateTestFile(new File(fileEntry.getName()))) {
-                            Assert.fail("Substitution failed in the test file.");
-                            break;
-                        }
-                    }
-                }
-            }
-            restoreTestFile();
-        } catch (StringSubstitutionException e) {
-            Assert.fail("Exception occurred during string substitution process.", e);
-        }
-    }
-
-    /**
-     * Validate if the substitution occurred properly in the test file.
-     */
-    private boolean validateTestFile(File testFile) {
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(new FileInputStream(testFile)));
-            String afterSubstitutionLine = null;
-            int i = 0;
-            while ((afterSubstitutionLine = reader.readLine()) != null) {
-                switch (i++) {
-                    case 0:
-                        if (!afterSubstitutionLine.equals("Substitute REPLACED_JAVA_HOME REPLACED_JAVA @MW_")) {
-                            return false;
-                        }
-                        break;
-                    case 1:
-                        if (!afterSubstitutionLine.equals("HOME@")) {
-                            return false;
-                        }
-                        break;
-                    default:
-                        break;
-                }
-            }
-        } catch (IOException e) {
-            return false;
-        } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    return false;
-                }
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Validate all the substitutable archive entries.
-     */
-    private void validateSubstitutedArchiveEntries(Group group) {
-        List<? extends Substitutable> substituables = new SubstituableFactoryImpl().getArchiveEntrySubstitutable(group.getArchive().get(0));
-        for (Substitutable substituable : substituables) {
-            Assert.assertTrue(validateTestFile(new File(substituable.getName())));
-            substituable.finish();
-        }
-    }
-
-    /**
-     * Restore the archive by performing reverse substitution.
-     */
-    private void backUpTestFile() {
-        try {
-            File testDir = new File(_testFileDirPath);
-            if (testDir.isDirectory()) {
-                for (File file : testDir.listFiles()) {
-                    if (file.getName().endsWith(_testArchiveName)
-                            || file.getName().endsWith(_testFileName)) {
-                        copy(file, new File(file.getAbsolutePath() + ".bkp") ,true);
-                    }
-                }
-            }
-        } catch (Exception e) {
-            Assert.fail("Error occured while restoring the archive after subsitution.", e);
-        }
-    }
-
-    private void restoreTestFile() {
-        try {
-            File testDir = new File(_testFileDirPath);
-            if (testDir.isDirectory()) {
-                for (File file : testDir.listFiles()) {
-                    if (file.getName().endsWith(_testArchiveName)
-                            || file.getName().endsWith(_testFileName)) {
-                        file.delete();
-                    }
-                }
-                for (File file : testDir.listFiles()) {
-                    if (file.getAbsolutePath().endsWith(".bkp")) {
-                        file.renameTo(new File(file.getAbsolutePath().replace(".bkp", "")));
-                    }
-                }
-            }
-        } catch (Exception e) {
-            Assert.fail("Error occured while restoring the archive after subsitution.", e);
-        }
-    }
-
-    /**
-     * Copies a file.
-     *
-     * @param from the file to copy from.
-     * @param to   the file to copy to.
-     * @param mkdirs if parent directory should be created.
-     * @throws IOException when an error occurs while trying to copy the file.
-     */
-    public void copy(File from, File to, boolean mkdirs)
-            throws IOException {
-        if (from == null) {
-            throw new NullPointerException("The source file was null.");
-        }
-
-        if (to == null) {
-            throw new NullPointerException("The destination file was null.");
-        }
-
-        if (from.isDirectory()) {
-            throw new IOException("The source file was a directory, FileCopy does not support directory copies.");
-        }
-
-        if (to.isDirectory()) {
-            to = new File(to, from.getName());
-        }
-
-        if (mkdirs) {
-            File parent = to.getParentFile();
-            if (parent != null)
-            {
-                parent.mkdirs();
-            }
-        }
-
-        FileInputStream in = new FileInputStream(from);
-        FileChannel fin = in.getChannel();
-        FileOutputStream out = new FileOutputStream(to);
-        FileChannel fout = out.getChannel();
-
-        long size = fin.size();
-        long position = 0;
-        while (position < size) {
-            position += fin.transferTo(position, 1000, fout);
-        }
-        fin.close();
-        in.close();
-        fout.close();
-        out.close();
-    }
-}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactoryTest.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactoryTest.java
new file mode 100644
index 0000000..105e49d
--- /dev/null
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/FileEntryFactoryTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
+
+import com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable;
+import com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry;
+
+import java.io.File;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+
+import static com.sun.enterprise.admin.servermgmt.test.ServerMgmgtTestFiles.getClassFile;
+import static org.hamcrest.CoreMatchers.endsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+
+/**
+ * Unit test for {@link FileEntryFactory} functionality.
+ */
+public class FileEntryFactoryTest {
+
+    private static final FileEntryFactory FACTORY = new FileEntryFactory();
+    private static final File CLASS_FILE = getClassFile(FileEntryFactoryTest.class);
+
+
+    /**
+     * Test get file by mentioning the path of an directory.
+     */
+    @Test
+    public void testGetFileFromDir() {
+        FileEntry fileEntry = new FileEntry();
+        fileEntry.setName(CLASS_FILE.getParentFile().getAbsolutePath());
+        List<Substitutable> substitutables = FACTORY.getFileElements(fileEntry);
+        assertFalse(substitutables.isEmpty());
+        for (Substitutable substitutable : substitutables) {
+            if (substitutable.getName().endsWith(CLASS_FILE.getAbsolutePath())) {
+                return;
+            }
+        }
+        fail("File was not found:" + CLASS_FILE);
+    }
+
+    /**
+     * Test get file by mentioning the absolute path of an file.
+     */
+    @Test
+    public void testGetFile() {
+        FileEntry fileEntry = new FileEntry();
+        fileEntry.setName(CLASS_FILE.getAbsolutePath());
+        List<Substitutable> substitutables = FACTORY.getFileElements(fileEntry);
+        assertEquals(1, substitutables.size(), "substitutables.size");
+        assertEquals(CLASS_FILE.getAbsolutePath(), substitutables.get(0).getName());
+    }
+
+    /**
+     * Test get file by using wild card.
+     */
+    @Test
+    public void testGetFilesUsingWildCard() {
+        FileEntry fileEntry = new FileEntry();
+        fileEntry.setName(CLASS_FILE.getParentFile().getAbsolutePath() + File.separator + "*Test.class");
+        List<Substitutable> substitutables = FACTORY.getFileElements(fileEntry);
+        assertFalse(substitutables.isEmpty());
+        for (Substitutable substitutable : substitutables) {
+            assertThat(new File(substitutable.getName()).getName(), endsWith("Test.class"));
+        }
+    }
+
+    /**
+     * Test get file by using wild card in between file path.
+     */
+    @Test
+    public void testGetFilesUsingWildCardBetweenPath() {
+        FileEntry fileEntry = new FileEntry();
+        File parentFile = CLASS_FILE.getParentFile();
+        File grandParentFile = parentFile.getParentFile();
+        if (grandParentFile == null || !grandParentFile.exists()) {
+            throw new IllegalStateException("grandParentFile doesn't exist!");
+        }
+        String className = this.getClass().getSimpleName() + ".class";
+        fileEntry.setName(grandParentFile.getAbsolutePath() + File.separator + "*" + File.separator + className);
+        List<Substitutable> substitutables = FACTORY.getFileElements(fileEntry);
+        assertEquals(1, substitutables.size(), "substitutables.size");
+        assertEquals(className, new File(substitutables.get(0).getName()).getName());
+    }
+
+    /**
+     * Test get file by using regex pattern.
+     */
+    @Test
+    public void testGetFilesUsingRegex() {
+        FileEntry fileEntry = new FileEntry();
+        fileEntry.setName(CLASS_FILE.getParentFile().getAbsolutePath() + File.separator + "(.*+)");
+        fileEntry.setRegex("yes");
+        List<Substitutable> substitutables = FACTORY.getFileElements(fileEntry);
+        for (Substitutable substitutable : substitutables) {
+            if (substitutable.getName().endsWith(CLASS_FILE.getAbsolutePath())) {
+                return;
+            }
+        }
+        fail("File wasn't found using regex.");
+    }
+
+    /**
+     * Test get files for invalid file name.
+     */
+    @Test
+    public void testGetFileInvalidInput() {
+        FileEntry fileEntry = new FileEntry();
+        fileEntry.setName(CLASS_FILE.getAbsolutePath() + File.separator + "zzzzzzzzz.class");
+        List<Substitutable> substitutables = FACTORY.getFileElements(fileEntry);
+        assertTrue(substitutables.isEmpty());
+    }
+}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestModeProcessor.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ModeProcessorTest.java
similarity index 80%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestModeProcessor.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ModeProcessorTest.java
index 5ab1d2c..ff5f2fc 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestModeProcessor.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/ModeProcessorTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,15 +18,18 @@
 
 import java.io.File;
 
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.sun.enterprise.admin.servermgmt.xml.stringsubs.ModeType;
 
 /**
  * Unit test for {@link ModeProcessor} functionality.
  */
-public class TestModeProcessor {
+public class ModeProcessorTest {
 
     /**
      * Test for <code>null</code> input string.
@@ -34,7 +37,7 @@
     @Test
     public void testNullInput() {
         String outputStr = ModeProcessor.processModeType(ModeType.DOUBLE, null);
-        Assert.assertNull(outputStr);
+        assertNull(outputStr);
     }
 
     /**
@@ -43,7 +46,7 @@
     @Test
     public void testInvalidMode() {
         String inputStr = "TEST";
-        Assert.assertEquals(inputStr, ModeProcessor.processModeType(null, inputStr));
+        assertEquals(inputStr, ModeProcessor.processModeType(null, inputStr));
     }
 
     /**
@@ -52,7 +55,7 @@
     @Test
     public void testEmptyInput() {
         String outputStr = ModeProcessor.processModeType(ModeType.DOUBLE, "");
-        Assert.assertTrue(outputStr.isEmpty());
+        assertTrue(outputStr.isEmpty());
     }
 
     /**
@@ -63,7 +66,7 @@
         String inputStr = "First Slash \\ Second Double Slash \\\\";
         String expectedOutput = "First Slash / Second Double Slash //";
         String outputStr = ModeProcessor.processModeType(ModeType.FORWARD, inputStr);
-        Assert.assertEquals(outputStr, expectedOutput);
+        assertEquals(outputStr, expectedOutput);
     }
 
     /**
@@ -74,7 +77,7 @@
         String inputStr = "First Slash \\ First Colon : Second Double Slash \\\\ Second Double Colon ::";
         String expectedOutput = "First Slash \\\\ First Colon \\: Second Double Slash \\\\\\\\ Second Double Colon \\:\\:";
         String outputStr = ModeProcessor.processModeType(ModeType.DOUBLE, inputStr);
-        Assert.assertEquals(outputStr, expectedOutput);
+        assertEquals(outputStr, expectedOutput);
     }
 
     /**
@@ -90,6 +93,6 @@
         builder.append(File.separator);
         String expectedOutput = "First Separator ${/} Second Double Separator ${/}${/}";
         String outputStr = ModeProcessor.processModeType(ModeType.POLICY, builder.toString());
-        Assert.assertEquals(outputStr, expectedOutput);
+        assertEquals(outputStr, expectedOutput);
     }
 }
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngineTest.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngineTest.java
new file mode 100644
index 0000000..cf11fe2
--- /dev/null
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionEngineTest.java
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
+
+import com.sun.enterprise.admin.servermgmt.stringsubs.AttributePreprocessor;
+import com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException;
+import com.sun.enterprise.admin.servermgmt.test.ServerMgmgtTestFiles;
+import com.sun.enterprise.admin.servermgmt.xml.stringsubs.StringsubsDefinition;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+/**
+ * Unit test class to test {@link StringSubstitutionEngine} functionality.
+ */
+public class StringSubstitutionEngineTest {
+
+    private static final ServerMgmgtTestFiles TEST_FILES = new ServerMgmgtTestFiles(StringSubstitutionEngineTest.class);
+    private static final String GROUP_WITHOUT_CHANGE_PAIR = "group_without_change_pair";
+    private static final String GROUP_WITHOUT_FILES = "group_without_files";
+    private static final String GROUP_WITH_INVALID_FILE_PATHS = "group_invalid_file_paths";
+    private static final String _testFileName = "testStringSubs.txt";
+    private final Map<String, String> substitutionRestoreMap = new HashMap<>();
+
+    private File testFile;
+    private Path archiveDirPath;
+    private StringSubstitutionEngine engine;
+
+    @BeforeEach
+    public void init() throws Exception {
+        archiveDirPath = TEST_FILES.getBasePackageAbsolutePath();
+
+        final Map<String, String> lookUpMap = new HashMap<>();
+        lookUpMap.put("ORACLE_HOME", "REPLACED_ORACLE_HOME");
+        lookUpMap.put("MW_HOME", "REPLACED_MW_HOME");
+        substitutionRestoreMap.put("REPLACED_ORACLE_HOME", "@ORACLE_HOME@");
+        substitutionRestoreMap.put("REPLACED_MW_HOME", "@MW_HOME@");
+        engine = new StringSubstitutionEngine(TEST_FILES.openInputStream("stringsubs.xml"));
+        engine.setAttributePreprocessor(new CustomAttributePreprocessor(lookUpMap));
+    }
+
+    /**
+     * Test the engine initialization for invalid stream.
+     */
+    @Test
+    public void testInitializationForInvalidStream() {
+        try {
+            new StringSubstitutionEngine(null);
+            fail("Allowing to parse the invalid stringsubs.xml stream.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("InputStream is null", e.getMessage());
+        }
+    }
+
+    /**
+     * Test the loaded string-subs.xml object.
+     */
+    @Test
+    public void testXMLLoading() {
+        StringsubsDefinition def = engine.getStringSubsDefinition();
+        assertNotNull(def);
+        assertNotNull(def.getComponent());
+        assertEquals(def.getComponent().size(), 2);
+        assertNotNull(def.getVersion());
+        assertFalse(def.getChangePair().isEmpty());
+    }
+
+    /**
+     * Test substitution for null Component.
+     */
+    @Test
+    public void testSubstitutionForNullComponent() {
+        try {
+            engine.substituteComponents(null);
+            fail("Allowing to peform substitution for null Component.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("No Component identifiers for substitution.", e.getMessage());
+        }
+    }
+
+    /**
+     * Test substitution for empty Component.
+     */
+    @Test
+    public void testSubstitutionForEmptyComponent() {
+        try {
+            engine.substituteComponents(new ArrayList<String>(1));
+            fail("Allowing to peform substitution for empty Component.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("No Component identifiers for substitution.", e.getMessage());
+        }
+    }
+
+    /**
+     * Test substitution for invalid Component.
+     * @throws Exception
+     */
+    @Test
+    public void testSubstitutionForInvalidComponent() throws Exception {
+        List<String> componentIDs = new ArrayList<>(1);
+        componentIDs.add("invalidComponent");
+        engine.substituteComponents(componentIDs);
+    }
+
+    /**
+     * Test substitution for invalid Component.
+     * @throws Exception
+     */
+    @Test
+    public void testSubstitutionForComponentWithoutGroup() throws Exception {
+        List<String> componentIDs = new ArrayList<>(1);
+        componentIDs.add("component_without_group");
+        engine.substituteComponents(componentIDs);
+    }
+
+    /**
+     * Test substitution for null Group.
+     */
+    @Test
+    public void testSubstitutionForNullGroup() {
+        try {
+            engine.substituteGroups(null);
+            fail("Allowing to peform substitution for null Groups.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("No Group identifiers for substitution.", e.getMessage());
+        }
+    }
+
+    /**
+     * Test substitution for empty Group.
+     */
+    @Test
+    public void testSubstitutionForEmptyGroup() {
+        try {
+            engine.substituteGroups(new ArrayList<String>(1));
+            fail("Allowing to peform substitution for empty Groups.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("No Group identifiers for substitution.", e.getMessage());
+        }
+    }
+
+    /**
+     * Test substitution for invalid Group.
+     * @throws Exception
+     */
+    @Test
+    public void testSubstitutionForInvalidGroup() throws Exception {
+        List<String> groupIDs = new ArrayList<>(1);
+        groupIDs.add("invalidGroup");
+        engine.substituteGroups(groupIDs);
+    }
+
+    /**
+     * Test substitution for Group without any change pair.
+     * @throws Exception
+     */
+    @Test
+    public void testSubstitutionForGroupWithoutChangePair() throws Exception {
+        List<String> groupIDs = new ArrayList<>(1);
+        groupIDs.add(GROUP_WITHOUT_CHANGE_PAIR);
+        createTextFile();
+        engine.substituteGroups(groupIDs);
+        final List<String> lines = Files.readAllLines(testFile.toPath());
+        assertEquals("@ORACLE_HOME@ First word in first line", lines.get(0));
+        assertEquals("Second line last word @MW_HOME@", lines.get(1));
+    }
+
+    /**
+     * Test substitution for Group pointing to invalid file paths.
+     * @throws Exception
+     */
+    @Test
+    public void testSubstitutionForGroupInvalidFilePath() throws Exception {
+        List<String> groupIDs = new ArrayList<>(1);
+        groupIDs.add(GROUP_WITH_INVALID_FILE_PATHS);
+        engine.substituteGroups(groupIDs);
+    }
+
+    /**
+     * Test substitution for empty Group.
+     * @throws Exception
+     */
+    @Test
+    public void testSubstitutionForGroupWithoutFiles() throws Exception {
+        List<String> groupIDs = new ArrayList<>(1);
+        groupIDs.add(GROUP_WITHOUT_FILES);
+        engine.substituteGroups(groupIDs);
+    }
+
+    /**
+     * Creates text file.
+     * @throws Exception
+     */
+    private void createTextFile() throws Exception {
+        if (testFile != null) {
+            destroy();
+        }
+        testFile = new File(_testFileName);
+        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(testFile)))) {
+            writer.write("@ORACLE_HOME@ First word in first line");
+            writer.newLine();
+            writer.write("Second line last word @MW_HOME@");
+        }
+    }
+
+    /**
+     * Custom implementation of {@link AttributePreprocessor}.
+     */
+    private class CustomAttributePreprocessor extends AttributePreprocessorImpl {
+        private final String testFilePath;
+
+        CustomAttributePreprocessor(Map<String, String> lookUpMap) throws Exception {
+            super(lookUpMap);
+            if (testFile == null) {
+                createTextFile();
+            }
+            testFilePath = testFile.getAbsolutePath().replace(File.separator + _testFileName, "");
+            lookUpMap.put("ARCHIVE_DIR", archiveDirPath.toString());
+            lookUpMap.put("TEST_FILE_DIR", testFilePath);
+        }
+    }
+
+    /**
+     * Delete test file after test case executions.
+     */
+    @AfterEach
+    public void destroy() {
+        if (testFile != null) {
+            testFile.delete();
+            testFile = null;
+        }
+    }
+}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParserTest.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParserTest.java
new file mode 100644
index 0000000..7c49d08
--- /dev/null
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/StringSubstitutionParserTest.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException;
+import com.sun.enterprise.admin.servermgmt.test.ServerMgmgtTestFiles;
+import com.sun.enterprise.admin.servermgmt.xml.stringsubs.StringsubsDefinition;
+
+/**
+ * Unit test class to test {@link StringSubstitutionParser} functionality.
+ */
+public class StringSubstitutionParserTest {
+
+    private static final ServerMgmgtTestFiles TEST_UTILS = new ServerMgmgtTestFiles(StringSubstitutionParserTest.class);
+    private InputStream _configStream;
+
+    @BeforeEach
+    public void init() {
+        _configStream = TEST_UTILS.openInputStream("stringsubs.xml");
+    }
+
+
+    @AfterEach
+    public void close() throws IOException {
+        if (_configStream != null) {
+            _configStream.close();
+        }
+    }
+
+
+    @Test
+    public void testParserWithNullInput() {
+        try {
+            StringSubstitutionParser.parse(null);
+            fail("Failed, Parser is allowing null stream to parse.");
+        } catch (StringSubstitutionException e) {
+            assertEquals("Invalid Stream.", e.getMessage());
+        }
+    }
+
+    /**
+     * Test string subs XML parsing.
+     * @throws Exception
+     */
+    @Test
+    public void testParser() throws Exception {
+        StringsubsDefinition def = StringSubstitutionParser.parse(_configStream);
+        assertNotNull(def);
+        assertNotNull(def.getComponent());
+        assertNotNull(def.getVersion());
+        assertFalse(def.getChangePair().isEmpty());
+    }
+}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstituionFileUtilTest.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstituionFileUtilTest.java
new file mode 100644
index 0000000..bc1578f
--- /dev/null
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/SubstituionFileUtilTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.greaterThan;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Unit test class for {@link SubstitutionFileUtil}.
+ */
+public class SubstituionFileUtilTest {
+
+    /**
+     * Test the file size for which in-memory substitution can be performed.
+     */
+    @Test
+    public void testInMemorySubstitutionFileSize() {
+        int maxSize = SubstitutionFileUtil.getInMemorySubstitutionFileSizeInBytes();
+        assertThat(maxSize, greaterThan(0));
+        assertEquals(maxSize, SubstitutionFileUtil.getInMemorySubstitutionFileSizeInBytes());
+    }
+
+    /**
+     * Test the creation of directory.
+     * @throws Exception
+     */
+    @Test
+    public void testDirSetUp() throws Exception {
+        File dir = SubstitutionFileUtil.setupDir("testing");
+        assertTrue(dir.exists());
+        assertTrue(dir.isDirectory());
+        assertEquals(0, dir.list().length);
+
+        SubstitutionFileUtil.removeDir(dir);
+        assertFalse(dir.exists());
+    }
+
+
+    /**
+     * Test the removal of null directory.
+     */
+    @Test
+    public void testRemoveNullDir() {
+        SubstitutionFileUtil.removeDir(null);
+    }
+
+
+    /**
+     * Test the removal of directory recursively.
+     * @throws Exception
+     */
+    @Test
+    public void testDirRemovalRecursively() throws Exception {
+        File dir = SubstitutionFileUtil.setupDir("testing");
+        assertTrue(dir.exists());
+        assertTrue(dir.isDirectory());
+        assertEquals(0, dir.list().length);
+
+        File testFile = new File(dir, "testFile.txt");
+        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(testFile)))) {
+            writer.write("Testing: " + SubstitutionFileUtil.class.getSimpleName());
+        }
+        SubstitutionFileUtil.removeDir(dir);
+        assertFalse(dir.exists());
+    }
+}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestFileEntryFactory.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestFileEntryFactory.java
deleted file mode 100644
index 32db93a..0000000
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestFileEntryFactory.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable;
-import com.sun.enterprise.admin.servermgmt.xml.stringsubs.FileEntry;
-
-/**
- * Unit test for {@link FileEntryFactory} functionality.
- */
-public class TestFileEntryFactory {
-
-    private static final String _qualifiedClassName = TestFileEntryFactory.class.getName().replace('.', '/') + ".class";
-    private FileEntryFactory _factory;
-    private File _classFile;
-
-    @BeforeClass
-    public void init() {
-        URL url = TestFileEntryFactory.class.getClassLoader().getResource(_qualifiedClassName);
-        _factory = new FileEntryFactory();
-        _classFile = new File(url.getPath());
-    }
-
-    /**
-     * Test get file by mentioning the path of an directory.
-     */
-    @Test
-    public void testGetFileFromDir() {
-        FileEntry fileEntry = new FileEntry();
-        fileEntry.setName(_classFile.getParentFile().getAbsolutePath());
-        List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
-        Assert.assertTrue(!substitutables.isEmpty());
-        boolean fileFound = false;
-        for (Substitutable substitutable : substitutables) {
-            if (substitutable.getName().endsWith(_classFile.getAbsolutePath())) {
-                fileFound = true;
-                break;
-            }
-        }
-        Assert.assertTrue(fileFound);
-    }
-
-    /**
-     * Test get file by mentioning the absolute path of an file.
-     */
-    @Test
-    public void testGetFile() {
-        FileEntry fileEntry = new FileEntry();
-        fileEntry.setName(_classFile.getAbsolutePath());
-        List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
-        Assert.assertTrue(!substitutables.isEmpty());
-        Assert.assertTrue(substitutables.size() == 1);
-        Assert.assertTrue(substitutables.get(0).getName().equals(_classFile.getAbsolutePath()));
-    }
-
-    /**
-     * Test get file by using wild card.
-     */
-    @Test
-    public void testGetFilesUsingWildCard() {
-        FileEntry fileEntry = new FileEntry();
-        fileEntry.setName(_classFile.getParentFile().getAbsolutePath() + File.separator + "Test*");
-        List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
-        Assert.assertTrue(!substitutables.isEmpty());
-        boolean validResult = true;
-        for (Substitutable substitutable : substitutables) {
-            if (!(new File(substitutable.getName())).getName().startsWith("Test")) {
-                validResult = false;
-                break;
-            }
-        }
-        Assert.assertTrue(validResult);
-    }
-
-    /**
-     * Test get file by using wild card in between file path.
-     */
-    @Test
-    public void testGetFilesUsingWildCardBetweenPath() {
-        FileEntry fileEntry = new FileEntry();
-        File parentFile = _classFile.getParentFile();
-        File grandParentFile = parentFile.getParentFile();
-        if (grandParentFile == null || !grandParentFile.exists()) {
-            return;
-        }
-        String className = this.getClass().getSimpleName() + ".class";
-        fileEntry.setName(grandParentFile.getAbsolutePath() + File.separator + "*" + File.separator + className);
-        List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
-        Assert.assertTrue(!substitutables.isEmpty());
-        Assert.assertTrue(substitutables.size() == 1);
-        Assert.assertTrue((new File(substitutables.get(0).getName())).getName().equals(className));
-    }
-
-    /**
-     * Test get file by using regex pattern.
-     */
-    @Test
-    public void testGetFilesUsingRegex() {
-        FileEntry fileEntry = new FileEntry();
-        if (!_classFile.exists()) {
-            Assert.fail("Not able to locate Test class :" + TestFileEntryFactory.class.getSimpleName());
-        }
-        fileEntry.setName(_classFile.getParentFile().getAbsolutePath() + File.separator + "(.*+)");
-        fileEntry.setRegex("yes");
-        List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
-        boolean fileFound = false;
-        for (Substitutable substitutable : substitutables) {
-            if (substitutable.getName().endsWith(_classFile.getAbsolutePath())) {
-                fileFound = true;
-                break;
-            }
-        }
-        Assert.assertTrue(fileFound);
-    }
-
-    /**
-     * Test get files for invalid file name.
-     */
-    @Test
-    public void testGetFileInvalidInput() {
-        FileEntry fileEntry = new FileEntry();
-        fileEntry.setName(_classFile.getAbsolutePath() + File.separator + "zzzzzzzzz.class");
-        List<Substitutable> substitutables = _factory.getFileElements(fileEntry);
-        Assert.assertTrue(substitutables.isEmpty());
-    }
-}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestStringSubstitutionEngine.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestStringSubstitutionEngine.java
deleted file mode 100644
index 33ce752..0000000
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestStringSubstitutionEngine.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.sun.enterprise.admin.servermgmt.stringsubs.AttributePreprocessor;
-import com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException;
-import com.sun.enterprise.admin.servermgmt.xml.stringsubs.StringsubsDefinition;
-
-/**
- * Unit test class to test {@link StringSubstitutionEngine} functionality.
- */
-public class TestStringSubstitutionEngine {
-
-    private final static String _stringSubsPath = TestStringSubstitutionEngine.class.getPackage().
-            getName().replace(".", "/") + "/stringsubs.xml";
-    private static final String GROUP_WITHOUT_CHANGE_PAIR = "group_without_change_pair";
-    private static final String GROUP_WITHOUT_FILES = "group_without_files";
-    private static final String GROUP_WITH_INVALID_FILE_PATHS = "group_invalid_file_paths";
-    private static final String _testFileName = "testStringSubs.txt";
-    private static Map<String, String> _substitutionRestoreMap = new HashMap<String, String>();
-
-    private File _testFile = null;
-    private String _archiveDirPath = null;
-    private StringSubstitutionEngine _engine;
-
-    @BeforeClass
-    public void init() throws Exception {
-        InputStream configStream = TestStringSubstitutionEngine.class.getClassLoader().
-                getResourceAsStream(_stringSubsPath);
-        URL url = TestStringSubstitutionEngine.class.getClassLoader().getResource(_stringSubsPath);
-        _archiveDirPath = new File(url.getPath()).getParentFile().getAbsolutePath();
-
-        Map<String, String> lookUpMap = new HashMap<String, String>();
-        lookUpMap.put("ORACLE_HOME", "REPLACED_ORACLE_HOME");
-        lookUpMap.put("MW_HOME", "REPLACED_MW_HOME");
-        _substitutionRestoreMap.put("REPLACED_ORACLE_HOME", "@ORACLE_HOME@");
-        _substitutionRestoreMap.put("REPLACED_MW_HOME", "@MW_HOME@");
-        _engine = new StringSubstitutionEngine(configStream);
-        _engine.setAttributePreprocessor(new CustomAttributePreprocessor(lookUpMap));
-    }
-
-    /**
-     * Test the engine initialization for invalid stream.
-     */
-    @Test
-    public void testInitializationForInvalidStream() {
-        try {
-            new StringSubstitutionEngine(null);
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("Allowing to parse the invalid stringsubs.xml stream.");
-    }
-
-    /**
-     * Test the loaded string-subs.xml object.
-     */
-    @Test
-    public void testXMLLoading() {
-        StringsubsDefinition def = _engine.getStringSubsDefinition();
-        Assert.assertNotNull(def);
-        Assert.assertNotNull(def.getComponent());
-        Assert.assertEquals(def.getComponent().size(), 2);
-        Assert.assertNotNull(def.getVersion());
-        Assert.assertFalse(def.getChangePair().isEmpty());
-    }
-
-    /**
-     * Test substitution for null Component.
-     */
-    @Test
-    public void testSubstitutionForNullComponent() {
-        try {
-            _engine.substituteComponents(null);
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("Allowing to peform substitution for null Component.");
-    }
-
-    /**
-     * Test substitution for empty Component.
-     */
-    @Test
-    public void testSubstitutionForEmptyComponent() {
-        try {
-            _engine.substituteComponents(new ArrayList<String>(1));
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("Allowing to peform substitution for empty Component.");
-    }
-
-    /**
-     * Test substitution for invalid Component.
-     */
-    @Test
-    public void testSubstitutionForInvalidComponent() {
-        List<String> componentIDs = new ArrayList<String>(1);
-        componentIDs.add("invalidComponent");
-        try {
-            _engine.substituteComponents(componentIDs);
-        }
-        catch (StringSubstitutionException e) {
-            Assert.fail("Throwing exception if invalid Component id is passed for susbtitution.");
-            return;
-        }
-    }
-
-    /**
-     * Test substitution for invalid Component.
-     */
-    @Test
-    public void testSubstitutionForComponentWithoutGroup() {
-        List<String> componentIDs = new ArrayList<String>(1);
-        componentIDs.add("component_without_group");
-        try {
-            _engine.substituteComponents(componentIDs);
-        } catch (StringSubstitutionException e) {
-            Assert.fail("Throwing exception if invalid Component id is passed for susbtitution.");
-            return;
-        }
-    }
-
-    /**
-     * Test substitution for null Group.
-     */
-    @Test
-    public void testSubstitutionForNullGroup() {
-        try {
-            _engine.substituteGroups(null);
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("Allowing to peform substitution for null Groups.");
-    }
-
-    /**
-     * Test substitution for empty Group.
-     */
-    @Test
-    public void testSubstitutionForEmptyGroup() {
-        try {
-            _engine.substituteGroups(new ArrayList<String>(1));
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("Allowing to peform substitution for empty Groups.");
-    }
-
-    /**
-     * Test substitution for invalid Group.
-     */
-    @Test
-    public void testSubstitutionForInvalidGroup() {
-        List<String> groupIDs = new ArrayList<String>(1);
-        groupIDs.add("invalidGroup");
-        try {
-            _engine.substituteGroups(groupIDs);
-        } catch (StringSubstitutionException e) {
-            Assert.fail("Throwing exception if invalid Group id is passed for susbtitution.");
-            return;
-        }
-    }
-
-    /**
-     * Test substitution for Group without any change pair.
-     */
-    @Test
-    public void testSubstitutionForGroupWithoutChangePair() {
-        List<String> groupIDs = new ArrayList<String>(1);
-        groupIDs.add(GROUP_WITHOUT_CHANGE_PAIR);
-        try {
-            createTextFile();
-            _engine.substituteGroups(groupIDs);
-            BufferedReader reader = null;
-            try {
-                reader = new BufferedReader(new InputStreamReader(new FileInputStream(_testFile)));
-                String afterSubstitutionLine = null;
-                int i = 0;
-                while ((afterSubstitutionLine = reader.readLine()) != null) {
-                    switch (i++)
-                    {
-                        case 0:
-                            Assert.assertTrue(afterSubstitutionLine.equals("@ORACLE_HOME@ First word in first line"));
-                            break;
-                        case 1:
-                            Assert.assertTrue(afterSubstitutionLine.equals("Second line last word @MW_HOME@"));
-                            break;
-                        default:
-                            Assert.fail("Substitution happening for a Group without change pair.");
-                            break;
-                    }
-                }
-            } finally {
-                if (reader != null) {
-                    reader.close();
-                }
-            }
-        } catch (Exception e) {
-            Assert.fail("Throwing exception if Group without change pair undergo substitution.");
-            return;
-        }
-    }
-
-    /**
-     * Test substitution for Group pointing to invalid file paths.
-     */
-    @Test
-    public void testSubstitutionForGroupInvalidFilePath() {
-        List<String> groupIDs = new ArrayList<String>(1);
-        groupIDs.add(GROUP_WITH_INVALID_FILE_PATHS);
-        try {
-            _engine.substituteGroups(groupIDs);
-        } catch (StringSubstitutionException e) {
-            Assert.fail("Throwing exception if Group having invalid file paths undergo substitution.");
-            return;
-        }
-    }
-
-    /**
-     * Test substitution for empty Group.
-     */
-    @Test
-    public void testSubstitutionForGroupWithoutFiles() {
-        List<String> groupIDs = new ArrayList<String>(1);
-        groupIDs.add(GROUP_WITHOUT_FILES);
-        try {
-            _engine.substituteGroups(groupIDs);
-        } catch (StringSubstitutionException e) {
-            Assert.fail("Throwing exception if Group without any substitutable entries undergo substitution.");
-            return;
-        }
-    }
-
-    /**
-     * Creates text file.
-     */
-    private void createTextFile() {
-        BufferedWriter writer = null;
-        try {
-            if (_testFile != null) {
-                destroy();
-            }
-            _testFile = new File(_testFileName);
-            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(_testFile)));
-            writer.write("@ORACLE_HOME@ First word in first line");
-            writer.newLine();
-            writer.write("Second line last word @MW_HOME@");
-            writer.close();
-        } catch (Exception e) {
-            Assert.fail("Not able to create test Text file", e);
-        }
-    }
-
-    /**
-     * Custom implementation of {@link AttributePreprocessor}.
-     */
-    private class CustomAttributePreprocessor extends AttributePreprocessorImpl {
-        private String testFilePath;
-
-        CustomAttributePreprocessor(Map<String, String> lookUpMap) {
-            super(lookUpMap);
-            if (_testFile == null) {
-                createTextFile();
-            }
-            testFilePath = _testFile.getAbsolutePath().replace(File.separator + _testFileName, "");
-            lookUpMap.put("ARCHIVE_DIR", _archiveDirPath);
-            lookUpMap.put("TEST_FILE_DIR", testFilePath);
-        }
-    }
-
-    /**
-     * Delete test file after test case executions.
-     */
-    @AfterTest
-    public void destroy() {
-        if (_testFile != null && _testFile.exists()) {
-            if(!_testFile.delete()) {
-                System.out.println("Not able to delete the temp file : " + _testFile.getAbsolutePath());
-                _testFile.deleteOnExit();
-            }
-        }
-        _testFile = null;
-    }
-}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestStringSubstitutionParser.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestStringSubstitutionParser.java
deleted file mode 100644
index 3923ac8..0000000
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestStringSubstitutionParser.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
-
-import java.io.File;
-import java.io.InputStream;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.sun.enterprise.admin.servermgmt.stringsubs.StringSubstitutionException;
-import com.sun.enterprise.admin.servermgmt.xml.stringsubs.StringsubsDefinition;
-
-/**
- * Unit test class to test {@link StringSubstitutionParser} functionality.
- */
-public class TestStringSubstitutionParser {
-
-    // Test string-subs.xml file.
-    private final String _stringSubsPath = TestStringSubstitutionParser.class.getPackage().
-            getName().replace(".", File.separator) + File.separator + "stringsubs.xml";
-    private InputStream _configStream = null;
-
-    @BeforeClass
-    public void init() {
-        _configStream = TestStringSubstitutionParser.class.getClassLoader().getResourceAsStream(_stringSubsPath);
-    }
-
-    @Test
-    public void testParserWithNullInput() {
-        try {
-            StringSubstitutionParser.parse(null);
-        } catch (StringSubstitutionException e) {
-            return;
-        }
-        Assert.fail("Failed, Parser is allowing null stream to parse.");
-    }
-
-    /**
-     * Test string subs XML parsing.
-     */
-    @Test
-    public void testParser() {
-        StringsubsDefinition def = null;
-        try {
-            def = StringSubstitutionParser.parse(_configStream);
-        } catch (StringSubstitutionException e) {
-            Assert.fail("Failed to parse xml : " + _stringSubsPath, e);
-        }
-        Assert.assertNotNull(def);
-        Assert.assertNotNull(def.getComponent());
-        Assert.assertNotNull(def.getVersion());
-        Assert.assertFalse(def.getChangePair().isEmpty());
-    }
-}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestSubstituionFileUtil.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestSubstituionFileUtil.java
deleted file mode 100644
index 5872f24..0000000
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/TestSubstituionFileUtil.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.enterprise.admin.servermgmt.stringsubs.impl;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * Unit test class for {@link SubstitutionFileUtil}.
- */
-public class TestSubstituionFileUtil {
-
-    /**
-     * Test the file size for which in-memory substitution can be performed.
-     */
-    @Test
-    public void testInMemorySubstitutionFileSize() {
-        int maxSize = SubstitutionFileUtil.getInMemorySubstitutionFileSizeInBytes();
-        Assert.assertTrue(maxSize > 0);
-        Assert.assertEquals(maxSize, SubstitutionFileUtil.getInMemorySubstitutionFileSizeInBytes());
-    }
-
-    /**
-     * Test the creation of directory.
-     */
-    @Test
-    public void testDirSetUp() {
-        try {
-            File dir = SubstitutionFileUtil.setupDir("testing");
-            Assert.assertTrue(dir.exists());
-            Assert.assertTrue(dir.isDirectory());
-            Assert.assertTrue(dir.list().length == 0);
-
-            SubstitutionFileUtil.removeDir(dir);
-            Assert.assertFalse(dir.exists());
-        } catch (IOException e) {
-            Assert.fail("Failed to setUp/remove directory by using subsitution file utility.", e);
-        }
-    }
-
-    /**
-     * Test the removal of null directory.
-     */
-    @Test
-    public void testRemoveNullDir() {
-        try {
-            SubstitutionFileUtil.removeDir(null);
-        } catch (Exception e) {
-            Assert.fail("Error occurred in directory deletion.", e);
-        }
-    }
-
-    /**
-     * Test the removal of directory recursively.
-     */
-    @Test
-    public void testDirRemovalRecursively() {
-        try {
-            File dir = SubstitutionFileUtil.setupDir("testing");
-            Assert.assertTrue(dir.exists());
-            Assert.assertTrue(dir.isDirectory());
-            Assert.assertTrue(dir.list().length == 0);
-
-            BufferedWriter writer = null;
-            try {
-                File testFile = new File(dir.getAbsolutePath() + File.separator + "testFile.txt");
-                writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(testFile)));
-                writer.write("Testing : " + SubstitutionFileUtil.class.getSimpleName());
-                writer.close();
-            } catch (Exception e) {
-                Assert.fail("Not able to create test Text file.", e);
-            }
-            SubstitutionFileUtil.removeDir(dir);
-            Assert.assertFalse(dir.exists());
-        } catch (IOException e) {
-            Assert.fail("Failed to setUp/remove directory by using subsitution file utility.", e);
-        }
-    }
-}
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/AbstractSubstitutionAlgo.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/AbstractSubstitutionAlgo.java
index d646ca3..e92837a 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/AbstractSubstitutionAlgo.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/AbstractSubstitutionAlgo.java
@@ -16,51 +16,50 @@
 
 package com.sun.enterprise.admin.servermgmt.stringsubs.impl.algorithm;
 
-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.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
 import com.sun.enterprise.admin.servermgmt.stringsubs.Substitutable;
 import com.sun.enterprise.admin.servermgmt.stringsubs.SubstitutionAlgorithm;
 import com.sun.enterprise.admin.servermgmt.stringsubs.impl.LargeFileSubstitutionHandler;
 import com.sun.enterprise.admin.servermgmt.stringsubs.impl.SmallFileSubstitutionHandler;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.file.Files;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+
 /**
  * Abstract class to test substitution algorithm. Derived classes will
  * provide the implementation of {@link SubstitutionAlgorithm} use to
  * execute the test cases, by defining the abstract method
  * {@link AbstractSubstitutionAlgo#getAlgorithm(Map)}
  */
-public abstract class AbstractSubstitutionAlgo
-{
-    private String _testFileName = "testStringSubs.txt";
-    private File _testFile;
-    private SubstitutionAlgorithm _algorithm;
+abstract class AbstractSubstitutionAlgo {
+    private final String testFileName = "testStringSubs.txt";
+    private File testFile;
+    private SubstitutionAlgorithm algorithm;
 
     /**
      * Create test file used as a input file for string substitution.
      */
-    @BeforeClass
+    @BeforeEach
     public void init() {
-        Map<String, String> substitutionMap = new HashMap<String, String>();
+        Map<String, String> substitutionMap = new HashMap<>();
         substitutionMap.put("line", "replacedLine");
         substitutionMap.put("file", "testFile");
         substitutionMap.put("HTTP_PORT", "8080");
         substitutionMap.put("HTTPS_PORT", "8443");
-        _algorithm = getAlgorithm(substitutionMap);
+        algorithm = getAlgorithm(substitutionMap);
     }
 
     /**
@@ -73,234 +72,121 @@
     /**
      * Test the {@link SubstitutionAlgorithm} instance for null map.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testSubstitutionForNullMap() {
-        getAlgorithm(null);
+        assertThrows(IllegalArgumentException.class, () -> getAlgorithm(null));
     }
 
     /**
      * Test the {@link SubstitutionAlgorithm} instance for empty map.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testSubstitutionForEmptyMap() {
-        getAlgorithm(new HashMap<String, String>());
+        assertThrows(IllegalArgumentException.class, () -> getAlgorithm(new HashMap<String, String>()));
     }
 
     /**
      * Test substitution for small text file.
+     * @throws Exception
      */
     @Test
-    public void testSmallTextFileSubstitution() {
+    public void testSmallTextFileSubstitution() throws Exception {
         createTextFile();
-        Substitutable resolver = null;
-        try {
-            resolver = new SmallFileSubstitutionHandler(_testFile);
-            _algorithm.substitute(resolver);
-            resolver.finish();
-        } catch (Exception e) {
-            Assert.fail("Test case execution failed", e);
-        }
-        try {
-            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(_testFile)));
-            String afterSubstitutionLine = null;
-            int i = 0;
-            while ((afterSubstitutionLine = reader.readLine()) != null) {
-                switch (i++)
-                {
-                    case 0:
-                        Assert.assertEquals(afterSubstitutionLine, "First replacedLine in testFile repeat First replacedLine in testFile");
-                        break;
-                    case 1:
-                        Assert.assertEquals(afterSubstitutionLine, "Second replacedLine in testFile");
-                        break;
-                    default:
-                        break;
-                }
-            }
-            reader.close();
-        } catch (IOException e) {
-            Assert.fail("Not able to read test file");
-        } finally {
-            _testFile.delete();
-        }
+        Substitutable resolver = new SmallFileSubstitutionHandler(testFile);
+        algorithm.substitute(resolver);
+        resolver.finish();
+        final List<String> lines = Files.readAllLines(testFile.toPath());
+        assertEquals(2, lines.size());
+        assertEquals(lines.get(0), "First replacedLine in testFile repeat First replacedLine in testFile");
+        assertEquals(lines.get(1), "Second replacedLine in testFile");
     }
 
     /**
      * Test substitution for small XML file.
+     * @throws Exception
      */
     @Test
-    public void testSmallXMLFileSubstitution() {
-        String fileName = _testFileName.replace(".txt", ".xml");
+    public void testSmallXMLFileSubstitution() throws Exception {
+        String fileName = testFileName.replace(".txt", ".xml");
         createXMLFile(fileName);
-        Substitutable resolver = null;
-        try {
-            resolver = new SmallFileSubstitutionHandler(new File(fileName));
-            _algorithm.substitute(resolver);
-            resolver.finish();
-        } catch (Exception e) {
-            Assert.fail("Test case failed", e);
-        }
-        try {
-            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(_testFile)));
-            String afterSubstitutionLine = null;
-            int i = 0;
-            while ((afterSubstitutionLine = reader.readLine()) != null) {
-                switch (i++)
-                {
-                    case 1:
-                        Assert.assertEquals(afterSubstitutionLine,
-                                "<port name=\"http\" value=\"8080\"></port>");
-                        break;
-                    case 2:
-                        Assert.assertEquals(afterSubstitutionLine,
-                                "<port name=\"https\" value=\"8443\"></port>");
-                        break;
-                    default:
-                        break;
-                }
-            }
-            reader.close();
-        } catch (IOException e) {
-            Assert.fail("Not able to read test file.", e);
-        } finally {
-            _testFile.delete();
-        }
+        Substitutable resolver = new SmallFileSubstitutionHandler(new File(fileName));
+        algorithm.substitute(resolver);
+        resolver.finish();
+        final List<String> lines = Files.readAllLines(testFile.toPath());
+        assertEquals(4, lines.size());
+        assertEquals(lines.get(0), " <ports>");
+        assertEquals(lines.get(1), "<port name=\"http\" value=\"8080\"></port>");
+        assertEquals(lines.get(2), "<port name=\"https\" value=\"8443\"></port>");
+        assertEquals(lines.get(3), "</ports>");
     }
 
     /**
      * Test substitution for large text file.
+     * @throws Exception
      */
-    //@Test
-    //TODO: Test case failing on hudson, Test case execution create temporary file
-    // to perform substitution.
-    public void testLargeTextFileSubstitution() {
+    @Test
+    public void testLargeTextFileSubstitution() throws Exception {
         createTextFile();
-        Substitutable resolver = null;
-        try {
-            resolver = new LargeFileSubstitutionHandler(_testFile);
-            _algorithm.substitute(resolver);
-            resolver.finish();
-        } catch (Exception e) {
-            Assert.fail("Test case failed : " + e.getMessage());
-        }
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(_testFileName))));
-        } catch (FileNotFoundException e) {
-            Assert.fail("Not able to locate test file : " + _testFileName, e);
-        }
-        String afterSubstitutionLine = null;
-        try {
-            int i = 0;
-            while ((afterSubstitutionLine = reader.readLine()) != null) {
-                switch (i++)
-                {
-                    case 0:
-                        Assert.assertEquals(afterSubstitutionLine,
-                                "First replacedLine in testFile repeat First replacedLine in testFile");
-                        break;
-                    case 1:
-                        Assert.assertEquals(afterSubstitutionLine,
-                                "Second replacedLine in testFile");
-                        break;
-                    default:
-                        break;
-                }
-            }
-            reader.close();
-        } catch (IOException e) {
-            Assert.fail("Not able to read test file");
-        } finally {
-            _testFile.delete();
-        }
+        Substitutable resolver = new LargeFileSubstitutionHandler(testFile);
+        algorithm.substitute(resolver);
+        resolver.finish();
+        final List<String> lines = Files.readAllLines(testFile.toPath());
+        assertEquals(2, lines.size());
+        assertEquals(lines.get(0), "First replacedLine in testFile repeat First replacedLine in testFile");
+        assertEquals(lines.get(1), "Second replacedLine in testFile");
     }
 
     /**
      * Test substitution for large XML file.
+     * @throws Exception
      */
-    //@Test
-    //TODO: Test case failing on hudson, Test case execution create temporary file
-    // to perform substitution.
-    public void testLargeXMLFileSubstitution() {
-        String fileName = _testFileName.replace(".txt", ".xml");
+    @Test
+    public void testLargeXMLFileSubstitution() throws Exception {
+        String fileName = testFileName.replace(".txt", ".xml");
         createXMLFile(fileName);
-        Substitutable resolver = null;
-        try {
-            resolver = new LargeFileSubstitutionHandler(_testFile);
-            _algorithm.substitute(resolver);
-            resolver.finish();
-        } catch (Exception e) {
-            Assert.fail("Test case failed : " + e.getMessage());
-        }
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName))));
-        } catch (FileNotFoundException e) {
-            Assert.fail("Test case failed : " + e.getMessage());
-        }
-        String afterSubstitutionLine = null;
-        try {
-            int i = 0;
-            while ((afterSubstitutionLine = reader.readLine()) != null) {
-                switch (i++)
-                {
-                    case 1:
-                        Assert.assertEquals(afterSubstitutionLine,
-                                "<port name=\"http\" value=\"8080\"></port>");
-                        break;
-                    case 2:
-                        Assert.assertEquals(afterSubstitutionLine,
-                                "<port name=\"https\" value=\"8443\"></port>");
-                        break;
-                    default:
-                        break;
-                }
-            }
-            reader.close();
-        } catch (IOException e) {
-            Assert.fail("Not able to read test file");
-        } finally {
-            _testFile.delete();
-        }
+        Substitutable resolver = new LargeFileSubstitutionHandler(testFile);
+        algorithm.substitute(resolver);
+        resolver.finish();
+        final List<String> lines = Files.readAllLines(testFile.toPath());
+        assertEquals(4, lines.size());
+        assertEquals(lines.get(0), " <ports>");
+        assertEquals(lines.get(1), "<port name=\"http\" value=\"8080\"></port>");
+        assertEquals(lines.get(2), "<port name=\"https\" value=\"8443\"></port>");
+        assertEquals(lines.get(3), "</ports>");
     }
 
     /**
      * Delete test file after test case executions.
      */
-    @AfterTest
+    @AfterEach
     public void destroy() {
-        if (_testFile != null && _testFile.exists()) {
-            if(!_testFile.delete())  {
-                System.out.println("Not able to delete the temp file : " + _testFile.getAbsolutePath());
+        if (testFile != null) {
+            if(!testFile.delete())  {
+                System.err.println("Not able to delete the temp file : " + testFile.getAbsolutePath());
             }
         }
     }
 
     /**
      * Creates text file.
+     * @throws Exception
      */
-    private void createTextFile() {
-        BufferedWriter writer = null;
-        try {
-            _testFile = new File(_testFileName);
-            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(_testFile)));
+    private void createTextFile() throws Exception {
+        testFile = new File(testFileName);
+        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(testFile)))) {
             writer.write("First line in file repeat First line in file");
             writer.newLine();
             writer.write("Second line in file");
-            writer.close();
-        } catch (Exception e) {
-            Assert.fail("Not able to create test Text file : " + _testFile.getAbsolutePath() + e.getMessage());
         }
     }
 
     /**
      * Creates XML file.
+     * @throws Exception
      */
-    private void createXMLFile(String fileName) {
-        _testFile = new File(fileName);
-        BufferedWriter writer = null;
-        try {
-            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(_testFile)));
+    private void createXMLFile(String fileName) throws Exception {
+        testFile = new File(fileName);
+        try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(testFile)))) {
             writer.write(" <ports>");
             writer.newLine();
             writer.write("<port name=\"http\" value=\"HTTP_PORT\"></port>");
@@ -308,9 +194,6 @@
             writer.write("<port name=\"https\" value=\"HTTPS_PORT\"></port>");
             writer.newLine();
             writer.write("</ports>");
-            writer.close();
-        } catch (Exception e) {
-            Assert.fail("Not able to create test XML file : " + _testFile.getAbsolutePath() + e.getMessage());
         }
     }
 }
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeNode.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNodeTest.java
similarity index 66%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeNode.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNodeTest.java
index 3ec3bf9..d6fa9dd 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeNode.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeNodeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,13 +16,18 @@
 
 package com.sun.enterprise.admin.servermgmt.stringsubs.impl.algorithm;
 
-import org.testng.Assert;
-import org.testng.annotations.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 
 /**
  * Unit test class for {@link RadixTreeNode}.
  */
-public class TestRadixTreeNode {
+public class RadixTreeNodeTest {
 
     private static final String UNIT_TEST = "unitTest";
 
@@ -32,43 +37,43 @@
     @Test
     public void testNodeCreation() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
-        Assert.assertEquals(rootNode.getKey(), UNIT_TEST);
-        Assert.assertEquals(rootNode.getValue(), UNIT_TEST);
+        assertEquals(rootNode.getKey(), UNIT_TEST);
+        assertEquals(rootNode.getValue(), UNIT_TEST);
         rootNode.setKey("newTest");
-        Assert.assertEquals(rootNode.getKey(), "newTest");
+        assertEquals(rootNode.getKey(), "newTest");
         rootNode.setValue("newValue");
-        Assert.assertEquals(rootNode.getValue(), "newValue");
-        Assert.assertNull(rootNode.getParentNode());
-        Assert.assertTrue(rootNode.getChildNodes().isEmpty());
+        assertEquals(rootNode.getValue(), "newValue");
+        assertNull(rootNode.getParentNode());
+        assertTrue(rootNode.getChildNodes().isEmpty());
     }
 
     /**
      * Test the child node addition for <code>null</code> child.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testAdditionForNullNode() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
-        rootNode.addChildNode(null);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.addChildNode(null));
     }
 
     /**
      * Test addition of child node having empty key.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testAdditionForEmptyChildKey() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode("", "");
-        rootNode.addChildNode(firstChildNode);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.addChildNode(firstChildNode));
     }
 
     /**
      * Test addition of child node having <code>null</code> key.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testAdditionForNullChildKey() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode(null, "");
-        rootNode.addChildNode(firstChildNode);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.addChildNode(firstChildNode));
     }
 
     /**
@@ -79,8 +84,8 @@
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode("firstChildKey", "firstChildValue");
         rootNode.addChildNode(firstChildNode);
-        Assert.assertTrue(rootNode.getChildNodes().size() == 1);
-        Assert.assertEquals(rootNode.getChildNode('f'), firstChildNode);
+        assertTrue(rootNode.getChildNodes().size() == 1);
+        assertEquals(rootNode.getChildNode('f'), firstChildNode);
     }
 
     /**
@@ -91,54 +96,54 @@
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode("test", "oldtest");
         rootNode.addChildNode(firstChildNode);
-        Assert.assertEquals(firstChildNode.getParentNode(), rootNode);
-        Assert.assertEquals(rootNode.getChildNode('t'), firstChildNode);
+        assertEquals(firstChildNode.getParentNode(), rootNode);
+        assertEquals(rootNode.getChildNode('t'), firstChildNode);
         RadixTreeNode duplicateNode = new RadixTreeNode("test", "newtest");
         rootNode.addChildNode(duplicateNode);
-        Assert.assertNull(firstChildNode.getParentNode());
-        Assert.assertEquals(rootNode.getChildNode('t'), duplicateNode);
-        Assert.assertTrue(rootNode.getChildNodes().size() == 1);
+        assertNull(firstChildNode.getParentNode());
+        assertEquals(rootNode.getChildNode('t'), duplicateNode);
+        assertTrue(rootNode.getChildNodes().size() == 1);
     }
 
     /**
      *  Test the child node removal for <code>null</code> child.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testRemovalForNullNode() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
-        rootNode.removeChildNode(null);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.removeChildNode(null));
     }
 
     /**
      * Test removal of child node having empty key.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testRemovalForEmptyChildKey() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode("", "");
-        rootNode.removeChildNode(firstChildNode);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.removeChildNode(firstChildNode));
     }
 
     /**
      * Test removal of child node having <code>null</code> key.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testRemovalForNullChildKey() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode(null, "");
-        rootNode.removeChildNode(firstChildNode);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.removeChildNode(firstChildNode));
     }
 
     /**
      * Test child node removal for invalid child node.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testInvalidChildNodeRemoval() {
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode("firstChildKey", "firstChildValue");
         rootNode.addChildNode(firstChildNode);
         RadixTreeNode invalidNode = new RadixTreeNode("InvalidChildKey", "InvalidChildValue");
-        rootNode.removeChildNode(invalidNode);
+        assertThrows(IllegalArgumentException.class, () -> rootNode.removeChildNode(invalidNode));
     }
 
     /**
@@ -149,9 +154,9 @@
         RadixTreeNode rootNode = new RadixTreeNode(UNIT_TEST, UNIT_TEST);
         RadixTreeNode firstChildNode = new RadixTreeNode("firstChildKey", "firstChildValue");
         rootNode.addChildNode(firstChildNode);
-        Assert.assertTrue(rootNode.getChildNodes().size() == 1);
-        Assert.assertEquals(rootNode.getChildNode('f'), firstChildNode);
+        assertTrue(rootNode.getChildNodes().size() == 1);
+        assertEquals(rootNode.getChildNode('f'), firstChildNode);
         rootNode.removeChildNode(firstChildNode);
-        Assert.assertTrue(rootNode.getChildNodes().isEmpty());
+        assertTrue(rootNode.getChildNodes().isEmpty());
     }
 }
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeSubstitutionAlgorithm.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgorithmTest.java
similarity index 71%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeSubstitutionAlgorithm.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgorithmTest.java
index 7dcee31..95fdd50 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeSubstitutionAlgorithm.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionAlgorithmTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,18 +18,15 @@
 
 import java.util.Map;
 
-import org.testng.annotations.Test;
-
 import com.sun.enterprise.admin.servermgmt.stringsubs.SubstitutionAlgorithm;
 
 /**
  * Unit test class for {@link RadixTreeSubstitutionAlgo}.
  */
-@Test
-public class TestRadixTreeSubstitutionAlgorithm extends AbstractSubstitutionAlgo {
+public class RadixTreeSubstitutionAlgorithmTest extends AbstractSubstitutionAlgo {
 
-  @Override
-  protected SubstitutionAlgorithm getAlgorithm(Map<String, String> substitutionMap) {
-    return new RadixTreeSubstitutionAlgo(substitutionMap);
-  }
+    @Override
+    protected SubstitutionAlgorithm getAlgorithm(Map<String, String> substitutionMap) {
+        return new RadixTreeSubstitutionAlgo(substitutionMap);
+    }
 }
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeSubstitution.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionTest.java
similarity index 70%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeSubstitution.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionTest.java
index 3b48802..20adbfb 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTreeSubstitution.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeSubstitutionTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,21 +16,24 @@
 
 package com.sun.enterprise.admin.servermgmt.stringsubs.impl.algorithm;
 
-import static org.testng.Assert.assertEquals;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.MethodOrderer.MethodName;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
 
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  * Unit test class for {@link RadixTreeSubstitution}.
  */
-@Test
-public class TestRadixTreeSubstitution {
+@TestMethodOrder(MethodName.class)
+public class RadixTreeSubstitutionTest {
 
     private RadixTree _tree;
     private RadixTreeSubstitution _substitution;
 
-    @BeforeClass
+    @BeforeEach
     public void init() {
         _tree = new RadixTree();
         _substitution = new RadixTreeSubstitution(_tree);
@@ -40,9 +43,9 @@
     /**
      * Test algorithm instance for null tree.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testSubstitutionForNullTree() {
-        new RadixTreeSubstitution(null);
+        assertThrows(IllegalArgumentException.class, () -> new RadixTreeSubstitution(null));
     }
 
     /**
@@ -50,8 +53,8 @@
      */
     @Test
     public void testInputExtendedMatch() {
-        assertEquals(callSubstitution("abe"), "abVale");
-        assertEquals(callSubstitution("acidic acidi"), "acidicVal acidVali");
+        assertEquals("abVale", callSubstitution("abe"));
+        assertEquals("acidicVal acidVali", callSubstitution("acidic acidi"));
     }
 
     /**
@@ -59,7 +62,7 @@
      */
     @Test
     public void testLastWordExactlyMatched() {
-        assertEquals(callSubstitution("  aci so abet ... &&& soft"), "  aci so abetVal ... &&& softVal");
+        assertEquals("  aci so abetVal ... &&& softVal", callSubstitution("  aci so abet ... &&& soft"));
     }
 
     /**
@@ -67,7 +70,7 @@
      */
     @Test
     public void testInputWithoutSpace() {
-        assertEquals(callSubstitution("acidysonacidyso"), "acidValysonValacidValyso");
+        assertEquals("acidValysonValacidValyso", callSubstitution("acidysonacidyso"));
     }
 
     /**
@@ -75,7 +78,7 @@
      */
     @Test
     public void testLastWordPartiallyMatched() {
-        assertEquals(callSubstitution("acidic abet softy"), "acidicVal abetVal softValy");
+        assertEquals("acidicVal abetVal softValy", callSubstitution("acidic abet softy"));
     }
 
     /**
@@ -83,7 +86,7 @@
      */
     @Test
     public void testUnmatchedInput() {
-        assertEquals(callSubstitution("@##ttt {{}:P"), "@##ttt {{}:P");
+        assertEquals("@##ttt {{}:P", callSubstitution("@##ttt {{}:P"));
     }
 
     /**
@@ -95,23 +98,22 @@
      * <p>Test-case depends on another methods as this method changes the tree reference
      *  which will cause the failure for other test cases.</p>
      */
-    @Test(dependsOnMethods = {"testLastWordPartiallyMatched", "testLastWordExactlyMatched",
-            "testInputWithoutSpace", "testInputExtendedMatch"})
-    public void testBackTrack() {
+    @Test
+    public void zzzTestBackTrack() {
         _tree = new RadixTree();
         _tree.insert("acidicity", "acidicityVal");
         _tree.insert("acidical", "acidicalVal");
         _tree.insert("acid", "acidVal");
         _substitution = new RadixTreeSubstitution(_tree);
-        assertEquals(callSubstitution("acidicit acidicit"), "acidValicit acidValicit");
+        assertEquals("acidValicit acidValicit", callSubstitution("acidicit acidicit"));
         _tree.insert("c", "cVal");
-        assertEquals(callSubstitution("acidicit acidicit"), "acidValicValit acidValicValit");
+        assertEquals("acidValicValit acidValicValit", callSubstitution("acidicit acidicit"));
         _tree.insert("ci", "ciVal");
-        assertEquals(callSubstitution("acidicit acidicit"), "acidValiciValt acidValiciValt");
+        assertEquals("acidValiciValt acidValiciValt", callSubstitution("acidicit acidicit"));
         _tree.insert("t", "tVal");
-        assertEquals(callSubstitution("acidicit"), "acidValiciValtVal");
+        assertEquals("acidValiciValtVal", callSubstitution("acidicit"));
         _tree.insert("icit", "icitVal");
-        assertEquals(callSubstitution("acidicit acidicit"), "acidValicitVal acidValicitVal");
+        assertEquals("acidValicitVal acidValicitVal", callSubstitution("acidicit acidicit"));
     }
 
     /**
@@ -122,7 +124,7 @@
      * @return substituted string.
      */
     private String callSubstitution(String input) {
-        StringBuffer outputBuffer = new StringBuffer();
+        StringBuilder outputBuffer = new StringBuilder();
         String substitution = null;
         for (char c : input.toCharArray()) {
             substitution = _substitution.substitute(c);
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTree.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeTest.java
similarity index 68%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTree.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeTest.java
index bc20b13..acdb2b2 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestRadixTree.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/RadixTreeTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -16,47 +16,56 @@
 
 package com.sun.enterprise.admin.servermgmt.stringsubs.impl.algorithm;
 
-import static org.testng.Assert.assertEquals;
+import org.junit.jupiter.api.TestMethodOrder;
+import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
 
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 
 /**
  * Unit test class for {@link RadixTree}.
  */
-public class TestRadixTree {
+@TestMethodOrder(OrderAnnotation.class)
+public class RadixTreeTest {
 
-    private RadixTree _tree;
+    private RadixTree tree;
 
-    @BeforeClass
+    @BeforeEach
     public void init() {
-        _tree = new RadixTree();
+        tree = new RadixTree();
         populateTree();
     }
 
     /**
      * Test insertion of null key in tree.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testInsertionForNullKey() {
-        _tree.insert(null, "value");
+        assertThrows(IllegalArgumentException.class, () -> tree.insert(null, "value"));
     }
 
     /**
      * Test insertion of null key in tree.
      */
-    @Test(expectedExceptions = IllegalArgumentException.class)
+    @Test
     public void testInsertionForEmptyKey() {
-        _tree.insert(null, "value");
+        assertThrows(IllegalArgumentException.class, () -> tree.insert(null, "value"));
     }
 
     /**
      * Test the tree structure.
      */
     @Test
+    @Order(1)
     public void testTreeStructure() {
-        RadixTreeNode rootNode = _tree.getRootNode();
+        RadixTreeNode rootNode = tree.getRootNode();
 
         // Validate root node
         assertEquals(rootNode.getKey(), "");
@@ -66,11 +75,11 @@
         // Validate first child node of rootNode.
         assertEquals(rootNode.getChildNodes().size(), 2);
         RadixTreeNode firstNode = rootNode.getChildNode('a');
-        RadixTreeNode secondNode = rootNode.getChildNode('s');;
+        RadixTreeNode secondNode = rootNode.getChildNode('s');
 
-        Assert.assertNotNull(firstNode);
+        assertNotNull(firstNode);
         assertEquals(firstNode.getParentNode(), rootNode);
-        Assert.assertNull(firstNode.getValue());
+        assertNull(firstNode.getValue());
         RadixTreeNode firstNodeFirstChild = firstNode.getChildNode('b');
         assertEquals(firstNodeFirstChild.getValue(), "abVal");
         assertEquals(firstNodeFirstChild.getParentNode(), firstNode);
@@ -82,7 +91,7 @@
         assertEquals(node.getValue(), "abaitVal");
         assertEquals(node.getKey(), "ait");
         assertEquals(node.getParentNode(), firstNodeFirstChild);
-        Assert.assertTrue(node.getChildNodes().isEmpty());
+        assertTrue(node.getChildNodes().isEmpty());
         RadixTreeNode firstNodeSecondChild = firstNode.getChildNode('c');
         assertEquals(firstNodeSecondChild.getValue(), "acidVal");
         assertEquals(firstNodeSecondChild.getParentNode(), firstNode);
@@ -91,10 +100,10 @@
         node = firstNodeSecondChild.getChildNode('i');
         assertEquals(node.getValue(), "acidicVal");
         assertEquals(node.getParentNode(), firstNodeSecondChild);
-        Assert.assertTrue(node.getChildNodes().isEmpty());
+        assertTrue(node.getChildNodes().isEmpty());
 
         assertEquals(secondNode.getParentNode(), rootNode);
-        Assert.assertNull(secondNode.getValue());
+        assertNull(secondNode.getValue());
         RadixTreeNode secondNodeFirstChild = secondNode.getChildNode('i');
         assertEquals(secondNodeFirstChild.getValue(), "sickVal");
         assertEquals(secondNodeFirstChild.getParentNode(), secondNode);
@@ -117,23 +126,24 @@
      * Test-case depends on another method as this method changes the tree
      * structure which may cause the failure for other tests.
      */
-    @Test(dependsOnMethods = {"testTreeStructure"})
+    @Test
+    @Order(2)
     public void testInsertExistingKey() {
-        _tree.insert("sick", "newValue");
-        assertEquals(_tree.getRootNode().getChildNode('s').getChildNode('i').getValue(), "newValue");
+        tree.insert("sick", "newValue");
+        assertEquals(tree.getRootNode().getChildNode('s').getChildNode('i').getValue(), "newValue");
     }
 
     /**
      * Populate tree.
      */
     private void populateTree() {
-        _tree.insert("acid", "acidVal");
-        _tree.insert("son", "sonVal");
-        _tree.insert("abet", "abetVal");
-        _tree.insert("ab", "abVal");
-        _tree.insert("sick", "sickVal");
-        _tree.insert("abait", "abaitVal");
-        _tree.insert("soft", "softVal");
-        _tree.insert("acidic", "acidicVal");
+        tree.insert("acid", "acidVal");
+        tree.insert("son", "sonVal");
+        tree.insert("abet", "abetVal");
+        tree.insert("ab", "abVal");
+        tree.insert("sick", "sickVal");
+        tree.insert("abait", "abaitVal");
+        tree.insert("soft", "softVal");
+        tree.insert("acidic", "acidicVal");
     }
 }
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestStringReplacementAlgorithm.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/StringReplacementAlgorithmTest.java
similarity index 85%
rename from nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestStringReplacementAlgorithm.java
rename to nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/StringReplacementAlgorithmTest.java
index f579f1f..23bae00 100644
--- a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/TestStringReplacementAlgorithm.java
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/stringsubs/impl/algorithm/StringReplacementAlgorithmTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2018-2021 Oracle and/or its affiliates. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -18,8 +18,6 @@
 
 import java.util.Map;
 
-import org.testng.annotations.Test;
-
 import com.sun.enterprise.admin.servermgmt.stringsubs.SubstitutionAlgorithm;
 
 /**
@@ -27,8 +25,7 @@
  * Class provides the algorithm to be used for test case execution
  * defined in {@link AbstractSubstitutionAlgo} class.
  */
-@Test
-public class TestStringReplacementAlgorithm extends AbstractSubstitutionAlgo {
+public class StringReplacementAlgorithmTest extends AbstractSubstitutionAlgo {
 
     @Override
     protected SubstitutionAlgorithm getAlgorithm(Map<String, String> substitutionMap) {
diff --git a/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/test/ServerMgmgtTestFiles.java b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/test/ServerMgmgtTestFiles.java
new file mode 100644
index 0000000..9c4cbae
--- /dev/null
+++ b/nucleus/admin/server-mgmt/src/test/java/com/sun/enterprise/admin/servermgmt/test/ServerMgmgtTestFiles.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2021 Eclipse Foundation and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package com.sun.enterprise.admin.servermgmt.test;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Purpose of this class is to simplify accessing files on classpath around test classes.
+ *
+ * @author David Matejcek
+ */
+public final class ServerMgmgtTestFiles {
+
+    private final Class<?> baseClass;
+
+    /**
+     * @param baseClass - class used as an orientation point. Will be used to get classloader and to
+     *            locate other files around the class.
+     */
+    public ServerMgmgtTestFiles(final Class<?> baseClass) {
+        this.baseClass = baseClass;
+    }
+
+
+    public Class<?> getBaseClass() {
+        return baseClass;
+    }
+
+
+    public Package getBasePackage() {
+        return this.getBaseClass().getPackage();
+    }
+
+
+    public Path getBasePackageAbsolutePath() {
+        return getPackageAbsolutePath(getBasePackage());
+    }
+
+
+    public File getBasePackageDirectory() {
+        return getBasePackageAbsolutePath().toFile();
+    }
+
+
+    public InputStream openInputStream(final String filename) {
+        return this.getBaseClass().getClassLoader()
+            .getResourceAsStream(getPackageRelativePath(getBasePackage()).resolve(filename).toString());
+    }
+
+
+    public static File getClassFile(final Class<?> clazz) {
+        return getPackageAbsolutePath(clazz.getPackage()).resolve(clazz.getSimpleName() + ".class").toFile();
+    }
+
+
+    private static Path getPackageAbsolutePath(final Package pkg) {
+        try {
+            String resourcePath = getPackageRelativePath(pkg).toString();
+            return Paths.get(ServerMgmgtTestFiles.class.getClassLoader().getResource(resourcePath).toURI());
+        } catch (URISyntaxException e) {
+            throw new IllegalStateException("Could not convert the package " + pkg + " to URI", e);
+        }
+    }
+
+
+    private static Path getPackageRelativePath(final Package pkg) {
+        return Paths.get(toPath(pkg.getName()));
+    }
+
+
+    private static String toPath(final String classOrPackageName) {
+        return classOrPackageName.replace('.', '/');
+    }
+}