1   /* Copyright 2004, 2005 Acegi Technology Pty Limited
2    *
3    * Licensed under the Apache License, Version 2.0 (the "License");
4    * you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    *     http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  
16  package org.acegisecurity.util;
17  
18  import java.io.IOException;
19  
20  import javax.servlet.Filter;
21  import javax.servlet.FilterChain;
22  import javax.servlet.FilterConfig;
23  import javax.servlet.ServletException;
24  import javax.servlet.ServletRequest;
25  import javax.servlet.ServletResponse;
26  
27  
28  /***
29   * A simple filter that the test case can delegate to.
30   *
31   * @author Ben Alex
32   * @version $Id: MockFilter.java,v 1.3 2005/11/17 00:56:08 benalex Exp $
33   */
34  public class MockFilter implements Filter {
35      //~ Instance fields ========================================================
36  
37      private boolean wasDestroyed = false;
38      private boolean wasDoFiltered = false;
39      private boolean wasInitialized = false;
40  
41      //~ Methods ================================================================
42  
43      public boolean isWasDestroyed() {
44          return wasDestroyed;
45      }
46  
47      public boolean isWasDoFiltered() {
48          return wasDoFiltered;
49      }
50  
51      public boolean isWasInitialized() {
52          return wasInitialized;
53      }
54  
55      public void destroy() {
56          wasDestroyed = true;
57      }
58  
59      public void doFilter(ServletRequest request, ServletResponse response,
60          FilterChain chain) throws IOException, ServletException {
61          wasDoFiltered = true;
62          chain.doFilter(request, response);
63      }
64  
65      public void init(FilterConfig config) throws ServletException {
66          wasInitialized = true;
67      }
68  }