@Documented @Retention(value=RUNTIME) @Target(value={ANNOTATION_TYPE,TYPE}) @Repeatable(value=LocalResources.class) public @interface LocalResource
An annotation that can be placed on integration and system tests to specify resources that must be loaded, configured, started, stopped before and after each test case (i.e. an in-memory database).
Note that an local resource consists of a server component and client component (optional).
For example, if a test class requires an in-memory database then the database
DataSource can be thought of as the server component and the
Connection to the DataSource as the client component.
| Modifier and Type | Required Element and Description |
|---|---|
Class<? extends LocalResourceProvider> |
value
Specifies the local resource's implementation provider class.
|
| Modifier and Type | Optional Element and Description |
|---|---|
Class |
clientContract
Specifies the contract implemented by the resource client.
|
String |
clientName
Specifies the resource's client name.
|
String |
configKey
The configuration section key in .testify.yml associated with the local resource.
|
String[] |
dataFiles
A list of classpath data files that should be loaded into the local resource prior to
being used.
|
Class<? extends DataProvider> |
dataProvider
Specifies a data provider implementations that loads data into the resource prior to it
being used.
|
String |
name
Specifies the name of the
LocalResourceInstance provided by value(). |
Class |
resourceContract
Specifies the contract implemented by the underlying local resource.
|
String |
resourceName
Specifies the underlying local resource name.
|
public abstract Class<? extends LocalResourceProvider> value
public abstract String name
Specifies the name of the LocalResourceInstance provided by value().
Note that if a test class requires multiple resources that provide similar resources then name must be specified to resolve ambiguity as to which resource instance should be injected into your test code.
public abstract String configKey
public abstract String[] dataFiles
FileSystem.getPathMatcher(java.lang.String)
glob patterns are supportedpublic abstract Class<? extends DataProvider> dataProvider
public abstract String resourceName
Specifies the underlying local resource name. This useful for giving the underlying resource a unique name that can be used to qualify and distinguish it from other similar services.
Note that if the name is not specified the name provided by the local resource provider implementation will be used.
public abstract Class resourceContract
Specifies the contract implemented by the underlying local resource. This useful for getting the underlying resource by its contract.
Note that if the underlying resource contract is not specified the underlying resource will be injectable by its implementation class only.
public abstract String clientName
Specifies the resource's client name. This useful for giving the client resource instance a unique name that can be used to qualify and distinguish it from other similar services.
Note that if the name is not specified the name provided by the required resource implementation will be used.
public abstract Class clientContract
Specifies the contract implemented by the resource client. This useful for getting the client resource by its contract.
Note that if the client contract is not specified the client resource instance will be injectable by its implementation class only.
Copyright © 2016–2018 Testify Project. All rights reserved.