KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > cache > tests > BdbjeCacheLoaderTest


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.cache.tests;
8
9 import junit.framework.Test;
10 import junit.framework.TestSuite;
11
12 import java.io.File JavaDoc;
13 import java.io.FileFilter JavaDoc;
14 import java.util.Properties JavaDoc;
15
16 /**
17  * Runs the same tests as {@link FileCacheLoaderTest}, but with Berkeley DB instead of a file-based CacheLoader
18  * @author Bela Ban
19  * @Version $Id: BdbjeCacheLoaderTest.java,v 1.3.2.3 2005/04/06 21:07:02 starksm Exp $
20  */

21 public class BdbjeCacheLoaderTest extends CacheLoaderTestsBase {
22
23
24    protected void configureCache() throws Exception JavaDoc {
25       File JavaDoc dir = new File JavaDoc(".");
26
27       class MyFilter implements FileFilter JavaDoc {
28          public boolean accept(File JavaDoc file) {
29             return file.getName().endsWith(".jdb");
30          }
31       }
32
33       File JavaDoc[] files=dir.listFiles(new MyFilter());
34       if (files != null) {
35          for (int i = 0; i < files.length; i += 1) {
36             File JavaDoc file = files[i];
37             if (file.isFile()) {
38                if (!file.delete()) {
39                   System.err.println("Unable to delete: " + file);
40                }
41             }
42          }
43       }
44
45       cache.setCacheLoaderClass("org.jboss.cache.loader.bdbje.BdbjeCacheLoader");
46       Properties JavaDoc props=new Properties JavaDoc();
47       props.setProperty("location", ".#temp");
48       cache.setCacheLoaderConfig(props);
49    }
50
51
52    public static Test suite() {
53       return new TestSuite(BdbjeCacheLoaderTest.class);
54    }
55
56
57
58 }
59
Popular Tags