From f61e57f377f5bba314df4a720bc4dfb2b98c899f Mon Sep 17 00:00:00 2001 From: baubakg Date: Sun, 18 Aug 2024 18:49:00 +0200 Subject: [PATCH] Solved issue with the java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask during NIE tests --- .../integro/phased/MutationListener.java | 66 +------------------ .../tests/integro/phased/Mutational.java | 5 +- .../integro/phased/PhasedEventManager.java | 4 +- .../tests/integro/phased/MutationalTests.java | 1 - 4 files changed, 9 insertions(+), 67 deletions(-) diff --git a/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java b/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java index 7dd71d7..a0111cf 100644 --- a/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java +++ b/src/main/java/com/adobe/campaign/tests/integro/phased/MutationListener.java @@ -301,71 +301,9 @@ public void onTestStart(ITestResult result) { //Continue } - /* - //Managing events - //Cases 4 & 5 - //TODO Move to PhasedParent - if (Phases.ASYNCHRONOUS.isSelected()) { - - //Check if there is an event declared - String lt_event = PhasedEventManager.fetchEvent(result); - if (PhasedEventManager.fetchEvent(result) != null) { - //TODO use PhasedTestManager for fetching full name instead - PhasedEventManager.startEvent(lt_event, ClassPathParser.fetchFullName(result)); - } - } - - */ } } - @Override - public void onTestFailure(ITestResult result) { - standardPostTestActions(result); - - } - - @Override - public void onTestSuccess(ITestResult result) { - standardPostTestActions(result); - } - - @Override - public void onTestSkipped(ITestResult result) { - standardPostTestActions(result); - - } - - /** - * This method groups all the post test actions, that are common in all cases - *

- * Author : gandomi - * - * @param result The TestNG result context - */ - protected void standardPostTestActions(ITestResult result) { - final Method l_method = result.getMethod().getConstructorOrMethod().getMethod(); - - /* - if (PhasedTestManager.isPhasedTest(l_method)) { - //TRIM add property check - //appendShuffleGroupToName(result); - // PhasedTestManager.scenarioStateStore(result); - - //Cases 4 & 5 - if (Phases.ASYNCHRONOUS.isSelected()) { - PhasedTestManager.getPhasedCache(); - //Check if there is an event declared - String lt_event = PhasedEventManager.fetchEvent(result); - if (lt_event != null) { - //TODO use PhasedTestManager for fetching full name instead - PhasedEventManager.finishEvent(lt_event, ClassPathParser.fetchFullName(result)); - } - } - } - - */ - } @Override @@ -380,7 +318,9 @@ public void onFinish(ITestContext context) { log.debug("{} Purging results - Keeping one method per test class", PhasedTestManager.PHASED_TEST_LOG_PREFIX); - PhasedEventManager.stopEventExecutor(); + if (Phases.ASYNCHRONOUS.isSelected()) { + PhasedEventManager.stopEventExecutor(); + } } } diff --git a/src/main/java/com/adobe/campaign/tests/integro/phased/Mutational.java b/src/main/java/com/adobe/campaign/tests/integro/phased/Mutational.java index 31a5bca..68038fa 100644 --- a/src/main/java/com/adobe/campaign/tests/integro/phased/Mutational.java +++ b/src/main/java/com/adobe/campaign/tests/integro/phased/Mutational.java @@ -53,6 +53,7 @@ public void shuffled(String phaseGroup) { //String lt_currentStepName = stepOrder.get(i).getStepName(); //Method stepMethod = Arrays.stream(l_executingClass.getMethods()).filter(m -> m.getName().equals(lt_currentStepName)).findFirst().get(); String stepName = l_orderList.get(i).getStepName(); + String stepId = l_executingClass.getTypeName() + "." + stepName+"("+phaseGroup+")"; //System.out.println("Executing - " + stepName); Method stepMethod = Arrays.stream(l_executingClass.getDeclaredMethods()) @@ -66,7 +67,7 @@ public void shuffled(String phaseGroup) { String lt_event = PhasedEventManager.fetchEvent(stepMethod, phaseGroup); if (lt_event != null) { //TODO use PhasedTestManager for fetching full name instead - PhasedEventManager.startEvent(lt_event, l_thisScneario); + PhasedEventManager.startEvent(lt_event, stepId); } } @@ -80,7 +81,7 @@ public void shuffled(String phaseGroup) { String lt_event = PhasedEventManager.fetchEvent(stepMethod, phaseGroup); if (lt_event != null) { //TODO use PhasedTestManager for fetching full name instead - PhasedEventManager.finishEvent(lt_event, l_thisScneario); + PhasedEventManager.finishEvent(lt_event, stepId); } } diff --git a/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedEventManager.java b/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedEventManager.java index 03af0a3..3047dc9 100644 --- a/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedEventManager.java +++ b/src/main/java/com/adobe/campaign/tests/integro/phased/PhasedEventManager.java @@ -83,7 +83,7 @@ protected static NonInterruptiveEvent startEvent(String in_event, String in_onAc NonInterruptiveEvent nie = instantiateClassFromString(in_event); logEvent(EventMode.START, in_event, in_onAccountOfStep); events.put(in_onAccountOfStep, nie); - eventExecutor.submit(nie); + eventExecutor.submit(nie); while (nie.getState().equals(NonInterruptiveEvent.states.DEFINED)) { try { Thread.sleep(1); @@ -206,6 +206,8 @@ public static ExecutorService getEventExecutor() { public static void stopEventExecutor() { if (eventExecutor != null) eventExecutor.shutdown(); + + eventExecutor = null; } diff --git a/src/test/java/com/adobe/campaign/tests/integro/phased/MutationalTests.java b/src/test/java/com/adobe/campaign/tests/integro/phased/MutationalTests.java index 7ffc90c..390a613 100644 --- a/src/test/java/com/adobe/campaign/tests/integro/phased/MutationalTests.java +++ b/src/test/java/com/adobe/campaign/tests/integro/phased/MutationalTests.java @@ -54,7 +54,6 @@ public void resetVariables() { PhasedTestManager.clearCache(); - PhasedTestManager.deactivateMergedReports(); PhasedTestManager.deactivateTestSelectionByProducerMode(); PhasedTestManager.MergedReportData.resetReport();