1 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 ; 39 40 import junit.extensions.TestSetup; 41 import junit.framework.Test; 42 import junit.framework.TestSuite; 43 44 54 public class TestCmsSystemInfo extends OpenCmsTestCase { 55 56 62 public TestCmsSystemInfo(String arg0) { 63 64 super(arg0); 65 } 66 67 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 105 public void getConfigurationFileRfsPath() { 106 107 CmsSystemInfo sysinfo = OpenCms.getSystemInfo(); 108 assertNotNull(sysinfo); 109 String path; 110 File file; 111 112 path = sysinfo.getConfigurationFileRfsPath(); 113 assertNotNull(path); 114 path = path.trim(); 115 assertEquals(true, path.length() != 0); 116 file = new File (path).getAbsoluteFile(); 117 assertEquals(true, file.exists()); 118 assertEquals(true, file.isFile()); 119 } 120 121 126 public void testGetAbsoluteRfsPathRelativeToWebApplication() { 127 128 CmsSystemInfo sysinfo = OpenCms.getSystemInfo(); 129 assertNotNull(sysinfo); 130 String path; 131 File file; 132 133 path = sysinfo.getAbsoluteRfsPathRelativeToWebApplication(""); 134 assertNotNull(path); 135 path = path.trim(); 136 assertEquals(true, path.length() != 0); 137 file = new File (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 (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 (path).getAbsoluteFile(); 154 assertEquals(file.getAbsolutePath() + " does not exist.", true, file.exists()); 155 assertEquals(true, file.isFile()); 156 157 } 158 159 164 public void testGetAbsoluteRfsPathRelativeToWebInf() { 165 166 CmsSystemInfo sysinfo = OpenCms.getSystemInfo(); 167 assertNotNull(sysinfo); 168 String path; 169 File file; 170 171 path = sysinfo.getAbsoluteRfsPathRelativeToWebInf(""); 172 assertNotNull(path); 173 path = path.trim(); 174 assertEquals(true, path.length() != 0); 175 file = new File (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 (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 (path).getAbsoluteFile(); 193 assertEquals(file.getAbsolutePath() + " does not exist.", true, file.exists()); 194 assertEquals(true, file.isFile()); 195 } 196 } 197 | Popular Tags |