KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jboss.cache.loader;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5 import org.jboss.cache.Fqn;
6
7 /**
8  * Created by IntelliJ IDEA.
9  * User: bela
10  * Date: Jun 9, 2004
11  * Time: 9:05:19 AM
12  */

13 public class FileCacheLoaderTest extends CacheLoaderTestsBase
14 {
15
16    protected void configureCache() throws Exception JavaDoc
17    {
18       cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("", "org.jboss.cache.loader.FileCacheLoader", "", false, true, false));
19    }
20
21    public void testIsCharacterPortableLocation()
22    {
23       FileCacheLoader fcl = new FileCacheLoader();
24
25       Object JavaDoc[][] data = new Object JavaDoc[][] {
26             {"C:\\here\\there.txt", true},
27             {"/home/here/there", true},
28             {"/home/*/jboss", false},
29             {"C:\\>/jgroups/jboss", false},
30             {"/cache/jboss<", false},
31             {"/pojocache|/galder", false},
32             {"/pojocache/gal\"der", false}};
33
34       for (int i=0; i < data.length; i++)
35       {
36          String JavaDoc path = (String JavaDoc)data[i][0];
37          boolean expected = (Boolean JavaDoc)data[i][1];
38          assertEquals(path, expected, fcl.isCharacterPortableLocation(path));
39       }
40    }
41
42    public void testIsCharacterPortableTree()
43    {
44       FileCacheLoader fcl = new FileCacheLoader();
45
46       Object JavaDoc[][] data = new Object JavaDoc[][] {
47             {Fqn.fromString("/a/b/c/d/e"), true},
48             {Fqn.fromString("/a/*/c/d/e"), false},
49             {Fqn.fromString("/a/b/>/d/e"), false},
50             {Fqn.fromString("/a/</c/d/e"), false},
51             {Fqn.fromString("/|/b/c/d/e"), false},
52             {Fqn.fromString("/|/b/c/d/e"), false},
53             {Fqn.fromString("/a/b/c/d/\""), false},
54             {Fqn.fromString("/a/b/c/d/\\"), false},
55             {Fqn.fromString("/a/b/c/d///"), true},
56             {Fqn.fromString("/a/b/c/:/e"), false}, };
57
58       for (int i=0; i < data.length; i++)
59       {
60          Fqn fqn = (Fqn)data[i][0];
61          boolean expected = (Boolean JavaDoc)data[i][1];
62          assertEquals(fqn.toString(), expected, fcl.isCharacterPortableTree(fqn));
63       }
64    }
65
66    public void testIsLengthPortablePath()
67    {
68       FileCacheLoader fcl = new FileCacheLoader();
69
70       Object JavaDoc[][] data = new Object JavaDoc[][] {
71             {"C:\\here\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\web_services\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\webservices\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\data.dat", true},
72             {"C:\\there\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\web_services\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\webservices\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\data.dat", true},
73             {"C:\\deerme\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\web_services\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\webservices\\org\\jboss\\cache\\jgroups\\pojocache\\application\\server\\clustering\\portal\\data.dat", false}};
74
75       for (int i=0; i < data.length; i++)
76       {
77          String JavaDoc path = (String JavaDoc)data[i][0];
78          boolean expected = (Boolean JavaDoc)data[i][1];
79          assertEquals(path, expected, fcl.isLengthPortablePath(path));
80       }
81    }
82
83    public static Test suite()
84    {
85       return new TestSuite(FileCacheLoaderTest.class);
86    }
87
88
89    public static void main(String JavaDoc[] args)
90    {
91       junit.textui.TestRunner.run(suite());
92    }
93
94 }
95
Popular Tags