use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class WikiManagerScriptServiceTest method setUp.
@Before
public void setUp() throws Exception {
wikiManager = mocker.getInstance(WikiManager.class);
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
authorizationManager = mocker.getInstance(AuthorizationManager.class);
scriptServiceManager = mocker.getInstance(ScriptServiceManager.class);
entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
standardURLConfiguration = mocker.getInstance(StandardURLConfiguration.class);
wikiConfiguration = mocker.getInstance(WikiConfiguration.class);
xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
xcontext = mock(XWikiContext.class);
when(xcontextProvider.get()).thenReturn(xcontext);
execution = mocker.getInstance(Execution.class);
executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
currentUserRef = new DocumentReference("mainWiki", "XWiki", "User");
when(xcontext.getUserReference()).thenReturn(currentUserRef);
currentDoc = mock(XWikiDocument.class);
when(xcontext.getDoc()).thenReturn(currentDoc);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
when(entityReferenceSerializer.serialize(currentUserRef)).thenReturn("mainWiki:XWiki.User");
wikiDescriptorDocumentHelper = mocker.getInstance(WikiDescriptorDocumentHelper.class);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class DefaultDocumentMergeImporterTest method setUp.
@Before
public void setUp() throws Exception {
this.xwiki = mock(XWiki.class);
when(this.xcontext.getWiki()).thenReturn(this.xwiki);
// documents
this.previousDocument = mock(XWikiDocument.class, "previous");
when(this.previousDocument.isNew()).thenReturn(false);
when(this.previousDocument.getDocumentReferenceWithLocale()).thenReturn(this.documentReference);
this.currentDocument = mock(XWikiDocument.class, "current");
when(this.currentDocument.isNew()).thenReturn(false);
when(this.currentDocument.getDocumentReferenceWithLocale()).thenReturn(this.documentReference);
when(this.xwiki.getDocument(same(this.documentReference), same(xcontext))).thenReturn(this.currentDocument);
this.nextDocument = mock(XWikiDocument.class, "next");
when(this.nextDocument.isNew()).thenReturn(false);
when(this.nextDocument.getDocumentReferenceWithLocale()).thenReturn(this.documentReference);
this.mergedDocument = mock(XWikiDocument.class, "merged");
when(this.mergedDocument.isNew()).thenReturn(false);
when(this.mergedDocument.getDocumentReferenceWithLocale()).thenReturn(this.documentReference);
when(this.currentDocument.clone()).thenReturn(this.mergedDocument);
// merge
this.configuration = new PackageConfiguration();
this.mergeResult = new MergeResult();
when(this.mergedDocument.merge(same(this.previousDocument), same(this.nextDocument), any(MergeConfiguration.class), any(XWikiContext.class))).thenReturn(this.mergeResult);
// job status
this.jobStatus = mock(JobStatus.class);
this.configuration.setJobStatus(this.jobStatus);
// execution
this.econtext = new ExecutionContext();
this.execution = this.mocker.getInstance(Execution.class);
when(this.execution.getContext()).thenReturn(this.econtext);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class LESSContextTest method setUp.
@Before
public void setUp() throws Exception {
execution = mocker.getInstance(Execution.class);
executionContext = new ExecutionContext();
when(execution.getContext()).thenReturn(executionContext);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class VelocityContextInitializerTest method testVelocityBridges.
/**
* Test the presence of velocity bridges.
*
* @throws Exception
*/
@Test
public void testVelocityBridges() throws Exception {
// Make sure the execution context is not null when velocity bridges are initialized.
getComponentManager().<Execution>getInstance(Execution.class).setContext(new ExecutionContext());
VelocityContextFactory factory = getComponentManager().getInstance(VelocityContextFactory.class);
VelocityContext context = factory.createContext();
Assert.assertNotNull(context.get("officeimporter"));
Assert.assertNotNull(context.get("ooconfig"));
Assert.assertNotNull(context.get("oomanager"));
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class XWikiSetupCleanupFilter method getReleasableComponents.
/**
* @param componentManager the component manager
* @return the list of JAX-RS resources that are implemented as components with per-lookup policy and that have been
* instantiated during this request
*/
private List<XWikiRestComponent> getReleasableComponents(ComponentManager componentManager) {
try {
ExecutionContext executionContext = componentManager.<Execution>getInstance(Execution.class).getContext();
@SuppressWarnings("unchecked") List<XWikiRestComponent> releasableComponents = (List<XWikiRestComponent>) executionContext.getProperty(Constants.RELEASABLE_COMPONENT_REFERENCES);
return releasableComponents != null ? releasableComponents : Collections.<XWikiRestComponent>emptyList();
} catch (Exception e) {
getLogger().log(Level.WARNING, "Failed to retrieve the list of releasable components.", e);
return Collections.emptyList();
}
}
Aggregations