[SUREFIRE-2157] Upgrade junit-jupiter to 5.9.3/junit-platform to 1.9.2
diff --git a/pom.xml b/pom.xml
index 1db5820..9004b0a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,7 @@
     <commonsCompress>1.21</commonsCompress>
     <commonsIoVersion>2.12.0</commonsIoVersion>
     <plexus-java-version>1.1.2</plexus-java-version>
+    <junit5Version>5.9.3</junit5Version>
     <!-- maven-shared-utils:3.3.4 uses org.fusesource.jansi:jansi:2.2.0 -->
     <mavenSharedUtilsVersion>3.3.4</mavenSharedUtilsVersion>
     <powermockVersion>2.0.9</powermockVersion>
@@ -240,17 +241,17 @@
       <dependency>
         <groupId>org.junit.platform</groupId>
         <artifactId>junit-platform-launcher</artifactId>
-        <version>1.3.2</version>
+        <version>1.9.2</version>
       </dependency>
       <dependency>
         <groupId>org.junit.jupiter</groupId>
         <artifactId>junit-jupiter-engine</artifactId>
-        <version>5.3.2</version>
+        <version>${junit5Version}</version>
       </dependency>
       <dependency>
         <groupId>org.junit.jupiter</groupId>
         <artifactId>junit-jupiter-params</artifactId>
-        <version>5.3.2</version>
+        <version>${junit5Version}</version>
       </dependency>
       <dependency>
         <groupId>org.mockito</groupId>
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
index 76b4a2e..6d4b000 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
@@ -20,6 +20,7 @@
 
 import org.apache.maven.surefire.api.util.ReflectionUtils;
 import org.junit.platform.launcher.Launcher;
+import org.junit.platform.launcher.LauncherDiscoveryListener;
 import org.junit.platform.launcher.LauncherDiscoveryRequest;
 import org.junit.platform.launcher.TestExecutionListener;
 import org.junit.platform.launcher.TestPlan;
@@ -35,6 +36,11 @@
     private Launcher launcher;
 
     @Override
+    public void registerLauncherDiscoveryListeners(LauncherDiscoveryListener... listeners) {
+        launcher().registerLauncherDiscoveryListeners(listeners);
+    }
+
+    @Override
     public void registerTestExecutionListeners(TestExecutionListener... testExecutionListeners) {
         launcher().registerTestExecutionListeners(testExecutionListeners);
     }
@@ -50,6 +56,11 @@
         launcher().execute(launcherDiscoveryRequest, testExecutionListeners);
     }
 
+    @Override
+    public void execute(TestPlan testPlan, TestExecutionListener... listeners) {
+        launcher().execute(testPlan, listeners);
+    }
+
     private Launcher launcher() {
         if (launcher == null) {
             try {
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
index b6ab263..b75ac6a 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
@@ -32,6 +32,9 @@
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.DisplayNameGenerator;
+import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
+import org.junit.jupiter.engine.config.JupiterConfiguration;
 import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor;
@@ -89,7 +92,7 @@
     public void setUp() {
         listener = mock(TestReportListener.class);
         adapter = new RunListenerAdapter(listener);
-        adapter.testPlanExecutionStarted(TestPlan.from(emptyList()));
+        adapter.testPlanExecutionStarted(TestPlan.from(emptyList(), CONFIG_PARAMS));
         adapter.setRunMode(NORMAL_RUN);
     }
 
@@ -97,7 +100,7 @@
     public void notifiedWithCorrectNamesWhenMethodExecutionStarted() throws Exception {
         ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
 
-        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(testPlan);
 
         TestIdentifier methodIdentifier =
@@ -116,7 +119,7 @@
     public void notifiedWithCompatibleNameForMethodWithArguments() throws Exception {
         ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
 
-        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(testPlan);
 
         TestIdentifier methodIdentifier =
@@ -140,7 +143,7 @@
         engine.addChild(parent);
         TestDescriptor child = newMethodDescriptor();
         parent.addChild(child);
-        TestPlan plan = TestPlan.from(singletonList(engine));
+        TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS);
 
         String className = MyTestClass.class.getName();
 
@@ -196,10 +199,11 @@
 
         UniqueId id2 = parent.getUniqueId().append(MyTestClass.class.getName(), MY_TEST_METHOD_NAME);
         Method m2 = MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME, String.class);
-        TestDescriptor child2 = new TestMethodTestDescriptor(id2, MyTestClass.class, m2);
+        TestDescriptor child2 = new TestMethodTestDescriptor(
+                id2, MyTestClass.class, m2, new DefaultJupiterConfiguration(CONFIG_PARAMS));
         parent.addChild(child2);
 
-        TestPlan plan = TestPlan.from(singletonList(engine));
+        TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS);
 
         InOrder inOrder = inOrder(listener);
 
@@ -291,7 +295,7 @@
                 return TEST;
             }
         };
