Search in sources :

Example 1 with MailSenderInitializerListener

use of org.xwiki.mail.internal.thread.MailSenderInitializerListener in project xwiki-platform by xwiki.

the class AuthenticatingIntegrationTest method initialize.

@Before
public void initialize() throws Exception {
    // Create a user in the SMTP server.
    this.mail.setUser("peter@doe.com", "peter", "password");
    this.defaultBodyPartFactory = this.componentManager.getInstance(new DefaultParameterizedType(null, MimeBodyPartFactory.class, String.class));
    this.sender = this.componentManager.getInstance(MailSender.class);
    // 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);
}
Also used : ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) MailSender(org.xwiki.mail.MailSender) DefaultMailSender(org.xwiki.mail.internal.DefaultMailSender) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) MailSenderInitializerListener(org.xwiki.mail.internal.thread.MailSenderInitializerListener) Before(org.junit.Before)

Example 2 with MailSenderInitializerListener

use of org.xwiki.mail.internal.thread.MailSenderInitializerListener 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);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) Copier(org.xwiki.mail.internal.thread.context.Copier) ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) XWikiContext(com.xpn.xwiki.XWikiContext) MailSender(org.xwiki.mail.MailSender) DefaultMailSender(org.xwiki.mail.internal.DefaultMailSender) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) MailSenderInitializerListener(org.xwiki.mail.internal.thread.MailSenderInitializerListener) Before(org.junit.Before)

Example 3 with MailSenderInitializerListener

use of org.xwiki.mail.internal.thread.MailSenderInitializerListener in project xwiki-platform by xwiki.

the class ScriptingIntegrationTest method initialize.

@Before
public void initialize() throws Exception {
    this.scriptService = this.componentManager.getInstance(ScriptService.class, "mailsender");
    // 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);
    execution.setContext(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);
}
Also used : ScriptService(org.xwiki.script.service.ScriptService) MailSenderScriptService(org.xwiki.mail.script.MailSenderScriptService) DefaultExecution(org.xwiki.context.internal.DefaultExecution) Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) Copier(org.xwiki.mail.internal.thread.context.Copier) ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) XWikiContext(com.xpn.xwiki.XWikiContext) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) MailSenderInitializerListener(org.xwiki.mail.internal.thread.MailSenderInitializerListener) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)3 ApplicationReadyEvent (org.xwiki.bridge.event.ApplicationReadyEvent)3 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)3 MailSenderInitializerListener (org.xwiki.mail.internal.thread.MailSenderInitializerListener)3 XWikiContext (com.xpn.xwiki.XWikiContext)2 Execution (org.xwiki.context.Execution)2 ExecutionContext (org.xwiki.context.ExecutionContext)2 MailSender (org.xwiki.mail.MailSender)2 DefaultMailSender (org.xwiki.mail.internal.DefaultMailSender)2 Copier (org.xwiki.mail.internal.thread.context.Copier)2 DefaultExecution (org.xwiki.context.internal.DefaultExecution)1 MailSenderScriptService (org.xwiki.mail.script.MailSenderScriptService)1 ScriptService (org.xwiki.script.service.ScriptService)1