Top Description Methods
org.junit.platform.engine

public sealed Interface CancellationToken

permits RegularCancellationToken, DisabledCancellationToken
Known Direct Implementers
org.junit.platform.engine.DisabledCancellationToken, org.junit.platform.engine.RegularCancellationToken
Annotations
@API
status:EXPERIMENTAL
since:6.0
Static Imports
org.apiguardian.api.API.Status.EXPERIMENTAL

Token that should be checked to determine whether an operation was requested to be cancelled.

For example, this is used by the org.junit.platform.launcher.Launcher and org.junit.platform.engine.TestEngine implementations to determine whether the current test execution should be cancelled.

This interface is not intended to be implemented by clients.

Since
6.0
See Also
org.junit.platform.launcher.core.LauncherExecutionRequestBuilder#cancellationToken(CancellationToken), org.junit.platform.launcher.LauncherExecutionRequest#getCancellationToken(), ExecutionRequest#getCancellationToken()

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Request cancellation.

public static CancellationToken
create()

Create a new, uncancelled cancellation token.

public static CancellationToken
disabled()

Get a new cancellation token that cannot be cancelled.

public boolean

Returns:

whether cancellation has been requested
isCancellationRequested
()

Returns whether cancellation has been requested.

Method Detail

cancelback to summary
public void cancel()

Request cancellation.

This will call subsequent calls to isCancellationRequested() to return true.

createback to summary
public static CancellationToken create()

Create a new, uncancelled cancellation token.

disabledback to summary
public static CancellationToken disabled()

Get a new cancellation token that cannot be cancelled.

This is only useful for cases when a cancellation token is required but is not supported or irrelevant, for example, in tests.

isCancellationRequestedback to summary
public boolean isCancellationRequested()

Returns whether cancellation has been requested.

Once this method returns true, it will never return false in a subsequent call.

Returns:boolean

whether cancellation has been requested