use of com.google.inject.Injector in project druid by druid-io.
the class MapLookupExtractionFnSerDeTest method setup.
@BeforeClass
public static void setup() throws JsonProcessingException {
Injector defaultInjector = GuiceInjectors.makeStartupInjector();
mapper = defaultInjector.getInstance(Key.get(ObjectMapper.class, Json.class));
}
use of com.google.inject.Injector in project che by eclipse.
the class CheBootstrap method contextDestroyed.
@Override
public void contextDestroyed(ServletContextEvent sce) {
final ServletContext ctx = sce.getServletContext();
final Injector injector = getInjector(ctx);
if (injector != null) {
injector.getInstance(Destroyer.class).destroy();
}
super.contextDestroyed(sce);
}
use of com.google.inject.Injector in project che by eclipse.
the class CheBootstrapTest method readsConfigurationPropertiesFromSystemProperties.
@Test
public void readsConfigurationPropertiesFromSystemProperties() throws Exception {
setSystemProperties(createTestProperties());
ModuleScanner.modules.add(binder -> binder.bind(TestSystemPropertiesComponent.class));
cheBootstrap.contextInitialized(new ServletContextEvent(servletContext));
Injector injector = retrieveComponentFromServletContext(Injector.class);
TestSystemPropertiesComponent testComponent = injector.getInstance(TestSystemPropertiesComponent.class);
assertEquals(testComponent.parameter_pair, Pair.of("a", "b"));
assertEquals(testComponent.parameter_pair2, Pair.of("a", (String) null));
assertEquals(testComponent.parameter_pair3, Pair.of("a", ""));
assertEquals(testComponent.parameter_pair_array, new Pair[] { Pair.of("a", "b"), Pair.of("c", "d") });
assertEquals(testComponent.nullable, null);
assertEquals(testComponent.parameter_uri, new URI("file:/a/b/c"));
assertEquals(testComponent.parameter_url, new URL("http://localhost"));
assertEquals(testComponent.parameter_file, new File("/a/b/c"));
assertEquals(testComponent.parameter_strings, new String[] { "a", "b", "c" });
assertEquals(testComponent.parameter_int, 123);
assertEquals(testComponent.parameter_long, 123);
assertEquals(testComponent.parameter_bool, true);
assertEquals(testComponent.someDir, new File(System.getProperty("java.io.tmpdir"), "/some_dir"));
assertEquals(testComponent.suffixedPath, System.getenv("PATH") + pathSeparator + "some_path");
}
use of com.google.inject.Injector in project che by eclipse.
the class CheBootstrapTest method environment_variables_prefixed_with_che_underscore_override_che_dot_prefixed_system_and_user_specified_and_che_properties.
@Test
public void environment_variables_prefixed_with_che_underscore_override_che_dot_prefixed_system_and_user_specified_and_che_properties() throws Exception {
Properties cheProperties = new Properties();
cheProperties.put("che.some.other.name", "che_value");
cheProperties.put("che.some.name", "NULL");
writePropertiesFile(che, "che.properties", cheProperties);
Properties userProperties = new Properties();
userProperties.put("che.some.other.name", "user_value");
writePropertiesFile(userCongDir, "user.properties", userProperties);
systemPropertiesHelper.property("che.some.other.name", "che_dot_system_property_value");
ModuleScanner.modules.add(binder -> binder.bind(TestConfOverrideComponent.class));
cheBootstrap.contextInitialized(new ServletContextEvent(servletContext));
Injector injector = retrieveComponentFromServletContext(Injector.class);
TestConfOverrideComponent testComponent = injector.getInstance(TestConfOverrideComponent.class);
assertEquals(testComponent.otherString, System.getenv("CHE_SOME_OTHER_NAME"));
}
use of com.google.inject.Injector in project che by eclipse.
the class CheBootstrapTest method propertiesFromUserSpecifiedLocationOverrideCheProperties.
@Test
public void propertiesFromUserSpecifiedLocationOverrideCheProperties() throws Exception {
systemPropertiesHelper.property(CHE_LOCAL_CONF_DIR, userCongDir.getAbsolutePath());
Properties cheProperties = new Properties();
cheProperties.put("che.some.name", "che_value");
writePropertiesFile(che, "che.properties", cheProperties);
Properties userProperties = new Properties();
userProperties.put("che.some.name", "user_value");
writePropertiesFile(userCongDir, "user.properties", userProperties);
ModuleScanner.modules.add(binder -> binder.bind(TestConfOverrideComponent.class));
cheBootstrap.contextInitialized(new ServletContextEvent(servletContext));
Injector injector = retrieveComponentFromServletContext(Injector.class);
TestConfOverrideComponent testComponent = injector.getInstance(TestConfOverrideComponent.class);
assertEquals(testComponent.string, "user_value");
}
Aggregations