1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| package org.jboss.cache; |
8 |
| |
9 |
| |
10 |
| import junit.framework.Test; |
11 |
| import junit.framework.TestCase; |
12 |
| import junit.framework.TestSuite; |
13 |
| |
14 |
| import java.io.ByteArrayOutputStream; |
15 |
| import java.io.ObjectOutputStream; |
16 |
| import java.util.Set; |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| public class GetKeysTest extends TestCase |
24 |
| { |
25 |
| CacheImpl cache; |
26 |
| |
27 |
2
| public GetKeysTest(String s)
|
28 |
| { |
29 |
2
| super(s);
|
30 |
| } |
31 |
| |
32 |
2
| public void setUp() throws Exception
|
33 |
| { |
34 |
2
| super.setUp();
|
35 |
| } |
36 |
| |
37 |
2
| public void tearDown() throws Exception
|
38 |
| { |
39 |
2
| super.tearDown();
|
40 |
| } |
41 |
| |
42 |
1
| public void testGetKeys() throws Exception
|
43 |
| { |
44 |
1
| cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache();
|
45 |
1
| cache.put("/a/b/c", "name", "Bela Ban");
|
46 |
1
| cache.put("/a/b/c", "age", 40);
|
47 |
1
| cache.put("/a/b/c", "city", "Kreuzlingen");
|
48 |
| |
49 |
1
| Set keys = cache.getKeys("/a/b/c");
|
50 |
1
| log("keys are " + keys);
|
51 |
1
| assertNotNull(keys);
|
52 |
1
| assertEquals(3, keys.size());
|
53 |
| |
54 |
1
| ByteArrayOutputStream outstream = new ByteArrayOutputStream(20);
|
55 |
1
| ObjectOutputStream out = new ObjectOutputStream(outstream);
|
56 |
1
| out.writeObject(keys);
|
57 |
| } |
58 |
| |
59 |
1
| public void testGetChildren() throws Exception
|
60 |
| { |
61 |
1
| cache = (CacheImpl) DefaultCacheFactory.getInstance().createCache();
|
62 |
1
| cache.put("/a/b/c", null);
|
63 |
1
| cache.put("/a/b/c/1", null);
|
64 |
1
| cache.put("/a/b/c/2", null);
|
65 |
1
| cache.put("/a/b/c/3", null);
|
66 |
| |
67 |
1
| Set children = cache.getChildrenNames("/a/b/c");
|
68 |
1
| log("children are " + children);
|
69 |
1
| assertNotNull(children);
|
70 |
1
| assertEquals(3, children.size());
|
71 |
| |
72 |
1
| ByteArrayOutputStream outstream = new ByteArrayOutputStream(20);
|
73 |
1
| ObjectOutputStream out = new ObjectOutputStream(outstream);
|
74 |
1
| out.writeObject(children);
|
75 |
| } |
76 |
| |
77 |
| |
78 |
2
| void log(String msg)
|
79 |
| { |
80 |
2
| System.out.println("-- " + msg);
|
81 |
| } |
82 |
| |
83 |
1
| public static Test suite()
|
84 |
| { |
85 |
1
| return new TestSuite(GetKeysTest.class);
|
86 |
| } |
87 |
| |
88 |
0
| public static void main(String[] args)
|
89 |
| { |
90 |
0
| junit.textui.TestRunner.run(suite());
|
91 |
| } |
92 |
| |
93 |
| } |