public void testPreconfiguredScope() throws Throwable
{
TestControllerContext test = new TestControllerContext("test");
ScopeInfo scopeInfo = test.getScopeInfo();
// Preconfigure the mutable scope
ScopeKey mutable = scopeInfo.getMutableScope();
MemoryMetaDataLoader loader = new MemoryMetaDataLoader(mutable);
loader.addMetaData("Preconfigured", "testPreconfigured", String.class);
repository.addMetaDataRetrieval(loader);
// Setup the full scope
ScopeKey scopeKey = scopeInfo.getScope();
List<MetaDataRetrieval> retrievals = new ArrayList<MetaDataRetrieval>();
for (Scope scope : scopeKey.getScopes())
{
ScopeKey thisScope = new ScopeKey(scope);
MetaDataRetrieval retrieval = repository.getMetaDataRetrieval(thisScope);
if (retrieval == null)
retrieval = new MemoryMetaDataLoader(thisScope);
retrievals.add(0, retrieval);
}
MetaDataContext metaDataContext = new AbstractMetaDataContext(null, retrievals);
repository.addMetaDataRetrieval(metaDataContext);
try
{
controller.install(test);
MetaData metaData = scopeInfo.getMetaData();
assertNotNull(metaData);
assertEquals("testPreconfigured", metaData.getMetaData("Preconfigured"));
assertEquals("testFromInstall", metaData.getMetaData("FromInstall"));
}