    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 junit.framework.TestCase;
    19
    20  import javax.servlet.FilterChain;
    21  import javax.servlet.ServletException;
    22  import javax.servlet.ServletRequest;
    23  import javax.servlet.ServletResponse;
    24  import java.io.IOException;
    25
    26
    27  /***
    28   * A mock <code>FilterChain</code>.
    29   *
    30   * @author Ben Alex
    31   * @version $Id: MockFilterChain.java,v 1.3 2005/11/17 00:56:08 benalex Exp $
    32   */
    33  public class MockFilterChain implements FilterChain {
    34      //~ Instance fields ========================================================
    35
    36      private boolean expectToProceed;
    37
    38      //~ Constructors ===========================================================
    39
    40      public MockFilterChain(boolean expectToProceed) {
    41          this.expectToProceed = expectToProceed;
    42      }
    43
    44      //~ Methods ================================================================
    45
    46      public void doFilter(ServletRequest request, ServletResponse response)
    47              throws IOException, ServletException {
    48          if (expectToProceed) {
    49              TestCase.assertTrue(true);
    50          } else {
    51              TestCase.fail("Did not expect filter chain to proceed");
    52          }
    53      }
    54  }