Search in sources :

Example 1 with ParamsScope

use of jodd.madvoc.scope.ParamsScope in project jodd by oblac.

the class MadvocParamsInjectorTest method testInjection.

@Test
void testInjection() {
    WebApp webapp = new WebApp();
    webapp.start();
    PetiteContainer madpc = webapp.madvocContainer().getPetiteContainer();
    String baseName = StringUtil.uncapitalize(FooBean.class.getSimpleName());
    madpc.defineParameter("foo", "1");
    madpc.defineParameter(baseName + ".integer", "173");
    madpc.defineParameter(baseName + ".string", "jodd");
    madpc.defineParameter(baseName, "huh");
    ParamsScope paramsScope = new ParamsScope();
    BeanUtil.declared.setProperty(paramsScope, "madpc", madpc);
    FooBean fooBean = new FooBean();
    paramsScope.inject(new Targets(fooBean, null));
    assertEquals(173, fooBean.getInteger().intValue());
    assertEquals("jodd", fooBean.getString());
}
Also used : ParamsScope(jodd.madvoc.scope.ParamsScope) Targets(jodd.madvoc.config.Targets) PetiteContainer(jodd.petite.PetiteContainer) WebApp(jodd.madvoc.WebApp) Test(org.junit.jupiter.api.Test)

Aggregations

WebApp (jodd.madvoc.WebApp)1 Targets (jodd.madvoc.config.Targets)1 ParamsScope (jodd.madvoc.scope.ParamsScope)1 PetiteContainer (jodd.petite.PetiteContainer)1 Test (org.junit.jupiter.api.Test)1