Issue #23507 diagnostics-context now uses junit5 instead of junit4

- ContextImplUnitTest is still disabled, because jacoco and jmockit agents
  are incompatible.
diff --git a/nucleus/diagnostics/context/pom.xml b/nucleus/diagnostics/context/pom.xml
index b07f31a..58b3c6a 100644
--- a/nucleus/diagnostics/context/pom.xml
+++ b/nucleus/diagnostics/context/pom.xml
@@ -42,6 +42,11 @@
         </developer>
     </developers>
 
+    <properties>
+        <!-- jmockit is used in test and depends on it's agent -->
+        <maven.test.jvmoptions.custom>-javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar</maven.test.jvmoptions.custom>
+    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.glassfish.hk2</groupId>
@@ -59,33 +64,19 @@
         </dependency>
 
         <dependency>
-            <groupId>org.jmockit</groupId>
-            <artifactId>jmockit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.glassfish.hk2</groupId>
-            <artifactId>hk2-junitrunner</artifactId>
+            <groupId>org.glassfish.main.tests</groupId>
+            <artifactId>utils</artifactId>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>
             <artifactId>hamcrest</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.jmockit</groupId>
+            <artifactId>jmockit</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
-
-    <build>
-        <plugins>
-            <plugin>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <argLine>
-                        -javaagent:"${settings.localRepository}"/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
-                    </argLine>
-                    <forkCount>1</forkCount>
-                    <reuseForks>true</reuseForks>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
 </project>
diff --git a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplContextPropagationIntegrationTest.java b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplContextPropagationIntegrationTest.java
index 1555a72..7638736 100644
--- a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplContextPropagationIntegrationTest.java
+++ b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplContextPropagationIntegrationTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012, 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
@@ -16,20 +17,22 @@
 
 package org.glassfish.diagnostics.context.impl;
 
-import org.glassfish.contextpropagation.bootstrap.*;
-
-import org.glassfish.diagnostics.context.Context;
-import org.glassfish.diagnostics.context.ContextManager;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.Ignore;
-
 import java.util.LinkedList;
 import java.util.List;
 
