use of jakarta.ws.rs.SeBootstrap.Configuration in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapTest method shouldUseDefaultConfigurationIfOmitted.
/**
* Assert that a default {@code Configuration} is used when not passed to the
* {@code SeBootstrap.start} method.
*
* @since 3.1
*/
@Test
public void shouldUseDefaultConfigurationIfOmitted() {
// given
final Application application = mock(Application.class);
final Configuration configuration = mock(Configuration.class);
SeBootstrap.Configuration.Builder builder = mock(SeBootstrap.Configuration.Builder.class);
given(SeBootstrap.Configuration.builder()).willReturn(builder);
given(builder.build()).willReturn(configuration);
// when
SeBootstrap.start(application);
// then
verify(RuntimeDelegate.getInstance()).bootstrap(application, configuration);
}
use of jakarta.ws.rs.SeBootstrap.Configuration in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapTest method shouldDelegateClassApplicationStartupToRuntimeDelegate.
/**
* Assert that {@link SeBootstrap#start(Class, Configuration)} will delegate to
* {@link RuntimeDelegate#bootstrap(Class, Configuration)}.
*
* @since 3.1
*/
@Test
public void shouldDelegateClassApplicationStartupToRuntimeDelegate() {
// given
final Application application = mock(Application.class);
final Class<? extends Application> clazz = application.getClass();
final Configuration configuration = mock(Configuration.class);
@SuppressWarnings("unchecked") final CompletionStage<SeBootstrap.Instance> nativeCompletionStage = mock(CompletionStage.class);
given(RuntimeDelegate.getInstance().bootstrap(clazz, configuration)).willReturn(nativeCompletionStage);
// when
final CompletionStage<SeBootstrap.Instance> actualCompletionStage = SeBootstrap.start(clazz, configuration);
// then
assertThat(actualCompletionStage, is(sameInstance(nativeCompletionStage)));
}
use of jakarta.ws.rs.SeBootstrap.Configuration in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapTest method shouldDelegateApplicationStartupToRuntimeDelegate.
/**
* Assert that {@link SeBootstrap#start(Application, Configuration)} will delegate to
* {@link RuntimeDelegate#bootstrap(Application, Configuration)}.
*
* @since 3.1
*/
@Test
public void shouldDelegateApplicationStartupToRuntimeDelegate() {
// given
final Application application = mock(Application.class);
final Configuration configuration = mock(Configuration.class);
@SuppressWarnings("unchecked") final CompletionStage<SeBootstrap.Instance> nativeCompletionStage = mock(CompletionStage.class);
given(RuntimeDelegate.getInstance().bootstrap(application, configuration)).willReturn(nativeCompletionStage);
// when
final CompletionStage<SeBootstrap.Instance> actualCompletionStage = SeBootstrap.start(application, configuration);
// then
assertThat(actualCompletionStage, is(sameInstance(nativeCompletionStage)));
}
use of jakarta.ws.rs.SeBootstrap.Configuration in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapTest method shouldReturnSameUri.
/**
* Assert that calling {@code Configuration.baseUri} returns the correct URI as set
* by the mocked classes.
*
* @since 3.1
*/
@Test
public void shouldReturnSameUri() {
// given
final URI uri = URI.create("http://localhost:8080/foo");
final UriBuilder uriBuilder = mock(UriBuilder.class);
given(uriBuilder.build()).willReturn(uri);
final Configuration configuration = mock(Configuration.class);
given(configuration.baseUri()).willCallRealMethod();
given(configuration.baseUriBuilder()).willReturn(uriBuilder);
final SeBootstrap.Instance instance = mock(SeBootstrap.Instance.class);
given(instance.configuration()).willReturn(configuration);
// when
URI returnedUri = instance.configuration().baseUri();
// then
assertThat(uri, is(returnedUri));
}
use of jakarta.ws.rs.SeBootstrap.Configuration in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapTest method shouldPullCorrespondingPropertiesFromConfiguration.
/**
* Assert that {@code Configuration}'s convenience methods delegate to its generic {@code property(name)} method using
* the <em>right</em> property name.
*
* @since 3.1
*/
@Test
public void shouldPullCorrespondingPropertiesFromConfiguration() {
// given
final String someProtocolValue = mockString();
final String someHostValue = mockString();
final int somePortValue = mockInt();
final String someRootPathValue = mockString();
final SSLContext someSSLContextValue = mock(SSLContext.class);
final SSLClientAuthentication someSSLClientAuthenticationValue = SSLClientAuthentication.MANDATORY;
final SeBootstrap.Configuration configuration = spy(SeBootstrap.Configuration.class);
given(configuration.property(SeBootstrap.Configuration.PROTOCOL)).willReturn(someProtocolValue);
given(configuration.property(SeBootstrap.Configuration.HOST)).willReturn(someHostValue);
given(configuration.property(SeBootstrap.Configuration.PORT)).willReturn(somePortValue);
given(configuration.property(SeBootstrap.Configuration.ROOT_PATH)).willReturn(someRootPathValue);
given(configuration.property(SeBootstrap.Configuration.SSL_CONTEXT)).willReturn(someSSLContextValue);
given(configuration.property(SeBootstrap.Configuration.SSL_CLIENT_AUTHENTICATION)).willReturn(someSSLClientAuthenticationValue);
// when
final String actualProtocolValue = configuration.protocol();
final String actualHostValue = configuration.host();
final int actualPortValue = configuration.port();
final String actualRootPathValue = configuration.rootPath();
final SSLContext actualSSLContextValue = configuration.sslContext();
final SSLClientAuthentication actualSSLClientAuthenticationValue = configuration.sslClientAuthentication();
// then
assertThat(actualProtocolValue, is(sameInstance(someProtocolValue)));
assertThat(actualHostValue, is(sameInstance(someHostValue)));
assertThat(actualPortValue, is(somePortValue));
assertThat(actualRootPathValue, is(sameInstance(someRootPathValue)));
assertThat(actualSSLContextValue, is(sameInstance(someSSLContextValue)));
assertThat(actualSSLClientAuthenticationValue, is(sameInstance(someSSLClientAuthenticationValue)));
}
Aggregations