use of io.dropwizard.setup.Bootstrap in project keywhiz by square.
the class KeywhizTestRunner method createInjector.
static Injector createInjector() {
KeywhizService service = new KeywhizService();
Bootstrap<KeywhizConfig> bootstrap = new Bootstrap<>(service);
service.initialize(bootstrap);
File yamlFile = new File(Resources.getResource("keywhiz-test.yaml").getFile());
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
ObjectMapper objectMapper = bootstrap.getObjectMapper().copy();
KeywhizConfig config;
try {
config = new ConfigurationFactory<>(KeywhizConfig.class, validator, objectMapper, "dw").build(yamlFile);
} catch (IOException | ConfigurationException e) {
throw Throwables.propagate(e);
}
Environment environment = new Environment(service.getName(), objectMapper, validator, bootstrap.getMetricRegistry(), bootstrap.getClassLoader());
Injector injector = Guice.createInjector(new ServiceModule(config, environment));
service.setInjector(injector);
return injector;
}
use of io.dropwizard.setup.Bootstrap in project dropwizard by dropwizard.
the class CommandTest method setUp.
@BeforeEach
void setUp() {
final JarLocation location = mock(JarLocation.class);
final Bootstrap<Configuration> bootstrap = new Bootstrap<>(app);
when(location.toString()).thenReturn("dw-thing.jar");
when(location.getVersion()).thenReturn(Optional.of("1.0.0"));
bootstrap.addCommand(command);
cli = new Cli(location, bootstrap, stdOut, stdErr);
}
use of io.dropwizard.setup.Bootstrap in project keywhiz by square.
the class EnvironmentsTest method createsEnvironmentFromBootstrap.
@Test
public void createsEnvironmentFromBootstrap() {
KeywhizService keywhiz = new KeywhizService();
Bootstrap<KeywhizConfig> bootstrap = new Bootstrap<>(keywhiz);
Environment environment = Environments.fromBootstrap(bootstrap);
assertEquals(keywhiz.getName(), environment.getName());
assertNotSame(bootstrap.getObjectMapper(), environment.getObjectMapper());
assertNotNull(environment.getValidator());
assertSame(bootstrap.getMetricRegistry(), environment.metrics());
assertSame(bootstrap.getClassLoader(), environment.getAdminContext().getClassLoader());
}
Aggregations