1 package com.mockobjects.helpers; 2 3 import com.mockobjects.servlet.MockFilterChain; 4 import com.mockobjects.servlet.MockFilterConfig; 5 6 import javax.servlet.Filter ; 7 import javax.servlet.ServletException ; 8 import java.io.IOException ; 9 10 13 public class FilterTestHelper extends AbstractServletTestHelper { 14 private final Filter filter; 15 private final MockFilterChain filterChain = new MockFilterChain(); 16 private final MockFilterConfig filterConfig = new MockFilterConfig(); 17 18 public FilterTestHelper(Filter filter) { 19 this.filter = filter; 20 filterConfig.setupGetServletContext(servletContext); 21 } 22 23 public MockFilterChain getFilterChain() { 24 return filterChain; 25 } 26 27 public MockFilterConfig getFilterConfig() { 28 return filterConfig; 29 } 30 31 public void testInit() throws ServletException { 32 filter.init(filterConfig); 33 } 34 35 public void testDoFilter() throws ServletException , IOException { 36 filter.doFilter(request, response, filterChain); 37 } 38 } 39 | Popular Tags |