use of org.apache.sling.caconfig.example.SimpleConfig in project sling by apache.
the class ConfigurationResolverAnnotationClassTest method testNonExistingConfig_Simple.
@Test
public void testNonExistingConfig_Simple() {
SimpleConfig cfg = underTest.get(site1Page1).as(SimpleConfig.class);
assertNull(cfg.stringParam());
assertEquals(5, cfg.intParam());
assertEquals(false, cfg.boolParam());
}
use of org.apache.sling.caconfig.example.SimpleConfig in project sling by apache.
the class ConfigurationResolverAnnotationClassTest method testConfig_Simple.
@Test
public void testConfig_Simple() {
context.build().resource("/conf/content/site1/sling:configs/org.apache.sling.caconfig.example.SimpleConfig", "stringParam", "configValue1", "intParam", 111, "boolParam", true);
SimpleConfig cfg = underTest.get(site1Page1).as(SimpleConfig.class);
assertEquals("configValue1", cfg.stringParam());
assertEquals(111, cfg.intParam());
assertEquals(true, cfg.boolParam());
}
use of org.apache.sling.caconfig.example.SimpleConfig in project sling by apache.
the class ConfigurationResolverAnnotationClassTest method testNonExistingContentResource_Simple.
@Test
public void testNonExistingContentResource_Simple() {
SimpleConfig cfg = underTest.get(null).as(SimpleConfig.class);
assertNull(cfg.stringParam());
assertEquals(5, cfg.intParam());
assertEquals(false, cfg.boolParam());
}
use of org.apache.sling.caconfig.example.SimpleConfig in project sling by apache.
the class ConfigurationResolverAnnotationClassTest method testConfig_Nested.
@Test
public void testConfig_Nested() {
context.build().resource("/conf/content/site1/sling:configs/org.apache.sling.caconfig.example.NestedConfig", "stringParam", "configValue3").siblingsMode().resource("subConfig", "stringParam", "configValue4", "intParam", 444, "boolParam", true).hierarchyMode().resource("subListConfig").siblingsMode().resource("1", "stringParam", "configValue2.1").resource("2", "stringParam", "configValue2.2").resource("3", "stringParam", "configValue2.3");
NestedConfig cfg = underTest.get(site1Page1).as(NestedConfig.class);
assertEquals("configValue3", cfg.stringParam());
SimpleConfig subConfig = cfg.subConfig();
assertEquals("configValue4", subConfig.stringParam());
assertEquals(444, subConfig.intParam());
assertEquals(true, subConfig.boolParam());
ListConfig[] listConfig = cfg.subListConfig();
assertEquals(3, listConfig.length);
assertEquals("configValue2.1", listConfig[0].stringParam());
assertEquals("configValue2.2", listConfig[1].stringParam());
assertEquals("configValue2.3", listConfig[2].stringParam());
}
use of org.apache.sling.caconfig.example.SimpleConfig in project sling by apache.
the class ConfigurationResolverAnnotationClassTest method testConfig_Nested_PropertyInheritance.
@Test
public void testConfig_Nested_PropertyInheritance() {
context.build().resource("/conf/global/sling:configs/org.apache.sling.caconfig.example.NestedConfig").resource("subConfig", "stringParam", "configValue1", "intParam", 111, "boolParam", true).resource("/conf/content/site1/sling:configs/org.apache.sling.caconfig.example.NestedConfig", "stringParam", "configValue3").resource("subConfig", "stringParam", "configValue4", PROPERTY_CONFIG_PROPERTY_INHERIT, true);
NestedConfig cfg = underTest.get(site1Page1).as(NestedConfig.class);
assertEquals("configValue3", cfg.stringParam());
SimpleConfig subConfig = cfg.subConfig();
assertEquals("configValue4", subConfig.stringParam());
assertEquals(111, subConfig.intParam());
assertEquals(true, subConfig.boolParam());
}
Aggregations