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
18 package ch.elca.el4j.tests.env;
19
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertTrue;
22
23 import org.junit.Test;
24 import org.springframework.context.ApplicationContext;
25
26 import ch.elca.el4j.core.context.ModuleApplicationContext;
27
28 /**
29 * This class test the environment support.
30 *
31 * @svnLink $Revision: 3874 $;$Date: 2009-08-04 14:25:40 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/tests/env/module/src/test/java/ch/elca/el4j/tests/env/EnvTest.java $
32 *
33 * @author Andreas Bur (ABU)
34 */
35 public class EnvTest {
36 /** The highest transport protocol port number. */
37 // Checkstyle: MagicNumber off
38 private static final int MAX_PORT = 1 << 16 - 1;
39 // Checkstyle: MagicNumber on
40
41 /** The application context. */
42 private final ApplicationContext m_appContext;
43
44 /** The container instance. */
45 private final ServletContainer m_container;
46
47 /**
48 * Default constructor.
49 */
50 public EnvTest() {
51 m_appContext = new ModuleApplicationContext(new String[] {
52 "classpath*:mandatory/*.xml",
53 "classpath:scenarios/envtest/environment.xml"},
54 false);
55
56 m_container
57 = (ServletContainer) m_appContext.getBean("servletContainer");
58 }
59
60 /**
61 * Checks whether the provided values are in the expected range.
62 *
63 */
64 @Test
65 public void testConformance() {
66 assertNotNull("Container name not set.", m_container.getContainer());
67 assertTrue("Container's port out of range.",
68 m_container.getPort() > 0
69 && m_container.getPort() <= MAX_PORT);
70 }
71 }