Search in sources :

Example 71 with Execution

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);
}
Also used : WatchListConfiguration(org.xwiki.watchlist.WatchListConfiguration) Execution(org.xwiki.context.Execution) DefaultExecution(org.xwiki.context.internal.DefaultExecution) ExecutionContext(org.xwiki.context.ExecutionContext) WatchListStore(org.xwiki.watchlist.internal.api.WatchListStore) EventListener(org.xwiki.observation.EventListener) Before(org.junit.Before)

Example 72 with Execution

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();
        }
    }
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContextManager(org.xwiki.context.ExecutionContextManager) XWikiContext(com.xpn.xwiki.XWikiContext) ExecutionContextException(org.xwiki.context.ExecutionContextException) DocumentReference(org.xwiki.model.reference.DocumentReference) XWikiException(com.xpn.xwiki.XWikiException)

Example 73 with Execution

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;
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext)

Example 74 with Execution

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);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext)

Example 75 with Execution

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);
}
Also used : ModelContext(org.xwiki.model.ModelContext) VelocityEngine(org.xwiki.velocity.VelocityEngine) Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) VelocityManager(org.xwiki.velocity.VelocityManager) VelocityContext(org.apache.velocity.VelocityContext) Before(org.junit.Before)

Aggregations

Execution (org.xwiki.context.Execution)82 ExecutionContext (org.xwiki.context.ExecutionContext)58 Before (org.junit.Before)36 XWikiContext (com.xpn.xwiki.XWikiContext)30 Test (org.junit.Test)19 DocumentReference (org.xwiki.model.reference.DocumentReference)17 XWiki (com.xpn.xwiki.XWiki)13 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)13 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)11 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)10 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)8 ComponentManager (org.xwiki.component.manager.ComponentManager)8 HashMap (java.util.HashMap)7 Expectations (org.jmock.Expectations)7 VelocityContext (org.apache.velocity.VelocityContext)5 ExecutionContextManager (org.xwiki.context.ExecutionContextManager)5 BaseObject (com.xpn.xwiki.objects.BaseObject)4 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)4 XDOM (org.xwiki.rendering.block.XDOM)4 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)4