Search in sources :

Example 76 with Execution

use of org.xwiki.context.Execution in project xwiki-platform by xwiki.

the class WikiUIExtensionRendererTest method setUp.

@Before
public void setUp() throws Exception {
    execution = cm.registerMockComponent(Execution.class);
    ExecutionContext executionContext = mock(ExecutionContext.class);
    renderingContext = mock(MutableRenderingContext.class);
    cm.registerComponent(RenderingContext.class, renderingContext);
    cm.registerMockComponent(Transformation.class, "macro");
    contentParser = cm.registerMockComponent(ContentParser.class);
    when(execution.getContext()).thenReturn(executionContext);
    xdom = mock(XDOM.class);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) XDOM(org.xwiki.rendering.block.XDOM) ContentParser(org.xwiki.component.wiki.internal.bridge.ContentParser) MutableRenderingContext(org.xwiki.rendering.internal.transformation.MutableRenderingContext) Before(org.junit.Before)

Example 77 with Execution

use of org.xwiki.context.Execution in project xwiki-platform by xwiki.

the class DomainWikiReferenceExtractorTest method setUpConfiguration.

private void setUpConfiguration(WikiNotFoundBehavior wikiNotFoundBehavior) throws Exception {
    // Simulate a configured Execution Context
    Execution execution = mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(new ExecutionContext());
    StandardURLConfiguration urlConfiguration = mocker.getInstance(StandardURLConfiguration.class);
    when(urlConfiguration.getWikiNotFoundBehavior()).thenReturn(wikiNotFoundBehavior);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext)

Example 78 with Execution

use of org.xwiki.context.Execution in project xwiki-platform by xwiki.

the class FilesystemExportContextProviderTest method getWhenExportContextAlreadyInEC.

@Test
public void getWhenExportContextAlreadyInEC() throws Exception {
    ExecutionContext ec = new ExecutionContext();
    FilesystemExportContext fec = new FilesystemExportContext();
    ec.setProperty("filesystemExportContext", fec);
    Execution execution = this.mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(ec);
    FilesystemExportContext newfec = this.mocker.getComponentUnderTest().get();
    assertSame(newfec, ec.getProperty("filesystemExportContext"));
    assertSame(newfec, fec);
}
Also used : ExecutionContext(org.xwiki.context.ExecutionContext) Execution(org.xwiki.context.Execution) FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) Test(org.junit.Test)

Example 79 with Execution

use of org.xwiki.context.Execution in project xwiki-platform by xwiki.

the class FilesystemExportContextProviderTest method getWhenExportContextNotInEC.

@Test
public void getWhenExportContextNotInEC() throws Exception {
    ExecutionContext ec = new ExecutionContext();
    Execution execution = this.mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(ec);
    FilesystemExportContext fec = this.mocker.getComponentUnderTest().get();
    assertSame(fec, ec.getProperty("filesystemExportContext"));
}
Also used : ExecutionContext(org.xwiki.context.ExecutionContext) Execution(org.xwiki.context.Execution) FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) Test(org.junit.Test)

Example 80 with Execution

use of org.xwiki.context.Execution in project xwiki-platform by xwiki.

the class ExtensionHistoryScriptServiceTest method configure.

@Before
public void configure() throws Exception {
    Provider<XWikiContext> xcontextProvider = this.mocker.getInstance(XWikiContext.TYPE_PROVIDER);
    when(xcontextProvider.get()).thenReturn(this.xcontext);
    Execution execution = this.mocker.getInstance(Execution.class);
    when(execution.getContext()).thenReturn(this.executionContext);
    this.jobExecutor = this.mocker.getInstance(JobExecutor.class);
    this.authorization = this.mocker.getInstance(ContextualAuthorizationManager.class);
    this.documentAccessBridge = this.mocker.getInstance(DocumentAccessBridge.class);
}
Also used : ContextualAuthorizationManager(org.xwiki.security.authorization.ContextualAuthorizationManager) Execution(org.xwiki.context.Execution) JobExecutor(org.xwiki.job.JobExecutor) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) XWikiContext(com.xpn.xwiki.XWikiContext) 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