KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > passivation > PassivationToFileCacheLoaderTest


1 package org.jboss.cache.passivation;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5 import org.jboss.cache.config.CacheLoaderConfig;
6 import org.jboss.cache.factories.XmlConfigurationParser;
7 import org.jboss.cache.xml.XmlHelper;
8 import org.w3c.dom.Element JavaDoc;
9
10 /**
11  * tests passivation using file cache loader
12  *
13  * @author <a HREF="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
14  * @version $Id: PassivationToFileCacheLoaderTest.java,v 1.8 2006/12/30 19:48:47 msurtani Exp $
15  */

16 public class PassivationToFileCacheLoaderTest extends PassivationTestsBase
17 {
18
19
20    protected void configureCache() throws Exception JavaDoc
21    {
22
23       String JavaDoc tmp_location = null;
24       String JavaDoc OS = System.getProperty("os.name").toLowerCase();
25       if (OS.contains("win") || OS.contains("nt"))
26       {
27          tmp_location = System.getProperty("java.io.tmpdir", "c:\\tmp");
28       }
29       else
30       {
31          tmp_location = System.getProperty("jva.io.tmpdir", "/tmp");
32       }
33
34       cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(tmp_location));
35    }
36
37    protected CacheLoaderConfig getCacheLoaderConfig(String JavaDoc loc) throws Exception JavaDoc
38    {
39       String JavaDoc xml = " <config>\n" +
40               " \n" +
41               " <passivation>true</passivation>\n" +
42               " <preload></preload>\n" +
43               "\n" +
44               " <cacheloader>\n" +
45               " <class>org.jboss.cache.loader.FileCacheLoader</class>\n" +
46               " <properties>\n" +
47               " </properties>\n" +
48               " <async>false</async>\n" +
49               " <fetchPersistentState>false</fetchPersistentState>\n" +
50               " <ignoreModifications>false</ignoreModifications>\n" +
51               " </cacheloader>\n" +
52               " \n" +
53               " </config>";
54       Element JavaDoc element = XmlHelper.stringToElement(xml);
55       return XmlConfigurationParser.parseCacheLoaderConfig(element);
56    }
57
58
59    public static Test suite()
60    {
61       return new TestSuite(PassivationToFileCacheLoaderTest.class);
62    }
63
64
65    public static void main(String JavaDoc[] args)
66    {
67       junit.textui.TestRunner.run(suite());
68    }
69
70 }
71
Popular Tags