-        TestPlan plan = TestPlan.from(singletonList(engine));
+        TestPlan plan = TestPlan.from(singletonList(engine), CONFIG_PARAMS);
 
         adapter.testPlanExecutionStarted(plan);
         assertThat((TestPlan) getInternalState(adapter, "testPlan")).isSameAs(plan);
@@ -343,7 +347,7 @@
         TestDescriptor method2 = newMethodDescriptor();
         classTestDescriptor.addChild(method2);
         engineDescriptor.addChild(classTestDescriptor);
-        TestPlan testPlan = TestPlan.from(singletonList(engineDescriptor));
+        TestPlan testPlan = TestPlan.from(singletonList(engineDescriptor), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(testPlan);
 
         TestIdentifier classIdentifier =
@@ -414,7 +418,7 @@
     @Test
     public void notifiedWithCorrectNamesWhenClassExecutionFailed() {
         ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
-        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(testPlan);
 
         adapter.executionFinished(
@@ -432,7 +436,7 @@
     @Test
     public void notifiedWithCorrectNamesWhenClassExecutionErrored() {
         ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
-        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(testPlan);
 
         adapter.executionFinished(
@@ -450,7 +454,7 @@
     @Test
     public void notifiedWithCorrectNamesWhenContainerFailed() throws Exception {
         ArgumentCaptor<ReportEntry> entryCaptor = ArgumentCaptor.forClass(ReportEntry.class);
-        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+        TestPlan testPlan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(testPlan);
 
         adapter.executionFinished(newContainerIdentifier(), failed(new RuntimeException()));
@@ -475,7 +479,7 @@
         EngineDescriptor engineDescriptor = newEngineDescriptor();
         TestDescriptor classDescriptor = newClassDescriptor();
         engineDescriptor.addChild(classDescriptor);
-        adapter.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor)));
+        adapter.testPlanExecutionStarted(TestPlan.from(singleton(engineDescriptor), CONFIG_PARAMS));
         adapter.executionStarted(TestIdentifier.from(classDescriptor));
 
         adapter.executionFinished(TestIdentifier.from(classDescriptor), successful());
@@ -505,7 +509,7 @@
     @Test
     public void notifiedWithParentDisplayNameWhenTestClassUnknown() {
         // Set up a test plan
-        TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")));
+        TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Luke's Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(plan);
 
         // Use the test plan to set up child with parent.
@@ -525,7 +529,7 @@
 
     @Test
     public void stackTraceWriterPresentWhenParentHasSource() {
-        TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")));
+        TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(plan);
 
         TestIdentifier child =
@@ -538,7 +542,7 @@
 
     @Test
     public void stackTraceWriterDefaultsToTestClass() {
-        TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")));
+        TestPlan plan = TestPlan.from(singletonList(new EngineDescriptor(newId(), "Some Plan")), CONFIG_PARAMS);
         adapter.testPlanExecutionStarted(plan);
 
         TestIdentifier child = newSourcelessChildIdentifierWithParent(plan, "Parent", null);
@@ -589,7 +593,8 @@
         return new TestMethodTestDescriptor(
                 UniqueId.forEngine("method"),
                 MyTestClass.class,
-                MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME, parameterTypes));
+                MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME, parameterTypes),
+                new DefaultJupiterConfiguration(CONFIG_PARAMS));
     }
 
     private static TestIdentifier newClassIdentifier() {
@@ -597,16 +602,20 @@
     }
 
     private static TestDescriptor newClassDescriptor(String displayName) {
+        JupiterConfiguration jupiterConfiguration = mock(JupiterConfiguration.class);
+        DisplayNameGenerator displayNameGenerator = mock(DisplayNameGenerator.class);
+        when(displayNameGenerator.generateDisplayNameForClass(MyTestClass.class))
+                .thenReturn(displayName);
+        when(jupiterConfiguration.getDefaultDisplayNameGenerator()).thenReturn(displayNameGenerator);
         return new ClassTestDescriptor(
-                UniqueId.root("class", MyTestClass.class.getName()),
-                c -> displayName,
-                MyTestClass.class,
-                CONFIG_PARAMS) {};
+                UniqueId.root("class", MyTestClass.class.getName()), MyTestClass.class, jupiterConfiguration) {};
     }
 
     private static TestDescriptor newClassDescriptor() {
         return new ClassTestDescriptor(
-                UniqueId.root("class", MyTestClass.class.getName()), MyTestClass.class, CONFIG_PARAMS);
+                UniqueId.root("class", MyTestClass.class.getName()),
+                MyTestClass.class,
+                new DefaultJupiterConfiguration(CONFIG_PARAMS));
     }
 
     private static TestIdentifier newSourcelessChildIdentifierWithParent(
@@ -631,8 +640,8 @@
         when(child.getParent()).thenReturn(Optional.of(parent));
         TestIdentifier childId = TestIdentifier.from(child);
 
-        testPlan.add(childId);
-        testPlan.add(parentId);
+        testPlan.addInternal(childId);
+        testPlan.addInternal(parentId);
 
         return childId;
     }
