Skip to content

Commit

Permalink
Solved issue with the java.util.concurrent.RejectedExecutionException…
Browse files Browse the repository at this point in the history
…: Task java.util.concurrent.FutureTask during NIE tests
  • Loading branch information
baubakg committed Aug 18, 2024
1 parent eb7db2d commit f61e57f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
* <p>
* 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
Expand All @@ -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();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -206,6 +206,8 @@ public static ExecutorService getEventExecutor() {
public static void stopEventExecutor() {
if (eventExecutor != null)
eventExecutor.shutdown();

eventExecutor = null;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void resetVariables() {

PhasedTestManager.clearCache();

PhasedTestManager.deactivateMergedReports();
PhasedTestManager.deactivateTestSelectionByProducerMode();

PhasedTestManager.MergedReportData.resetReport();
Expand Down

0 comments on commit f61e57f

Please sign in to comment.