1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache.passivation; |
8 |
| |
9 |
| import junit.framework.Test; |
10 |
| import junit.framework.TestSuite; |
11 |
| |
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; |
16 |
| |
17 |
| import java.util.Properties; |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase |
27 |
| { |
28 |
| |
29 |
| |
30 |
45
| protected CacheLoaderConfig getCacheLoaderConfig() throws Exception
|
31 |
| { |
32 |
45
| String xml = " <config>\n" +
|
33 |
| " \n" + |
34 |
| " <passivation>true</passivation>\n" + |
35 |
| " <preload></preload>\n" + |
36 |
| "\n" + |
37 |
| " <cacheloader>\n" + |
38 |
| " <class>org.jboss.cache.loader.JDBCCacheLoader</class>\n" + |
39 |
| " <properties>\n" + |
40 |
| getJDBCProps() + |
41 |
| " </properties>\n" + |
42 |
| " <async>false</async>\n" + |
43 |
| " <fetchPersistentState>false</fetchPersistentState>\n" + |
44 |
| " <ignoreModifications>false</ignoreModifications>\n" + |
45 |
| " </cacheloader>\n" + |
46 |
| " \n" + |
47 |
| " </config>"; |
48 |
45
| Element element = XmlHelper.stringToElement(xml);
|
49 |
45
| return XmlConfigurationParser.parseCacheLoaderConfig(element);
|
50 |
| } |
51 |
| |
52 |
| |
53 |
45
| protected String getJDBCProps() throws Exception
|
54 |
| { |
55 |
45
| Properties prop = new Properties();
|
56 |
45
| try
|
57 |
| { |
58 |
45
| prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
|
59 |
| } |
60 |
| catch (Exception e) |
61 |
| { |
62 |
0
| System.out.println("Error loading jdbc properties ");
|
63 |
| } |
64 |
45
| return "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
|
65 |
| "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" + |
66 |
| "cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" + |
67 |
| "cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" + |
68 |
| "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type"); |
69 |
| } |
70 |
| |
71 |
45
| protected void configureCache() throws Exception
|
72 |
| { |
73 |
45
| cache.getConfiguration().setCacheLoaderConfig(getCacheLoaderConfig());
|
74 |
| } |
75 |
| |
76 |
1
| public static Test suite()
|
77 |
| { |
78 |
1
| return new TestSuite(PassivationToJDBCCacheLoaderTest.class);
|
79 |
| } |
80 |
| |
81 |
0
| public static void main(String[] args)
|
82 |
| { |
83 |
0
| junit.textui.TestRunner.run(suite());
|
84 |
| } |
85 |
| } |