1 31 32 package org.opencms.cache; 33 34 import org.opencms.file.CmsResource; 35 import org.opencms.test.OpenCmsTestCase; 36 import org.opencms.test.OpenCmsTestProperties; 37 38 import junit.extensions.TestSetup; 39 import junit.framework.Test; 40 import junit.framework.TestSuite; 41 42 51 public class TestCache extends OpenCmsTestCase { 52 53 58 public TestCache(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(TestCache.class.getName()); 74 75 suite.addTest(new TestCache("testVfsMemoryObjectCache")); 76 77 TestSetup wrapper = new TestSetup(suite) { 78 79 protected void setUp() { 80 81 setupOpenCms("simpletest", "/sites/default/"); 82 } 83 84 protected void tearDown() { 85 86 removeOpenCms(); 87 } 88 }; 89 90 return wrapper; 91 } 92 93 98 public void testVfsMemoryObjectCache() throws Exception { 99 100 CmsVfsMemoryObjectCache cache = CmsVfsMemoryObjectCache.getVfsMemoryObjectCache(); 102 103 104 String res1RootPath ="/sites/default/index.html"; 105 String res1Path ="/index.html"; 106 CmsResource res1; 107 108 Object o = cache.getCachedObject(getCmsObject(), res1RootPath); 110 assertNull(o); 112 113 res1 = getCmsObject().readResource(res1Path); 115 cache.putCachedObject(getCmsObject(), res1RootPath, res1); 116 117 o = cache.getCachedObject(getCmsObject(), res1RootPath); 119 assertEquals(o, res1); 121 122 getCmsObject().lockResource(res1Path); 124 getCmsObject().setDateLastModified(res1Path, 12345, false); 125 getCmsObject().unlockResource(res1Path); 126 127 res1 = getCmsObject().readResource(res1Path); 129 o = cache.getCachedObject(getCmsObject(), res1RootPath); 130 assertNull(o); 132 133 } 134 135 136 137 138 } 139 | Popular Tags |