TempDirectory is a JUnit Jupiter extension that creates and cleans
up temporary directories if a field in a test class or a parameter in a
test class constructor, lifecycle method, or test method is annotated with
@TempDir.
Consult the Javadoc for TempDir for details on the contract.
@TempDir, Files#createTempDirectory
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | TempDirectory.
References Deprecated
ExtensionContext.Store.CloseableResource is deprecated or references (maybe indirectly) at least one deprecated element.
|
| private static record | TempDirectory.
References Deprecated
ExtensionContext.Store.CloseableResource is deprecated or references (maybe indirectly) at least one deprecated element.
|
| private static record | |
| pack-priv static interface |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private final JupiterConfiguration | |
| private static final String | |
| pack-priv static final String | |
| private static final String | |
| pack-priv static final ExtensionContext. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| private static void | |
| public void | beforeAll(ExtensionContext context)
Implements org. Perform field injection for non-private, |
| public void | beforeEach(ExtensionContext context)
Implements org. Perform field injection for non-private, non-static fields (i.e.,
instance fields) of type |
| pack-priv static TempDirectory. | createTempDir(TempDirFactory factory, CleanupMode cleanupMode, Class<?> elementType, AnnotatedElementContext elementContext, ExtensionContext extensionContext)
References Deprecated
TempDirectory.CloseablePath is deprecated or references (maybe indirectly) at least one deprecated element.
|
| private CleanupMode | |
| private CleanupMode | |
| private CleanupMode | |
| private TempDirFactory | |
| private TempDirFactory | |
| private TempDirFactory | |
| private static ExtensionContext. | |
| private static Object | getPathOrFile(Class<?> elementType, AnnotatedElementContext elementContext, TempDirFactory factory, CleanupMode cleanupMode, ExtensionContext extensionContext)
|
| public TestInstantiationAwareExtension. | getTestInstantiationExtensionContextScope(ExtensionContext rootContext)
Overrides default org. Determine whether this extension should receive a test-method scoped
|
| private void | injectFields(ExtensionContext context, @Nullable Object testInstance, Class<?> testClass, Predicate<Field> predicate)
|
| private void | |
| private void | |
| private static void | |
| private static void | |
| public Object | resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
Implements org. Resolve the current temporary directory for the |
| private static boolean | |
| public boolean | supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
Implements org. Determine if the |
| CHILD_FAILED | back to summary |
|---|---|
| private static final String CHILD_FAILED | |
| configuration | back to summary |
|---|---|
| private final JupiterConfiguration configuration | |
| FAILURE_TRACKER | back to summary |
|---|---|
| private static final String FAILURE_TRACKER | |
| FILE_OPERATIONS_KEY | back to summary |
|---|---|
| pack-priv static final String FILE_OPERATIONS_KEY | |
| KEY | back to summary |
|---|---|
| private static final String KEY | |
| NAMESPACE | back to summary |
|---|---|
| pack-priv static final ExtensionContext. | |
| TempDirectory | back to summary |
|---|---|
| pack-priv TempDirectory(JupiterConfiguration configuration) | |
| assertNonFinalField | back to summary |
|---|---|
| private static void assertNonFinalField(Field field) | |
| assertSupportedType | back to summary |
|---|---|
| private static void assertSupportedType(String target, Class<?> type) | |
| beforeAll | back to summary |
|---|---|
| public void beforeAll(ExtensionContext context) Implements org. Perform field injection for non-private,
| |
| beforeEach | back to summary |
|---|---|
| public void beforeEach(ExtensionContext context) Implements org. Perform field injection for non-private, non-static fields (i.e.,
instance fields) of type
| |
| createTempDir | back to summary |
|---|---|
| pack-priv static TempDirectory. References Deprecated
See corresponding docs for further information. | |
| determineCleanupMode | back to summary |
|---|---|
| private CleanupMode determineCleanupMode(TempDir tempDir) | |
| determineCleanupModeForField | back to summary |
|---|---|
| private CleanupMode determineCleanupModeForField(Field field) | |
| determineCleanupModeForParameter | back to summary |
|---|---|
| private CleanupMode determineCleanupModeForParameter(ParameterContext parameterContext) | |
| determineTempDirFactory | back to summary |
|---|---|
| private TempDirFactory determineTempDirFactory(TempDir tempDir) | |
| determineTempDirFactoryForField | back to summary |
|---|---|
| private TempDirFactory determineTempDirFactoryForField(Field field) | |
| determineTempDirFactoryForParameter | back to summary |
|---|---|
| private TempDirFactory determineTempDirFactoryForParameter(ParameterContext parameterContext) | |
| getContextSpecificStore | back to summary |
|---|---|
| private static ExtensionContext. | |
| getPathOrFile | back to summary |
|---|---|
| private static Object getPathOrFile(Class<?> elementType, AnnotatedElementContext elementContext, TempDirFactory factory, CleanupMode cleanupMode, ExtensionContext extensionContext) | |
| getTestInstantiationExtensionContextScope | back to summary |
|---|---|
| public TestInstantiationAwareExtension. Overrides default org. Determine whether this extension should receive a test-method scoped
If an extension returns
When a test-method scoped
Note The behavior which is enabled by returning
| |
| injectFields | back to summary |
|---|---|
| private void injectFields(ExtensionContext context, @Nullable Object testInstance, Class<?> testClass, Predicate<Field> predicate) | |
| injectInstanceFields | back to summary |
|---|---|
| private void injectInstanceFields(ExtensionContext context, Object instance) | |
| injectStaticFields | back to summary |
|---|---|
| private void injectStaticFields(ExtensionContext context, Class<?> testClass) | |
| installFailureTracker | back to summary |
|---|---|
| private static void installFailureTracker(ExtensionContext context) | |
| installFailureTracker | back to summary |
|---|---|
| private static void installFailureTracker(ExtensionContext context, ExtensionContext parentContext) | |
| resolveParameter | back to summary |
|---|---|
| public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) Implements org. Resolve the current temporary directory for the
| |
| selfOrChildFailed | back to summary |
|---|---|
| private static boolean selfOrChildFailed(ExtensionContext context) | |
| supportsParameter | back to summary |
|---|---|
| public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) Implements org. Determine if the
| |
References Deprecated
ExtensionContext.Store.CloseableResource is deprecated or references (maybe indirectly) at least one deprecated element.
See corresponding docs for further information.
| Modifier and Type | Field and Description |
|---|---|
| private final AnnotatedElement | |
| private final CleanupMode | |
| private final Path | |
| private final ExtensionContext | |
| private final TempDirFactory | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| private | CloseablePath(TempDirFactory factory, CleanupMode cleanupMode, Class<?> elementType, AnnotatedElementContext elementContext, ExtensionContext extensionContext)
|
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements org. Close underlying resources. |
| private IOException | |
| private SortedMap | |
| private static String | |
| private static String | |
| pack-priv Path | |
| private Path | |
| private Path | |
| private static void |
| annotatedElement | back to summary |
|---|---|
| private final AnnotatedElement annotatedElement | |
| cleanupMode | back to summary |
|---|---|
| private final CleanupMode cleanupMode | |
| dir | back to summary |
|---|---|
| private final Path dir | |
| extensionContext | back to summary |
|---|---|
| private final ExtensionContext extensionContext | |
| factory | back to summary |
|---|---|
| private final TempDirFactory factory | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| CloseablePath | back to summary |
|---|---|
| private CloseablePath(TempDirFactory factory, CleanupMode cleanupMode, Class<?> elementType, AnnotatedElementContext elementContext, ExtensionContext extensionContext) throws Exception | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements org. Doc from org. Close underlying resources.
| |
| createIOExceptionWithAttachedFailures | back to summary |
|---|---|
| private IOException createIOExceptionWithAttachedFailures(SortedMap<Path, IOException> failures) | |
| deleteAllFilesAndDirectories | back to summary |
|---|---|
| private SortedMap | |
| descriptionFor | back to summary |
|---|---|
private static String descriptionFor(AnnotatedElement annotatedElement)
| |
| descriptionFor | back to summary |
|---|---|
private static String descriptionFor(Executable executable)
| |
| get | back to summary |
|---|---|
| pack-priv Path get() | |
| relativizeSafely | back to summary |
|---|---|
| private Path relativizeSafely(Path path) | |
| tryToDeleteOnExit | back to summary |
|---|---|
private Path tryToDeleteOnExit(Path path)
| |
| tryToResetPermissions | back to summary |
|---|---|
private static void tryToResetPermissions(Path path)
| |
References Deprecated
ExtensionContext.Store.CloseableResource is deprecated or references (maybe indirectly) at least one deprecated element.
See corresponding docs for further information.
| Modifier and Type | Field and Description |
|---|---|
| private final ExtensionContext | |
| private final ExtensionContext | parentContext
Record Component accessed by parentContext(). |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements org. Close underlying resources. |
| public ExtensionContext | |
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public ExtensionContext | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| context | back to summary |
|---|---|
| private final ExtensionContext context Record Component accessed by context(). | |
| parentContext | back to summary |
|---|---|
| private final ExtensionContext parentContext Record Component accessed by parentContext(). | |
| FailureTracker | back to summary |
|---|---|
| private FailureTracker(ExtensionContext context, ExtensionContext parentContext) | |
| close | back to summary |
|---|---|
| public void close() Implements org. Doc from org. Close underlying resources.
| |
| context | back to summary |
|---|---|
| public ExtensionContext context() Record Component getter of context. | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| parentContext | back to summary |
|---|---|
| public ExtensionContext parentContext() Record Component getter of parentContext. | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| Modifier and Type | Field and Description |
|---|---|
| private final Field |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public Field | |
| public AnnotatedElement | getAnnotatedElement()
Implements org. Get the |
| public final int | |
| public String | toString()
Implements abstract java. Returns a string representation of the record. |
| field | back to summary |
|---|---|
| private final Field field Record Component accessed by field(). | |
| FieldContext | back to summary |
|---|---|
| private FieldContext(Field field) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| field | back to summary |
|---|---|
| public Field field() Record Component getter of field. | |
| getAnnotatedElement | back to summary |
|---|---|
| public AnnotatedElement getAnnotatedElement() Implements org. Doc from org. Get the WARNINGWhen searching for annotations on the annotated element in this context,
favor
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| toString | back to summary |
|---|---|
| public String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final TempDirectory. |
| DEFAULT | back to summary |
|---|---|
| public static final TempDirectory. | |
| delete | back to summary |
|---|---|
| public void delete(Path path) throws IOException | |