use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isNotValidWhenNoQ2TServersAreDefined.
@Test
public void isNotValidWhenNoQ2TServersAreDefined() {
List<ServerConfig> serverConfigList = serverConfigList().stream().filter(s -> s.getApp() != AppType.Q2T).collect(Collectors.toList());
Config config = new Config();
config.setServerConfigs(serverConfigList);
assertThat(validator.isValid(config, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("At least one Q2T server must be configured or bootstrap mode enabled."));
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isNotValidWhenQ2TServersAreDefinedOnBootstrapNode.
@Test
public void isNotValidWhenQ2TServersAreDefinedOnBootstrapNode() {
List<ServerConfig> serverConfigList = serverConfigList();
Config config = new Config();
config.setBootstrapNode(true);
config.setServerConfigs(serverConfigList);
assertThat(validator.isValid(config, cvc)).isFalse();
verify(cvc).disableDefaultConstraintViolation();
verify(cvc).buildConstraintViolationWithTemplate(eq("Q2T server cannot be specified on a bootstrap node."));
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class ServerConfigsValidatorTest method isValidWhenValidDataIsSupplied.
@Test
public void isValidWhenValidDataIsSupplied() {
List<ServerConfig> serverConfigList = serverConfigList();
Config config = new Config();
config.setServerConfigs(serverConfigList);
assertThat(validator.isValid(config, cvc)).isTrue();
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class JerseyServerFactory method createServer.
@Override
public TesseraServer createServer(ServerConfig serverConfig, Set<Object> services) {
LOGGER.debug("Creating JAXRS application with {} services: {}", serverConfig, services.stream().map(Object::toString).collect(Collectors.joining(",")));
Application application = services.stream().filter(TesseraApp.class::isInstance).filter(Application.class::isInstance).map(TesseraApp.class::cast).filter(a -> a.getAppType().equals(serverConfig.getApp())).map(Application.class::cast).findFirst().get();
LOGGER.debug("Created JAXRS application {}", application);
return new JerseyServer(serverConfig, application.getClass());
}
use of com.quorum.tessera.config.ServerConfig in project tessera by ConsenSys.
the class VersionHeaderDecoratorTest method onSetUp.
@Before
public void onSetUp() throws Exception {
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
ServerConfig serverConfig = new ServerConfig();
serverConfig.setCommunicationType(CommunicationType.REST);
serverConfig.setServerAddress("http://localhost:8080");
final ResourceConfig config = new ResourceConfig(SomeResource.class);
this.server = ServerUtils.buildWebServer(serverConfig);
ServletContextHandler context = new ServletContextHandler(server, "/");
ServletContainer servletContainer = new ServletContainer(config);
ServletHolder jerseyServlet = new ServletHolder(servletContainer);
context.addServlet(jerseyServlet, "/*");
// Sample Usage
context.addFilter(VersionHeaderDecorator.class, "/*", EnumSet.allOf(DispatcherType.class));
server.start();
}
Aggregations