KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > configuration > web > TestServletConfiguration


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License")
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.commons.configuration.web;
18
19 import javax.servlet.Servlet JavaDoc;
20 import javax.servlet.ServletConfig JavaDoc;
21 import javax.servlet.http.HttpServlet JavaDoc;
22
23 import com.mockobjects.servlet.MockServletConfig;
24 import org.apache.commons.configuration.AbstractConfiguration;
25 import org.apache.commons.configuration.TestAbstractConfiguration;
26
27 /**
28  * Test case for the {@link ServletConfiguration} class.
29  *
30  * @author Emmanuel Bourg
31  * @version $Revision: 155408 $, $Date: 2005-02-26 13:56:39 +0100 (Sa, 26 Feb 2005) $
32  */

33 public class TestServletConfiguration extends TestAbstractConfiguration
34 {
35     protected AbstractConfiguration getConfiguration()
36     {
37         final MockServletConfig config = new MockServletConfig();
38         config.setInitParameter("key1", "value1");
39         config.setInitParameter("key2", "value2");
40         config.setInitParameter("list", "value1, value2");
41
42         Servlet JavaDoc servlet = new HttpServlet JavaDoc() {
43             public ServletConfig JavaDoc getServletConfig()
44             {
45                 return config;
46             }
47         };
48
49         return new ServletConfiguration(servlet);
50     }
51
52     protected AbstractConfiguration getEmptyConfiguration()
53     {
54         return new ServletConfiguration(new MockServletConfig());
55     }
56
57     public void testAddPropertyDirect()
58     {
59         try
60         {
61             super.testAddPropertyDirect();
62             fail("addPropertyDirect should throw an UnsupportedException");
63         }
64         catch (UnsupportedOperationException JavaDoc e)
65         {
66             // ok
67
}
68     }
69
70     public void testClearProperty()
71     {
72         try
73         {
74             super.testClearProperty();
75             fail("testClearProperty should throw an UnsupportedException");
76         }
77         catch (UnsupportedOperationException JavaDoc e)
78         {
79             // ok
80
}
81     }
82
83 }
84
Popular Tags