Class TestResourcesClientFactory
java.lang.Object
io.micronaut.testresources.client.TestResourcesClientFactory
A factory responsible for creating a
TestResourcesClient
.
Because this client is used in services which are loaded via
service loading during application context building, we can't use
regular dependency injection, so this factory creates an application
context to create the client.-
Method Summary
Modifier and TypeMethodDescriptionstatic TestResourcesClient
extractFrom
(io.micronaut.context.ApplicationContext context) Extracts theTestResourcesClient
from the givenApplicationContext
.static Optional<TestResourcesClient>
Tries to configure a test resources client by looking for configuration in conventional places.static Optional<TestResourcesClient>
fromFileSystem
(Path location) Tries to configure a test resources client from properties configuration file found on a specific file system location.static Optional<TestResourcesClient>
Creates a new test resources client configured via system properties.
-
Method Details
-
findByConvention
Tries to configure a test resources client by looking for configuration in conventional places. It will first look for the configuration as system properties, which is the most reliable way for the client to figure out how to connect to the server.If not found, then it will try to read configuration from the working directory, and then, from the user home. It is recommended that consumers prefer passing the configuration via system properties in order to support all possible options to configure the client (in particular, shared mode or namespaces, which is not possible to figure out via standard file system lookups).
- Returns:
- a configured client, or an empty optional.
-
fromFileSystem
Tries to configure a test resources client from properties configuration file found on a specific file system location.- Parameters:
location
- the path to the configuration file- Returns:
- a configured client if found, otherwise an empty optional
-
fromSystemProperties
Creates a new test resources client configured via system properties.- Returns:
- a new test resources client, if system properties were found.
-
extractFrom
Extracts theTestResourcesClient
from the givenApplicationContext
.- Parameters:
context
- the application context- Returns:
- the test resources client
-