1 7 package com.inversoft.junit.internal.http; 8 9 10 import java.util.Enumeration ; 11 import java.util.HashMap ; 12 import java.util.Iterator ; 13 import java.util.Map ; 14 15 import javax.servlet.ServletConfig ; 16 import javax.servlet.ServletContext ; 17 18 19 30 public class MockServletConfig implements ServletConfig { 31 32 String servletName; 33 Map initParameters; 34 ServletContext context; 35 36 37 41 public MockServletConfig() { 42 this.context = new MockServletContext(); 43 this.initParameters = new HashMap (); 44 } 45 46 52 public MockServletConfig(String servletName) { 53 this.initParameters = new HashMap (); 54 this.context = new MockServletContext(); 55 this.servletName = servletName; 56 } 57 58 66 public MockServletConfig(ServletContext context) { 67 assert (context != null) : "context == null"; 68 69 this.initParameters = new HashMap (); 70 this.context = context; 71 } 72 73 82 public MockServletConfig(String servletName, ServletContext context) { 83 assert (context != null) : "context == null"; 84 85 this.initParameters = new HashMap (); 86 this.context = context; 87 this.servletName = servletName; 88 } 89 90 91 98 public String getServletName() { 99 return servletName; 100 } 101 102 107 public void setServletName(String servletName) { 108 this.servletName = servletName; 109 } 110 111 119 public ServletContext getServletContext() { 120 return context; 121 } 122 123 126 public String getInitParameter(String name) { 127 return (String ) initParameters.get(name); 128 } 129 130 133 public Enumeration getInitParameterNames() { 134 final Iterator iter = initParameters.keySet().iterator(); 135 return new Enumeration () { 136 public boolean hasMoreElements() { 137 return iter.hasNext(); 138 } 139 public java.lang.Object nextElement() { 140 return iter.next(); 141 } 142 }; 143 } 144 } 145 | Popular Tags |