Search in sources :

Example 11 with ConfigurationSource

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

the class DefaultMailStorageConfigurationTest method discardSuccessStatusesWhenNotDefined.

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

Example 12 with ConfigurationSource

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

the class DefaultExtendedRenderingConfigurationTest method isImageDimensionsIncludedInImageURL.

@Test
public void isImageDimensionsIncludedInImageURL() throws Exception {
    ConfigurationSource source = this.mocker.getInstance(ConfigurationSource.class);
    when(source.getProperty("rendering.imageDimensionsIncludedInImageURL", true)).thenReturn(false);
    assertFalse(this.mocker.getComponentUnderTest().isImageDimensionsIncludedInImageURL());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 13 with ConfigurationSource

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

the class DefaultExtendedRenderingConfigurationTest method getImageHeightLimit.

@Test
public void getImageHeightLimit() throws Exception {
    ConfigurationSource source = this.mocker.getInstance(ConfigurationSource.class);
    when(source.getProperty("rendering.imageHeightLimit", -1)).thenReturn(150);
    assertEquals(150, this.mocker.getComponentUnderTest().getImageHeightLimit());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 14 with ConfigurationSource

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

the class DefaultExtendedRenderingConfigurationTest method getConfiguredAndDisabledSyntaxesWhenNoConfigXObjectAndExistingXWikiCfgProperty.

@Test
public void getConfiguredAndDisabledSyntaxesWhenNoConfigXObjectAndExistingXWikiCfgProperty() throws Exception {
    ConfigurationSource renderingSource = this.mocker.getInstance(ConfigurationSource.class, "rendering");
    when(renderingSource.getProperty("disabledSyntaxes")).thenReturn(null);
    ConfigurationSource xwikiCfgSource = this.mocker.getInstance(ConfigurationSource.class, "xwikicfg");
    when(xwikiCfgSource.getProperty("xwiki.rendering.syntaxes", List.class)).thenReturn(Arrays.asList("xwiki/2.0", "xwiki/2.1"));
    // Register some Syntaxes for the test
    Parser xwikiSyntax20Parser = this.mocker.registerMockComponent(Parser.class, Syntax.XWIKI_2_0.toIdString());
    when(xwikiSyntax20Parser.getSyntax()).thenReturn(Syntax.XWIKI_2_0);
    Parser xwikiSyntax21Parser = this.mocker.registerMockComponent(Parser.class, Syntax.XWIKI_2_1.toIdString());
    when(xwikiSyntax21Parser.getSyntax()).thenReturn(Syntax.XWIKI_2_1);
    Syntax syntax1 = new Syntax(new SyntaxType("syntax1", "Syntax 1"), "1.0");
    Parser syntax1Parser = this.mocker.registerMockComponent(Parser.class, syntax1.toIdString());
    when(syntax1Parser.getSyntax()).thenReturn(syntax1);
    Syntax syntax2 = new Syntax(new SyntaxType("syntax2", "Syntax 2"), "1.0");
    Parser syntax2Parser = this.mocker.registerMockComponent(Parser.class, syntax2.toIdString());
    when(syntax2Parser.getSyntax()).thenReturn(syntax2);
    List<Syntax> disabledSyntaxes = this.mocker.getComponentUnderTest().getDisabledSyntaxes();
    assertEquals(2, disabledSyntaxes.size());
    assertTrue(disabledSyntaxes.contains(syntax1));
    assertTrue(disabledSyntaxes.contains(syntax2));
    List<Syntax> configuredSyntaxes = this.mocker.getComponentUnderTest().getConfiguredSyntaxes();
    assertEquals(2, configuredSyntaxes.size());
    assertTrue(configuredSyntaxes.contains(Syntax.XWIKI_2_0));
    assertTrue(configuredSyntaxes.contains(Syntax.XWIKI_2_1));
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) SyntaxType(org.xwiki.rendering.syntax.SyntaxType) Syntax(org.xwiki.rendering.syntax.Syntax) Parser(org.xwiki.rendering.parser.Parser) Test(org.junit.Test)

Example 15 with ConfigurationSource

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

the class DefaultExtendedRenderingConfigurationTest method getConfiguredAndDisabledSyntaxesWhenConfigXObjectExists.

@Test
public void getConfiguredAndDisabledSyntaxesWhenConfigXObjectExists() throws Exception {
    ConfigurationSource renderingSource = this.mocker.getInstance(ConfigurationSource.class, "rendering");
    when(renderingSource.getProperty("disabledSyntaxes")).thenReturn(Arrays.asList("syntax1/1.0", "syntax2/1.0"));
    // Register some Syntaxes for the test
    Parser syntax1Parser = this.mocker.registerMockComponent(Parser.class, "syntax1/1.0");
    Syntax syntax1 = new Syntax(new SyntaxType("syntax1", "Syntax 1"), "1.0");
    when(syntax1Parser.getSyntax()).thenReturn(syntax1);
    Parser syntax2Parser = this.mocker.registerMockComponent(Parser.class, "syntax2/1.0");
    Syntax syntax2 = new Syntax(new SyntaxType("syntax2", "Syntax 2"), "1.0");
    when(syntax2Parser.getSyntax()).thenReturn(syntax2);
    Parser xwikiSyntax20Parser = this.mocker.registerMockComponent(Parser.class, "xwiki/2.0");
    Syntax xwikiSyntax20 = new Syntax(new SyntaxType("xwiki", "XWiki"), "2.0");
    when(xwikiSyntax20Parser.getSyntax()).thenReturn(xwikiSyntax20);
    List<Syntax> disabledSyntaxes = this.mocker.getComponentUnderTest().getDisabledSyntaxes();
    assertEquals(2, disabledSyntaxes.size());
    assertTrue(disabledSyntaxes.contains(syntax1));
    assertTrue(disabledSyntaxes.contains(syntax2));
    List<Syntax> configuredSyntaxes = this.mocker.getComponentUnderTest().getConfiguredSyntaxes();
    assertEquals(1, configuredSyntaxes.size());
    assertTrue(configuredSyntaxes.contains(xwikiSyntax20));
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) SyntaxType(org.xwiki.rendering.syntax.SyntaxType) Syntax(org.xwiki.rendering.syntax.Syntax) Parser(org.xwiki.rendering.parser.Parser) 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