-
-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SerenityReporterParallel: improve integration of custom listeners (#3599
- Loading branch information
Showing
5 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
serenity-core/src/main/java/net/thucydides/core/steps/session/PlaybackSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.thucydides.core.steps.session; | ||
|
||
import net.thucydides.core.steps.StepEventBus; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
|
||
public class PlaybackSession { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(PlaybackSession.class); | ||
|
||
private static final ThreadLocal<PlaybackSessionContext> sessionContext = ThreadLocal.withInitial(PlaybackSessionContext::new); | ||
|
||
public static void startSession(String sessionId, StepEventBus stepEventBus) { | ||
sessionContext.get().getSessionStarted().set(true); | ||
sessionContext.get().setSessionId(sessionId); | ||
sessionContext.get().setStepEventBus(stepEventBus); | ||
LOGGER.debug("SRP:PlaybackSessionStart: id: {} " , sessionId); | ||
} | ||
|
||
public static void closeSession() { | ||
sessionContext.get().getSessionStarted().set(false); | ||
LOGGER.debug("SRP:PlaybackSessionEnd: id: {} ", sessionContext.get().getSessionId()); | ||
} | ||
|
||
public static PlaybackSessionContext getTestSessionContext() { | ||
return sessionContext.get(); | ||
} | ||
|
||
|
||
public static boolean isSessionStarted() { | ||
return sessionContext.get().getSessionStarted().get(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
serenity-core/src/main/java/net/thucydides/core/steps/session/PlaybackSessionContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.thucydides.core.steps.session; | ||
|
||
import net.thucydides.core.steps.StepEventBus; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public class PlaybackSessionContext { | ||
|
||
private String sessionId; | ||
|
||
private StepEventBus stepEventBus; | ||
|
||
private final AtomicBoolean sessionStarted = new AtomicBoolean(false); | ||
|
||
public AtomicBoolean getSessionStarted() { | ||
return sessionStarted; | ||
} | ||
|
||
public void setSessionId(String sessionId) { | ||
this.sessionId = sessionId; | ||
} | ||
|
||
public String getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
public StepEventBus getStepEventBus() { | ||
return stepEventBus; | ||
} | ||
|
||
public void setStepEventBus(StepEventBus stepEventBus) { | ||
this.stepEventBus = stepEventBus; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters