KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > loader > AbstractCacheLoaderTestBase


1 /*
2  * JBoss, Home of Professional Open Source
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.cache.loader;
8
9 import junit.framework.TestCase;
10 import org.apache.commons.logging.Log;
11 import org.apache.commons.logging.LogFactory;
12 import org.jboss.cache.config.CacheLoaderConfig;
13 import org.jboss.cache.factories.XmlConfigurationParser;
14 import org.jboss.cache.xml.XmlHelper;
15 import org.w3c.dom.Element JavaDoc;
16
17 /**
18  * Very basic test case that provides methods to create a cache loader config.
19  *
20  * @author <a HREF="mailto:manik@jboss.org">Manik Surtani (manik@jboss.org)</a>
21  */

22 public abstract class AbstractCacheLoaderTestBase extends TestCase
23 {
24
25    protected final Log log = LogFactory.getLog(getClass());
26
27    public AbstractCacheLoaderTestBase(String JavaDoc name)
28    {
29       super(name);
30    }
31
32    public AbstractCacheLoaderTestBase()
33    {
34    }
35
36    protected void setUp() throws Exception JavaDoc
37    {
38       log.debug("");
39       log.debug("test " + getName());
40    }
41
42
43    protected CacheLoaderConfig getSingleCacheLoaderConfig(String JavaDoc preload, String JavaDoc cacheloaderClass, String JavaDoc properties, boolean async, boolean fetchPersistentState, boolean shared) throws Exception JavaDoc
44    {
45       return getSingleCacheLoaderConfig(preload, cacheloaderClass, properties, async, fetchPersistentState, shared, false);
46    }
47
48    protected CacheLoaderConfig getSingleCacheLoaderConfig(String JavaDoc preload, String JavaDoc cacheloaderClass, String JavaDoc properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception JavaDoc
49    {
50       return getSingleCacheLoaderConfig(false, preload, cacheloaderClass, properties, async, fetchPersistentState, shared, purgeOnStartup);
51    }
52
53    protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String JavaDoc preload, String JavaDoc cacheloaderClass, String JavaDoc properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception JavaDoc
54    {
55       String JavaDoc xml = "<config>\n" +
56               "<passivation>" + passivation + "</passivation>\n" +
57               "<preload>" + preload + "</preload>\n" +
58               "<cacheloader>\n" +
59               "<class>" + cacheloaderClass + "</class>\n" +
60               "<properties>" + properties + "</properties>\n" +
61               "<async>" + async + "</async>\n" +
62               "<shared>" + shared + "</shared>\n" +
63               "<fetchPersistentState>" + fetchPersistentState + "</fetchPersistentState>\n" +
64               "<purgeOnStartup>" + purgeOnStartup + "</purgeOnStartup>\n" +
65               "</cacheloader>\n" +
66               "</config>";
67       Element JavaDoc element = XmlHelper.stringToElement(xml);
68       return XmlConfigurationParser.parseCacheLoaderConfig(element);
69    }
70 }
71
Popular Tags