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