Search in sources :

Example 1 with Globals

use of se.jbee.inject.config.Globals in project silk by jbee.

the class TestExample1Binds method constructorArgumentsCanBePassedToBootstrappingUsingPresets.

@Test
public void constructorArgumentsCanBePassedToBootstrappingUsingPresets() {
    Properties props = new Properties();
    props.put("x", "abc");
    props.put("y", 12);
    Presets presets = Presets.EMPTY.preset(Properties.class, props);
    Globals globals = Globals.STANDARD.presets(presets);
    Injector injector = Bootstrap.injector(Example1Module1.class, globals);
    MyClass obj = injector.resolve(Dependency.dependency(MyClass.class));
    assertEquals(12, obj.twelve);
    assertEquals("abc", obj.abc);
}
Also used : Globals(se.jbee.inject.config.Globals) Presets(se.jbee.inject.config.Presets) Injector(se.jbee.inject.Injector) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with Globals

use of se.jbee.inject.config.Globals in project silk by jbee.

the class TestMultipleOptionChoicesBinds method thatMultipleOptionChoicesArePossible.

@Test
public void thatMultipleOptionChoicesArePossible() {
    Options options = Options.STANDARD.chosen(Choices.A, Choices.D);
    Globals globals = Globals.STANDARD.options(options);
    Injector injector = Bootstrap.injector(RootBundle.class, globals);
    assertEqualSets(new String[] { "A", "D" }, injector.resolve(dependency(String[].class)));
}
Also used : Globals(se.jbee.inject.config.Globals) Options(se.jbee.inject.config.Options) Injector(se.jbee.inject.Injector) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Injector (se.jbee.inject.Injector)2 Globals (se.jbee.inject.config.Globals)2 Properties (java.util.Properties)1 Options (se.jbee.inject.config.Options)1 Presets (se.jbee.inject.config.Presets)1