+import org.glassfish.contextpropagation.bootstrap.ContextBootstrap;
+import org.glassfish.diagnostics.context.Context;
+import org.glassfish.diagnostics.context.ContextManager;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+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.assertSame;
+import static org.junit.jupiter.api.Assertions.fail;
+
 /**
  * Integration test between diagnostics context implementation and
  * context propagation.
@@ -39,141 +42,120 @@
  */
 public class ContextImplContextPropagationIntegrationTest {
 
-  private ContextManager mContextManager = null;
+    private ContextManager mContextManager;
 
-  @BeforeClass
-  public static void setUpOncePerTestClass() throws Exception {
-    // Natural place to add initialization of context propagation but
-    // the ContextBootstrap therein initializes as part of class
-    // load. We could wait for lazy initialization per test but
-    // clearer to force it to happen here
-    Class.forName(ContextBootstrap.class.getName());
-  }
-
-  @Before
-  public void setUpOncePerTestMethod(){
-    mContextManager = new ContextManagerImpl();
-  }
-
- /**
-  * Verify that multiple calls to get the current diagnostics context
-  * return the same instance.
-  */
-  @Test
-  @Ignore
-  public void testThreadLocalBehaviour(){
-    Context diagnosticsContextStart = mContextManager.getContext();
-
-    Assert.assertEquals("The implementation class of diagnosticsContext1 is not as expected.",
-      diagnosticsContextStart.getClass().getName(),
-      ContextImpl.class.getName());
-
-    for (int i = 0; i < 13; i++)
-    {
-      Context diagnosticsContext = mContextManager.getContext();
-
-      Assert.assertSame("The diagnostics context instance returned in iteration " + i + " is not the same instance as fetched at the start of the test.",
-        diagnosticsContextStart, diagnosticsContext);
-    }
-  }
-
- /**
-  * Verify that values set on the incumbent diagnostics context remain
-  * accessible on subsequent fetches of the diagnostics context.
-  */
-  @Test
-  @Ignore
-  public void testValuePersistence(){
-
-    final String propagatingKey = "propagatingKey";
-    final String propagatingValue = "propagatingValue";
-    final String nonPropagatingKey = "nonPropagatingKey";
-    final String nonPropagatingValue = "nonPropagatingValue";
-
-    {
-      Context diagnosticsContextStart = mContextManager.getContext();
-      diagnosticsContextStart.put(propagatingKey, propagatingValue, true);
-      diagnosticsContextStart.put(nonPropagatingKey, nonPropagatingValue, false);
+    @BeforeAll
+    public static void setUpOncePerTestClass() throws Exception {
+        // Natural place to add initialization of context propagation but
+        // the ContextBootstrap therein initializes as part of class
+        // load. We could wait for lazy initialization per test but
+        // clearer to force it to happen here
+        Class.forName(ContextBootstrap.class.getName());
     }
 
-    for (int i = 0; i < 17; i++)
-    {
-      Context diagnosticsContext = mContextManager.getContext();
 
-      Assert.assertEquals("The value associated with key " + propagatingKey + " is not as expected.",
-        propagatingValue, diagnosticsContext.get(propagatingKey));
-      Assert.assertEquals("The value associated with key " + nonPropagatingKey + " is not as expected.",
-        nonPropagatingValue, diagnosticsContext.get(nonPropagatingKey));
-    }
-  }
-
- /**
-  *
-  */
-  @Test
-  @Ignore
-  public void testValuePropagationAndNonPropagation() throws Exception {
-
-    final String propagatingKey = "propagatingKey";
-    final String propagatingValue = "propagatingValue";
-    final String nonPropagatingKey = "nonPropagatingKey";
-    final String nonPropagatingValue = "nonPropagatingValue";
-    final ContextManager contextManager = mContextManager;
-    final List<Throwable> exceptionList = new LinkedList();
-    final List<Thread> threadList = new LinkedList();
-
-    {
-      Context diagnosticsContextStart = mContextManager.getContext();
-      diagnosticsContextStart.put(propagatingKey, propagatingValue, true);
-      diagnosticsContextStart.put(nonPropagatingKey, nonPropagatingValue, false);
+    @BeforeEach
+    public void setUpOncePerTestMethod() {
+        mContextManager = new ContextManagerImpl();
     }
 
-    for (int i = 0; i < 17; i++)
-    {
-      Thread t = new Thread(
-        new Runnable(){
-          public void run()
-          {
-            try
-            {
-              String threadName = Thread.currentThread().getName();
-              Context diagnosticsContext = contextManager.getContext();
 
-              Assert.assertEquals("The value associated with key " + propagatingKey + " on thread " + threadName + " is not as expected.",
-                                     propagatingValue, diagnosticsContext.get(propagatingKey));
-              Assert.assertNull("The null value should be associated with key " + nonPropagatingKey + " on thread " + threadName,
-                                     diagnosticsContext.get(nonPropagatingKey));
-            }
-            catch (Throwable e)
-            {
-              synchronized(exceptionList)
-              {
-                exceptionList.add(e);
-              }
-            }
-          }
+    /**
+     * Verify that multiple calls to get the current diagnostics context
+     * return the same instance.
+     */
+    @Test
+    public void testThreadLocalBehaviour() {
+        Context diagnosticsContextStart = mContextManager.getContext();
+        assertEquals(ContextImpl.class.getName(), diagnosticsContextStart.getClass().getName());
+        for (int i = 0; i < 13; i++) {
+            Context diagnosticsContext = mContextManager.getContext();
+            assertSame(diagnosticsContextStart, diagnosticsContext,
+                "The diagnostics context instance returned in iteration " + i
+                    + " is not the same instance as fetched at the start of the test.");
         }
-      );
-      t.setName("Child_" + i + "_of_parent_'" + Thread.currentThread().getName() + "'");
-      t.start();
-      threadList.add(t);
     }
 
-    for(Thread t : threadList){
-      t.join();
+
+    /**
+     * Verify that values set on the incumbent diagnostics context remain
+     * accessible on subsequent fetches of the diagnostics context.
+     */
+    @Test
+    public void testValuePersistence() {
+        final String propagatingKey = "propagatingKey";
+        final String propagatingValue = "propagatingValue";
+        final String nonPropagatingKey = "nonPropagatingKey";
+        final String nonPropagatingValue = "nonPropagatingValue";
+
+        {
+            Context diagnosticsContextStart = mContextManager.getContext();
+            diagnosticsContextStart.put(propagatingKey, propagatingValue, true);
+            diagnosticsContextStart.put(nonPropagatingKey, nonPropagatingValue, false);
+        }
+
+        for (int i = 0; i < 17; i++) {
+            Context diagnosticsContext = mContextManager.getContext();
+            assertEquals(propagatingValue, diagnosticsContext.get(propagatingKey),
+                "The value associated with key " + propagatingKey + " is not as expected.");
+            assertEquals(nonPropagatingValue, diagnosticsContext.get(nonPropagatingKey),
+                "The value associated with key " + nonPropagatingKey + " is not as expected.");
+        }
     }
 
-    if (exceptionList.size() > 0)
-    {
-      StringBuilder sb = new StringBuilder();
-      for (Throwable e : exceptionList){
-        sb.append("\n  ").append(e.getMessage());
-      }
-      sb.append("\n");
 
-      // TODO: Enable this assertion when/if contextpropagation takes
-      //       place to child thread.
-      /* Assert.fail("Compound failure: " + sb.toString()); */
+    @Test
+    @Disabled("this test fails, decide if it is a feature or a bug and fix this discrepancy.")
+    public void testValuePropagationAndNonPropagation() throws Exception {
+        final String propagatingKey = "propagatingKey";
+        final String propagatingValue = "propagatingValue";
+        final String nonPropagatingKey = "nonPropagatingKey";
+        final String nonPropagatingValue = "nonPropagatingValue";
+        final ContextManager contextManager = mContextManager;
+        final List<Throwable> exceptionList = new LinkedList();
+        final List<Thread> threadList = new LinkedList();
+
+        {
+            Context diagnosticsContextStart = mContextManager.getContext();
+            diagnosticsContextStart.put(propagatingKey, propagatingValue, true);
+            diagnosticsContextStart.put(nonPropagatingKey, nonPropagatingValue, false);
+        }
+
+        for (int i = 0; i < 17; i++) {
+            Thread t = new Thread(() -> {
+                try {
+                    String threadName = Thread.currentThread().getName();
+                    Context diagnosticsContext = contextManager.getContext();
+                    assertEquals(propagatingValue, diagnosticsContext.get(propagatingKey),
+                        "The value associated with key " + propagatingKey + " on thread " + threadName
+                            + " is not as expected.");
+                    assertNull(diagnosticsContext.get(nonPropagatingKey),
+                        "The null value should be associated with key " + nonPropagatingKey + " on thread "
+                            + threadName);
+                } catch (Throwable e) {
+                    synchronized (exceptionList) {
+                        exceptionList.add(e);
+                    }
+                }
+            });
+            t.setName("Child_" + i + "_of_parent_'" + Thread.currentThread().getName() + "'");
+            t.start();
+            threadList.add(t);
+        }
+
+        for (Thread t : threadList) {
+            t.join();
+        }
+
+        if (!exceptionList.isEmpty()) {
+            fail(() -> {
+                StringBuilder sb = new StringBuilder();
+                for (Throwable e : exceptionList) {
+                    sb.append("\n  ").append(e.getMessage());
+                }
+                sb.append("\n");
+                return sb.toString();
+            });
+        }
     }
-  }
 }
diff --git a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplIntegrationTest.java b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplIntegrationTest.java
index 23945d0..e8f6478 100644
--- a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplIntegrationTest.java
+++ b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplIntegrationTest.java
@@ -16,25 +16,24 @@
 
 package org.glassfish.diagnostics.context.impl;
 
-import junit.framework.Assert;
 import org.glassfish.diagnostics.context.ContextManager;
-import org.junit.Test;
-import org.junit.Ignore;
+import org.glassfish.tests.utils.HK2JUnit5Extension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
 
 import jakarta.inject.Inject;
 
-public class ContextImplIntegrationTest
-    extends org.jvnet.hk2.testing.junit.HK2Runner
-{
-  @Inject
-  private ContextManager mContextManager;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
-  @Test
-  @Ignore
-  public void testInjectionOccurred()
-  {
-    System.out.println("mContextManager instance of " + mContextManager.getClass().getName());
-    Assert.assertNotNull("mContextManager should have been injected, but it is still null.", mContextManager);
-  }
+@ExtendWith(HK2JUnit5Extension.class)
+public class ContextImplIntegrationTest {
 
+    @Inject
+    private ContextManager mContextManager;
+
+    @Test
+    public void testInjectionOccurred() {
+        System.out.println("mContextManager instance of " + mContextManager.getClass().getName());
+        assertNotNull(mContextManager, "mContextManager should have been injected, but it is still null.");
+    }
 }
diff --git a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplUnitTest.java b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplUnitTest.java
index da2b3fd..382ad20 100644
--- a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplUnitTest.java
+++ b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextImplUnitTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012, 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
@@ -21,9 +22,8 @@
 import org.glassfish.contextpropagation.Location;
 import org.glassfish.contextpropagation.PropagationMode;
 import org.glassfish.contextpropagation.View;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 import mockit.Expectations;
 import mockit.Mock;
@@ -31,123 +31,133 @@
 import mockit.Mocked;
 import mockit.Verifications;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+@Disabled("Incompatible Jmockit 1.49 and JaCoCo 0.8.7, causes ArrayIndexOutOfBoundsException")
 public class ContextImplUnitTest {
 
- /**
-  * Test that the Location field of ContextImpl uses the Location
-  * object used at construction and that the Location returned from the
-  * ContextImpl does not then change over the lifetime of the ContextImpl.
-  */
-  @Test
-  @Ignore
-  public void testConstructorsLocation(
-    @Mocked final Location mockedLocation,
-    @Mocked final View mockedView)
-  {
+    /**
+     * Test that the Location field of ContextImpl uses the Location
+     * object used at construction and that the Location returned from the
+     * ContextImpl does not then change over the lifetime of the ContextImpl.
+     */
+    @Test
+    public void testConstructorsLocation(
+        @Mocked final Location mockedLocation,
+        @Mocked final View mockedView) {
 
-    final String mockedLocationIdReturnValue = "mockedLocationIdReturnValue";
-    final String mockedOriginReturnValue = "mockedOriginReturnValue";
+        final String mockedLocationIdReturnValue = "mockedLocationIdReturnValue";
+        final String mockedOriginReturnValue = "mockedOriginReturnValue";
 
-    new MockUp<Location>()
-    {
-      @Mock
-      public String getLocationId() { return mockedLocationIdReturnValue; }
+        new MockUp<Location>() {
+            @Mock
+            public String getLocationId() {
+                return mockedLocationIdReturnValue;
+            }
 
-      @Mock
-      public String getOrigin() { return mockedOriginReturnValue; }
-    };
 
-    ContextImpl contextImpl = new ContextImpl(mockedView, mockedLocation);
+            @Mock
+            public String getOrigin() {
+                return mockedOriginReturnValue;
+            }
+        };
 
-    Location location1 = contextImpl.getLocation();
-    Assert.assertSame("Location from contextImpl.getLocation() should be the instance passed in on construction.", mockedLocation, location1);
+        ContextImpl contextImpl = new ContextImpl(mockedView, mockedLocation);
 
-    // On the face of is these next two assertions seem perfectly reasonable
-    // but in reality they prove nothing regarding the behaviour of the
-    // org.glassfish.diagnostics.context.impl code, but rather
-    // verify that the  mocking framework is doing it's job: the getLocationId
-    // and getOrigin methods are overridden by the mock framework to
-    // return the values above, they are not returning state from the
-    // mockedLocation object itself.
-    /*
-       Assert.assertEquals("LocationId from contextImpl.getLocation() should be the locationId value from the location used when constructing the ContextImpl.", location1.getLocationId(), mockedLocationIdReturnValue);
-       Assert.assertEquals("Origin from contextImpl.getOrigin() should be the origin value from the location used when constructing the ContextImpl.", location1.getOrigin(), mockedOriginReturnValue);
-    */
+        Location location1 = contextImpl.getLocation();
+        assertSame(mockedLocation, location1,
+            "Location from contextImpl.getLocation() should be the instance passed in on construction.");
 
-    Location location2 = contextImpl.getLocation();
-    Assert.assertSame("Location from contextImpl.getLocation() should still be the instance passed in on construction.", mockedLocation, location2);
-  }
+        // On the face of is these next two assertions seem perfectly reasonable
+        // but in reality they prove nothing regarding the behaviour of the
+        // org.glassfish.diagnostics.context.impl code, but rather
+        // verify that the  mocking framework is doing it's job: the getLocationId
+        // and getOrigin methods are overridden by the mock framework to
+        // return the values above, they are not returning state from the
+        // mockedLocation object itself.
+        assertEquals(
+            location1.getLocationId(), mockedLocationIdReturnValue,
+            "LocationId from contextImpl.getLocation() should be the locationId value from the location used"
+            + " when constructing the ContextImpl.");
+        assertEquals(location1.getOrigin(), mockedOriginReturnValue,
+            "Origin from contextImpl.getOrigin() should be the origin value from the location used"
+            + " when constructing the ContextImpl.");
 
- /**
-  * Test that the put operations on an instance of ContextImpl delegate
-  * as expected to the View object used in construction.
-  */
-  @Test
-  @Ignore
-  public void testDelegationOfPut(
-    @Mocked final Location mockedLocation,
-    @Mocked final View mockedView){
+        Location location2 = contextImpl.getLocation();
+        assertSame(mockedLocation, location2,
+            "Location from contextImpl.getLocation() should still be the instance passed in on construction.");
+    }
 
-    ContextImpl contextImpl = new ContextImpl(mockedView, mockedLocation);
 
-    contextImpl.put("KeyForString-Value1-true", "Value1", true);
-    contextImpl.put("KeyForString-Value2-false", "Value2", false);
+    /**
+     * Test that the put operations on an instance of ContextImpl delegate
+     * as expected to the View object used in construction.
+     */
+    @Test
+    public void testDelegationOfPut(
+        @Mocked final Location mockedLocation,
+        @Mocked final View mockedView){
 
-    contextImpl.put("KeyForNumber-5-true", 5, true);
-    contextImpl.put("KeyForNumber-7-false", 7, false);
+        ContextImpl contextImpl = new ContextImpl(mockedView, mockedLocation);
 
-    new Verifications(){{
-      mockedView.put("KeyForString-Value1-true", "Value1", EnumSet.of(
-                                                  PropagationMode.THREAD,
-                                                  PropagationMode.RMI,
-                                                  PropagationMode.JMS_QUEUE,
-                                                  PropagationMode.SOAP,
-                                                  PropagationMode.MIME_HEADER,
-                                                  PropagationMode.ONEWAY));
-      mockedView.put("KeyForString-Value2-false", "Value2", EnumSet.of(
-                                                  PropagationMode.LOCAL));
+        contextImpl.put("KeyForString-Value1-true", "Value1", true);
+        contextImpl.put("KeyForString-Value2-false", "Value2", false);
 
-      mockedView.put("KeyForNumber-5-true", 5, EnumSet.of(
-                                                  PropagationMode.THREAD,
-                                                  PropagationMode.RMI,
-                                                  PropagationMode.JMS_QUEUE,
-                                                  PropagationMode.SOAP,
-                                                  PropagationMode.MIME_HEADER,
-                                                  PropagationMode.ONEWAY));
-      mockedView.put("KeyForNumber-7-false", 7, EnumSet.of(
-                                                  PropagationMode.LOCAL));
-    }};
+        contextImpl.put("KeyForNumber-5-true", 5, true);
+        contextImpl.put("KeyForNumber-7-false", 7, false);
 
-  }
+        new Verifications(){{
+            mockedView.put("KeyForString-Value1-true", "Value1", EnumSet.of(
+                PropagationMode.THREAD,
+                PropagationMode.RMI,
+                PropagationMode.JMS_QUEUE,
+                PropagationMode.SOAP,
+                PropagationMode.MIME_HEADER,
+                PropagationMode.ONEWAY));
+            mockedView.put("KeyForString-Value2-false", "Value2", EnumSet.of(
+                PropagationMode.LOCAL));
 
- /**
-  * Test that the get operation on an instance of ContextImpl delegates
-  * as expected to the View object used in construction.
-  */
-  @Test
-  @Ignore
-  public void testDelegationOfGet(
-    @Mocked final Location mockedLocation,
-    @Mocked final View mockedView){
+            mockedView.put("KeyForNumber-5-true", Integer.valueOf(5), EnumSet.of(
+                PropagationMode.THREAD,
+                PropagationMode.RMI,
+                PropagationMode.JMS_QUEUE,
+                PropagationMode.SOAP,
+                PropagationMode.MIME_HEADER,
+                PropagationMode.ONEWAY));
+            mockedView.put("KeyForNumber-7-false", Integer.valueOf(7), EnumSet.of(
+                PropagationMode.LOCAL));
+        }};
 
-    final String key = "testDelegationOfGet-Key1";
-    final String expectedValueOfKey1 = "testDelegationOfGet-Value1";
-    ContextImpl contextImpl = new ContextImpl(mockedView, mockedLocation);
+    }
 
-    new Expectations(){
+    /**
+     * Test that the get operation on an instance of ContextImpl delegates
+     * as expected to the View object used in construction.
+     */
+    @Test
+    public void testDelegationOfGet(
+        @Mocked final Location mockedLocation,
+        @Mocked final View mockedView){
 
-      // We expect get to be called on the view, and we'll
-      // instruct the mocking framework to return expectedValueOfKey1
-      // so that we can also verify that contextImpl returns it.
-      View expectationsRefViewVariable = mockedView;
-      {
-        expectationsRefViewVariable.get(key); returns(expectedValueOfKey1,null,null);
-      }
-    };
+        final String key = "testDelegationOfGet-Key1";
+        final String expectedValueOfKey1 = "testDelegationOfGet-Value1";
+        ContextImpl contextImpl = new ContextImpl(mockedView, mockedLocation);
 
-    String value = contextImpl.get(key);
+        new Expectations(){
 
-    Assert.assertEquals("Value returned from contextImpl.get(\""+key+"\") is not the value expected.", expectedValueOfKey1, value);
-  }
+            // We expect get to be called on the view, and we'll
+            // instruct the mocking framework to return expectedValueOfKey1
+            // so that we can also verify that contextImpl returns it.
+            View expectationsRefViewVariable = mockedView;
+            {
+                expectationsRefViewVariable.get(key);
+                returns(expectedValueOfKey1, null);
+            }
+        };
+
+        assertEquals(expectedValueOfKey1, contextImpl.get(key),
+            "Value returned from contextImpl.get(\"" + key + "\") is not the value expected.");
+    }
 
 }
diff --git a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextManagerImplUnitTest.java b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextManagerImplUnitTest.java
index 4dcffdf..2fd4405 100644
--- a/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextManagerImplUnitTest.java
+++ b/nucleus/diagnostics/context/src/test/java/org/glassfish/diagnostics/context/impl/ContextManagerImplUnitTest.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2012, 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
@@ -16,80 +17,23 @@
 
 package org.glassfish.diagnostics.context.impl;
 
-import org.glassfish.contextpropagation.ContextMap;
-import org.glassfish.contextpropagation.ContextViewFactory;
-import org.glassfish.contextpropagation.spi.ContextMapHelper;
 import org.glassfish.diagnostics.context.Context;
-import org.glassfish.diagnostics.context.ContextManager;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
-import mockit.Expectations;
-import mockit.Mock;
-import mockit.MockUp;
-import mockit.Mocked;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
 
 public class ContextManagerImplUnitTest {
 
- /**
-  * Verify that ContextManagerImpl initialization registers a
-  * ContextViewFactory with the ContextMapHelper.
-  *
-  * This test assumes only that initialization takes place by the time
-  * the first new ContextManagerImpl has been created.
-  */
-  @Test
-  @Ignore
-  public void testViewFactoryRegistration()
-  {
-    new MockUp<ContextMapHelper>(){
-      @Mock
-      public void registerContextFactoryForPrefixNamed(
-        String prefixName, ContextViewFactory factory)
-      {
-        Assert.assertEquals(prefixName, ContextManager.WORK_CONTEXT_KEY);
-        Assert.assertTrue("org.glassfish.diagnostics.context.impl.ContextManagerImpl$DiagnosticContextViewFactory".equals(factory.getClass().getName()));
-      }
-    };
-
-    ContextManagerImpl cmi = new ContextManagerImpl();
-  }
-
- /**
-  * Verify the expected delegation to ContextMap by
-  * ContextManagerImpl on invocation of getContext.
-  */
-  @Test
-  @Ignore
-  public void testGetContextUseOfContextMap_new(
-    @Mocked final ContextMap mockedContextMap)
-  throws Exception
-  {
-    new Expectations(){
-
-      // We expect ContextManagerImpl to call getScopeAwareContextMap, but
-      // we also need that method to return a ContextMap instance so
-      // we tell the mocking framework to return an instance.
-      ContextMapHelper expectationsRefContextMapHelper;
-      {
-        expectationsRefContextMapHelper.getScopeAwareContextMap(); returns(mockedContextMap,null,null);
-      }
-
-      // We expect ContextManagerImpl to then go ahead and use the
-      // ContextMap - in particular to call get (from which we deliberately
-      // return null) and the createViewCapable (from which we return null
-      // which is in practice an exceptional condition (which will result
-      // in a WARNING log message) but does fine for this test.
-      ContextMap expectationsRefContextMap = mockedContextMap;
-      {
-        expectationsRefContextMap.get(ContextManager.WORK_CONTEXT_KEY); returns(null,null,null);
-        expectationsRefContextMap.createViewCapable(ContextManager.WORK_CONTEXT_KEY); returns(null,null,null);
-      }
-    };
-
-    ContextManagerImpl cmi = new ContextManagerImpl();
-    Context ci = cmi.getContext();
-  }
+    /**
+     * Verify the expected delegation to ContextMap by
+     * ContextManagerImpl on invocation of getContext.
+     */
+    @Test
+    public void testGetContextUseOfContextMap_new() throws Exception {
+        ContextManagerImpl cmi = new ContextManagerImpl();
+        Context ci = cmi.getContext();
+        assertThat(ci, instanceOf(org.glassfish.diagnostics.context.impl.ContextImpl.class));
+    }
 
 }