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; |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| public class PassivationToFileCacheLoaderTest extends PassivationTestsBase |
17 |
| { |
18 |
| |
19 |
| |
20 |
45
| protected void configureCache() throws Exception
|
21 |
| { |
22 |
| |
23 |
45
| String tmp_location = null;
|
24 |
45
| String OS = System.getProperty("os.name").toLowerCase();
|
25 |
45
| if (OS.contains("win") || OS.contains("nt"))
|
26 |
| { |
27 |
0
| tmp_location = System.getProperty("java.io.tmpdir", "c:\\tmp");
|
28 |
| } |
29 |
| else |
30 |
| { |
31 |
45
| tmp_location = System.getProperty("jva.io.tmpdir", "/tmp");
|
32 |
| } |
33 |
| |
34 |
45
| cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig(tmp_location));
|
35 |
| } |
36 |
| |
37 |
45
| protected CacheLoaderConfig getCacheLoaderConfig(String loc) throws Exception
|
38 |
| { |
39 |
45
| String 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 |
45
| Element element = XmlHelper.stringToElement(xml);
|
55 |
45
| return XmlConfigurationParser.parseCacheLoaderConfig(element);
|
56 |
| } |
57 |
| |
58 |
| |
59 |
1
| public static Test suite()
|
60 |
| { |
61 |
1
| return new TestSuite(PassivationToFileCacheLoaderTest.class);
|
62 |
| } |
63 |
| |
64 |
| |
65 |
0
| public static void main(String[] args)
|
66 |
| { |
67 |
0
| junit.textui.TestRunner.run(suite());
|
68 |
| } |
69 |
| |
70 |
| } |