use of org.apache.sling.caconfig.ConfigurationResolver in project sling by apache.
the class ConfigurationResolverValueMapIT method testNonExistingConfig.
@Test
public void testNonExistingConfig() throws Exception {
Resource resourcePage1 = resourceBuilder.resource(PAGE_PATH).getCurrentParent();
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
ValueMap props = configResolver.get(resourcePage1).name("test").asValueMap();
assertNotNull(props);
assertNull(props.get("stringParam", String.class));
assertEquals(0, (int) props.get("intParam", 0));
assertEquals(false, props.get("boolParam", false));
}
use of org.apache.sling.caconfig.ConfigurationResolver in project sling by apache.
the class ConfigurationResolverConfigClassIT method testExistingConfig.
@Test
public void testExistingConfig() throws Exception {
resourceBuilder.resource(CONFIG_PATH + "/sling:configs/test", "stringParam", "value1", "intParam", 123, "boolParam", true).resource(PAGE_PATH, "sling:configRef", CONFIG_PATH);
Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
SimpleConfig config = configResolver.get(resourcePage1).name("test").as(SimpleConfig.class);
assertNotNull(config);
assertEquals("value1", config.stringParam());
assertEquals("defValue", config.stringParamDefault());
assertEquals(123, (int) config.intParam());
assertEquals(true, config.boolParam());
}
use of org.apache.sling.caconfig.ConfigurationResolver in project sling by apache.
the class ConfigurationResolverConfigClassIT method testNonExistingConfig.
@Test
public void testNonExistingConfig() throws Exception {
Resource resourcePage1 = resourceBuilder.resource(PAGE_PATH).getCurrentParent();
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
SimpleConfig config = configResolver.get(resourcePage1).name("test").as(SimpleConfig.class);
assertNotNull(config);
assertNull(config.stringParam());
assertEquals("defValue", config.stringParamDefault());
assertEquals(0, config.intParam());
assertEquals(false, config.boolParam());
}
use of org.apache.sling.caconfig.ConfigurationResolver in project sling by apache.
the class ConfigurationResolverValueMapIT method testExistingConfig.
@Test
public void testExistingConfig() throws Exception {
resourceBuilder.resource(CONFIG_PATH + "/sling:configs/test", "stringParam", "value1", "intParam", 123, "boolParam", true).resource(PAGE_PATH, "sling:configRef", CONFIG_PATH);
Resource resourcePage1 = resourceResolver.getResource(PAGE_PATH);
ConfigurationResolver configResolver = teleporter.getService(ConfigurationResolver.class);
ValueMap props = configResolver.get(resourcePage1).name("test").asValueMap();
assertNotNull(props);
assertEquals("value1", props.get("stringParam", String.class));
assertEquals(123, (int) props.get("intParam", 0));
assertEquals(true, props.get("boolParam", false));
}
Aggregations