use of com.peterphi.std.guice.common.serviceprops.ServicePropertiesModule in project stdlib by petergeneric.
the class CoreGuiceRole method register.
@Override
public void register(final Stage stage, final ClassScannerFactory scanner, final GuiceConfig config, final GuiceSetup setup, final List<Module> modules, final AtomicReference<Injector> injectorRef, final MetricRegistry metrics) {
modules.add(new ServicePropertiesModule(config));
modules.add(new ConfigurationPropertyRegistryModule(config, injectorRef));
modules.add(new GuiceLifecycleModule());
modules.add(new CoreMetricsModule(metrics));
modules.add(new CacheModule(metrics));
modules.add(new RetryModule(metrics));
modules.add(new JAXBModule(config));
modules.add(new Log4JModule(config, metrics));
}
use of com.peterphi.std.guice.common.serviceprops.ServicePropertiesModule in project stdlib by petergeneric.
the class TimeoutConverterTest method test.
@Test
public void test() {
PropertyFile props = new PropertyFile();
props.set("timeout1msNoUnit", "1");
props.set("timeout1ms", "1ms");
props.set("timeout1s", "1s");
props.set("timeout1h", "1h");
props.set("timeout60m", "60m");
props.set("timeout50h", "50h");
final Injector injector = Guice.createInjector(new ServicePropertiesModule(props));
injector.injectMembers(this);
// extract values
assertEquals(new Timeout(1, TimeUnit.MILLISECONDS), timeout1msNoUnit);
assertEquals(new Timeout(1, TimeUnit.MILLISECONDS), timeout1ms);
assertEquals(new Timeout(1, TimeUnit.SECONDS), timeout1s);
assertEquals(new Timeout(60, TimeUnit.MINUTES), timeout60m);
assertEquals(new Timeout(1, TimeUnit.HOURS), timeout1h);
// compare against one another
assertEquals(timeout60m, timeout1h);
assertEquals(timeout1msNoUnit, timeout1ms);
assertFalse(timeout50h.equals(timeout1h));
}
Aggregations