View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2006 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.tests.util.config;
18  
19  import static org.junit.Assert.assertTrue;
20  
21  import org.springframework.context.ApplicationContext;
22  
23  import ch.elca.el4j.core.context.ModuleApplicationContext;
24  import ch.elca.el4j.util.config.GenericConfig;
25  
26  // Checkstyle: MagicNumber off
27  // Checkstyle: EmptyBlock off
28  
29  /**
30   * This class tests {@link GenericConfig} using Spring.
31   *
32   * @svnLink $Revision: 3875 $;$Date: 2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/test/java/ch/elca/el4j/tests/util/config/GenericConfigSpringTest.java $
33   *
34   * @author Stefan Wismer (SWI)
35   */
36  public class GenericConfigSpringTest extends AbstractGenericConfigTest {
37  	
38  	/** The application context. */
39  	final ApplicationContext m_appContext;
40  
41  	/**
42  	 * Default constructor.
43  	 */
44  	public GenericConfigSpringTest() {
45  		m_appContext = new ModuleApplicationContext(
46  			"classpath:scenarios/util/config/genericConfig.xml", false);
47  	}
48  	
49  	/** {@inheritDoc} */
50  	@Override
51  	protected GenericConfig getDefaultConfig() {
52  		return (GenericConfig) m_appContext.getBean("DefaultConfig");
53  	}
54  	
55  	/** {@inheritDoc} */
56  	@Override
57  	protected GenericConfig getSpecificConfig() {
58  		return (GenericConfig) m_appContext.getBean("SpecificConfig");
59  	}
60  	
61  	/** {@inheritDoc} */
62  	@Override
63  	protected GenericConfig getMoreSpecificConfig() {
64  		return (GenericConfig) m_appContext.getBean("MoreSpecificConfig");
65  	}
66  	
67  	/***/
68  	public void testMoreSpecificConfigUsingProperties() {
69  		GenericConfig config = (GenericConfig)
70  			m_appContext.getBean("MoreSpecificConfigUsingProperties");
71  		assertTrue(config.get("class").equals(
72  			"MoreSpecificConfigUsingProperties"));
73  		assertTrue(config.get("MoreSpecificConfigUsingProperties")
74  			.equals("MoreSpecificConfigUsingProperties"));
75  		assertTrue(config.get("SpecificConfig").equals("SpecificConfig"));
76  		assertTrue(config.getMap().size() == 4);
77  	}
78  }
79  // Checkstyle: EmptyBlock on
80  // Checkstyle: MagicNumber on