@@ -641,7 +650,8 @@
         return TestIdentifier.from(new TestTemplateTestDescriptor(
                 UniqueId.forEngine("method"),
                 MyTestClass.class,
-                MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME)));
+                MyTestClass.class.getDeclaredMethod(MY_TEST_METHOD_NAME),
+                new DefaultJupiterConfiguration(CONFIG_PARAMS)));
     }
 
     private static TestIdentifier newEngineIdentifier() {
@@ -660,15 +670,15 @@
         TestIdentifier parentIdentifier = TestIdentifier.from(parent);
         TestIdentifier childIdentifier = TestIdentifier.from(child);
 
-        plan.add(parentIdentifier);
-        plan.add(childIdentifier);
+        plan.addInternal(parentIdentifier);
+        plan.addInternal(childIdentifier);
 
         return childIdentifier;
     }
 
     private static TestIdentifier identifiersAsParentOnTestPlan(TestPlan plan, TestDescriptor root) {
         TestIdentifier rootIdentifier = TestIdentifier.from(root);
-        plan.add(rootIdentifier);
+        plan.addInternal(rootIdentifier);
         return rootIdentifier;
     }
 
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
index 18b81e5..aa1b80a 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
@@ -22,6 +22,7 @@
 
 import org.apache.maven.surefire.api.testset.TestListResolver;
 import org.junit.Test;
+import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
 import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
 import org.junit.platform.engine.ConfigurationParameters;
@@ -78,12 +79,13 @@
         UniqueId uniqueId = UniqueId.forEngine("method");
         Class<TestClass> testClass = TestClass.class;
         Method testMethod = testClass.getMethod("testMethod");
-        return new TestMethodTestDescriptor(uniqueId, testClass, testMethod);
+        return new TestMethodTestDescriptor(
+                uniqueId, testClass, testMethod, new DefaultJupiterConfiguration(CONFIG_PARAMS));
     }
 
     private static ClassTestDescriptor newClassTestDescriptor() {
         UniqueId uniqueId = UniqueId.forEngine("class");
-        return new ClassTestDescriptor(uniqueId, TestClass.class, CONFIG_PARAMS);
+        return new ClassTestDescriptor(uniqueId, TestClass.class, new DefaultJupiterConfiguration(CONFIG_PARAMS));
     }
 
     /**