Author: taylor Date: Thu Nov 12 02:44:59 2015 New Revision: 1713961 URL: http://svn.apache.org/viewvc?rev=1713961&view=rev Log: use recommended cache initialization for tests
Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestDecorationContentCache.java Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java?rev=1713961&r1=1713960&r2=1713961&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestContentCache.java Thu Nov 12 02:44:59 2015 @@ -16,18 +16,12 @@ */ package org.apache.jetspeed.cache; -import java.io.PrintWriter; -import java.security.Principal; -import java.util.LinkedList; -import java.util.List; - -import javax.portlet.PortletMode; -import javax.portlet.WindowState; - +import com.mockrunner.mock.web.MockHttpServletRequest; +import com.mockrunner.mock.web.MockHttpServletResponse; +import com.mockrunner.mock.web.MockHttpSession; import junit.framework.TestCase; import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; - import org.apache.jetspeed.aggregator.PortletContent; import org.apache.jetspeed.cache.impl.EhCacheConfigResource; import org.apache.jetspeed.cache.impl.EhPortletContentCacheImpl; @@ -36,9 +30,12 @@ import org.apache.jetspeed.mockobjects.r import org.apache.jetspeed.portlet.HeadElement; import org.apache.jetspeed.util.KeyValue; -import com.mockrunner.mock.web.MockHttpServletRequest; -import com.mockrunner.mock.web.MockHttpServletResponse; -import com.mockrunner.mock.web.MockHttpSession; +import javax.portlet.PortletMode; +import javax.portlet.WindowState; +import java.io.PrintWriter; +import java.security.Principal; +import java.util.LinkedList; +import java.util.List; /** * <p> @@ -58,7 +55,7 @@ public class TestContentCache extends Te { // initialize ehCache EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true); - CacheManager cacheManager = new CacheManager(); + CacheManager cacheManager = CacheManager.create(); Cache ehContentCache = new Cache("ehPortletContentCache", 10000, false, false, 28800, 28800); cacheManager.addCache(ehContentCache); ehContentCache.setCacheManager(cacheManager); @@ -116,7 +113,7 @@ public class TestContentCache extends Te assertTrue(contentCache.isKeyInCache(cckey2)); // test user stuff - request.setUserPrincipal(new MockPrincipal("sean")); + request.setUserPrincipal(new MockPrincipal("sean")); // create a simple key String window3 = "555-03"; ContentCacheKey cckey3 = contentCache.createCacheKey(context, window3); @@ -140,19 +137,20 @@ public class TestContentCache extends Te // assert 3 and 4 assertTrue(contentCache.isKeyInCache(cckey3)); assertTrue(contentCache.isKeyInCache(cckey4)); - + // remove for user contentCache.evictContentForUser("sean"); assertFalse(contentCache.isKeyInCache(cckey3)); assertFalse(contentCache.isKeyInCache(cckey4)); - assertTrue(contentCache.isKeyInCache(cckey2)); + assertTrue(contentCache.isKeyInCache(cckey2)); + cacheManager.shutdown(); } public void testContentCacheBySession() throws Exception { // initialize ehCache EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true); - CacheManager cacheManager = new CacheManager(); + CacheManager cacheManager = CacheManager.create(); Cache ehContentCache = new Cache("ehPortletContentCache", 10000, false, false, 28800, 28800); cacheManager.addCache(ehContentCache); ehContentCache.setCacheManager(cacheManager); @@ -217,7 +215,7 @@ public class TestContentCache extends Te session = new MockHttpSession(); request.setSession(session); sessionId = session.getId(); - request.setUserPrincipal(new MockPrincipal("sean")); + request.setUserPrincipal(new MockPrincipal("sean")); // create a simple key String window3 = "555-03"; ContentCacheKey cckey3 = contentCache.createCacheKey(context, window3); @@ -241,12 +239,13 @@ public class TestContentCache extends Te // assert 3 and 4 assertTrue(contentCache.isKeyInCache(cckey3)); assertTrue(contentCache.isKeyInCache(cckey4)); - + // remove for user contentCache.evictContentForSession(sessionId); assertFalse(contentCache.isKeyInCache(cckey3)); assertFalse(contentCache.isKeyInCache(cckey4)); - assertTrue(contentCache.isKeyInCache(cckey2)); + assertTrue(contentCache.isKeyInCache(cckey2)); + cacheManager.shutdown(); } class MockPrincipal implements Principal Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestDecorationContentCache.java URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestDecorationContentCache.java?rev=1713961&r1=1713960&r2=1713961&view=diff ============================================================================== --- portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestDecorationContentCache.java (original) +++ portals/jetspeed-2/portal/trunk/components/jetspeed-cm/src/test/java/org/apache/jetspeed/cache/TestDecorationContentCache.java Thu Nov 12 02:44:59 2015 @@ -16,23 +16,21 @@ */ package org.apache.jetspeed.cache; -import java.io.Serializable; -import java.security.Principal; -import java.util.LinkedList; -import java.util.List; - +import com.mockrunner.mock.web.MockHttpServletRequest; +import com.mockrunner.mock.web.MockHttpServletResponse; +import com.mockrunner.mock.web.MockHttpSession; import junit.framework.TestCase; import net.sf.ehcache.Cache; import net.sf.ehcache.CacheManager; - import org.apache.jetspeed.cache.impl.EhCacheConfigResource; import org.apache.jetspeed.cache.impl.EhDecorationContentCacheImpl; import org.apache.jetspeed.cache.impl.JetspeedCacheKeyGenerator; import org.apache.jetspeed.mockobjects.request.MockRequestContext; -import com.mockrunner.mock.web.MockHttpServletRequest; -import com.mockrunner.mock.web.MockHttpServletResponse; -import com.mockrunner.mock.web.MockHttpSession; +import java.io.Serializable; +import java.security.Principal; +import java.util.LinkedList; +import java.util.List; /** * <p> @@ -52,7 +50,7 @@ public class TestDecorationContentCache { // initialize ehCache EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true); - CacheManager cacheManager = new CacheManager(); + CacheManager cacheManager = CacheManager.create(); Cache ehContentCache = new Cache("ehDecorationContentCache", 10000, false, false, 28800, 28800); cacheManager.addCache(ehContentCache); ehContentCache.setCacheManager(cacheManager); @@ -139,14 +137,15 @@ public class TestDecorationContentCache contentCache.evictContentForUser("sean"); assertFalse(contentCache.isKeyInCache(cckey3)); assertFalse(contentCache.isKeyInCache(cckey4)); - assertTrue(contentCache.isKeyInCache(cckey2)); + assertTrue(contentCache.isKeyInCache(cckey2)); + cacheManager.shutdown(); } public void testContentCacheBySession() throws Exception { // initialize ehCache EhCacheConfigResource.getInstance(EhCacheConfigResource.EHCACHE_CONFIG_RESOURCE_DEFAULT, true); - CacheManager cacheManager = new CacheManager(); + CacheManager cacheManager = CacheManager.create(); Cache ehContentCache = new Cache("ehDecorationContentCache", 10000, false, false, 28800, 28800); cacheManager.addCache(ehContentCache); ehContentCache.setCacheManager(cacheManager); @@ -240,7 +239,8 @@ public class TestDecorationContentCache contentCache.evictContentForSession(sessionId); assertFalse(contentCache.isKeyInCache(cckey3)); assertFalse(contentCache.isKeyInCache(cckey4)); - assertTrue(contentCache.isKeyInCache(cckey2)); + assertTrue(contentCache.isKeyInCache(cckey2)); + cacheManager.shutdown(); } class MockPrincipal implements Principal --------------------------------------------------------------------- To unsubscribe, e-mail: jetspeed-dev-unsubscr...@portals.apache.org For additional commands, e-mail: jetspeed-dev-h...@portals.apache.org