@Test public void testLastModifiedTime() throws Exception { WikiPage page = WikiPageUtil.addPage(root, PathParser.parse("SomePage"), "some text"); page.commit(page.getData()); long now = Clock.currentTimeInMillis(); Date lastModified = page.getData().getProperties().getLastModificationTime(); assertTrue(now - lastModified.getTime() <= 5000); }
public Date getLastModificationTime() { String dateStr = get(PageData.PropertyLAST_MODIFIED); if (dateStr == null) return Clock.currentDate(); else try { return getTimeFormat().parse(dateStr); } catch (ParseException e) { throw new IllegalStateException("Unable to parse date '" + dateStr + "'", e); } }
@Test public void testLastModificationTime() throws Exception { DateFormat format = WikiPageProperty.getTimeFormat(); WikiPageProperties props = new WikiPageProperties(); assertEquals( format.format(Clock.currentDate()), format.format(props.getLastModificationTime())); Date date = format.parse("20040101000001"); props.setLastModificationTime(date); assertEquals("20040101000001", props.get(PageData.PropertyLAST_MODIFIED)); assertEquals(date, props.getLastModificationTime()); }