-
- Type Parameters:
T- the type of the resource
- All Superinterfaces:
org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource
- All Known Implementing Classes:
TemporaryDirectory.TemporaryDirectoryResource
public interface Resource<T> extends org.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResourceResourceis the common interface for "resources", as managed byResourceFactoryimplementations.It is part of the "resources" JUnit Jupiter extension, which pertains to anything that needs to be injected into tests and which may need to be started up or torn down. Temporary directories are a common example.
This class is intended for implementors of new kinds of resources.
For more details and examples, see the documentation on resources.
- Since:
- 1.9.0
- See Also:
ResourceFactory
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()Closes the resource.Tget()Returns the contents of the resource.
-
-
-
Method Detail
-
get
T get() throws java.lang.Exception
Returns the contents of the resource.- Throws:
java.lang.Exception- if getting the resource failed
-
close
default void close() throws java.lang.ExceptionCloses the resource.- Specified by:
closein interfaceorg.junit.jupiter.api.extension.ExtensionContext.Store.CloseableResource- Throws:
java.lang.Exception- if closing the resource failed
-
-