1 |
| package org.jboss.cache.loader; |
2 |
| |
3 |
| import junit.framework.Test; |
4 |
| import junit.framework.TestSuite; |
5 |
| |
6 |
| import java.io.File; |
7 |
| import java.io.FileFilter; |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| public class JdbmCacheLoaderTest extends CacheLoaderTestsBase |
16 |
| { |
17 |
| |
18 |
| private String tmp_location = System.getProperty("java.io.tmpdir", "/tmp"); |
19 |
| private File dir = new File(tmp_location); |
20 |
| |
21 |
59
| public JdbmCacheLoaderTest()
|
22 |
| { |
23 |
0
| if (!dir.exists()) dir.mkdirs();
|
24 |
| } |
25 |
| |
26 |
59
| protected void configureCache() throws Exception
|
27 |
| { |
28 |
| |
29 |
| class MyFilter implements FileFilter |
30 |
| { |
31 |
4071
| public boolean accept(File file)
|
32 |
| { |
33 |
4071
| return file.getName().endsWith(".db");
|
34 |
| } |
35 |
| } |
36 |
| |
37 |
59
| File[] files = dir.listFiles(new MyFilter());
|
38 |
59
| if (files != null)
|
39 |
| { |
40 |
59
| for (int i = 0; i < files.length; i += 1)
|
41 |
| { |
42 |
59
| File file = files[i];
|
43 |
59
| if (file.isFile())
|
44 |
| { |
45 |
59
| if (!file.delete())
|
46 |
| { |
47 |
0
| System.err.println("Unable to delete: " + file);
|
48 |
| } |
49 |
| } |
50 |
| } |
51 |
| } |
52 |
| |
53 |
59
| cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.jdbm.JdbmCacheLoader", "", false, true, false));
|
54 |
| } |
55 |
| |
56 |
1
| public static Test suite()
|
57 |
| { |
58 |
1
| return new TestSuite(JdbmCacheLoaderTest.class);
|
59 |
| } |
60 |
| |
61 |
0
| public static void main(String[] args)
|
62 |
| { |
63 |
0
| junit.textui.TestRunner.run(suite());
|
64 |
| } |
65 |
| |
66 |
| } |