BaseLocaleUrlDefinitionDAO implements
        DefinitionDAO<Locale>, RefreshMonitor { public boolean refreshRequired() { boolean status = false; Set<String> paths = lastModifiedDates.keySet(); try { for (String path : paths) { Long lastModifiedDate = lastModifiedDates.get(path); ApplicationResource resource = applicationContext.getResource(path); long newModDate = resource.getLastModified(); if (newModDate != lastModifiedDate) { status = true; break; } } } catch (IOException e) { log.warn("Exception while monitoring update times.", e); return true; } return status; } BaseLocaleUrlDefinitionDAO(ApplicationContext applicationContext); void setSources(List<ApplicationResource> sources); void setReader(DefinitionsReader reader); boolean refreshRequired();  }
@Test public void testRefreshRequired() throws URISyntaxException, IOException, InterruptedException { Map<String, Attribute> attribs = new HashMap<String, Attribute>(); attribs.put("testparm", new Attribute("testval")); Definition rewriteTest = new Definition("rewrite.test", Attribute.createTemplateAttribute("/test.jsp"), attribs); expect(dao.getDefinition("rewrite.test", null)).andReturn(rewriteTest); replay(dao); List<ApplicationResource> sources = new ArrayList<ApplicationResource>(); sources.add(resource); dao.setSources(sources); DefinitionsReader reader = new DigesterDefinitionsReader(); dao.setReader(reader); Request context = createMock(Request.class); expect(context.getContext("session")).andReturn(new HashMap<String, Object>()).anyTimes(); expect(context.getRequestLocale()).andReturn(null).anyTimes(); replay(context); Definition definition = dao.getDefinition("rewrite.test", null); assertNotNull("rewrite.test definition not found.", definition); assertEquals("Incorrect initial template value", "/test.jsp", definition.getTemplateAttribute().getValue()); RefreshMonitor reloadable = dao; dao.loadDefinitionsFromResource(resource); assertEquals("Factory should be fresh.", false, reloadable.refreshRequired()); Thread.sleep(SLEEP_MILLIS); resource.modify("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n" + "<!DOCTYPE tiles-definitions PUBLIC " + "\"- + "\"http: + "<definition name=\"rewrite.test\" template=\"/newtest.jsp\">" + "<put-attribute name=\"testparm\" value=\"testval\"/>" + "</definition>" + "</tiles-definitions>"); assertEquals("Factory should be stale.", true, reloadable.refreshRequired()); verify(context, dao); }