Skip to content
Snippets Groups Projects
Commit 2a42110d authored by Simon Urli's avatar Simon Urli
Browse files

XWIKI-22368: Missing mandatory document initialized in the demo package

  * Ignore XWiki.SheetClass which is coming from a legacy module
parent 402c6b94
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,11 @@ public class MandatoryDocInitializedTest extends AbstractTest
// define the pages that should be created at startup
def startupPages = ["XWiki.XWikiServerXwiki"];
// Pages that are completely ignored from the test
// SheetClass is initialized in a legacy package: we got it tested from the CI but it's expected that it's
// initialized late.
def ignoredPages = ["XWiki.SheetClass"];
def dateFormat = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss");
def rb = ManagementFactory.getRuntimeMXBean();
......@@ -52,6 +57,11 @@ public class MandatoryDocInitializedTest extends AbstractTest
for (startupPage in startupPages) {
startupPageRef.add(services.model.resolveDocument(startupPage));
}
def ignoredPagesRef = [];
for (ignoredPage in ignoredPages) {
ignoredPagesRef.add(services.model.resolveDocument(ignoredPage));
}
def componentManager = services.component.getContextComponentManager();
def documentInitializersList = componentManager.getInstanceList(MandatoryDocumentInitializer.class);
......@@ -60,13 +70,17 @@ public class MandatoryDocInitializedTest extends AbstractTest
def foundErrorsCreatedBefore = [];
for (initializer in documentInitializersList) {
def ref = initializer.getDocumentReference();
def classDoc = xwiki.getDocument(ref);
def creationDate = classDoc.getCreationDate();
def shouldBeBefore = (!startupPageRef.contains(ref));
if (shouldBeBefore && creationDate.after(startedSince)) {
foundErrorsCreatedAfter.add(ref.toString() + " ("+dateFormat.format(creationDate)+")");
} else if (!shouldBeBefore && creationDate.before(startedSince)) {
foundErrorsCreatedBefore.add(ref.toString() + " ("+dateFormat.format(creationDate)+")");
// the provided ref might be a local document ref, so we serialize and resolve again to obtain same
// canonical ref
if (!ignoredPagesRef.contains(services.model.resolveDocument(services.model.serialize(ref)))) {
def classDoc = xwiki.getDocument(ref);
def creationDate = classDoc.getCreationDate();
def shouldBeBefore = (!startupPageRef.contains(ref));
if (shouldBeBefore && creationDate.after(startedSince)) {
foundErrorsCreatedAfter.add(ref.toString() + " ("+dateFormat.format(creationDate)+")");
} else if (!shouldBeBefore && creationDate.before(startedSince)) {
foundErrorsCreatedBefore.add(ref.toString() + " ("+dateFormat.format(creationDate)+")");
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment