1 16 17 package org.apache.commons.configuration.web; 18 19 import org.apache.commons.configuration.AbstractConfiguration; 20 import org.apache.commons.configuration.TestAbstractConfiguration; 21 22 import javax.servlet.FilterConfig ; 23 import javax.servlet.ServletContext ; 24 import java.util.Enumeration ; 25 import java.util.Properties ; 26 27 33 public class TestServletFilterConfiguration extends TestAbstractConfiguration 34 { 35 protected AbstractConfiguration getConfiguration() 36 { 37 MockFilterConfig config = new MockFilterConfig(); 38 config.setInitParameter("key1", "value1"); 39 config.setInitParameter("key2", "value2"); 40 config.setInitParameter("list", "value1, value2"); 41 42 return new ServletFilterConfiguration(config); 43 } 44 45 protected AbstractConfiguration getEmptyConfiguration() 46 { 47 return new ServletFilterConfiguration(new MockFilterConfig()); 48 } 49 50 private class MockFilterConfig implements FilterConfig 51 { 52 private Properties parameters = new Properties (); 53 54 public String getFilterName() 55 { 56 return null; 57 } 58 59 public ServletContext getServletContext() 60 { 61 return null; 62 } 63 64 public String getInitParameter(String key) 65 { 66 return parameters.getProperty(key); 67 } 68 69 public Enumeration getInitParameterNames() 70 { 71 return parameters.keys(); 72 } 73 74 public void setInitParameter(String key, String value) 75 { 76 parameters.setProperty(key, value); 77 } 78 } 79 80 public void testAddPropertyDirect() 81 { 82 try 83 { 84 super.testAddPropertyDirect(); 85 fail("addPropertyDirect should throw an UnsupportedException"); 86 } 87 catch (UnsupportedOperationException e) 88 { 89 } 91 } 92 93 public void testClearProperty() 94 { 95 try 96 { 97 super.testClearProperty(); 98 fail("testClearProperty should throw an UnsupportedException"); 99 } 100 catch (UnsupportedOperationException e) 101 { 102 } 104 } 105 106 } 107 | Popular Tags |