diff --git a/appserver/tests/appserv-tests/util/reportbuilder/pom.xml b/appserver/tests/appserv-tests/util/reportbuilder/pom.xml index 628d780f83f..68857b32c49 100644 --- a/appserver/tests/appserv-tests/util/reportbuilder/pom.xml +++ b/appserver/tests/appserv-tests/util/reportbuilder/pom.xml @@ -32,7 +32,7 @@ jar report-builder - ${artifactId} + ${artifactId} install diff --git a/appserver/tests/cdi/cases/runner/pom.xml b/appserver/tests/cdi/cases/runner/pom.xml index b0add8483ed..479afe0d5c2 100644 --- a/appserver/tests/cdi/cases/runner/pom.xml +++ b/appserver/tests/cdi/cases/runner/pom.xml @@ -74,17 +74,7 @@ lib ${project.version} - - org.testng - testng - test - - - org.glassfish.main.tests - utils-ng - ${project.version} - test - + org.glassfish.main.appclient gf-client diff --git a/appserver/tests/cdi/negative/runner/pom.xml b/appserver/tests/cdi/negative/runner/pom.xml index 196312f78f1..4fda13c3613 100644 --- a/appserver/tests/cdi/negative/runner/pom.xml +++ b/appserver/tests/cdi/negative/runner/pom.xml @@ -52,17 +52,6 @@ normalScopeWithFinal ${project.version} - - org.testng - testng - test - - - org.glassfish.main.tests - utils-ng - ${project.version} - test - org.glassfish.main.appclient gf-client diff --git a/appserver/tests/hk2/cdi/basic/runner/pom.xml b/appserver/tests/hk2/cdi/basic/runner/pom.xml index a72c484fd12..47089907fe4 100644 --- a/appserver/tests/hk2/cdi/basic/runner/pom.xml +++ b/appserver/tests/hk2/cdi/basic/runner/pom.xml @@ -65,17 +65,6 @@ ejb1 ${project.version} - - org.testng - testng - test - - - org.glassfish.main.tests - utils-ng - ${project.version} - test - org.glassfish.main.appclient gf-client diff --git a/appserver/tests/hk2/cdi/ear/runner/pom.xml b/appserver/tests/hk2/cdi/ear/runner/pom.xml index 2569c01ca79..395ee2290e4 100644 --- a/appserver/tests/hk2/cdi/ear/runner/pom.xml +++ b/appserver/tests/hk2/cdi/ear/runner/pom.xml @@ -74,17 +74,6 @@ ${project.version} test - - org.testng - testng - test - - - org.glassfish.main.tests - utils-ng - ${project.version} - test - org.glassfish.main.appclient gf-client diff --git a/appserver/tests/hk2/cdi/jersey/runner/pom.xml b/appserver/tests/hk2/cdi/jersey/runner/pom.xml index 72fddc35631..60c1d4eaaf4 100644 --- a/appserver/tests/hk2/cdi/jersey/runner/pom.xml +++ b/appserver/tests/hk2/cdi/jersey/runner/pom.xml @@ -54,17 +54,6 @@ war test - - org.testng - testng - test - - - org.glassfish.main.tests - utils-ng - ${project.version} - test - org.glassfish.main.appclient gf-client diff --git a/appserver/tests/hk2/isolation/runner/pom.xml b/appserver/tests/hk2/isolation/runner/pom.xml index df3d3bd67ec..6a39e0fa6b3 100755 --- a/appserver/tests/hk2/isolation/runner/pom.xml +++ b/appserver/tests/hk2/isolation/runner/pom.xml @@ -61,17 +61,5 @@ ${project.version} war - - org.testng - testng - test - - - org.glassfish.main.tests - utils-ng - ${project.version} - test - jar - diff --git a/nucleus/admin/rest/pom.xml b/nucleus/admin/rest/pom.xml index 0dde725d46d..a70dfc46b33 100644 --- a/nucleus/admin/rest/pom.xml +++ b/nucleus/admin/rest/pom.xml @@ -73,10 +73,5 @@ logging-annotation-processor true - - org.testng - testng - test - diff --git a/nucleus/parent/pom.xml b/nucleus/parent/pom.xml index 392980da71a..f702734005f 100644 --- a/nucleus/parent/pom.xml +++ b/nucleus/parent/pom.xml @@ -448,12 +448,6 @@ 2.2 test - - org.testng - testng - ${testng.version} - test - org.jmockit jmockit diff --git a/nucleus/test-utils/pom.xml b/nucleus/test-utils/pom.xml index d022913705d..aadb9ea1e32 100755 --- a/nucleus/test-utils/pom.xml +++ b/nucleus/test-utils/pom.xml @@ -33,7 +33,6 @@ utils - utils-ng diff --git a/nucleus/test-utils/utils-ng/pom.xml b/nucleus/test-utils/utils-ng/pom.xml deleted file mode 100644 index 2520faf0b4b..00000000000 --- a/nucleus/test-utils/utils-ng/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - 4.0.0 - - - org.glassfish.main - test-utils - 6.2.1-SNAPSHOT - - - org.glassfish.main.tests - utils-ng - - nucleus.tests.utils-ng - - - - trmueller - Tom Mueller - Oracle, Inc. - - lead - developer - - - - - - - org.glassfish.main.common - common-util - ${project.version} - jar - - - org.testng - testng - compile - - - diff --git a/nucleus/test-utils/utils-ng/src/main/java/org/glassfish/tests/utils/NucleusStartStopTest.java b/nucleus/test-utils/utils-ng/src/main/java/org/glassfish/tests/utils/NucleusStartStopTest.java deleted file mode 100644 index 53708d67f80..00000000000 --- a/nucleus/test-utils/utils-ng/src/main/java/org/glassfish/tests/utils/NucleusStartStopTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2012, 2020 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 org.glassfish.tests.utils; - -import static org.glassfish.tests.utils.NucleusTestUtils.*; -import static org.testng.AssertJUnit.assertTrue; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; - -public class NucleusStartStopTest { - - @BeforeSuite - public void setUp() { - assertTrue(nadmin("start-domain")); - } - - @AfterSuite - public void tearDown() { - assertTrue(nadmin("stop-domain")); - } - -} diff --git a/nucleus/test-utils/utils-ng/src/main/java/org/glassfish/tests/utils/NucleusTestUtils.java b/nucleus/test-utils/utils-ng/src/main/java/org/glassfish/tests/utils/NucleusTestUtils.java deleted file mode 100644 index 5a487ef5a1b..00000000000 --- a/nucleus/test-utils/utils-ng/src/main/java/org/glassfish/tests/utils/NucleusTestUtils.java +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (c) 2012, 2020 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 org.glassfish.tests.utils; - -import com.sun.enterprise.universal.process.ProcessManager; -import com.sun.enterprise.universal.process.ProcessManagerException; -import com.sun.enterprise.universal.process.ProcessManagerTimeoutException; -import java.io.*; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static java.util.Arrays.asList; -import static org.testng.AssertJUnit.assertNotNull; - -/** - * - * @author Tom Mueller - */ -public class NucleusTestUtils { - protected static final int DEFAULT_TIMEOUT_MSEC = 480000; // 8 minutes - private static boolean verbose = true; - private static Map env; - private static String[] envp; - private static String envProps[] = { - "AS_ADMIN_PASSWORDFILE", - "AS_LOGFILE", - "AS_ADMIN_USER", - "P_ADMIN_PASSWORDFILE", - "P_ADMIN_USER", - "P_ADMIN_READTIMEOUT", - "C_ADMIN_READTIMEOUT", }; - protected static final File nucleusRoot = initNucleusRoot(); - - private static File initNucleusRoot() { - // Initialize the environment with environment variables that can be - // used when running commands - env = new HashMap<>(System.getenv()); - for (String propertyKey : envProps) { - String propertyValue = System.getProperty(propertyKey); - if (propertyValue != null) { - putEnv(propertyKey, propertyValue); - } - } - - String nucleusRootProp = System.getProperty("nucleus.home"); - if (nucleusRootProp == null) { - String basedir = System.getProperty("basedir"); - assertNotNull(basedir); - nucleusRootProp = basedir + "/../../distributions/nucleus/target/stage/nucleus"; - } - - System.out.println("nucleus.home=" + nucleusRootProp); - - return new File(nucleusRootProp); - } - - // All methods are static, do not allow an object to be created. - protected NucleusTestUtils() { - } - - public static File getNucleusRoot() { - return nucleusRoot; - } - - public static void putEnv(String name, String value) { - env.put(name, value); - if (!env.isEmpty()) { - envp = new String[env.size()]; - int i = 0; - for (Map.Entry me : env.entrySet()) { - envp[i++] = me.getKey() + "=" + me.getValue(); - } - } else { - envp = null; - } - } - - /** - * Runs the command with the args given - * - * @param args - * - * @return true if successful - */ - public static boolean nadmin(int timeout, final String... args) { - return nadminWithOutput(timeout, args).returnValue; - } - - public static boolean nadmin(final String... args) { - return nadmin(DEFAULT_TIMEOUT_MSEC, args); - } - - /** - * Runs the command with the args given Returns the precious output strings for further processing. - * - * @param args - * - * @return true if successful - */ - public static NadminReturn nadminWithOutput(final String... args) { - return nadminWithOutput(DEFAULT_TIMEOUT_MSEC, args); - } - - public static NadminReturn nadminWithOutput(final int timeout, final String... args) { - File cmd = new File(nucleusRoot, isWindows() ? "bin/nadmin.bat" : "bin/nadmin"); - - if (!cmd.canExecute()) { - cmd = new File(nucleusRoot, isWindows() ? "bin/asadmin.bat" : "bin/asadmin"); - if (!cmd.canExecute()) { - cmd = new File(nucleusRoot, isWindows() ? "bin/nadmin.bat" : "bin/nadmin"); - } - } - - return cmdWithOutput(cmd, timeout, args); - } - - public static NadminReturn nadminDetachWithOutput(String... args) { - File cmd = new File(nucleusRoot, isWindows() ? "bin/nadmin.bat" : "bin/nadmin"); - if (!cmd.canExecute()) { - cmd = new File(nucleusRoot, isWindows() ? "bin/asadmin.bat" : "bin/asadmin"); - if (!cmd.canExecute()) { - cmd = new File(nucleusRoot, isWindows() ? "bin/nadmin.bat" : "bin/nadmin"); - } - } - - return cmdDetachWithOutput(cmd, DEFAULT_TIMEOUT_MSEC, args); - } - - public static NadminReturn cmdWithOutput(File cmd, int timeout, String... args) { - List command = new ArrayList(); - command.add(cmd.toString()); - command.add("--echo"); - command.addAll(asList(args)); - - ProcessManager processManager = new ProcessManager(command); - - // The tests may be running unattended -- don't wait forever! - processManager.setTimeoutMsec(timeout); - processManager.setEcho(false); - processManager.setEnvironment(envp); - - int exit; - String myErr = ""; - try { - exit = processManager.execute(); - } catch (ProcessManagerTimeoutException tex) { - myErr = "\nProcessManagerTimeoutException: command timed out after " + timeout + " ms."; - exit = 1; - } catch (ProcessManagerException ex) { - ex.printStackTrace(); - myErr = "\n" + ex.getMessage(); - exit = 1; - } - - NadminReturn ret = new NadminReturn(exit, processManager.getStdout(), processManager.getStderr() + myErr, args[0]); - - write(ret.outAndErr); - return ret; - } - - public static NadminReturn cmdDetachWithOutput(File cmd, int timeout, String... args) { - List command = new ArrayList<>(); - command.add(cmd.toString()); - command.add("--echo"); - command.add("--detach"); - command.addAll(Arrays.asList(args)); - - ProcessManager pm = new ProcessManager(command); - - // the tests may be running unattended -- don't wait forever! - pm.setTimeoutMsec(timeout); - pm.setEcho(false); - pm.setEnvironment(envp); - - int exit; - String myErr = ""; - try { - exit = pm.execute(); - } catch (ProcessManagerTimeoutException tex) { - myErr = "\nProcessManagerTimeoutException: command timed out after " + timeout + " ms."; - exit = 1; - } catch (ProcessManagerException ex) { - exit = 1; - } - - NadminReturn ret = new NadminReturn(exit, pm.getStdout(), pm.getStderr() + myErr, args[0]); - - write(ret.outAndErr); - return ret; - } - - private static boolean validResults(String text, String... invalidResults) { - for (String result : invalidResults) { - if (text.contains(result)) { - return false; - } - } - return true; - } - - private static void write(final String text) { - if (verbose && !text.isEmpty()) - System.out.print(text); - } - - protected static boolean isWindows() { - return System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("win"); - } - - /** - * Returns true if String b contains String a. Returns true if both strings are null. Returns false if only one of the - * strings is null. - * - * @param a The possibly null string that must be contained in b - * @param b The possibly null string that must contain a - * @return true if b contains a - */ - public static boolean matchString(String a, String b) { - if (a == null && b == null) { - return true; - } - - if (a == null) { - return false; - } - - if (b == null) { - return false; - } - - return b.indexOf(a) != -1; - } - - /** - * This methods opens a connection to the given URL and returns the string that is returned from that URL. This is - * useful for simple servlet retrieval - * - * @param urlstr The URL to connect to - * @return The string returned from that URL, or empty string if there was a problem contacting the URL - */ - public static String getURL(String urlstr) { - // @todo Java SE 7 use try with resources - StringWriter ow = null; - BufferedReader ir = null; - try { - URL u = new URL(urlstr); - URLConnection urlc = u.openConnection(); - ir = new BufferedReader(new InputStreamReader(urlc.getInputStream(), "ISO-8859-1")); - try { - ow = new StringWriter(); - String line; - while ((line = ir.readLine()) != null) { - ow.write(line); - ow.write("\n"); - } - - return ow.getBuffer().toString(); - } finally { - if (ow != null) { - ow.close(); - } - } - } catch (IOException ex) { - System.out.println("unable to fetch URL:" + urlstr + ", reason: " + ex.getMessage()); - return ""; - } finally { - if (ir != null) { - try { - ir.close(); - } catch (IOException ex) { - Logger.getLogger(NucleusTestUtils.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - } - - // simple C-struct -- DIY - public static class NadminReturn { - NadminReturn(int exit, String out, String err, String cmd) { - this.returnValue = exit == 0 && validResults(out, String.format("Command %s failed.", cmd)); - this.out = out; - this.err = err; - this.outAndErr = this.out + this.err; - } - - public boolean returnValue; - public String out; - public String err; - public String outAndErr; - } - - public static void deleteDirectoryContents(final File dir) { - if (dir == null || !dir.exists()) { - return; - } - System.out.println("Deleting contents of directory : " + dir); - File[] files = dir.listFiles(); - if (files != null) { - for (File f : files) { - if (f.isDirectory()) { - deleteDirectory(f); - } else { - f.delete(); - } - } - } - } - - public static void deleteDirectory(final File dir) { - if (dir == null || !dir.exists()) { - return; - } - File[] files = dir.listFiles(); - if (files != null) { - for (File f : files) { - if (f.isDirectory()) { - deleteDirectory(f); - } else { - f.delete(); - } - } - } - dir.delete(); - } - - public static void touchDirectory(final File dir) { - if (dir == null || !dir.exists()) { - return; - } - long timestamp; - File[] files = dir.listFiles(); - if (files != null) { - for (File f : files) { - if (f.isDirectory()) { - touchDirectory(f); - } else { - timestamp = System.currentTimeMillis(); - f.setLastModified(timestamp); - } - } - } - timestamp = System.currentTimeMillis(); - dir.setLastModified(timestamp); - System.out.println("Touched contents of directory : " + dir); - } -} diff --git a/nucleus/tests/admin/pom.xml b/nucleus/tests/admin/pom.xml index 9df585799f8..cda4bb37829 100644 --- a/nucleus/tests/admin/pom.xml +++ b/nucleus/tests/admin/pom.xml @@ -66,12 +66,6 @@ of COPY_LIB map constant.) This pom describes how to run admin developer tests on the Nucleus Bundle - - org.testng - testng - test - - org.glassfish.hk2 hk2-api @@ -107,12 +101,6 @@ of COPY_LIB map constant.) ${project.version} test - - org.glassfish.main.tests - utils-ng - ${project.version} - test - jakarta.xml.bind jakarta.xml.bind-api