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());
}
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());
}
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());
}
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"));
}
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());
}
Aggregations