use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class AutomaticWatchModeListenerTest method setUp.
@Before
public void setUp() throws Exception {
this.mockStore = mocker.getInstance(WatchListStore.class);
// Make sure we have an Execution Context since the observationContextListener will store current events in it
Execution execution = mocker.getInstance(Execution.class);
execution.setContext(new ExecutionContext());
this.observationContextListener = mocker.getInstance(EventListener.class, "ObservationContextListener");
this.configuration = mocker.getInstance(WatchListConfiguration.class);
when(this.configuration.isEnabled()).thenReturn(true);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class HtmlPackager method renderDocuments.
/**
* Init provided {@link ExportURLFactory} and add rendered documents to ZIP stream.
*
* @param zos the ZIP output stream.
* @param urlf the {@link com.xpn.xwiki.web.XWikiURLFactory} used to render the documents.
* @param context the XWiki context.
* @throws XWikiException error when render documents.
* @throws IOException error when render documents.
*/
private void renderDocuments(ZipOutputStream zos, ExportURLFactory urlf, XWikiContext context) throws XWikiException, IOException {
ExecutionContextManager ecm = Utils.getComponent(ExecutionContextManager.class);
Execution execution = Utils.getComponent(Execution.class);
for (DocumentReference pageReference : this.pageReferences) {
try {
// Isolate and initialize Contexts
XWikiContext renderContext = initializeContexts(ecm, execution, urlf, context);
renderDocument(pageReference, zos, urlf.getFilesystemExportContext(), renderContext);
} catch (ExecutionContextException e) {
throw new XWikiException(XWikiException.MODULE_XWIKI_EXPORT, XWikiException.ERROR_XWIKI_INIT_FAILED, "Failed to initialize Execution Context", e);
} finally {
// Clean up context
execution.popContext();
}
}
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class DownloadAction method getContext.
private XWikiContext getContext() {
Execution execution = Utils.getComponent(Execution.class);
ExecutionContext econtext = execution.getContext();
return econtext != null ? (XWikiContext) econtext.getProperty("xwikicontext") : null;
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class DeleteJobTest method configure.
@Override
public void configure() throws Exception {
super.configure();
Execution execution = mocker.getInstance(Execution.class);
ExecutionContext executionContext = mock(ExecutionContext.class);
when(execution.getContext()).thenReturn(executionContext);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class WikiUIExtensionParametersTest method setUp.
@Before
public void setUp() throws Exception {
VelocityManager velocityManager = componentManager.registerMockComponent(VelocityManager.class);
execution = componentManager.registerMockComponent(Execution.class);
modelContext = componentManager.registerMockComponent(ModelContext.class);
velocityEngine = mock(VelocityEngine.class);
velocityContext = new VelocityContext();
ExecutionContext executionContext = mock(ExecutionContext.class);
when(execution.getContext()).thenReturn(executionContext);
when(velocityManager.getVelocityContext()).thenReturn(velocityContext);
when(velocityManager.getVelocityEngine()).thenReturn(velocityEngine);
}
Aggregations