Annotation Type RestBootstrap
SeBootstrap.Instance for unit testing.
There are two ways to specify what to bootstrap:
- Application class - Specify a custom
Applicationclass viaapplication():@RestBootstrap(application = MyApplication.class) public class MyTest { // Tests run with MyApplication } - Resource classes - For simple cases, specify Jakarta REST resource classes via
value():@RestBootstrap({ UserResource.class, OrderResource.class }) public class MyTest { // Tests run with a synthetic Application containing these resources }
Exactly one of application() or value() must be specified. Specifying both or neither will result
in an ExtensionConfigurationException.
The default provider attempts to use a ServiceLoader to lookup the first provider found. If
found that provider will be used. This can be useful when when you want to use the same provider across all tests
without having to define the type on each annotation.
- Since:
- 1.0
- Author:
- James R. Perkins
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends jakarta.ws.rs.core.Application> The application to use for starting aSeBootstrap.Instance.Class<? extends ConfigurationProvider> A factory used to be build the configuration for starting theSeBootstrap.jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthenticationThe SSL client authentication mode to use when the test class is also annotated with@SelfSignedCert.longThe timeout used to wait for theSeBootstrapto start.The time unit to use for the timeout.Class<?>[]Jakarta REST resource classes to bootstrap for testing.
-
Element Details
-
value
Class<?>[] valueJakarta REST resource classes to bootstrap for testing.This provides a simplified alternative to
application()for common cases where you only need to specify resource classes without customApplicationconfiguration. Whenvalue()is specified, the extension creates a syntheticApplicationthat returns these classes fromApplication.getClasses().This is mutually exclusive with
application(). Exactly one must be specified.Example
@RestBootstrap({ UserResource.class, OrderResource.class }) public class SimpleTest { @RestResource private Client client; @Test public void testUser() { // Test UserResource } }When to use
value()vsapplication():- Use
value()for simple tests that only need to specify resource classes - Use
application()when you need:- Custom
ApplicationPathconfiguration - Custom
Applicationproperties - Programmatic resource filtering or dynamic configuration
- Custom
- Returns:
- an array of Jakarta REST resource classes, or empty if using
application()instead
- Default:
{}
- Use
-
application
Class<? extends jakarta.ws.rs.core.Application> applicationThe application to use for starting aSeBootstrap.Instance.This is mutually exclusive with
value(). Exactly one must be specified.The default value of
Application.class serves as a marker indicating no application was specified. In this case,value()must be non-empty.- Returns:
- the application class, or
Application.class if usingvalue()instead
- Default:
jakarta.ws.rs.core.Application.class
-
configFactory
Class<? extends ConfigurationProvider> configFactoryA factory used to be build the configuration for starting theSeBootstrap.- Returns:
- the configuration factory to use
- Default:
dev.resteasy.junit.extension.api.ConfigurationProvider.class
-
timeout
long timeoutThe timeout used to wait for theSeBootstrapto start.- Returns:
- the timeout value
- Default:
60L
-
timeoutUnit
TimeUnit timeoutUnitThe time unit to use for the timeout.- Returns:
- the timeout unit
- Default:
SECONDS
-
sslClientAuthentication
jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication sslClientAuthenticationThe SSL client authentication mode to use when the test class is also annotated with@SelfSignedCert.This controls whether the server requests or requires a client certificate during the TLS handshake:
OPTIONAL(default) — the server requests a client certificate but does not require one. This is the recommended default for testing, as the injectedClientis always configured with the client SSL context.MANDATORY— the server requires a valid client certificate. Connections without a client certificate will be rejected.NONE— the server does not request a client certificate.
This attribute is only used by the default
ConfigurationProvider. Custom providers specified viaconfigFactory()are responsible for their own SSL client authentication configuration.This attribute has no effect if the test class is not annotated with
@SelfSignedCert.- Returns:
- the SSL client authentication mode
- See Also:
- Default:
OPTIONAL
-