}
}
public void testRemove()
{
VariableStore store = new VariableStore();
store.startOutlet();
QualifiedName qualifiedName
= new QualifiedName("org.apache.torque.name");
// fill store
store.set(new Variable(
qualifiedName,
"org.apache.torque.GENERATOR",
Variable.Scope.OUTLET));
store.set(new Variable(
qualifiedName,
"org.apache.torque.CHILDREN",
Variable.Scope.CHILDREN));
store.set(new Variable(
qualifiedName,
"org.apache.torque.FILE",
Variable.Scope.FILE));
store.set(new Variable(
qualifiedName,
"org.apache.torque.GLOBAL",
Variable.Scope.GLOBAL));
assertEquals(
"org.apache.torque.GENERATOR",
store.getInHierarchy(qualifiedName).getValue());
store.remove(store.getInHierarchy(qualifiedName));
assertEquals(
"org.apache.torque.CHILDREN",
store.getInHierarchy(qualifiedName).getValue());
store.remove(store.getInHierarchy(qualifiedName));
assertEquals(
"org.apache.torque.FILE",
store.getInHierarchy(qualifiedName).getValue());
store.remove(store.getInHierarchy(qualifiedName));
assertEquals(
"org.apache.torque.GLOBAL",
store.getInHierarchy(qualifiedName).getValue());
store.remove(store.getInHierarchy(qualifiedName));
assertNull(store.getInHierarchy(qualifiedName));
// test whether we can remove hidden variables
Variable childrenVariable = new Variable(
qualifiedName,
"org.apache.torque.CHILDREN",
Variable.Scope.CHILDREN);
store.set(new Variable(
qualifiedName,
"org.apache.torque.GENERATOR",
Variable.Scope.OUTLET));
store.set(childrenVariable);
store.set(new Variable(
qualifiedName,
"org.apache.torque.FILE",
Variable.Scope.FILE));
assertEquals(
"org.apache.torque.GENERATOR",
store.getInHierarchy(qualifiedName).getValue());
store.remove(childrenVariable);
assertEquals(
"org.apache.torque.GENERATOR",
store.getInHierarchy(qualifiedName).getValue());
store.remove(store.getInHierarchy(qualifiedName));
assertEquals(
"org.apache.torque.FILE",
store.getInHierarchy(qualifiedName).getValue());
}