use of jakarta.ws.rs.core.Application in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapIT method shouldBootInstanceUsingProperties.
/**
* Verifies that an instance will boot using explicit configuration given by
* properties.
*
* @throws ExecutionException if the instance didn't boot correctly
* @throws InterruptedException if the test took much longer than usually
* expected
* @throws IOException if no IP port was free
*/
@Test
public final void shouldBootInstanceUsingProperties() throws InterruptedException, ExecutionException, IOException {
// given
final int expectedResponse = mockInt();
final Application application = new StaticApplication(expectedResponse);
final SeBootstrap.Configuration.Builder bootstrapConfigurationBuilder = SeBootstrap.Configuration.builder();
final SeBootstrap.Configuration requestedConfiguration = bootstrapConfigurationBuilder.property(SeBootstrap.Configuration.PROTOCOL, "HTTP").property(SeBootstrap.Configuration.HOST, "localhost").property(SeBootstrap.Configuration.PORT, someFreeIpPort()).property(SeBootstrap.Configuration.ROOT_PATH, "/root/path").build();
// when
final CompletionStage<SeBootstrap.Instance> completionStage = SeBootstrap.start(application, requestedConfiguration);
final SeBootstrap.Instance instance = completionStage.toCompletableFuture().get();
final SeBootstrap.Configuration actualConfiguration = instance.configuration();
final int actualResponse = client.target(UriBuilder.newInstance().scheme(actualConfiguration.protocol()).host(actualConfiguration.host()).port(actualConfiguration.port()).path(actualConfiguration.rootPath()).path("application/resource")).request().get(int.class);
// then
assertThat(actualResponse, is(expectedResponse));
assertThat(actualConfiguration.protocol(), is(requestedConfiguration.protocol()));
assertThat(actualConfiguration.host(), is(requestedConfiguration.host()));
assertThat(actualConfiguration.port(), is(requestedConfiguration.port()));
assertThat(actualConfiguration.rootPath(), is(requestedConfiguration.rootPath()));
instance.stop().toCompletableFuture().get();
}
use of jakarta.ws.rs.core.Application in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapIT method shouldBootInstanceUsingConvenienceMethods.
/**
* Verifies that an instance will boot using explicit configuration given by
* convenience methods.
*
* @throws ExecutionException if the instance didn't boot correctly
* @throws InterruptedException if the test took much longer than usually
* expected
* @throws IOException if no IP port was free
*/
@Test
public final void shouldBootInstanceUsingConvenienceMethods() throws InterruptedException, ExecutionException, IOException {
// given
final int expectedResponse = mockInt();
final Application application = new StaticApplication(expectedResponse);
final SeBootstrap.Configuration.Builder bootstrapConfigurationBuilder = SeBootstrap.Configuration.builder();
final SeBootstrap.Configuration requestedConfiguration = bootstrapConfigurationBuilder.protocol("HTTP").host("localhost").port(someFreeIpPort()).rootPath("/root/path").build();
// when
final CompletionStage<SeBootstrap.Instance> completionStage = SeBootstrap.start(application, requestedConfiguration);
final SeBootstrap.Instance instance = completionStage.toCompletableFuture().get();
final SeBootstrap.Configuration actualConfiguration = instance.configuration();
final int actualResponse = client.target(UriBuilder.newInstance().scheme(actualConfiguration.protocol()).host(actualConfiguration.host()).port(actualConfiguration.port()).path(actualConfiguration.rootPath()).path("application/resource")).request().get(int.class);
// then
assertThat(actualResponse, is(expectedResponse));
assertThat(actualConfiguration.protocol(), is(requestedConfiguration.protocol()));
assertThat(actualConfiguration.host(), is(requestedConfiguration.host()));
assertThat(actualConfiguration.port(), is(requestedConfiguration.port()));
assertThat(actualConfiguration.rootPath(), is(requestedConfiguration.rootPath()));
instance.stop().toCompletableFuture().get();
}
use of jakarta.ws.rs.core.Application in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method defaultGetPropertiesIsEmptyTest.
/*
* @testName: defaultGetPropertiesIsEmptyTest
*
* @assertion_ids: JAXRS:JAVADOC:1035;
*
* @test_Strategy: The default implementation returns an empty set.
*/
@Test
public void defaultGetPropertiesIsEmptyTest() throws Fault {
Application application = new Application();
Map<String, Object> properties = application.getProperties();
assertNotNull(properties, "Default implementation is not empty map, but null");
assertTrue(properties.isEmpty(), "Default implementation is not empty, but" + JaxrsUtil.mapToString(properties));
logMsg("Default implementation gets empty map as expected");
}
Aggregations