use of com.xpn.xwiki.XWikiConfig in project xwiki-platform by xwiki.
the class XWikiTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
this.xwiki = new com.xpn.xwiki.XWiki();
getContext().setWiki(this.xwiki);
this.xwiki.setConfig(new XWikiConfig());
this.apiXWiki = new XWiki(this.xwiki, getContext());
this.mockXWikiStore = mock(XWikiHibernateStore.class, new java.lang.Class[] { com.xpn.xwiki.XWiki.class, XWikiContext.class }, new java.lang.Object[] { this.xwiki, getContext() });
this.mockXWikiStore.stubs().method("loadXWikiDoc").will(new CustomStub("Implements XWikiStoreInterface.loadXWikiDoc") {
@Override
public java.lang.Object invoke(Invocation invocation) throws Throwable {
XWikiDocument shallowDoc = (XWikiDocument) invocation.parameterValues.get(0);
if (XWikiTest.this.docs.containsKey(shallowDoc.getName())) {
return XWikiTest.this.docs.get(shallowDoc.getName());
} else {
return shallowDoc;
}
}
});
this.mockXWikiStore.stubs().method("saveXWikiDoc").will(new CustomStub("Implements XWikiStoreInterface.saveXWikiDoc") {
@Override
public java.lang.Object invoke(Invocation invocation) throws Throwable {
XWikiDocument document = (XWikiDocument) invocation.parameterValues.get(0);
document.setNew(false);
document.setStore((XWikiStoreInterface) XWikiTest.this.mockXWikiStore.proxy());
document.setId(rand.nextLong());
XWikiTest.this.docs.put(document.getName(), document);
return null;
}
});
this.mockXWikiStore.stubs().method("getTranslationList").will(returnValue(Collections.EMPTY_LIST));
this.mockXWikiVersioningStore = mock(XWikiHibernateVersioningStore.class, new java.lang.Class[] { com.xpn.xwiki.XWiki.class, XWikiContext.class }, new java.lang.Object[] { this.xwiki, getContext() });
this.mockXWikiVersioningStore.stubs().method("getXWikiDocumentArchive").will(returnValue(new XWikiDocumentArchive()));
this.mockXWikiVersioningStore.stubs().method("saveXWikiDocArchive").will(returnValue(null));
this.mockXWikiRightService = mock(XWikiRightServiceImpl.class, new java.lang.Class[] {}, new java.lang.Object[] {});
this.mockXWikiRightService.stubs().method("hasAccessLevel").will(returnValue(true));
this.mockXWikiRightService.stubs().method("hasProgrammingRights").will(returnValue(true));
this.xwiki.setStore((XWikiStoreInterface) this.mockXWikiStore.proxy());
this.xwiki.setVersioningStore((XWikiVersioningStoreInterface) this.mockXWikiVersioningStore.proxy());
this.xwiki.setRightService((XWikiRightService) this.mockXWikiRightService.proxy());
getContext().setUser("Redtail");
this.apiDocument = new Document(new XWikiDocument(new DocumentReference("Wiki", "MilkyWay", "Fidis")), getContext());
this.apiDocument.getDocument().setCreator("c" + getContext().getUser());
this.apiDocument.getDocument().setAuthor("a" + getContext().getUser());
this.apiDocument.save();
getContext().setUser("Earth");
}
use of com.xpn.xwiki.XWikiConfig in project xwiki-platform by xwiki.
the class AbstractDataMigrationManager method tryToProcceedToMigration.
/**
* Start migrations if migrations are enabled.
*
* @throws DataMigrationException
*/
private void tryToProcceedToMigration() throws DataMigrationException {
XWikiConfig config = getXWikiConfig();
if ("1".equals(config.getProperty("xwiki.store.migration", "0")) && !"0".equals(config.getProperty("xwiki.store.hibernate.updateschema"))) {
// Run migrations
this.logger.info("Storage schema updates and data migrations are enabled");
startMigrationsOnlyOnce();
// TODO: Improve or remove this which is inappropriate in a container environment
if ("1".equals(config.getProperty("xwiki.store.migration.exitAfterEnd", "0"))) {
this.logger.error("Exiting because xwiki.store.migration.exitAfterEnd is set");
System.exit(0);
}
}
}
Aggregations