Package dev.resteasy.junit.extension.api
package dev.resteasy.junit.extension.api
Extension API and SPI for customizing the RESTEasy JUnit extension.
This package contains interfaces that allow users to extend and customize the behavior of the RESTEasy JUnit extension through Service Provider Interfaces (SPI).
Types
SelfSignedCertificate- Provides access to generated self-signed certificate artifacts for SSL/TLS testing
SPI Interfaces
ConfigurationProvider- Provides customSeBootstrap.Configurationfor test instancesRestClientBuilderProvider- Provides customClientBuilderconfigurationRestResourceProducer- Enables injection of custom types into test classes
Service Registration
All SPI implementations must be registered via Java's ServiceLoader mechanism by creating a file in
META-INF/services/ with the fully-qualified interface name.
Example: Custom Configuration Provider
public class CustomPortProvider implements ConfigurationProvider {
@Override
public SeBootstrap.Configuration getConfiguration() {
return SeBootstrap.Configuration.builder()
.port(9090)
.build();
}
}
@RestBootstrap(value = MyApp.class, configFactory = CustomPortProvider.class)
public class MyTest {
// Test will run on port 9090
}
Example: Custom Injection Producer
public class DatabaseProducer implements RestResourceProducer {
@Override
public boolean canInject(ExtensionContext context, Class<?> clazz, Annotation... qualifiers) {
return DataSource.class.isAssignableFrom(clazz);
}
@Override
public Object produce(ExtensionContext context, Class<?> clazz, Annotation... qualifiers) {
// Create and return DataSource
}
}
// Now you can inject DataSource in tests:
@RestBootstrap(MyApp.class)
public class MyTest {
@RestResource
private DataSource dataSource;
}
- Since:
- 1.0
- See Also:
-
ClassDescriptionProvides custom
SeBootstrap.Configurationfor test instances.Provides customClientBuilderconfiguration for creating REST clients.Enables injection of custom types into test classes.Defines the lifecycle scope for resources produced by aRestResourceProducer.Provides access to self-signed certificate artifacts generated for SSL/TLS testing.