KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > configuration > TestSiteConfiguration


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/configuration/TestSiteConfiguration.java,v $
3  * Date : $Date: 2005/06/27 23:22:20 $
4  * Version: $Revision: 1.8 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31  
32 package org.opencms.configuration;
33
34 import org.opencms.main.OpenCms;
35 import org.opencms.site.CmsSite;
36 import org.opencms.site.CmsSiteManager;
37 import org.opencms.site.CmsSiteMatcher;
38 import org.opencms.test.OpenCmsTestCase;
39 import org.opencms.test.OpenCmsTestProperties;
40
41 import junit.extensions.TestSetup;
42 import junit.framework.Test;
43 import junit.framework.TestSuite;
44
45 /**
46  * Unit tests for site configuration.<p>
47  *
48  * @author Armen Markarian
49  *
50  * @version $Revision: 1.8 $
51  */

52 public class TestSiteConfiguration extends OpenCmsTestCase {
53   
54     /**
55      * Default JUnit constructor.<p>
56      *
57      * @param arg0 JUnit parameters
58      */

59     public TestSiteConfiguration(String JavaDoc arg0) {
60         super(arg0);
61     }
62     
63     /**
64      * Test suite for this test class.<p>
65      *
66      * @return the test suite
67      */

68     public static Test suite() {
69         OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH);
70         
71         TestSuite suite = new TestSuite();
72         suite.setName(TestSiteConfiguration.class.getName());
73              
74         suite.addTest(new TestSiteConfiguration("testConfiguredSites"));
75          
76         TestSetup wrapper = new TestSetup(suite) {
77             
78             protected void setUp() {
79                 setupOpenCms("simpletest", "/sites/default/");
80             }
81             
82             protected void tearDown() {
83                 removeOpenCms();
84             }
85         };
86         
87         return wrapper;
88     }
89     
90     /**
91      * Tests the configured site settings.<p>
92      *
93      * @throws Throwable if something goes wrong
94      */

95     public void testConfiguredSites() throws Throwable JavaDoc {
96         echo("Testing Site Configuration");
97         CmsSiteManager siteManager = OpenCms.getSiteManager();
98         echo("Testing default Uri");
99         assertEquals("/sites/default/", siteManager.getDefaultUri());
100         echo("Testing workplace server");
101         assertEquals("http://localhost:8080", siteManager.getWorkplaceServer());
102         CmsSite site = CmsSiteManager.getSite("/sites/default/folder1");
103         if (site != null) {
104             echo("Testing Site: '"+site.toString()+"'");
105             CmsSiteMatcher matcher = site.getSiteMatcher();
106             echo("Testing Server Protocol");
107             assertEquals("http", matcher.getServerProtocol());
108             echo("Testing Server Name");
109             assertEquals("localhost", matcher.getServerName());
110             echo("Testing Server Port");
111             assertEquals(8081, matcher.getServerPort());
112         } else {
113             fail("Test failed: site was null!");
114         }
115     }
116 }
117
118
Popular Tags