assertFalse("nsCmp is not in cache", isInDefsCache(nsCmpDef, mdri2));
}
public void testDescriptorFilterCache() throws Exception {
ConfigAdapter configAdapter = Aura.getConfigAdapter();
MasterDefRegistry mdr = getAuraMDR();
MasterDefRegistryImpl mdri = (MasterDefRegistryImpl) mdr;
Map<DefType, DefDescriptor<?>> defs = addDefsToCaches(mdri);
Map<DefType, DefDescriptor<?>> nonPrivDefs = addNonPriveledgedDefsToMDR(mdri);
DefDescriptor<?> nsDef = defs.get(DefType.NAMESPACE);
DefDescriptor<?> layoutDef = defs.get(DefType.LAYOUTS);
DefDescriptor<?> rendererDef = defs.get(DefType.RENDERER);
DefDescriptor<?> npNSDef = nonPrivDefs.get(DefType.NAMESPACE);
DefDescriptor<?> npLayoutDef = nonPrivDefs.get(DefType.LAYOUTS);
DefDescriptor<?> npRendererDef = nonPrivDefs.get(DefType.RENDERER);
// only picking 3 defs to test the ns as they are mostly dupes
assertTrue(nsDef.getNamespace() + " should have been isPriveleged",
configAdapter.isPrivilegedNamespace(nsDef.getNamespace()));
assertTrue(layoutDef.getNamespace() + " should have been isPriveleged",
configAdapter.isPrivilegedNamespace(layoutDef.getNamespace()));
assertTrue(rendererDef.getNamespace() + " should have been isPriveleged",
configAdapter.isPrivilegedNamespace(rendererDef.getNamespace()));
assertFalse(npLayoutDef.getNamespace() + " should not have been isPriveleged",
configAdapter.isPrivilegedNamespace(npLayoutDef.getNamespace()));
assertFalse(npNSDef.getNamespace() + " should not have been isPriveleged",
configAdapter.isPrivilegedNamespace(npNSDef.getNamespace()));
assertFalse(npRendererDef.getNamespace() + " should not have been isPriveleged",
configAdapter.isPrivilegedNamespace(npRendererDef.getNamespace()));
DescriptorFilter filter = new DescriptorFilter("*://test:*");
Set<DefDescriptor<?>> results = mdr.find(filter);
assertTrue("results should be cached", isInDescriptorFilterCache(filter, results, mdri));
DescriptorFilter filter2 = new DescriptorFilter("*://gvpTest:*");
Set<DefDescriptor<?>> results2 = mdr.find(filter2);
assertTrue("results2 should be cached", isInDescriptorFilterCache(filter2, results2, mdri));
DescriptorFilter filter3 = new DescriptorFilter("*://cstring:*");
Set<DefDescriptor<?>> results3 = mdr.find(filter3);
assertFalse("results3 should not be cached", isInDescriptorFilterCache(filter3, results3, mdri));
DescriptorFilter filter4 = new DescriptorFilter("*://cstring1:*");
Set<DefDescriptor<?>> results4 = mdr.find(filter4);
assertFalse("results4 should be cached", isInDescriptorFilterCache(filter4, results4, mdri));
DescriptorFilter filter5 = new DescriptorFilter("*://*:*");
Set<DefDescriptor<?>> results5 = mdr.find(filter5);
assertFalse("results5 should not be cached", isInDescriptorFilterCache(filter5, results5, mdri));
// DescriptorFilter filter6 = new DescriptorFilter("*://*test:*");
// Set<DefDescriptor<?>> results6 = mdr.find(filter6);
// assertFalse("results6 should be cached", isInDescriptorFilterCache(filter6, results6, mdri));
MasterDefRegistry mdr2 = restartContextGetNewMDR();
MasterDefRegistryImpl mdri2 = (MasterDefRegistryImpl) mdr2;
assertTrue("results should still be cached", isInDescriptorFilterCache(filter, results, mdri2));
assertTrue("results2 should still be cached", isInDescriptorFilterCache(filter2, results2, mdri2));
assertFalse("results3 should not be cached", isInDescriptorFilterCache(filter3, results3, mdri2));
assertFalse("results4 should not be cached", isInDescriptorFilterCache(filter4, results4, mdri2));