Issue #23507 amx-core now uses junit5 instead of junit4

- also moved tests to packages of units which are tested.
diff --git a/nucleus/common/amx-core/pom.xml b/nucleus/common/amx-core/pom.xml
index dc789a3..2a754e7 100755
--- a/nucleus/common/amx-core/pom.xml
+++ b/nucleus/common/amx-core/pom.xml
@@ -80,6 +80,10 @@
         </dependency>
 
         <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest</artifactId>
         </dependency>
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/UtilTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/core/UtilTest.java
similarity index 64%
rename from nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/UtilTest.java
rename to nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/core/UtilTest.java
index 7fcf00f..bb635f7 100644
--- a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/UtilTest.java
+++ b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/core/UtilTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v. 2.0, which is available at
@@ -14,36 +15,20 @@
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
  */
 
-package org.glassfish.admin.amx.test;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
+package org.glassfish.admin.amx.core;
 
 import org.glassfish.admin.amx.base.DomainRoot;
-import org.glassfish.admin.amx.core.Util;
+import org.junit.jupiter.api.Test;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.glassfish.admin.amx.test.AmxTestExtension;
+
+@ExtendWith(AmxTestExtension.class)
 public final class UtilTest {
-    public UtilTest()
-    {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
 
     @Test
-    public void testTypes() {
-        assert Util.deduceType(DomainRoot.class).equals( "domain-root" );
+    public void testDeduceType() {
+        assertEquals("domain-root", Util.deduceType(DomainRoot.class));
     }
 }
-
-
-
-
-
-
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/config/AMXConfigImplTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/config/AMXConfigImplTest.java
new file mode 100644
index 0000000..845e4df
--- /dev/null
+++ b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/config/AMXConfigImplTest.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
+ *
+ * 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.admin.amx.impl.config;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public final class AMXConfigImplTest {
+
+    @Test
+    public void testConvertAttributeName() {
+        testDomConvertName("Is", "is");
+        testDomConvertName("IsFooBar", "is-foo-bar");
+        testDomConvertName("IsConnectionValidationRequired", "is-connection-validation-required");
+    }
+
+    private void testDomConvertName(final String mixedCaseString, final String expected) {
+        assertEquals(expected, AMXConfigImpl.convertAttributeName(mixedCaseString));
+        assertEquals(expected, AMXConfigImpl.convertAttributeName(expected));
+    }
+}
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/util/ObjectNameBuilderTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/util/ObjectNameBuilderTest.java
new file mode 100644
index 0000000..ccb5e24
--- /dev/null
+++ b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/util/ObjectNameBuilderTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
+ *
+ * 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.admin.amx.impl.util;
+
+import java.lang.management.ManagementFactory;
+
+import org.glassfish.admin.amx.test.AmxTestExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@ExtendWith(AmxTestExtension.class)
+public final class ObjectNameBuilderTest {
+
+    @Test
+    public void testGetJMXDomain() {
+        assertEquals("test", new ObjectNameBuilder(ManagementFactory.getPlatformMBeanServer(), "test").getJMXDomain());
+    }
+}
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/util/SingletonEnforcerTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/util/SingletonEnforcerTest.java
new file mode 100644
index 0000000..957059b
--- /dev/null
+++ b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/impl/util/SingletonEnforcerTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
+ *
+ * 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.admin.amx.impl.util;
+
+import org.glassfish.admin.amx.test.AmxTestExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+
+@ExtendWith(AmxTestExtension.class)
+public final class SingletonEnforcerTest {
+
+    @Test
+    public void testForNull() {
+        assertNull(SingletonEnforcer.get(Dummy.class));
+    }
+
+
+    @Test
+    public void testVariety() {
+        SingletonEnforcer.register(String.class, "hello");
+        assertNotNull(SingletonEnforcer.get(String.class));
+
+        SingletonEnforcer.register(Boolean.class, Boolean.TRUE);
+        assertNotNull(SingletonEnforcer.get(Boolean.class));
+
+        SingletonEnforcer.register(Integer.class, Integer.valueOf(0));
+        assertNotNull(SingletonEnforcer.get(Integer.class));
+    }
+
+
+    @Test
+    public void testForDuplicates() {
+        assertDoesNotThrow(() -> SingletonEnforcer.register(Dummy2.class, this));
+        assertThrows(IllegalArgumentException.class, () -> SingletonEnforcer.register(Dummy2.class, this));
+    }
+
+    private static final class Dummy {
+    }
+
+    private static final class Dummy2 {
+    }
+}
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/AMXConfigTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/AMXConfigTest.java
deleted file mode 100644
index a35f643..0000000
--- a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/AMXConfigTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2011, 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 org.glassfish.admin.amx.test;
-
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-
-import org.glassfish.admin.amx.impl.config.AMXConfigImpl;
-
-public final class AMXConfigTest {
-    public AMXConfigTest()
-    {
-    }
-
-    @Before
-    public void setUp() {
-    }
-
-    @After
-    public void tearDown() {
-    }
-
-    private void _testConvertName( final String str, final String out)
-    {
-        assert AMXConfigImpl.convertAttributeName(str).equals(out) :
-            "Expected " + out + " for " + str;
-
-        assert AMXConfigImpl.convertAttributeName(out).equals(out) :
-            "Expected " + out + " for " + out + " (no change), but got " + AMXConfigImpl.convertAttributeName(out);
-    }
-
-    @Test
-    public void testDomConvertName() {
-        _testConvertName( "Is", "is" );
-
-        _testConvertName( "IsFooBar", "is-foo-bar" );
-
-        _testConvertName( "IsConnectionValidationRequired", "is-connection-validation-required" );
-    }
-}
-
-
-
-
-
-
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/AmxTestExtension.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/AmxTestExtension.java
new file mode 100644
index 0000000..71c2dc8
--- /dev/null
+++ b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/AmxTestExtension.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2021 Contributors to the Eclipse Foundation
+ *
+ * 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.admin.amx.test;
+
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+public final class AmxTestExtension implements BeforeAllCallback, AfterAllCallback {
+
+
+    @Override
+    public void beforeAll(ExtensionContext context) {
+        checkAssertsOn();
+        System.setProperty("com.sun.aas.instanceRoot", "/tmp/amx-test");
+    }
+
+
+    @Override
+    public void afterAll(ExtensionContext context) {
+        System.clearProperty("com.sun.aas.instanceRoot");
+    }
+
+
+    private void checkAssertsOn() {
+        try {
+            assert false;
+            throw new Error("Assertions must be enabled for unit tests, because they are used in library sources.");
+        } catch (AssertionError a) {
+            // OK, this is the desired outcome
+        }
+    }
+}
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/ObjectNamesTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/ObjectNamesTest.java
deleted file mode 100644
index b77204a..0000000
--- a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/ObjectNamesTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1997, 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 org.glassfish.admin.amx.test;
-
-import org.glassfish.admin.amx.impl.util.ObjectNameBuilder;
-
-import org.junit.Test;
-import org.junit.Before;
-
-import java.lang.management.ManagementFactory;
-
-
-public final class ObjectNamesTest extends TestBase
-{
-
-    public ObjectNamesTest() {
-    }
-
-    private ObjectNameBuilder get() {
-        return new ObjectNameBuilder( ManagementFactory.getPlatformMBeanServer(), amxDomain());
-    }
-
-    @Before
-    public void setUp() {
-        initBootUtil();
-    }
-
-    @Test
-    public void testCreate() {
-        final ObjectNameBuilder objectNames = get();
-    }
-
-    private String amxDomain()
-    {
-        return "test";
-    }
-
-    @Test
-    public void testMisc() {
-        get().getJMXDomain();
-    }
-}
-
-
-
-
-
-
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/SingletonEnforcerTest.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/SingletonEnforcerTest.java
deleted file mode 100644
index 51cf365..0000000
--- a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/SingletonEnforcerTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 1997, 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 org.glassfish.admin.amx.test;
-
-import org.glassfish.admin.amx.impl.util.SingletonEnforcer;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-
-public final class SingletonEnforcerTest extends TestBase
-{
-    public SingletonEnforcerTest() {
-    }
-
-    private static final class Dummy {}
-
-    @Test
-    public void testForNull() {
-        assertTrue( SingletonEnforcer.get( Dummy.class ) == null );
-    }
-
-    @Test
-    public void testVariety() {
-        SingletonEnforcer.register( String.class, "hello" );
-        assertNotNull( SingletonEnforcer.get( String.class ) );
-
-        SingletonEnforcer.register( Boolean.class, Boolean.TRUE );
-        assertNotNull( SingletonEnforcer.get( Boolean.class ) );
-
-        SingletonEnforcer.register( Integer.class, new Integer(0) );
-        assertNotNull( SingletonEnforcer.get( Integer.class ) );
-    }
-
-    /*
-    @Test(expected=IllegalArgumentException.class)
-    public void testForBrokenJUnit() {
-        throw new IllegalArgumentException( "expected" );
-    }
-    */
-
-
-    private static final class Dummy2 {}
-    @Test
-    public void testForDuplicates() {
-        final String s = "";
-        SingletonEnforcer.register( Dummy2.class, this );
-        try {
-            SingletonEnforcer.register( Dummy2.class, this );
-        }
-        catch( IllegalArgumentException e) { /*OK*/ }
-    }
-}
-
-
-
-
-
-
diff --git a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/TestBase.java b/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/TestBase.java
deleted file mode 100644
index babaceb..0000000
--- a/nucleus/common/amx-core/src/test/java/org/glassfish/admin/amx/test/TestBase.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 1997, 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 org.glassfish.admin.amx.test;
-
-import org.junit.Ignore;
-
-@Ignore
-class TestBase extends junit.framework.TestCase {
-
-    /** some tests might need this */
-    protected static void initBootUtil() {
-        System.setProperty( "com.sun.aas.instanceRoot", "/tmp/amx-test" );
-    }
-
-
-    protected void
-    checkAssertsOn() {
-        try {
-            assert false;
-            throw new Error("Assertions must be enabled for unit tests");
-        }
-        catch (AssertionError a) {
-            // OK, this is the desired outcome
-        }
-    }
-
-
-    public TestBase() {
-        checkAssertsOn();
-    }
-}
-
-
-
-
-
-