Package org.apache.maven.surefire.booter
Class ForkedBooter
- java.lang.Object
-
- org.apache.maven.surefire.booter.ForkedBooter
-
public final class ForkedBooter extends java.lang.Object
The part of the booter that is unique to a forked vm.
Deals with deserialization of the booter wire-level protocol
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ForkedBooter.PingScheduler
-
Field Summary
Fields Modifier and Type Field Description private CommandReader
commandReader
private static long
DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS
private ForkedChannelEncoder
eventChannel
private java.util.concurrent.Semaphore
exitBarrier
private ForkingReporterFactory
forkingReporterFactory
private java.util.concurrent.ScheduledThreadPoolExecutor
jvmTerminator
private static java.lang.String
LAST_DITCH_SHUTDOWN_THREAD
private static long
ONE_SECOND_IN_MILLIS
private static java.lang.String
PING_THREAD
private static long
PING_TIMEOUT_IN_SECONDS
private ForkedBooter.PingScheduler
pingScheduler
private ProviderConfiguration
providerConfiguration
private StartupConfiguration
startupConfiguration
private long
systemExitTimeoutInSeconds
private java.lang.Object
testSet
-
Constructor Summary
Constructors Constructor Description ForkedBooter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
acknowledgedExit()
private static void
acquireOnePermit(java.util.concurrent.Semaphore barrier, long timeoutMillis)
private void
cancelPingScheduler()
private static boolean
canUseNewPingMechanism(PpidChecker pluginProcessChecker)
private CommandListener
createExitHandler(PpidChecker ppidChecker)
private ForkingReporterFactory
createForkingReporterFactory()
private CommandListener
createPingHandler(java.util.concurrent.atomic.AtomicBoolean pingDone)
private java.lang.Runnable
createPingJob(java.util.concurrent.atomic.AtomicBoolean pingDone, PpidChecker pluginProcessChecker)
private static java.util.concurrent.ScheduledExecutorService
createPingScheduler()
private SurefireProvider
createProviderInCurrentClassloader(ForkingReporterFactory reporterManagerFactory)
private static java.io.InputStream
createSurefirePropertiesIfFileExists(java.lang.String tmpDir, java.lang.String propFileName)
private java.lang.Object
createTestSet(TypeEncodedValue forkedTestSet, boolean readTestsFromCommandReader, java.lang.ClassLoader cl)
private void
execute()
private void
exit1()
private static java.lang.String
generateThreadDump()
private java.util.concurrent.ScheduledThreadPoolExecutor
getJvmTerminator()
private static java.lang.String
getProcessName()
private static boolean
isDebugging()
private void
kill()
private void
kill(int returnCode)
private void
launchLastDitchDaemonShutdownThread(int returnCode)
private ForkedBooter.PingScheduler
listenToShutdownCommands(java.lang.String ppid, ConsoleLogger logger)
static void
main(java.lang.String[] args)
This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and then calls the Surefire class' run method.private java.lang.Runnable
processCheckerJob(ForkedBooter.PingScheduler pingMechanism)
private static void
run(ForkedBooter booter, java.lang.String[] args)
created for testing purposes.private void
runSuitesInProcess()
private void
setupBooter(java.lang.String tmpDir, java.lang.String dumpFileName, java.lang.String surefirePropsFileName, java.lang.String effectiveSystemPropertiesFileName)
-
-
-
Field Detail
-
DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS
private static final long DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS
- See Also:
- Constant Field Values
-
PING_TIMEOUT_IN_SECONDS
private static final long PING_TIMEOUT_IN_SECONDS
- See Also:
- Constant Field Values
-
ONE_SECOND_IN_MILLIS
private static final long ONE_SECOND_IN_MILLIS
- See Also:
- Constant Field Values
-
LAST_DITCH_SHUTDOWN_THREAD
private static final java.lang.String LAST_DITCH_SHUTDOWN_THREAD
- See Also:
- Constant Field Values
-
PING_THREAD
private static final java.lang.String PING_THREAD
- See Also:
- Constant Field Values
-
commandReader
private final CommandReader commandReader
-
eventChannel
private final ForkedChannelEncoder eventChannel
-
exitBarrier
private final java.util.concurrent.Semaphore exitBarrier
-
systemExitTimeoutInSeconds
private volatile long systemExitTimeoutInSeconds
-
pingScheduler
private volatile ForkedBooter.PingScheduler pingScheduler
-
jvmTerminator
private java.util.concurrent.ScheduledThreadPoolExecutor jvmTerminator
-
providerConfiguration
private ProviderConfiguration providerConfiguration
-
forkingReporterFactory
private ForkingReporterFactory forkingReporterFactory
-
startupConfiguration
private StartupConfiguration startupConfiguration
-
testSet
private java.lang.Object testSet
-
-
Method Detail
-
setupBooter
private void setupBooter(java.lang.String tmpDir, java.lang.String dumpFileName, java.lang.String surefirePropsFileName, java.lang.String effectiveSystemPropertiesFileName) throws java.io.IOException
- Throws:
java.io.IOException
-
execute
private void execute()
-
createTestSet
private java.lang.Object createTestSet(TypeEncodedValue forkedTestSet, boolean readTestsFromCommandReader, java.lang.ClassLoader cl)
-
cancelPingScheduler
private void cancelPingScheduler()
-
listenToShutdownCommands
private ForkedBooter.PingScheduler listenToShutdownCommands(java.lang.String ppid, ConsoleLogger logger)
-
processCheckerJob
private java.lang.Runnable processCheckerJob(ForkedBooter.PingScheduler pingMechanism)
-
createPingHandler
private CommandListener createPingHandler(java.util.concurrent.atomic.AtomicBoolean pingDone)
-
createExitHandler
private CommandListener createExitHandler(PpidChecker ppidChecker)
-
createPingJob
private java.lang.Runnable createPingJob(java.util.concurrent.atomic.AtomicBoolean pingDone, PpidChecker pluginProcessChecker)
-
kill
private void kill()
-
kill
private void kill(int returnCode)
-
exit1
private void exit1()
-
acknowledgedExit
private void acknowledgedExit()
-
runSuitesInProcess
private void runSuitesInProcess() throws TestSetFailedException, java.lang.reflect.InvocationTargetException
- Throws:
TestSetFailedException
java.lang.reflect.InvocationTargetException
-
createForkingReporterFactory
private ForkingReporterFactory createForkingReporterFactory()
-
getJvmTerminator
private java.util.concurrent.ScheduledThreadPoolExecutor getJvmTerminator()
-
launchLastDitchDaemonShutdownThread
private void launchLastDitchDaemonShutdownThread(int returnCode)
-
createProviderInCurrentClassloader
private SurefireProvider createProviderInCurrentClassloader(ForkingReporterFactory reporterManagerFactory)
-
main
public static void main(java.lang.String[] args)
This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and then calls the Surefire class' run method.
The system exit code will be 1 if an exception is thrown.- Parameters:
args
- Commandline arguments
-
run
private static void run(ForkedBooter booter, java.lang.String[] args)
created for testing purposes.- Parameters:
booter
- booter in JVMargs
- arguments passed to JVM
-
canUseNewPingMechanism
private static boolean canUseNewPingMechanism(PpidChecker pluginProcessChecker)
-
acquireOnePermit
private static void acquireOnePermit(java.util.concurrent.Semaphore barrier, long timeoutMillis)
-
createPingScheduler
private static java.util.concurrent.ScheduledExecutorService createPingScheduler()
-
createSurefirePropertiesIfFileExists
private static java.io.InputStream createSurefirePropertiesIfFileExists(java.lang.String tmpDir, java.lang.String propFileName) throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
-
isDebugging
private static boolean isDebugging()
-
generateThreadDump
private static java.lang.String generateThreadDump()
-
getProcessName
private static java.lang.String getProcessName()
-
-