1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.configuration.web;
19
20 import org.apache.commons.configuration.AbstractConfiguration;
21 import org.apache.commons.configuration.TestAbstractConfiguration;
22
23 import javax.servlet.FilterConfig;
24 import javax.servlet.ServletContext;
25 import java.util.Enumeration;
26 import java.util.Properties;
27
28 /***
29 * Test case for the {@link ServletFilterConfiguration} class.
30 *
31 * @author Emmanuel Bourg
32 * @version $Revision: 515306 $, $Date: 2007-03-06 22:15:00 +0100 (Di, 06 Mrz 2007) $
33 */
34 public class TestServletFilterConfiguration extends TestAbstractConfiguration
35 {
36 protected AbstractConfiguration getConfiguration()
37 {
38 MockFilterConfig config = new MockFilterConfig();
39 config.setInitParameter("key1", "value1");
40 config.setInitParameter("key2", "value2");
41 config.setInitParameter("list", "value1, value2");
42 config.setInitParameter("listesc", "value1//,value2");
43
44 return new ServletFilterConfiguration(config);
45 }
46
47 protected AbstractConfiguration getEmptyConfiguration()
48 {
49 return new ServletFilterConfiguration(new MockFilterConfig());
50 }
51
52 private class MockFilterConfig implements FilterConfig
53 {
54 private Properties parameters = new Properties();
55
56 public String getFilterName()
57 {
58 return null;
59 }
60
61 public ServletContext getServletContext()
62 {
63 return null;
64 }
65
66 public String getInitParameter(String key)
67 {
68 return parameters.getProperty(key);
69 }
70
71 public Enumeration getInitParameterNames()
72 {
73 return parameters.keys();
74 }
75
76 public void setInitParameter(String key, String value)
77 {
78 parameters.setProperty(key, value);
79 }
80 }
81
82 public void testAddPropertyDirect()
83 {
84 try
85 {
86 super.testAddPropertyDirect();
87 fail("addPropertyDirect should throw an UnsupportedException");
88 }
89 catch (UnsupportedOperationException e)
90 {
91
92 }
93 }
94
95 public void testClearProperty()
96 {
97 try
98 {
99 super.testClearProperty();
100 fail("testClearProperty should throw an UnsupportedException");
101 }
102 catch (UnsupportedOperationException e)
103 {
104
105 }
106 }
107
108 }