Search in sources :

Example 1 with EnvironmentConfiguration

use of org.xwiki.environment.internal.EnvironmentConfiguration in project xwiki-platform by xwiki.

the class JavaIntegrationTest method registerConfiguration.

@BeforeComponent
public void registerConfiguration() throws Exception {
    this.configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
    this.componentManager.registerComponent(MailSenderConfiguration.class, this.configuration);
    // Set the current wiki in the Context
    ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
    XWikiContext xcontext = mock(XWikiContext.class);
    when(xcontext.getWikiId()).thenReturn("wiki");
    Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    when(xwikiContextProvider.get()).thenReturn(xcontext);
    this.componentManager.registerMockComponent(ExecutionContextManager.class);
    this.componentManager.registerMockComponent(Execution.class);
    this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
    EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
    when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
}
Also used : ModelContext(org.xwiki.model.ModelContext) ExecutionContext(org.xwiki.context.ExecutionContext) EnvironmentConfiguration(org.xwiki.environment.internal.EnvironmentConfiguration) Copier(org.xwiki.mail.internal.thread.context.Copier) XWikiContext(com.xpn.xwiki.XWikiContext) Properties(java.util.Properties) WikiReference(org.xwiki.model.reference.WikiReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 2 with EnvironmentConfiguration

use of org.xwiki.environment.internal.EnvironmentConfiguration in project xwiki-platform by xwiki.

the class AuthenticatingIntegrationTest method registerConfiguration.

@BeforeComponent
public void registerConfiguration() throws Exception {
    Properties properties = new Properties();
    properties.setProperty("mail.smtp.starttls.enable", "true");
    // Required by GreenMail. When using XWiki with Gmail for example this is not required.
    properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    this.configuration = new TestMailSenderConfiguration(this.mail.getSmtps().getPort(), "peter", "password", properties);
    this.componentManager.registerComponent(MailSenderConfiguration.class, this.configuration);
    // Set the current wiki in the Context
    ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
    Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    when(xwikiContextProvider.get()).thenReturn(Mockito.mock(XWikiContext.class));
    this.componentManager.registerMockComponent(ExecutionContextManager.class);
    this.componentManager.registerMockComponent(Execution.class);
    this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
    EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
    when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
}
Also used : ModelContext(org.xwiki.model.ModelContext) ExecutionContext(org.xwiki.context.ExecutionContext) EnvironmentConfiguration(org.xwiki.environment.internal.EnvironmentConfiguration) Copier(org.xwiki.mail.internal.thread.context.Copier) XWikiContext(com.xpn.xwiki.XWikiContext) Properties(java.util.Properties) WikiReference(org.xwiki.model.reference.WikiReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 3 with EnvironmentConfiguration

use of org.xwiki.environment.internal.EnvironmentConfiguration in project xwiki-platform by xwiki.

the class ScriptingIntegrationTest method registerConfiguration.

@BeforeComponent
public void registerConfiguration() throws Exception {
    MailSenderConfiguration configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
    this.componentManager.registerComponent(MailSenderConfiguration.class, configuration);
    // Register a test Permission Checker that allows sending mails
    ScriptServicePermissionChecker checker = mock(ScriptServicePermissionChecker.class);
    this.componentManager.registerComponent(ScriptServicePermissionChecker.class, "test", checker);
    // Set the current wiki in the Context
    ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
    Mockito.when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
    Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    when(xwikiContextProvider.get()).thenReturn(Mockito.mock(XWikiContext.class));
    this.componentManager.registerMockComponent(ExecutionContextManager.class);
    this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
    EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
    when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
    this.componentManager.registerMockComponent(ConverterManager.class);
}
Also used : ModelContext(org.xwiki.model.ModelContext) ExecutionContext(org.xwiki.context.ExecutionContext) EnvironmentConfiguration(org.xwiki.environment.internal.EnvironmentConfiguration) Copier(org.xwiki.mail.internal.thread.context.Copier) XWikiContext(com.xpn.xwiki.XWikiContext) Properties(java.util.Properties) WikiReference(org.xwiki.model.reference.WikiReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ScriptServicePermissionChecker(org.xwiki.mail.script.ScriptServicePermissionChecker) MailSenderConfiguration(org.xwiki.mail.MailSenderConfiguration) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)3 Properties (java.util.Properties)3 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)3 ExecutionContext (org.xwiki.context.ExecutionContext)3 EnvironmentConfiguration (org.xwiki.environment.internal.EnvironmentConfiguration)3 Copier (org.xwiki.mail.internal.thread.context.Copier)3 ModelContext (org.xwiki.model.ModelContext)3 WikiReference (org.xwiki.model.reference.WikiReference)3 BeforeComponent (org.xwiki.test.annotation.BeforeComponent)3 MailSenderConfiguration (org.xwiki.mail.MailSenderConfiguration)1 ScriptServicePermissionChecker (org.xwiki.mail.script.ScriptServicePermissionChecker)1