Search in sources :

Example 1 with PortMapping

use of org.eclipse.dataspaceconnector.extension.jetty.PortMapping in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ContractDefinitionsApiControllerIntegrationTest method prepareWebserver.

@BeforeAll
static void prepareWebserver() {
    port = TestUtils.getFreePort();
    var monitor = mock(Monitor.class);
    var config = new JettyConfiguration(null, null);
    config.portMapping(new PortMapping("data", port, "/api/v1/data"));
    var jetty = new JettyService(config, monitor);
    var ctrl = new ContractDefinitionApiController(monitor);
    var jerseyService = new JerseyRestService(jetty, new TypeManager(), mock(CorsFilterConfiguration.class), monitor);
    jetty.start();
    jerseyService.registerResource("data", ctrl);
    jerseyService.start();
}
Also used : JerseyRestService(org.eclipse.dataspaceconnector.extension.jersey.JerseyRestService) JettyConfiguration(org.eclipse.dataspaceconnector.extension.jetty.JettyConfiguration) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) PortMapping(org.eclipse.dataspaceconnector.extension.jetty.PortMapping) CorsFilterConfiguration(org.eclipse.dataspaceconnector.extension.jersey.CorsFilterConfiguration) JettyService(org.eclipse.dataspaceconnector.extension.jetty.JettyService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with PortMapping

use of org.eclipse.dataspaceconnector.extension.jetty.PortMapping in project DataSpaceConnector by eclipse-dataspaceconnector.

the class PolicyApiControllerIntegrationTest method prepareWebserver.

@BeforeAll
static void prepareWebserver() {
    port = TestUtils.getFreePort();
    var monitor = mock(Monitor.class);
    var config = new JettyConfiguration(null, null);
    config.portMapping(new PortMapping("data", port, "/api/v1/data"));
    var jetty = new JettyService(config, monitor);
    var ctrl = new PolicyApiController(monitor);
    var jerseyService = new JerseyRestService(jetty, new TypeManager(), mock(CorsFilterConfiguration.class), monitor);
    jetty.start();
    jerseyService.registerResource("data", ctrl);
    jerseyService.start();
}
Also used : JerseyRestService(org.eclipse.dataspaceconnector.extension.jersey.JerseyRestService) JettyConfiguration(org.eclipse.dataspaceconnector.extension.jetty.JettyConfiguration) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) PortMapping(org.eclipse.dataspaceconnector.extension.jetty.PortMapping) CorsFilterConfiguration(org.eclipse.dataspaceconnector.extension.jersey.CorsFilterConfiguration) JettyService(org.eclipse.dataspaceconnector.extension.jetty.JettyService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with PortMapping

use of org.eclipse.dataspaceconnector.extension.jetty.PortMapping in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ContractAgreementApiControllerIntegrationTest method prepareWebserver.

@BeforeAll
static void prepareWebserver() {
    port = TestUtils.getFreePort();
    var monitor = mock(Monitor.class);
    var config = new JettyConfiguration(null, null);
    config.portMapping(new PortMapping("data", port, "/api/v1/data"));
    var jetty = new JettyService(config, monitor);
    var ctrl = new ContractAgreementApiController(monitor);
    var jerseyService = new JerseyRestService(jetty, new TypeManager(), mock(CorsFilterConfiguration.class), monitor);
    jetty.start();
    jerseyService.registerResource("data", ctrl);
    jerseyService.start();
}
Also used : JerseyRestService(org.eclipse.dataspaceconnector.extension.jersey.JerseyRestService) JettyConfiguration(org.eclipse.dataspaceconnector.extension.jetty.JettyConfiguration) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) PortMapping(org.eclipse.dataspaceconnector.extension.jetty.PortMapping) CorsFilterConfiguration(org.eclipse.dataspaceconnector.extension.jersey.CorsFilterConfiguration) JettyService(org.eclipse.dataspaceconnector.extension.jetty.JettyService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with PortMapping

use of org.eclipse.dataspaceconnector.extension.jetty.PortMapping in project DataSpaceConnector by eclipse-dataspaceconnector.

the class ContractNegotiationApiControllerIntegrationTest method prepareWebserver.

@BeforeAll
static void prepareWebserver() {
    port = TestUtils.getFreePort();
    var monitor = mock(Monitor.class);
    var config = new JettyConfiguration(null, null);
    config.portMapping(new PortMapping("data", port, "/api/v1/data"));
    var jetty = new JettyService(config, monitor);
    var controller = new ContractNegotiationController(monitor);
    var jerseyService = new JerseyRestService(jetty, new TypeManager(), mock(CorsFilterConfiguration.class), monitor);
    jetty.start();
    jerseyService.registerResource("data", controller);
    jerseyService.start();
}
Also used : JerseyRestService(org.eclipse.dataspaceconnector.extension.jersey.JerseyRestService) JettyConfiguration(org.eclipse.dataspaceconnector.extension.jetty.JettyConfiguration) TypeManager(org.eclipse.dataspaceconnector.spi.types.TypeManager) PortMapping(org.eclipse.dataspaceconnector.extension.jetty.PortMapping) CorsFilterConfiguration(org.eclipse.dataspaceconnector.extension.jersey.CorsFilterConfiguration) JettyService(org.eclipse.dataspaceconnector.extension.jetty.JettyService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with PortMapping

use of org.eclipse.dataspaceconnector.extension.jetty.PortMapping in project DataSpaceConnector by eclipse-dataspaceconnector.

the class JerseyRestServiceTest method verifyIdenticalContextPats_throwsException.

@Test
@DisplayName("Verifies that registering two port mappings under the same path throws an exception")
void verifyIdenticalContextPats_throwsException() {
    var port1 = getFreePort();
    var port2 = getFreePort();
    startJetty(new PortMapping("path1", port1, "/path"), new PortMapping("path2", port2, "/path"));
    jerseyRestService.registerResource("path1", new TestController());
    jerseyRestService.registerResource("path2", new TestController());
    assertThatThrownBy(() -> jerseyRestService.start()).isInstanceOf(EdcException.class).hasRootCauseInstanceOf(IllegalStateException.class);
}
Also used : PortMapping(org.eclipse.dataspaceconnector.extension.jetty.PortMapping) EdcException(org.eclipse.dataspaceconnector.spi.EdcException) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

PortMapping (org.eclipse.dataspaceconnector.extension.jetty.PortMapping)14 JettyConfiguration (org.eclipse.dataspaceconnector.extension.jetty.JettyConfiguration)8 BeforeAll (org.junit.jupiter.api.BeforeAll)8 TypeManager (org.eclipse.dataspaceconnector.spi.types.TypeManager)7 CorsFilterConfiguration (org.eclipse.dataspaceconnector.extension.jersey.CorsFilterConfiguration)6 JerseyRestService (org.eclipse.dataspaceconnector.extension.jersey.JerseyRestService)6 JettyService (org.eclipse.dataspaceconnector.extension.jetty.JettyService)6 DisplayName (org.junit.jupiter.api.DisplayName)6 Test (org.junit.jupiter.api.Test)6 EdcException (org.eclipse.dataspaceconnector.spi.EdcException)3 ContainerRequestContext (jakarta.ws.rs.container.ContainerRequestContext)2 ConsoleMonitor (org.eclipse.dataspaceconnector.spi.monitor.ConsoleMonitor)1 Monitor (org.eclipse.dataspaceconnector.spi.monitor.Monitor)1