1 16 17 package org.springframework.mock.web; 18 19 import java.util.Enumeration ; 20 import java.util.Properties ; 21 22 import javax.servlet.FilterConfig ; 23 import javax.servlet.ServletContext ; 24 25 import org.springframework.util.Assert; 26 27 38 public class MockFilterConfig implements FilterConfig { 39 40 private final ServletContext servletContext; 41 42 private final String filterName; 43 44 private final Properties initParameters = new Properties (); 45 46 47 50 public MockFilterConfig() { 51 this(null, ""); 52 } 53 54 58 public MockFilterConfig(String filterName) { 59 this(null, filterName); 60 } 61 62 66 public MockFilterConfig(ServletContext servletContext) { 67 this(servletContext, ""); 68 } 69 70 75 public MockFilterConfig(ServletContext servletContext, String filterName) { 76 this.servletContext = (servletContext != null ? servletContext : new MockServletContext()); 77 this.filterName = filterName; 78 } 79 80 81 public String getFilterName() { 82 return filterName; 83 } 84 85 public ServletContext getServletContext() { 86 return servletContext; 87 } 88 89 public void addInitParameter(String name, String value) { 90 Assert.notNull(name, "Parameter name must not be null"); 91 this.initParameters.setProperty(name, value); 92 } 93 94 public String getInitParameter(String name) { 95 Assert.notNull(name, "Parameter name must not be null"); 96 return this.initParameters.getProperty(name); 97 } 98 99 public Enumeration getInitParameterNames() { 100 return this.initParameters.keys(); 101 } 102 103 } 104 | Popular Tags |