001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.test.web; 017 018import io.jboot.core.JbootCoreConfig; 019 020import javax.servlet.FilterConfig; 021import javax.servlet.ServletContext; 022import java.util.Collections; 023import java.util.Enumeration; 024import java.util.HashMap; 025import java.util.Map; 026 027public class MockFilterConfig implements FilterConfig { 028 029 protected Map<String,String> initParameters = new HashMap<>(); 030 protected ServletContext servletContext = MockServletContext.DEFAULT; 031 032 public MockFilterConfig() { 033 initParameters.put("configClass", JbootCoreConfig.class.getName()); 034 } 035 036 @Override 037 public String getFilterName() { 038 return "mockFilter"; 039 } 040 041 @Override 042 public ServletContext getServletContext() { 043 return servletContext; 044 } 045 046 public void setServletContext(ServletContext servletContext) { 047 this.servletContext = servletContext; 048 } 049 050 @Override 051 public String getInitParameter(String name) { 052 return initParameters.get(name); 053 } 054 055 @Override 056 public Enumeration<String> getInitParameterNames() { 057 return Collections.enumeration(initParameters.keySet()); 058 } 059}