1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.jsieve;
21
22 import java.util.HashMap;
23 import java.util.Iterator;
24 import java.util.Map;
25
26 import junit.framework.TestCase;
27
28 import org.apache.jsieve.ConfigurationManager;
29 import org.apache.jsieve.SieveConfigurationException;
30
31
32
33
34 public class ConfigurationManagerTest extends TestCase {
35
36
37
38
39
40 public void testCommandMap() {
41 Map<String, String> map = new HashMap<String, String>();
42
43
44 map.put("if", "org.apache.jsieve.commands.If");
45 map.put("else", "org.apache.jsieve.commands.Else");
46 map.put("elsif", "org.apache.jsieve.commands.Elsif");
47 map.put("require", "org.apache.jsieve.commands.Require");
48 map.put("stop", "org.apache.jsieve.commands.Stop");
49
50
51
52 map.put("keep", "org.apache.jsieve.commands.Keep");
53 map.put("discard", "org.apache.jsieve.commands.Discard");
54 map.put("redirect", "org.apache.jsieve.commands.Redirect");
55
56 map.put("reject", "org.apache.jsieve.commands.optional.Reject");
57 map.put("fileinto", "org.apache.jsieve.commands.optional.FileInto");
58
59 boolean isTestPassed = false;
60 try {
61 Map commandMap = new ConfigurationManager().getCommandMap();
62
63 Iterator mapIter = map.entrySet().iterator();
64 while (mapIter.hasNext()) {
65 Map.Entry entry = (Map.Entry) mapIter.next();
66 assertTrue("Key: " + entry.getKey(), commandMap
67 .containsKey(entry.getKey()));
68 assertTrue("Value: " + entry.getValue(), commandMap.get(
69 entry.getKey()).equals(entry.getValue()));
70 }
71 isTestPassed = true;
72 } catch (SieveConfigurationException e) {
73 }
74 assertTrue(isTestPassed);
75 }
76
77
78
79
80
81 public void testTestMap() {
82 Map<String, String> map = new HashMap<String, String>();
83
84
85 map.put("address", "org.apache.jsieve.tests.Address");
86 map.put("allof", "org.apache.jsieve.tests.AllOf");
87 map.put("anyof", "org.apache.jsieve.tests.AnyOf");
88 map.put("exists", "org.apache.jsieve.tests.Exists");
89 map.put("false", "org.apache.jsieve.tests.False");
90 map.put("header", "org.apache.jsieve.tests.Header");
91 map.put("not", "org.apache.jsieve.tests.Not");
92 map.put("size", "org.apache.jsieve.tests.Size");
93 map.put("true", "org.apache.jsieve.tests.True");
94
95
96 map.put("envelope", "org.apache.jsieve.tests.optional.Envelope");
97
98 boolean isTestPassed = false;
99 try {
100 Map testMap = new ConfigurationManager().getTestMap();
101
102 Iterator mapIter = map.entrySet().iterator();
103 while (mapIter.hasNext()) {
104 Map.Entry entry = (Map.Entry) mapIter.next();
105 assertTrue("Key: " + entry.getKey(), testMap.containsKey(entry
106 .getKey()));
107 assertTrue("Value: " + entry.getValue(), testMap.get(
108 entry.getKey()).equals(entry.getValue()));
109 }
110 isTestPassed = true;
111 } catch (SieveConfigurationException e) {
112 }
113 assertTrue(isTestPassed);
114 }
115
116
117
118
119
120 public void testComparatorMap() {
121 Map<String, String> map = new HashMap<String, String>();
122
123
124 map.put("i;octet", "org.apache.jsieve.comparators.Octet");
125 map
126 .put("i;ascii-casemap",
127 "org.apache.jsieve.comparators.AsciiCasemap");
128
129 boolean isTestPassed = false;
130 try {
131 Map comparatorMap = new ConfigurationManager().getComparatorMap();
132
133 Iterator mapIter = map.entrySet().iterator();
134 while (mapIter.hasNext()) {
135 Map.Entry entry = (Map.Entry) mapIter.next();
136 assertTrue("Key: " + entry.getKey(), comparatorMap
137 .containsKey(entry.getKey()));
138 assertTrue("Value: " + entry.getValue(), comparatorMap.get(
139 entry.getKey()).equals(entry.getValue()));
140 }
141 isTestPassed = true;
142 } catch (SieveConfigurationException e) {
143 }
144 assertTrue(isTestPassed);
145 }
146
147 }