1 // $Id: DictionaryTest.java,v 1.1.1.1 2002/09/29 17:26:06 powerpete Exp $
2 package de.jface.util;
3
4 import java.io.ByteArrayInputStream;
5 import java.io.ByteArrayOutputStream;
6
7 import junit.framework.TestCase;
8
9 /***
10 * The test case <code>DictionaryTest</code>
11 * tests the [your text here].
12 *
13 * @author Moritz Petersen
14 * @version $Revision: 1.1.1.1 $
15 */
16 public class DictionaryTest extends TestCase
17 {
18 /***
19 * This constructor creates a new
20 * DictionaryTest test case.
21 */
22 public DictionaryTest(String name)
23 {
24 super(name);
25 }
26
27 /***
28 * This method tests [your text here].
29 */
30 public void testRootKey()
31 {
32 Dictionary d = new Dictionary("root");
33
34 assertEquals(d.getRootKey(), new Key("root"));
35 }
36
37 public void testRead() throws Exception
38 {
39 String xml = "<root><foo><bar>test</bar><test>Hello World!</test></foo></root>";
40 ByteArrayInputStream in = new ByteArrayInputStream(xml.getBytes());
41
42 Dictionary dictionary = Dictionary.create(in);
43 Key root = dictionary.getRootKey();
44
45 assertEquals("test", dictionary.get(root.getKey("foo").getKey("bar")));
46 assertEquals("Hello World!",
47 dictionary.get(root.getKey("foo").getKey("test")));
48 }
49
50 public void testWrite() throws Exception
51 {
52 Dictionary dictionary = new Dictionary("root");
53
54 dictionary.put(dictionary.getRootKey().getKey("foo"), "bar");
55
56 ByteArrayOutputStream out = new ByteArrayOutputStream();
57
58 dictionary.write(out);
59
60 // TODO: finish this test
61 }
62
63 public void testPath()
64 {
65 String expected = "Hello World!";
66 Dictionary dictionary = new Dictionary("test");
67
68 dictionary.put("foo.bar", expected);
69
70 String result = dictionary.get("foo.bar");
71
72 assertEquals(expected, result);
73 result = dictionary.get(dictionary.getRootKey().getKey("foo")
74 .getKey("bar"));
75 assertEquals(expected, result);
76 }
77 }
78
79 // ------1---------2---------3---------4---------5---------6---------7---------8
This page was automatically generated by Maven