1 31 32 package org.opencms.file; 33 34 import org.opencms.test.OpenCmsTestCase; 35 import org.opencms.test.OpenCmsTestProperties; 36 37 import java.util.List ; 38 39 import junit.extensions.TestSetup; 40 import junit.framework.Test; 41 import junit.framework.TestSuite; 42 43 51 public class TestChangeProperties extends OpenCmsTestCase { 52 53 58 public TestChangeProperties(String arg0) { 59 60 super(arg0); 61 } 62 63 68 public static Test suite() { 69 70 OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH); 71 72 TestSuite suite = new TestSuite(); 73 suite.setName(TestChangeProperties.class.getName()); 74 75 suite.addTest(new TestChangeProperties("testChangeResourcesRelativePath")); 76 suite.addTest(new TestChangeProperties("testChangeResourcesFullPath")); 77 78 TestSetup wrapper = new TestSetup(suite) { 79 80 protected void setUp() { 81 82 setupOpenCms("simpletest", "/sites/default/"); 83 } 84 85 protected void tearDown() { 86 87 removeOpenCms(); 88 } 89 }; 90 91 return wrapper; 92 } 93 94 105 public void testChangeResourcesRelativePath() throws Throwable { 106 107 CmsObject cms = getCmsObject(); 108 109 String resource1 = "/folder1/subfolder11/index.html"; 111 String resource2 = "/folder1/subfolder12/index.html"; 112 cms.lockResource(resource1); 113 cms.lockResource(resource2); 114 assertLock(cms, resource1); 115 assertLock(cms, resource2); 116 117 System.out.println("Changing property of \"" 119 + resource1 120 + "\" in \"" 121 + cms.getRequestContext().getSiteRoot() 122 + "\""); 123 124 List l1 = cms.changeResourcesInFolderWithProperty( 125 resource1, 126 CmsPropertyDefinition.PROPERTY_DESCRIPTION, 127 "This is the index page of subfolder11", 128 "Changed Value", 129 true); 130 131 System.out.println("Changing property of \"" 133 + resource2 134 + "\" in \"" 135 + cms.getRequestContext().getSiteRoot() 136 + "\""); 137 138 List l2 = cms.changeResourcesInFolderWithProperty( 139 resource2, 140 CmsPropertyDefinition.PROPERTY_DESCRIPTION, 141 "This is the index in subfolder12", 142 "Changed value", 143 false); 144 145 assertEquals(l1.size(), l2.size()); 147 } 148 149 160 public void testChangeResourcesFullPath() throws Throwable { 161 162 CmsObject cms = getCmsObject(); 163 164 String resource1 = cms.getRequestContext().getSiteRoot() + "/folder2/subfolder21/index.html"; 166 String resource2 = cms.getRequestContext().getSiteRoot() + "/folder2/subfolder22/index.html"; 167 168 cms.getRequestContext().setSiteRoot(""); 169 170 cms.lockResource(resource1); 171 cms.lockResource(resource2); 172 assertLock(cms, resource1); 173 assertLock(cms, resource2); 174 175 System.out.println("Changing property of \"" 177 + resource1 178 + "\" in \"" 179 + cms.getRequestContext().getSiteRoot() 180 + "\""); 181 182 List l1 = cms.changeResourcesInFolderWithProperty( 183 resource1, 184 CmsPropertyDefinition.PROPERTY_DESCRIPTION, 185 "This is the index page in subfolder21", 186 "Changed Value", 187 true); 188 189 System.out.println("Changing property of \"" 191 + resource2 192 + "\" in \"" 193 + cms.getRequestContext().getSiteRoot() 194 + "\""); 195 196 List l2 = cms.changeResourcesInFolderWithProperty( 197 resource2, 198 CmsPropertyDefinition.PROPERTY_DESCRIPTION, 199 "This is the index page in subfolder22", 200 "Changed value", 201 false); 202 203 assertEquals(l1.size(), l2.size()); 205 } 206 } 207 | Popular Tags |