import org.lilyproject.runtime.conf.ConfImpl;
import org.lilyproject.runtime.conf.XmlConfBuilder;
public class InheritanceTest extends TestCase {
public void testInheritance1() throws Exception {
ConfImpl parent = loadConf("inherit1_parent.xml");
// Child 1
{
ConfImpl child = loadConf("inherit1_child1.xml");
child.inherit(parent);
JXPathContext context = JXPathContext.newContext(child);
assertEquals(1, context.getValue("count(properties)", Integer.class));
assertEquals(3, context.getValue("count(properties/property)", Integer.class));
assertEquals("value1", context.getValue("properties/property[@key='key1']"));
assertEquals("value2 - altered", context.getValue("properties/property[@key='key2']"));
assertEquals("value3", context.getValue("properties/property[@key='key3']"));
}
// Child 2
{
ConfImpl child = loadConf("inherit1_child2.xml");
child.inherit(parent);
JXPathContext context = JXPathContext.newContext(child);
assertEquals(1, context.getValue("count(properties)", Integer.class));
assertEquals(4, context.getValue("count(properties/property)", Integer.class));
assertEquals("value1", context.getValue("properties/property[@key='key1']"));
assertEquals("value2 - altered", context.getValue("properties/property[@key='key2'][1]"));
assertEquals("value2", context.getValue("properties/property[@key='key2'][2]"));
assertEquals("value3", context.getValue("properties/property[@key='key3']"));
}
// Child 3
{
ConfImpl child = loadConf("inherit1_child3.xml");
child.inherit(parent);
JXPathContext context = JXPathContext.newContext(child);
assertEquals(1, context.getValue("count(properties)", Integer.class));
assertEquals(1, context.getValue("count(properties/property)", Integer.class));
assertEquals("value3", context.getValue("properties/property[@key='key3']"));
}
// Child 4
{
ConfImpl child = loadConf("inherit1_child4.xml");
child.inherit(parent);
JXPathContext context = JXPathContext.newContext(child);
assertEquals(0, context.getValue("count(*)", Integer.class));
}
}