1 31 32 package org.opencms.file.types; 33 34 import org.opencms.file.CmsObject; 35 import org.opencms.file.CmsProperty; 36 import org.opencms.file.CmsPropertyDefinition; 37 import org.opencms.file.CmsResource; 38 import org.opencms.file.CmsResourceFilter; 39 import org.opencms.test.OpenCmsTestCase; 40 import org.opencms.test.OpenCmsTestProperties; 41 42 import java.util.List ; 43 44 import junit.extensions.TestSetup; 45 import junit.framework.Test; 46 import junit.framework.TestSuite; 47 48 54 public class TestConfigurationOptions extends OpenCmsTestCase { 55 56 61 public TestConfigurationOptions(String arg0) { 62 63 super(arg0); 64 } 65 66 71 public static Test suite() { 72 73 OpenCmsTestProperties.initialize(org.opencms.test.AllTests.TEST_PROPERTIES_PATH); 74 75 TestSuite suite = new TestSuite(); 76 suite.setName(TestConfigurationOptions.class.getName()); 77 78 suite.addTest(new TestConfigurationOptions("testDefaultPropertyCreation")); 79 suite.addTest(new TestConfigurationOptions("testCopyResourcesOnCreation")); 80 81 TestSetup wrapper = new TestSetup(suite) { 82 83 protected void setUp() { 84 85 setupOpenCms("simpletest", "/sites/default/"); 86 } 87 88 protected void tearDown() { 89 90 removeOpenCms(); 91 } 92 }; 93 94 return wrapper; 95 } 96 97 102 public void testCopyResourcesOnCreation() throws Throwable { 103 104 CmsObject cms = getCmsObject(); 105 echo("Testing 'copy resources' on resource creation"); 106 107 String resourcename = "/newlinkgallery/"; 109 110 cms.createResource(resourcename, 11); 111 112 List subResources = cms.readResources(resourcename, CmsResourceFilter.ALL); 113 assertTrue(subResources.size() > 15); 114 115 CmsResource res; 117 118 res = cms.readResource(resourcename + "newname.html"); 119 assertTrue(res.getSiblingCount() == 2); 121 122 cms.readResource(resourcename + "mytypes"); 123 res = cms.readResource(resourcename + "mytypes/text.txt"); 124 assertTrue(res.getSiblingCount() == 1); 126 127 cms.readResource(resourcename + "subfolder11"); 128 cms.readResource(resourcename + "subfolder11/subsubfolder111"); 129 } 130 131 136 public void testDefaultPropertyCreation() throws Throwable { 137 138 CmsObject cms = getCmsObject(); 139 echo("Testing default property creation"); 140 141 String resourcename = "/folder1/article_test.html"; 142 byte[] content = new byte[0]; 143 144 cms.createResource(resourcename, 12, content, null); 146 147 assertResourceType(cms, resourcename, 12); 149 assertProject(cms, resourcename, cms.getRequestContext().currentProject()); 151 assertState(cms, resourcename, CmsResource.STATE_NEW); 153 assertUserLastModified(cms, resourcename, cms.getRequestContext().currentUser()); 155 156 CmsProperty property1, property2; 157 property1 = new CmsProperty(CmsPropertyDefinition.PROPERTY_TITLE, "Test title", null); 158 property2 = cms.readPropertyObject(resourcename, CmsPropertyDefinition.PROPERTY_TITLE, false); 159 assertTrue(property1.isIdentical(property2)); 160 161 property1 = new CmsProperty( 162 "template-elements", 163 "/system/modules/org.opencms.frontend.templateone.form/pages/form.html", 164 null); 165 property2 = cms.readPropertyObject(resourcename, "template-elements", false); 166 assertTrue(property1.isIdentical(property2)); 167 168 property1 = new CmsProperty( 169 CmsPropertyDefinition.PROPERTY_DESCRIPTION, 170 null, 171 "Admin_/folder1/article_test.html_/sites/default/folder1/article_test.html"); 172 property2 = cms.readPropertyObject(resourcename, CmsPropertyDefinition.PROPERTY_DESCRIPTION, false); 173 assertTrue(property1.isIdentical(property2)); 174 175 cms.unlockProject(cms.getRequestContext().currentProject().getId()); 177 cms.publishProject(); 178 179 assertState(cms, resourcename, CmsResource.STATE_UNCHANGED); 180 } 181 } 182 | Popular Tags |