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) 2005 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.junit.Test;
22  
23  import ch.elca.el4j.util.config.GenericConfig;
24  
25  //Checkstyle: MagicNumber off
26  //Checkstyle: EmptyBlock off
27  
28  /**
29   * This class tests {@link GenericConfig}.
30   *
31   * @svnLink $Revision: 3873 $;$Date: 2009-08-04 13:59:45 +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/AbstractGenericConfigTest.java $
32   *
33   * @author Stefan Wismer (SWI)
34   */
35  public abstract class AbstractGenericConfigTest {
36  	/***/
37  	@Test
38  	public void testGenericConfig() {
39  		GenericConfig config = getDefaultConfig();
40  		assertTrue(config.get("class").equals("DefaultConfig"));
41  		assertTrue(config.get("DefaultConfig").equals("DefaultConfig"));
42  		assertTrue(config.getMap().size() == 2);
43  	}
44  	
45  	/***/
46  	@Test
47  	public void testSpecificConfig() {
48  		GenericConfig config = getSpecificConfig();
49  		assertTrue(config.get("class").equals("SpecificConfig"));
50  		assertTrue(config.get("DefaultConfig").equals("DefaultConfig"));
51  		assertTrue(config.get("SpecificConfig").equals("SpecificConfig"));
52  		assertTrue(config.getMap().size() == 3);
53  	}
54  	
55  	/***/
56  	@Test
57  	public void testMoreSpecificConfig() {
58  		GenericConfig config = getMoreSpecificConfig();
59  		assertTrue(config.get("class").equals("MoreSpecificConfig"));
60  		assertTrue(config.get("MoreSpecificConfig")
61  			.equals("MoreSpecificConfig"));
62  		assertTrue(config.get("SpecificConfig").equals("SpecificConfig"));
63  		assertTrue(config.get("DefaultConfig").equals("DefaultConfig"));
64  		assertTrue(config.getMap().size() == 4);
65  	}
66  	
67  	/**
68  	 * @return    the default configuration
69  	 */
70  	protected abstract GenericConfig getDefaultConfig();
71  	
72  	/**
73  	 * @return    the specific configuration
74  	 */
75  	protected abstract GenericConfig getSpecificConfig();
76  	
77  	/**
78  	 * @return    the more specific configuration
79  	 */
80  	protected abstract GenericConfig getMoreSpecificConfig();
81  }
82  
83  //Checkstyle: EmptyBlock on
84  //Checkstyle: MagicNumber on