Search in sources :

Example 36 with ConfigurationSource

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

the class DefaultExtendedRenderingConfigurationTest method getImageWidthLimit.

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

Example 37 with ConfigurationSource

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

the class XWikiRenderingConfigurationTest method getLinkLabelFormat.

@Test
public void getLinkLabelFormat() throws Exception {
    ConfigurationSource source = this.mocker.getInstance(ConfigurationSource.class);
    when(source.getProperty("rendering.linkLabelFormat", "%np")).thenReturn("%np");
    assertEquals("%np", this.mocker.getComponentUnderTest().getLinkLabelFormat());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Test(org.junit.Test)

Example 38 with ConfigurationSource

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

the class XWikiMacroTransformationConfigurationTest method getCategories.

@Test
public void getCategories() throws Exception {
    ConfigurationSource source = this.mocker.getInstance(ConfigurationSource.class);
    when(source.getProperty("rendering.transformation.macro.categories", Properties.class)).thenReturn(new Properties());
    Properties categories = this.mocker.getComponentUnderTest().getCategories();
    assertNotNull(categories);
    assertEquals(0, categories.size());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource) Properties(java.util.Properties) Test(org.junit.Test)

Example 39 with ConfigurationSource

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

the class SpacesConfigurationSourceTest method containsKey.

@Test
public void containsKey() throws Exception {
    WikiReference wikiReference = new WikiReference("wiki");
    SpaceReference space1Reference = new SpaceReference("space1", wikiReference);
    SpaceReference space2Reference = new SpaceReference("space2", space1Reference);
    Map<String, String> space1Preferences = new LinkedHashMap<>();
    space1Preferences.put("pref", "prefvalue1");
    space1Preferences.put("pref1", "pref1value1");
    Map<String, String> space2Preferences = new LinkedHashMap<>();
    space2Preferences.put("pref", "prefvalue2");
    space2Preferences.put("pref2", "pref2value2");
    this.spacesPreferences.put(space1Reference.getName(), space1Preferences);
    this.spacesPreferences.put(space2Reference.getName(), space2Preferences);
    // Tests
    ConfigurationSource spaces = this.mocker.getComponentUnderTest();
    assertTrue(spaces.isEmpty());
    assertFalse(spaces.containsKey("nopref"));
    assertEquals(Arrays.asList(), spaces.getKeys());
    assertNull(spaces.getProperty("nopref"));
    assertNull(spaces.getProperty("nopref", String.class));
    assertEquals("defaultvalue", spaces.getProperty("nopref", "defaultvalue"));
    xcontext.setDoc(new XWikiDocument(new DocumentReference("document", space1Reference)));
    assertFalse(spaces.isEmpty());
    assertFalse(spaces.containsKey("nopref"));
    assertEquals(Arrays.asList("pref", "pref1"), spaces.getKeys());
    assertNull(spaces.getProperty("nopref"));
    assertNull(spaces.getProperty("nopref", String.class));
    assertEquals("defaultvalue", spaces.getProperty("nopref", "defaultvalue"));
    assertTrue(spaces.containsKey("pref"));
    assertEquals("prefvalue1", spaces.getProperty("pref"));
    assertEquals("prefvalue1", spaces.getProperty("pref", String.class));
    assertEquals("prefvalue1", spaces.getProperty("pref", "defaultvalue"));
    assertTrue(spaces.containsKey("pref1"));
    assertEquals("pref1value1", spaces.getProperty("pref1"));
    assertEquals("pref1value1", spaces.getProperty("pref1", String.class));
    assertFalse(spaces.containsKey("pref2"));
    assertNull(spaces.getProperty("pref2"));
    xcontext.setDoc(new XWikiDocument(new DocumentReference("document", space2Reference)));
    assertFalse(spaces.isEmpty());
    assertFalse(spaces.containsKey("nopref"));
    assertEquals(Arrays.asList("pref", "pref2", "pref1"), spaces.getKeys());
    assertNull(spaces.getProperty("nopref"));
    assertNull(spaces.getProperty("nopref", String.class));
    assertEquals("defaultvalue", spaces.getProperty("nopref", "defaultvalue"));
    assertTrue(spaces.containsKey("pref"));
    assertNull(spaces.getProperty("nopref"));
    assertEquals("defaultvalue", spaces.getProperty("nopref", "defaultvalue"));
    assertTrue(spaces.containsKey("pref1"));
    assertEquals("prefvalue2", spaces.getProperty("pref"));
    assertEquals("prefvalue2", spaces.getProperty("pref", "defaultvalue"));
    assertEquals("pref1value1", spaces.getProperty("pref1"));
    assertTrue(spaces.containsKey("pref2"));
    assertEquals("pref2value2", spaces.getProperty("pref2"));
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) ConfigurationSource(org.xwiki.configuration.ConfigurationSource) SpaceReference(org.xwiki.model.reference.SpaceReference) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 40 with ConfigurationSource

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

the class DefaultStandardURLConfigurationTest method getEntityPathPrefix.

@Test
public void getEntityPathPrefix() throws Exception {
    ConfigurationSource source = this.mocker.getInstance(ConfigurationSource.class, "xwikiproperties");
    when(source.getProperty("url.standard.entityPathPrefix", "bin")).thenReturn("bin");
    assertEquals("bin", this.mocker.getComponentUnderTest().getEntityPathPrefix());
}
Also used : ConfigurationSource(org.xwiki.configuration.ConfigurationSource)

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