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: 439648 $, $Date: 2006-09-02 22:42:10 +0200 (Sa, 02 Sep 2006) $
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
43 return new ServletFilterConfiguration(config);
44 }
45
46 protected AbstractConfiguration getEmptyConfiguration()
47 {
48 return new ServletFilterConfiguration(new MockFilterConfig());
49 }
50
51 private class MockFilterConfig implements FilterConfig
52 {
53 private Properties parameters = new Properties();
54
55 public String getFilterName()
56 {
57 return null;
58 }
59
60 public ServletContext getServletContext()
61 {
62 return null;
63 }
64
65 public String getInitParameter(String key)
66 {
67 return parameters.getProperty(key);
68 }
69
70 public Enumeration getInitParameterNames()
71 {
72 return parameters.keys();
73 }
74
75 public void setInitParameter(String key, String value)
76 {
77 parameters.setProperty(key, value);
78 }
79 }
80
81 public void testAddPropertyDirect()
82 {
83 try
84 {
85 super.testAddPropertyDirect();
86 fail("addPropertyDirect should throw an UnsupportedException");
87 }
88 catch (UnsupportedOperationException e)
89 {
90
91 }
92 }
93
94 public void testClearProperty()
95 {
96 try
97 {
98 super.testClearProperty();
99 fail("testClearProperty should throw an UnsupportedException");
100 }
101 catch (UnsupportedOperationException e)
102 {
103
104 }
105 }
106
107 }