use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class JavaIntegrationTest method initialize.
@Before
public void initialize() throws Exception {
this.defaultBodyPartFactory = this.componentManager.getInstance(new DefaultParameterizedType(null, MimeBodyPartFactory.class, String.class));
this.htmlBodyPartFactory = this.componentManager.getInstance(new DefaultParameterizedType(null, MimeBodyPartFactory.class, String.class), "text/html");
this.sender = this.componentManager.getInstance(MailSender.class);
// Set the EC
Execution execution = this.componentManager.getInstance(Execution.class);
ExecutionContext executionContext = new ExecutionContext();
XWikiContext xContext = new XWikiContext();
xContext.setWikiId("wiki");
executionContext.setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, xContext);
when(execution.getContext()).thenReturn(executionContext);
Copier<ExecutionContext> executionContextCloner = this.componentManager.getInstance(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
// Just return the same execution context
when(executionContextCloner.copy(executionContext)).thenReturn(executionContext);
// Simulate receiving the Application Ready Event to start the mail threads
MailSenderInitializerListener listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
listener.onEvent(new ApplicationReadyEvent(), null, null);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class GroupMimeMessageIterator method getXWikiContext.
private XWikiContext getXWikiContext() throws MessagingException {
XWikiContext xWikiContext;
try {
Execution execution = this.componentManager.getInstance(Execution.class);
xWikiContext = (XWikiContext) execution.getContext().getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
} catch (ComponentLookupException e) {
throw new MessagingException("Failed to find default Execution context", e);
}
return xWikiContext;
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class AbstractXWikiRunnable method initExecutionContext.
/**
* Initialize execution context for the current thread.
*
* @return the new execution context
* @throws ExecutionContextException error when try to initialize execution context
*/
protected ExecutionContext initExecutionContext() throws ExecutionContextException {
// Keep a reference to the Execution component to avoid a lookup in #cleanupExecutionContext() in case this
// thread is stopped after the Component Manager disposes its components.
this.execution = Utils.getComponent(Execution.class);
ExecutionContextManager ecim = Utils.getComponent(ExecutionContextManager.class);
ExecutionContext context = new ExecutionContext();
declareProperties(context);
ecim.initialize(context);
context.setProperties(this.properties);
return context;
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class RestoreJobTest 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);
modelContext = mocker.getInstance(ModelContext.class);
}
use of org.xwiki.context.Execution in project xwiki-platform by xwiki.
the class RefactoringScriptServiceTest method configure.
@Before
public void configure() throws Exception {
this.jobExecutor = this.mocker.getInstance(JobExecutor.class);
Execution execution = this.mocker.getInstance(Execution.class);
when(execution.getContext()).thenReturn(executionContext);
DocumentAccessBridge documentAccessBridge = this.mocker.getInstance(DocumentAccessBridge.class);
when(documentAccessBridge.getCurrentUserReference()).thenReturn(this.userReference);
EntityReferenceProvider defaultEntityReferenceProvider = this.mocker.getInstance(EntityReferenceProvider.class);
when(defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(new EntityReference("WebHome", EntityType.DOCUMENT, null));
}
Aggregations