KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jboss.cache.loader;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5
6 import java.io.File JavaDoc;
7 import java.io.FileFilter JavaDoc;
8
9 /**
10  * Tests {@link org.jboss.cache.loader.jdbm.JdbmCacheLoader}.
11  *
12  * @author Elias Ross
13  * @version $Id: JdbmCacheLoaderTest.java,v 1.6 2006/11/06 23:34:09 genman Exp $
14  */

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