KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > main > TestCmsSystemInfo


1 /*
2  * File : $Source: /usr/local/cvs/opencms/test/org/opencms/main/TestCmsSystemInfo.java,v $
3  * Date : $Date: 2006/03/27 14:52:59 $
4  * Version: $Revision: 1.2 $
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.main;
33
34 import org.opencms.configuration.CmsSearchConfiguration;
35 import org.opencms.test.OpenCmsTestCase;
36 import org.opencms.test.OpenCmsTestProperties;
37
38 import java.io.File JavaDoc;
39
40 import junit.extensions.TestSetup;
41 import junit.framework.Test;
42 import junit.framework.TestSuite;
43
44 /**
45  * Test case for {@link CmsSystemInfo}.
46  * <p>
47  *
48  * @author Achim Westermann
49  *
50  * @version $Revision: 1.2 $
51  *
52  * @since 6.0.0
53  */

54 public class TestCmsSystemInfo extends OpenCmsTestCase {
55
56     /**
57      * Default JUnit constructor.
58      * <p>
59      *
60      * @param arg0 JUnit parameters
61      */

62     public TestCmsSystemInfo(String JavaDoc arg0) {
63
64         super(arg0);
65     }
66
67     /**
68      * Test suite for this test class.
69      * <p>
70      *
71      * @return the test suite
72      */

73     public static Test suite() {
74
75         OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH);
76
77         TestSuite suite = new TestSuite();
78         suite.setName(TestCmsSystemInfo.class.getName());
79
80         suite.addTest(new TestCmsSystemInfo("testGetAbsoluteRfsPathRelativeToWebApplication"));
81         suite.addTest(new TestCmsSystemInfo("testGetAbsoluteRfsPathRelativeToWebInf"));
82         suite.addTest(new TestCmsSystemInfo("getConfigurationFileRfsPath"));
83
84         TestSetup wrapper = new TestSetup(suite) {
85
86             protected void setUp() {
87
88                 setupOpenCms(null, "/sites/default/");
89             }
90
91             protected void tearDown() {
92
93                 removeOpenCms();
94             }
95         };
96
97         return wrapper;
98     }
99
100     /**
101      * Tests {@link CmsSystemInfo#getConfigurationFileRfsPath()}.
102      * <p>
103      *
104      */

105     public void getConfigurationFileRfsPath() {
106
107         CmsSystemInfo sysinfo = OpenCms.getSystemInfo();
108         assertNotNull(sysinfo);
109         String JavaDoc path;
110         File JavaDoc file;
111
112         path = sysinfo.getConfigurationFileRfsPath();
113         assertNotNull(path);
114         path = path.trim();
115         assertEquals(true, path.length() != 0);
116         file = new File JavaDoc(path).getAbsoluteFile();
117         assertEquals(true, file.exists());
118         assertEquals(true, file.isFile());
119     }
120
121     /**
122      * Tests {@link CmsSystemInfo#getAbsoluteRfsPathRelativeToWebApplication(String)}.
123      * <p>
124      *
125      */

126     public void testGetAbsoluteRfsPathRelativeToWebApplication() {
127
128         CmsSystemInfo sysinfo = OpenCms.getSystemInfo();
129         assertNotNull(sysinfo);
130         String JavaDoc path;
131         File JavaDoc file;
132
133         path = sysinfo.getAbsoluteRfsPathRelativeToWebApplication("");
134         assertNotNull(path);
135         path = path.trim();
136         assertEquals(true, path.length() != 0);
137         file = new File JavaDoc(path).getAbsoluteFile();
138         assertEquals(true, file.exists());
139         assertEquals(true, file.isDirectory());
140
141         path = sysinfo.getAbsoluteRfsPathRelativeToWebApplication("WEB-INF");
142         assertNotNull(path);
143         path = path.trim();
144         assertEquals(true, path.length() != 0);
145         file = new File JavaDoc(path).getAbsoluteFile();
146         assertEquals(true, file.exists());
147         assertEquals(true, file.isDirectory());
148
149         path = sysinfo.getAbsoluteRfsPathRelativeToWebApplication("WEB-INF/log/opencms.log");
150         assertNotNull(path);
151         path = path.trim();
152         assertEquals(true, path.length() != 0);
153         file = new File JavaDoc(path).getAbsoluteFile();
154         assertEquals(file.getAbsolutePath() + " does not exist.", true, file.exists());
155         assertEquals(true, file.isFile());
156
157     }
158
159     /**
160      * Tests {@link CmsSystemInfo#getAbsoluteRfsPathRelativeToWebInf(String)}.
161      * <p>
162      *
163      */

164     public void testGetAbsoluteRfsPathRelativeToWebInf() {
165
166         CmsSystemInfo sysinfo = OpenCms.getSystemInfo();
167         assertNotNull(sysinfo);
168         String JavaDoc path;
169         File JavaDoc file;
170
171         path = sysinfo.getAbsoluteRfsPathRelativeToWebInf("");
172         assertNotNull(path);
173         path = path.trim();
174         assertEquals(true, path.length() != 0);
175         file = new File JavaDoc(path).getAbsoluteFile();
176         assertEquals(true, file.exists());
177         assertEquals(true, file.isDirectory());
178
179         path = sysinfo.getAbsoluteRfsPathRelativeToWebInf(CmsSystemInfo.FOLDER_CONFIG);
180         assertNotNull(path);
181         path = path.trim();
182         assertEquals(true, path.length() != 0);
183         file = new File JavaDoc(path).getAbsoluteFile();
184         assertEquals(path + " does not exist.", true, file.exists());
185         assertEquals(true, file.isDirectory());
186
187         path = sysinfo.getAbsoluteRfsPathRelativeToWebInf(CmsSystemInfo.FOLDER_CONFIG
188             + CmsSearchConfiguration.DEFAULT_XML_FILE_NAME);
189         assertNotNull(path);
190         path = path.trim();
191         assertEquals(true, path.length() != 0);
192         file = new File JavaDoc(path).getAbsoluteFile();
193         assertEquals(file.getAbsolutePath() + " does not exist.", true, file.exists());
194         assertEquals(true, file.isFile());
195     }
196 }
197
Popular Tags