Skip to content
Snippets Groups Projects
Commit 009c5c7c authored by Vincent Massol's avatar Vincent Massol
Browse files

Added unit test for DefaultConfigurationSourceCollection.

git-svn-id: https://svn.xwiki.org/svnroot/xwiki/platform/core/trunk@12324 f329d543-caf0-0310-9063-dda96c69346f
parent 17131c26
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,12 @@
<artifactId>commons-beanutils-core</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>com.xpn.xwiki.platform.tools</groupId>
<artifactId>xwiki-shared-tests</artifactId>
<version>${platform.tool.test.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -35,14 +35,13 @@
import java.net.MalformedURLException;
/**
* Default list of {@link org.xwiki.configuration.ConfigurationSource}s that contain the default global XWiki configuration
* file (xwiki.properties).
* Default list of {@link org.xwiki.configuration.ConfigurationSource}s that contain the default global XWiki
* configuration file (xwiki.properties).
*
* @version $Id: $
* @since 1.6M1
*/
public class DefaultConfigurationSourceCollection implements ConfigurationSourceCollection,
Initializable
public class DefaultConfigurationSourceCollection implements ConfigurationSourceCollection, Initializable
{
private static final String XWIKI_PROPERTIES_FILE = "xwiki.properties";
......@@ -61,16 +60,13 @@ public void initialize() throws InitializationException
// in the XWiki path somewhere.
URL xwikiPropertiesUrl = null;
try {
xwikiPropertiesUrl =
this.container.getApplicationContext().getResource(XWIKI_PROPERTIES_FILE);
xwikiPropertiesUrl = this.container.getApplicationContext().getResource(XWIKI_PROPERTIES_FILE);
} catch (MalformedURLException e) {
throw new InitializationException("Failed to locate property file ["
+ XWIKI_PROPERTIES_FILE + "]", e);
throw new InitializationException("Failed to locate property file [" + XWIKI_PROPERTIES_FILE + "]", e);
}
try {
this.sources.add(
new CommonsConfigurationSource(new PropertiesConfiguration(xwikiPropertiesUrl)));
this.sources.add(new CommonsConfigurationSource(new PropertiesConfiguration(xwikiPropertiesUrl)));
} catch (ConfigurationException e) {
throw new InitializationException("Failed to load property file ["
+ XWIKI_PROPERTIES_FILE + "]", e);
......
......@@ -27,6 +27,12 @@
import java.util.Arrays;
/**
* Unit tests for {@link org.xwiki.configuration.internal.DefaultConfigurationManagerTest}.
*
* @version $Id: $
* @since 1.6M1
*/
public class DefaultConfigurationManagerTest extends TestCase
{
public class TestConfiguration
......
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.configuration.internal;
import org.xwiki.container.Container;
import org.xwiki.container.ApplicationContext;
import org.xwiki.configuration.ConfigurationSourceCollection;
import org.jmock.Mock;
import java.io.InputStream;
import java.net.URL;
import java.net.MalformedURLException;
import com.xpn.xwiki.test.AbstractXWikiComponentTestCase;
/**
* Unit tests for {@link org.xwiki.configuration.internal.DefaultConfigurationSourceCollection}.
*
* @version $Id: $
* @since 1.6M2
*/
public class DefaultConfigurationSourceCollectionTest extends AbstractXWikiComponentTestCase
{
/**
* Verify initialization of component.
*/
public void testInitialization() throws Exception
{
Container container = (Container) getComponentManager().lookup(Container.ROLE);
Mock mockApplicationContext = mock(ApplicationContext.class);
mockApplicationContext.expects(once()).method("getResource").with(eq("xwiki.properties")).will(
returnValue(this.getClass().getClassLoader().getResource("xwiki.properties")));
container.setApplicationContext((ApplicationContext) mockApplicationContext.proxy());
// Verify that initialization works here.
ConfigurationSourceCollection sources =
(ConfigurationSourceCollection) getComponentManager().lookup(ConfigurationSourceCollection.ROLE);
assertEquals(1, sources.getConfigurationSources().size());
}
}
# Empty Test file
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment