Search in sources :

Example 26 with ConfigurationSource

use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.

the class DefaultMailSenderConfigurationTest method usesAuthenticationWhenNoUserNameAndPassword.

@Test
public void usesAuthenticationWhenNoUserNameAndPassword() throws Exception {
    ConfigurationSource documentsSource = this.mocker.getInstance(ConfigurationSource.class, "documents");
    when(documentsSource.getProperty("smtp_server_username", (String) null)).thenReturn(null);
    when(documentsSource.getProperty("smtp_server_password", (String) null)).thenReturn(null);
    assertFalse(this.mocker.getComponentUnderTest().usesAuthentication());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 27 with ConfigurationSource

use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.

the class DefaultMailSenderConfigurationTest method getBCCAddressesFromMailConfig.

@Test
public void getBCCAddressesFromMailConfig() throws Exception {
    ConfigurationSource mailConfigDocumentSource = this.mocker.getInstance(ConfigurationSource.class, "mailsend");
    when(mailConfigDocumentSource.getProperty("bcc", String.class)).thenReturn("john@doe.com, mary@doe.com");
    assertThat(Arrays.asList("john@doe.com", "mary@doe.com"), containsInAnyOrder(this.mocker.getComponentUnderTest().getBCCAddresses().toArray()));
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 28 with ConfigurationSource

use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.

the class DefaultMailSenderConfigurationTest method getPortFromXWikiPreferences.

@Test
public void getPortFromXWikiPreferences() throws Exception {
    ConfigurationSource documentsSource = this.mocker.getInstance(ConfigurationSource.class, "documents");
    when(documentsSource.getProperty("smtp_port")).thenReturn("25");
    ConfigurationSource mailConfigDocumentSource = this.mocker.getInstance(ConfigurationSource.class, "mailsend");
    when(mailConfigDocumentSource.getProperty("port", 25)).thenReturn(25);
    assertEquals(25, this.mocker.getComponentUnderTest().getPort());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 29 with ConfigurationSource

use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.

the class DefaultMailSenderConfigurationTest method getPortWhenMailConfigDoesntExist.

@Test
public void getPortWhenMailConfigDoesntExist() throws Exception {
    ConfigurationSource xwikiPropertiesSource = this.mocker.getInstance(ConfigurationSource.class, "xwikiproperties");
    when(xwikiPropertiesSource.getProperty("mail.sender.port", 25)).thenReturn(25);
    assertEquals(25, this.mocker.getComponentUnderTest().getPort());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 30 with ConfigurationSource

use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.

the class DefaultMailSenderConfigurationTest method getFromAddressWhenDefinedInMailConfig.

@Test
public void getFromAddressWhenDefinedInMailConfig() throws Exception {
    ConfigurationSource documentsSource = this.mocker.getInstance(ConfigurationSource.class, "documents");
    when(documentsSource.getProperty("admin_email", String.class)).thenReturn(null);
    ConfigurationSource mailConfigDocumentSource = this.mocker.getInstance(ConfigurationSource.class, "mailsend");
    when(mailConfigDocumentSource.getProperty("from", (String) null)).thenReturn("john@doe.com");
    assertEquals("john@doe.com", this.mocker.getComponentUnderTest().getFromAddress());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Aggregations

ConfigurationSource (org.xwiki.configuration.ConfigurationSource)42 Test (org.junit.Test)29 Properties (java.util.Properties)7 XWikiContext (com.xpn.xwiki.XWikiContext)3 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)3 XWikiCfgConfigurationSource (com.xpn.xwiki.internal.XWikiCfgConfigurationSource)3 ArrayList (java.util.ArrayList)3 Expectations (org.jmock.Expectations)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Parser (org.xwiki.rendering.parser.Parser)3 Syntax (org.xwiki.rendering.syntax.Syntax)3 SyntaxType (org.xwiki.rendering.syntax.SyntaxType)3 ContextualAuthorizationManager (org.xwiki.security.authorization.ContextualAuthorizationManager)3 CoreConfiguration (com.xpn.xwiki.CoreConfiguration)2 File (java.io.File)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2