* Verify staleness check is done when CachingDefRegistry is not filled up.
*/
public void _testForStaleCheckWhenRegistryPartiallyFull() throws Exception {
String markup = "<aura:component> %s </aura:component>";
DefDescriptor<ComponentDef> dd = addSourceAutoCleanup(ComponentDef.class, String.format(markup, ""));
ComponentDef initialDef = dd.getDef();
long initialTimeStamp = initialDef.getLocation().getLastModified();
// Have to stop and start context because a given def is cached in MasterDefRegistry per request (context of the
// request)
Aura.getContextService().endContext();
Aura.getContextService().startContext(Mode.PROD, null, Format.JSON, Authentication.AUTHENTICATED);
StringSource<?> source = (StringSource<?>) getSource(dd);
source.addOrUpdate(String.format(markup, "<aura:attribute type=\"String\" name=\"attr\"/>"));
// Verify that the initial def object hasn't been updated
assertEquals(initialTimeStamp, initialDef.getLocation().getLastModified());
// Fetch the def
assertTrue(Aura.getContextService().getCurrentContext().getDefRegistry().exists(dd));
ComponentDef updatedDef = dd.getDef();
// Verify that stale check has been performed
long updatedTimeStamp = updatedDef.getLocation().getLastModified();
assertTrue("Time stamp on def should have been updated", updatedTimeStamp > initialTimeStamp);
assertTrue(updatedDef instanceof BaseComponentDefImpl);
BaseComponentDefImpl<?> def = (BaseComponentDefImpl<?>) updatedDef;
assertNotNull("Failed to obtain the updated component Def", def.getAttributeDef("attr"));
}